/* =============================================================
 * 診断エディター
 *
 * モーダルは1規格のみ。サイズは修飾子で変える。
 *   .asb-modal        基本
 *   .asb-modal.-full  全画面（診断エディター本体）
 *   .asb-modal.-sub   中サイズ（アップロードなどの補助）
 * 機能ごとに寸法・配色を変えないこと。
 * ============================================================= */

/* ---------- モーダル ---------- */
.asb-modal{
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.asb-modal.is-open{ display: flex; }

.asb-modal__overlay{
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
}

.asb-modal__content{
  position: relative;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 960px;
  max-height: 86vh;
  overflow: hidden;
}
/* 全画面エディターはできるだけ広く使う（カード内を全幅で見せたい） */
.asb-modal.-full .asb-modal__content{ max-width: 96vw; width: 96vw; height: 92vh; max-height: 92vh; }
.asb-modal.-sub  .asb-modal__content{ max-width: 760px; }

/* ---------- フォント統一 ----------
 * モーダル全体をゴシック（sans-serif）で統一する。
 * input / textarea / select はブラウザ既定で別フォント・別サイズになりがちなので、
 * font: inherit で本文と揃える。これをしないと「枠の中と外でフォントが違う」状態になる。
 */
.asb-modal,
.asb-modal input,
.asb-modal textarea,
.asb-modal select,
.asb-modal button{
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", "Meiryo", "Noto Sans JP", sans-serif;
}
.asb-modal input,
.asb-modal textarea,
.asb-modal select{
  font-size: 14px;
  line-height: 1.5;
  color: #1d2327;
}
.asb-modal textarea{ resize: vertical; }

.asb-modal__header{
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid #e5e5e5;
  background: #fafafa;
}
.asb-modal__title{ font-weight: 700; font-size: 16px; margin-right: 4px; }
.asb-modal__tabs{ display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 auto; }
.asb-modal__actions{ display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }

.asb-modal__body{
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 16px 20px;
  background: #f6f7f8;
}

/* ---------- サブタブのパネル ---------- */
.asb-shindan-panel{ display: none; }
.asb-shindan-panel.is-active{ display: block; }

/* ---------- 進捗バー ---------- */
.asb-taskbar{ display: block; }
.asb-taskbar__bar{
  height: 8px;
  border-radius: 999px;
  background: #e3e6e8;
  overflow: hidden;
}
.asb-taskbar__fill{
  height: 100%;
  width: 0;
  background: #2b7cd3;
  transition: width .25s ease;
}
.asb-taskbar__steps{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  font-size: 12px;
  color: #666;
}
.asb-taskstep.is-done{ color: #2b7cd3; font-weight: 700; }
.asb-taskstep.is-active{ color: #111; font-weight: 700; }

/* ---------- ログ表示 ---------- */
.asb-ai-log{
  min-height: 120px;
  max-height: 260px;
  overflow: auto;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}
.asb-ai-log .-err{ color: #c00; }
.asb-ai-log .-ok{ color: #17803d; }

/* ---------- テーマ由来の「フォーム下の余計な余白」を全域で消す ----------
 * WPテーマは input/select/textarea/table に margin-bottom を付ける。
 * 従来は .asb-api-table / .asb-param-table だけリセットしていたため、
 * 診断エディター(.asb-modal)とレイアウトエディター(.asb-vrb-root)の
 * 新しいフォーム部品に余白が残っていた（＝「フォーム下の余計な余白」の正体）。
 * ここでエディター全域を一括リセットする。 */
.asb-modal input,
.asb-modal select,
.asb-modal textarea,
.asb-modal table,
.asb-modal p,
.asb-rb-root input,
.asb-rb-root select,
.asb-rb-root textarea,
.asb-rb-root table,
.asb-rb-root p{
  margin-bottom: 0 !important;
}

/* ---------- 入力欄の枠線 ----------
 * 既定の枠線が薄くて見えづらいので、はっきりした枠にする。
 * 幅は親のセル幅いっぱいに広げ、box-sizing で崩れないようにする。
 */
.asb-modal input[type="text"],
.asb-modal input[type="number"],
.asb-modal input[type="password"],
.asb-modal textarea,
.asb-modal select{
  width: 100%;
  box-sizing: border-box;
  padding: 7px 9px;
  border: 1px solid #8c8f94;
  border-radius: 6px;
  background: #fff;
}
.asb-modal input:focus,
.asb-modal textarea:focus,
.asb-modal select:focus{
  border-color: #2b7cd3;
  outline: none;
  box-shadow: 0 0 0 2px rgba(43,124,211,.18);
}

/* ---------- 表 ---------- */
.asb-scroll-x{ overflow-x: auto; }
.asb-r-table, .asb-c-table{
  min-width: 900px;
  width: 100%;
  border-collapse: collapse;
}
.asb-r-table th, .asb-c-table th{
  vertical-align: top;
  text-align: left;
  padding: 8px;
  background: #eef1f4;
  border: 1px solid #d5d9dd;
  font-weight: 700;
}
.asb-r-table td, .asb-c-table td{
  vertical-align: top;
  padding: 8px;
  border: 1px solid #e3e6e8;
}

/* ===== 問題作成：左=編集／右=プレビュー の2カラム ===== */
.asb-q2col{ display: flex; gap: 16px; align-items: flex-start; }
.asb-q2col__edit{ flex: 1 1 auto; min-width: 0; }
.asb-q2col__preview{ flex: 0 0 320px; position: sticky; top: 0; align-self: flex-start; }
.asb-qprev-head{ font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.asb-qprev-sub{ font-weight: 400; color: #777; margin-left: 6px; }
/* スマホ枠（縦持ち 9:19.5） */
.asb-qprev-phone{ width: 300px; max-width: 100%; aspect-ratio: 9 / 19.5; background: #141414; border-radius: 26px; padding: 10px; box-sizing: border-box; margin: 0 auto; }
.asb-qprev-screen{ width: 100%; height: 100%; background: #fff; border-radius: 18px; overflow-y: auto; box-sizing: border-box; padding: 18px 16px; display: flex; flex-direction: column; }
.asb-qprev-empty{ margin: auto; color: #999; font-size: 12px; text-align: center; }
.asb-qprev-q{ font-size: 15px; font-weight: 700; line-height: 1.5; color: #222; margin-bottom: 16px; }
.asb-qprev-cat{ font-size: 11px; color: #2b7cd3; font-weight: 700; margin-bottom: 8px; }
.asb-qprev-choices{ display: flex; flex-direction: column; gap: 10px; }
.asb-qprev-choice{ border: 1px solid #d0d4d9; border-radius: 10px; padding: 11px 14px; font-size: 13px; line-height: 1.4; background: #f8f9fb; color: #333; }
.asb-qprev-choice.-empty{ color: #bbb; font-style: italic; }
.asb-qprev-choice__badge{ display: inline-block; min-width: 20px; font-weight: 700; color: #2b7cd3; margin-right: 6px; }
@media (max-width: 900px){
  .asb-q2col{ flex-direction: column; }
  .asb-q2col__preview{ position: static; flex: 0 0 auto; width: 100%; }
}

/* ===== 問題作成：カード形式 =====
 * 1問＝1カード。テーブルの横並びだと選択肢が縦に積まれて行が崩れるため、
 * カードで縦に自然に流す。フォーム部品はすべて高さ36pxで揃える。 */
.asb-qcards{ display: flex; flex-direction: column; gap: 12px; }
.asb-qcard{
  border: 1px solid #d8dce0;
  border-radius: 10px;
  background: #fff;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.asb-qcard__head{ display: flex; align-items: center; gap: 10px; }
.asb-qcard__no{ font-weight: 700; font-size: 13px; white-space: nowrap; }
.asb-qcard__spacer{ flex: 1 1 auto; }
.asb-qcard__head select{
  flex: 0 0 220px; width: auto; height: 36px; box-sizing: border-box;
  padding: 6px 10px; border: 1px solid #8c8f94; border-radius: 6px;
}
.asb-qcard__head .asb-btn{ height: 36px; }
.asb-qcard__q{
  width: 100%; box-sizing: border-box; min-height: 56px; height: 56px; resize: vertical;
  padding: 8px 10px; border: 1px solid #8c8f94; border-radius: 6px; font: inherit;
}
.asb-qcard__label{ font-size: 12px; color: #555; }
.asb-qcard__choices{ display: flex; flex-direction: column; gap: 8px; }
.asb-crow{ display: flex; align-items: center; gap: 8px; }
.asb-crow__n{ flex: 0 0 auto; width: 22px; text-align: right; color: #888; font-size: 12px; }
.asb-crow select{
  flex: 0 0 200px; width: auto; min-width: 0; height: 36px; box-sizing: border-box;
  padding: 6px 10px; border: 1px solid #8c8f94; border-radius: 6px;
}
.asb-crow input{
  flex: 1 1 auto; min-width: 0; height: 36px; box-sizing: border-box;
  padding: 6px 10px; border: 1px solid #8c8f94; border-radius: 6px; font: inherit;
}
.asb-crow .asb-btn{ flex: 0 0 auto; height: 36px; }
.asb-qcard__foot{ display: flex; }

/* 使い方モーダルの説明リスト */
.asb-help-list{ margin: 0; padding-left: 20px; line-height: 1.9; font-size: 13px; color: #333; }
.asb-help-list li{ margin-bottom: 6px; }

.asb-th-top{ vertical-align: top; }
.asb-small{ font-size: 12px; }
.asb-actions{ display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- 生成物 ---------- */
.asb-genfile{
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
  margin-bottom: 12px;
  overflow: hidden;
}
.asb-genfile__head{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: #fafafa;
  border-bottom: 1px solid #eee;
}
.asb-genfile__name{ font-weight: 700; font-size: 13px; }
.asb-genfile__path{ font-size: 12px; color: #666; }
.asb-genfile__body{
  margin: 0;
  padding: 10px;
  max-height: 260px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre;
  background: #fff;
}

/* ---------- 概要 ---------- */
.asb-shindan-summary{
  margin-top: 10px;
  font-size: 13px;
  color: #444;
}
.asb-shindan-summary .-warn{ color: #b45309; }
.asb-shindan-summary .-err{ color: #c00; }

/* ---------- 狭い画面 ---------- */
@media screen and (max-width: 782px){
  .asb-modal{ padding: 0; }
  .asb-modal__content,
  .asb-modal.-full .asb-modal__content,
  .asb-modal.-sub .asb-modal__content{
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
  .asb-modal__actions{ margin-left: 0; width: 100%; }
}

/* ===== AABフォーム選択ゲート（診断エディター。レイアウトと共有） ===== */
.asb-modal.-full .asb-modal__content{ position: relative; }
.asb-shindan-gate{ position:absolute; inset:0; z-index:30; display:none; align-items:center; justify-content:center; }
.asb-shindan-gate__backdrop{ position:absolute; inset:0; background:rgba(20,22,26,.5); }
.asb-shindan-gate__dialog{ position:relative; z-index:1; width:min(520px,92%); background:#fff; border-radius:12px; border:1px solid #d0d4d9; box-shadow:0 18px 48px rgba(0,0,0,.3); padding:18px 20px; box-sizing:border-box; }
.asb-shindan-gate__head{ font-size:16px; font-weight:700; margin-bottom:8px; }
.asb-shindan-gate__note{ font-size:12px; color:#555; line-height:1.7; margin-bottom:12px; }
.asb-shindan-gate__dialog select{ width:100%; height:2.6em; border:1px solid #c9ccd1; border-radius:8px; padding:0 .8em; box-sizing:border-box; font:inherit; background:#fff; }
.asb-shindan-gate__meta{ min-height:18px; margin:8px 0; font-size:12px; color:#2b6cb0; }
.asb-shindan-gate__actions{ display:flex; gap:8px; justify-content:flex-end; flex-wrap:wrap; }
.asb-shindan-form-badge{ display:inline-flex; align-items:center; border:1px solid rgba(0,0,0,.12); background:#fff; border-radius:999px; padding:.25em .7em; font-size:11px; white-space:nowrap; }

/* 問題作成プレビュー：レイアウトエディターと同じライブアプリ（iframe） */
.asb-qprev-screen.-iframe{ padding: 0; }
.asb-qprev-iframe{ width: 100%; height: 100%; border: 0; background: #fff; display: block; }
.asb-qprev-reload{ font-size: 11px; padding: 2px 8px; margin-left: 8px; }
.asb-qprev-note{ margin-top: 6px; text-align: center; }

/* ===== 問題作成プレビュー：レイアウトと同じVCフォン枠(phone-frame/screen/iframe) =====
 * VCの外側ラッパー(preview-area/fitbox)はモーダルのfitPreview(JS)がサイズを決めるため
 * モーダル外では崩れる。見える本体のフォン枠だけを使い、サイズはaspect-ratioで与える。 */
.asb-qprev-vc{ --asb-rb-phone-bezel:#141414; }
.asb-qprev-vc .asb-qprev-head{ display:flex; align-items:center; justify-content:space-between; }
.asb-qprev-reload{ font-size:11px; color:#2b6cb0; cursor:pointer; font-weight:600; }
.asb-qprev-reload:hover{ text-decoration:underline; }
.asb-qprev-stage{ background:#d3d3d5; border-radius:12px; padding:14px; display:flex; align-items:center; justify-content:center; box-sizing:border-box; }
.asb-qprev-vc .asb-rb-phone-frame{ width:100%; max-width:260px; margin:0 auto; aspect-ratio:375 / 667; height:auto; transform:none !important; }
.asb-qprev-note{ margin-top:6px; text-align:center; }

/* ===== 問題作成：VCモーダルの左カラムに入れる問題フォーム ===== */
.asb-rb-qform{ display:flex; flex-direction:column; height:100%; min-height:0; }
.asb-rb-qform-head{ flex:0 0 auto; display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:8px; }
.asb-rb-qform-title{ font-weight:700; font-size:14px; }
.asb-rb-qform .asb-qcards{ flex:1 1 auto; min-height:0; overflow-y:auto; padding-right:4px; }
