/*
 * Advance Content Builder 共通ベースCSS
 * - カード… AAM (.aam-card) を使用
 * - フォーム／テーブル… ASB(.asb-*)のレイアウトを acb-* にコピー
 * - ページャの「前へ/次へ」… 白い角丸ボタン（クイズと同系統）
 * - エディターヘッダ（パンくず＋戻る＋タブ）… 戻る＋左詰めタブ
 * - APIキー設定カード… 60% / 40%・3行構成
 * - 詳細ログ用の黒パネル＆開閉ボタン
 */

/* AAMカードの形を利用 */
@import url("../../advance-app-manager/assets/admin.css");
@import url("../../advance-app-manager/assets/my-page.css");

/* ラッパー */
.aam-wrap.acb-wrap {
  max-width: 980px;
  margin: 20px auto;
  padding: 0 12px 32px;
  box-sizing: border-box;
  font-size: 14px;
  line-height: 1.6;
}

/* パンくず：少し小さめに */
.aam-breadcrumb.acb-breadcrumb {
  margin-top: 6px;
  margin-bottom: 8px;
  color: #666;
  font-size: 12px;
}

/* カード内タイトル */
.aam-card .acb-sec-title {
  font-weight: 600;
  margin-bottom: 10px;
  font-size: 15px;
}

/* ========= エディターヘッダ（戻る＋タブ） ========= */
/* カード無し。戻るボタンの右側にタブボタンを左詰めで並べる */

.acb-editor-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}

.acb-editor-header-left {
  flex-shrink: 0;
}

.acb-editor-header-right {
  flex: 1;
  display: flex;
  justify-content: flex-start;
}

/* ========= ボタン ========= */

.acb-btn {
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 8px 12px;
  background: #f9fafb;
  cursor: pointer;
  font-size: clamp(12px, 1.4vw, 14px);  /* 変動タイプで小さめ統一 */
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #111827;
  box-sizing: border-box;
}
.acb-btn.-primary {
  background: #111827;
  color: #fff;
  border-color: #111827;
  text-align: center;
}
.acb-btn.-ghost {
  background: #fff;
}
.acb-btn.-danger {
  background: #fee2e2;
  border-color: #fecaca;
}

/* ========= 入力フォーム ========= */

.acb-input,
.acb-table input,
.acb-table select,
.acb-table textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-sizing: border-box;
  font-size: clamp(12px, 1.4vw, 14px);
}
.acb-input--sm {
  width: auto;
  padding: 6px 8px;
}

/* ========= 新規作成フォーム（リスト側） ========= */

.aam-card table.acb-create-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  border-spacing: 0;
}
.aam-card table.acb-create-table tr {
  margin: 0;
}
.aam-card table.acb-create-table td {
  padding: 4px 0;
  border: 0;
  vertical-align: middle;
}
.aam-card table.acb-create-table .td-input {
  padding-right: 8px;
}
.aam-card table.acb-create-table .td-actions {
  white-space: nowrap;
  text-align: center;
}
.aam-card table.acb-create-table .td-actions .acb-btn {
  margin: 0 auto;
}

/* 入力:ボタン = 80% : 20% */
.aam-card table.acb-create-table col:first-child {
  width: 80% !important;
}
.aam-card table.acb-create-table col:last-child {
  width: 20% !important;
}

/* 入力直下の余白を削る（新規作成フォーム） */
.aam-card .acb-create-table input[type="text"],
.aam-card .acb-create-table .acb-input {
  margin-bottom: 0 !important;
}

/* ========= 一覧テーブル ========= */

.aam-card table.acb-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  border-spacing: 0;
}
.aam-card table.acb-table th,
.aam-card table.acb-table td {
  border-top: 1px solid #eee;
  padding: 10px;
  vertical-align: top;
  text-align: left;
}
.aam-card table.acb-table th {
  font-weight: 600;
  color: #111;
  background: #f6f7f7;
}
.aam-card table.acb-table td {
  background: #fff;
}
.acb-w64  { width: 64px; }
.acb-w120 { width: 120px; }

/* ========= ツールバー／ページネーション ========= */

.acb-list-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 8px 0;
  gap: 12px;
}
.acb-list-toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.acb-muted {
  font-size: 0.9rem;
  color: #666;
}

.acb-pagination {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 10px;
}
.acb-pagination .acb-btn {
  min-width: 70px;
}
.acb-page-info {
  color: #333;
  font-size: 0.9rem;
}

/* ========= タブUI（エディターページ用） ========= */

.acb-tabs {
  /* ヘッダ内に置くだけなので装飾は最小限 */
}

.acb-tab-headers {
  display: flex;
  gap: 6px;
  margin-bottom: 0;
}

.acb-tab-btn {
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;            /* 角を少し緩め */
  background: #fff;
  font-size: clamp(12px, 1.4vw, 14px);
  cursor: pointer;
  color: #111;                    /* 非アクティブ時は黒 */
}
.acb-tab-btn.is-active {
  background: #111827;
  color: #fff;
  border-color: #111827;
}

.acb-tab-panel {
  display: none;
}
.acb-tab-panel.is-active {
  display: block;
}

/* ========= APIキー設定カード専用レイアウト（60% / 40%・3行構成） ========= */

.acb-api-table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
}

/* テーブルセルは「下だけ白ボーダー」、他は消す */
.acb-api-table td,
.acb-api-table th {
  background: transparent !important;
  border: 0;
  border-bottom: 1px solid #fff;
  padding: 8px 10px;
  vertical-align: top;
}

/* 左60% / 右40% */
.acb-api-main {
  width: 60%;
}
.acb-api-side {
  width: 40%;
  text-align: left;        /* セル自体は左寄せ */
}

/* APIテーブル内フォームの下余白も消す */
.acb-api-table .acb-input,
.acb-api-table input,
.acb-api-table select {
  margin-bottom: 0 !important;
}

/* テーブルセルは縦方向も中央寄せにしておく */
.acb-api-table td {
  vertical-align: middle;
}

/* ラベル：チェック＋テキストを「普通の1行ラベル」にする */
.acb-api-label-side {
  font-size: clamp(10px, 1.2vw, 12px);
  display: inline-block;   /* ★ flexやwidth指定はやめる */
  margin: 0;
  padding: 0;
  line-height: 1.3;
  max-width: 100%;
  white-space: normal;     /* ★ 通常の改行ルールに戻す */
}

/* ラベル内のチェックボックス：余白を完全リセット＋横並び */
.acb-api-label-side input[type="checkbox"] {
  display: inline-block;   /* ★ ブロック化させない */
  margin: 0 !important;  /* 左0, 右4pxだけ隙間 */
  padding: 0 !important;
  vertical-align: middle;  /* テキストと上下中央揃え */
}
  
/* フィールド */
.acb-api-field {
  display: block;
}

input.acb-api-keepcheckbox {
  width: auto;
}

/* ========= アプリパラメーター設定カード用テーブル ========= */
/* 背景なし・下線だけ白・フォーム下余白もゼロに */

.aam-card .acb-param-table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
}

/* th, td とも背景色なし・下ボーダーだけ白 */
.aam-card .acb-param-table th,
.aam-card .acb-param-table td {
  background: transparent !important;   /* ★ 背景色なし */
  border: 0;                            /* 上・左右ボーダー消す */
  border-bottom: 1px solid #fff;        /* ★ 下線だけ白 */
  padding: 8px 10px;
  vertical-align: middle;               /* セル内縦方向を中央寄せ */
}

/* 項目名（th）の文字だけ少し強調 */
.aam-card .acb-param-table th {
  font-weight: 600;
  color: #111;
}

/* このカード内のフォーム類は下余白を消す */
.acb-param-table .acb-input,
.acb-param-table input,
.acb-param-table select,
.acb-param-table textarea {
  margin-bottom: 0 !important;          /* ★ フォーム直下の余白ゼロ */
}

/* 詳細データカードのヘッダー行：左にタイトル、右にボタン */
.acb-log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

/* ログパネル：黒背景＋緑文字 */
.acb-log-panel {
  display: none;
  margin-top: 4px;
  padding: 10px 12px;
  background: #000;              /* 黒 */
  color: #22c55e;                /* 緑系（見やすいグリーン） */
  border-radius: 8px;
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.5;
  max-height: 260px;
  overflow: auto;
}
.acb-log-panel.is-open {
  display: block;
}


/* マスクキー入力欄の背景とボーダーを完全に消す */
.acb-api-table .acb-input-masked {
  background-color: transparent !important;
  border: none !important;
}


/* 保存／削除ボタンは横並び＋50%ずつ */
.acb-api-actions {
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  align-items: stretch;
  gap: 6px;
}
.acb-api-actions .acb-btn {
  flex: 1 1 50%;
  max-width: 50%;
  justify-content: center;
}

/* マスク済みキー表示用 */
.acb-input-masked {
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* 注釈テキスト（小さめ） */
.acb-api-note {
  font-size: clamp(10px, 1.2vw, 12px);  /* ★ 小さく統一 */
  color: #555;
}

/* マスクキー + 残り時間 + 注釈 の横並び行 */
.acb-api-mask-row {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;   /* 左詰め */
}

/* マスクキーは可変幅・最小限（背景・ボーダーなし） */
.acb-api-table .acb-input-masked {
  background-color: transparent !important;
  border: none !important;
  padding: 0 4px;
  width: auto;                   /* 可変幅 */
  flex: 0 0 auto;                /* 必要なだけの幅 */
}

/* 残り時間表示（中央） */
.acb-api-remaining {
  font-size: clamp(10px, 1.2vw, 12px);
  color: #333;
  white-space: nowrap;           /* 折り返さない */
}

/* 右端の注釈 */
.acb-api-note-inline {
  font-size: clamp(10px, 1.2vw, 12px);
  color: #555;
  line-height: 1.4;
  text-align: left;
  flex: 1 1 auto;               /* 余ったスペースをここで受ける */
}

/* スマホ用調整 */
@media (max-width: 640px) {
  .acb-api-main,
  .acb-api-side {
    width: auto;
  }
  .acb-api-actions {
    flex-wrap: wrap;
    justify-content: center;
  }
  .acb-api-actions .acb-btn {
    max-width: none;
    flex: 1 1 45%;
  }
  .acb-api-note {
    margin-top: 4px;
  }
}


/* ========= 詳細ログパネル ========= */

.acb-log-toggle {
  margin-top: 4px;
}

.acb-log-panel {
  display: none;
  margin-top: 8px;
  padding: 10px 12px;
  background: #111827;
  color: #f9fafb;
  border-radius: 8px;
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.5;
  max-height: 260px;
  overflow: auto;
}
.acb-log-panel.is-open {
  display: block;
}

/* ========== スマホ向けレスポンシブ調整 ========== */
@media (max-width: 640px) {

  /* エディターヘッダは縦積み */
  .acb-editor-header {
    flex-direction: column;
    align-items: stretch;
  }
  .acb-editor-header-right {
    justify-content: flex-start;
  }

  .aam-card table.acb-create-table td {
    padding: 2vw 0;
  }

  .aam-card table.acb-table th,
  .aam-card table.acb-table td {
    padding: 2.4vw 3vw;
  }

  .acb-tab-btn {
    font-size: 3.4vw;
    padding: 2.2vw 3vw;
  }

  /* APIカード：スマホでは左右幅にあまり縛られないように */
  .acb-api-main,
  .acb-api-side {
    width: auto;
  }
  .acb-api-actions {
    flex-wrap: wrap;
    justify-content: center;
  }
  .acb-api-actions .acb-btn {
    max-width: none;
    flex: 1 1 45%;
  }
  .acb-api-note {
    margin-top: 4px;
  }
}

/* ログパネル：黒背景＋中の文字をすべて緑に固定 */
.acb-log-panel {
  display: none;
  margin-top: 4px;
  padding: 10px 12px;
  background: #000;
  color: #22c55e;
  border-radius: 8px;
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.5;
  max-height: 260px;
  overflow: auto;
}

/* テキスト系がテーマCSSに上書きされないよう強制 */
.acb-log-panel * {
  color: #22c55e !important;
}
.acb-log-panel.is-open {
  display: block;
}

