/*
 * styles/booking.css — 共通予約UI（Issue #269）専用スタイル。
 *
 * SNB/mensの styles/common.css と Studio X の studio-x/style.css は、テーマ変数の
 * 名前自体が異なる（--bg-card/--text-muted/--border 対 --surface/--muted/--line）。
 * このファイルは var(--a, var(--b, fallback)) のフォールバック連鎖で両方の変数名を
 * 吸収し、ブランドごとにCSSを複製せずに済むようにしている（3ブランドとも
 * 同じ .booking-app 配下のクラスをそのまま使う）。
 */

.booking-app {
  --ba-bg: var(--bg, #ffffff);
  --ba-surface: var(--bg-card, var(--surface, #f4f4f4));
  --ba-surface-2: var(--bg-section, var(--surface-2, #e9e9e9));
  --ba-text: var(--text, #1a1a1a);
  --ba-muted: var(--text-muted, var(--muted, #666666));
  --ba-border: var(--border, var(--line, #dddddd));
  --ba-accent: var(--accent, #4a6d3c);
  --ba-error: var(--secondary, #c0392b);
  --ba-radius: var(--radius, 6px);

  max-width: 720px;
  margin: 0 auto;
  color: var(--ba-text);
}

.booking-app [hidden] { display: none !important; }

/* ── 進捗表示 ── */
.ba-progress {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin: 0 0 28px;
  padding: 0;
  list-style: none;
}

.ba-progress li {
  padding: 6px 10px;
  border: 1px solid var(--ba-border);
  border-radius: var(--ba-radius);
  color: var(--ba-muted);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.ba-progress li[aria-current="step"] {
  border-color: var(--ba-accent);
  color: var(--ba-accent);
}

.ba-progress li.ba-progress-done {
  color: var(--ba-text);
}

/* ── 共通バナー（エラー／注意） ── */
.ba-banner {
  margin: 0 0 20px;
  padding: 14px 16px;
  border: 1px solid var(--ba-border);
  border-left: 3px solid var(--ba-accent);
  border-radius: var(--ba-radius);
  background: var(--ba-surface);
  font-size: 0.86rem;
  line-height: 1.7;
}

.ba-banner--error {
  border-color: var(--ba-error);
  border-left-color: var(--ba-error);
  color: var(--ba-error);
  font-weight: 700;
}

.ba-banner--notice {
  border-left-color: var(--ba-accent);
  color: var(--ba-text);
}

.ba-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

/* ── ステップ共通 ── */
.ba-step {
  padding: clamp(20px, 4vw, 32px);
  border: 1px solid var(--ba-border);
  border-radius: var(--ba-radius);
  background: var(--ba-surface);
  margin-bottom: 20px;
}

.ba-step h2 {
  margin: 0 0 6px;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--ba-text);
}

.ba-step-desc {
  margin: 0 0 20px;
  color: var(--ba-muted);
  font-size: 0.86rem;
  line-height: 1.7;
}

.ba-field { margin-bottom: 18px; }
.ba-field:last-child { margin-bottom: 0; }

.ba-field label,
.ba-fieldset legend {
  display: block;
  margin-bottom: 8px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ba-text);
}

.ba-required {
  margin-left: 4px;
  color: var(--ba-error);
  font-size: 0.72rem;
  font-weight: 700;
}

.ba-optional {
  margin-left: 4px;
  color: var(--ba-muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.booking-app input[type="text"],
.booking-app input[type="email"],
.booking-app input[type="tel"],
.booking-app input[type="date"],
.booking-app input[type="number"],
.booking-app select,
.booking-app textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 12px;
  border: 1px solid var(--ba-border);
  border-radius: var(--ba-radius);
  background: var(--ba-surface-2);
  color: var(--ba-text);
  font: inherit;
  font-size: 16px; /* iOSの自動ズームを防ぐ */
  line-height: 1.5;
}

.booking-app textarea { min-height: 120px; resize: vertical; }

.booking-app input:focus-visible,
.booking-app select:focus-visible,
.booking-app textarea:focus-visible,
.ba-choice label:focus-within,
.ba-time-slot:focus-visible,
.ba-cal-day:focus-visible,
.ba-calendar-nav-btn:focus-visible {
  outline: 2px solid var(--ba-accent);
  outline-offset: 2px;
}

.booking-app [aria-invalid="true"] {
  border-color: var(--ba-error);
  box-shadow: 0 0 0 1px var(--ba-error);
}

.ba-field-error {
  margin-top: 6px;
  color: var(--ba-error);
  font-size: 0.76rem;
  font-weight: 700;
}

.ba-field-help {
  margin-top: 6px;
  color: var(--ba-muted);
  font-size: 0.76rem;
  line-height: 1.6;
}

/* 利用料金の見積り表示（Issue #342）。Step1内の1か所（#ba-price-box）だけで使う。 */
.ba-price-box {
  margin: 18px 0;
  padding: 14px 16px;
  border: 1px solid var(--ba-border);
  border-radius: 8px;
  background: var(--ba-surface);
}

.ba-price-line {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ba-text);
}

.ba-price-note {
  margin: 0;
  color: var(--ba-muted);
  font-size: 0.82rem;
}

.ba-price-note:empty { display: none; }

.ba-fieldset { border: 0; padding: 0; margin: 0 0 18px; }
.ba-choices { display: flex; flex-wrap: wrap; gap: 10px; }

.ba-choice {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid var(--ba-border);
  border-radius: var(--ba-radius);
  background: var(--ba-surface-2);
  font-size: 0.84rem;
  cursor: pointer;
}

.ba-choice input { flex: 0 0 auto; width: 18px; height: 18px; accent-color: var(--ba-accent); }

/* カード決済が96時間未満で選択不可の間の見た目（Issue #334 PR-B）。 */
.ba-choice--disabled { opacity: 0.5; cursor: not-allowed; }
.ba-choice--disabled input { cursor: not-allowed; }

/* ── スクリーンリーダー専用（視覚的には非表示だがaria-labelledbyの対象として読める） ── */
.ba-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ba-field-label-like {
  display: block;
  margin-bottom: 8px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ba-text);
}

/* ── 月間空き状況カレンダー（Issue #318） ── */
.ba-calendar-hint {
  margin: 0;
  padding: 14px;
  color: var(--ba-muted);
  font-size: 0.84rem;
  line-height: 1.7;
  border: 1px dashed var(--ba-border);
  border-radius: var(--ba-radius);
}

.ba-calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.ba-calendar-nav-btn {
  min-height: 40px;
  padding: 8px 14px;
  font-size: 0.82rem;
  flex: 0 0 auto;
}

.ba-calendar-month {
  font-size: 0.94rem;
  font-weight: 800;
  color: var(--ba-text);
}

/* テーブルレイアウト（table-layout: fixed）で7列を等幅にし、スマートフォンでも
   横スクロールを必要としないようにする（Issue #318要件）。 */
.ba-calendar-grid {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  margin-bottom: 10px;
}

.ba-calendar-grid th {
  padding: 6px 2px;
  color: var(--ba-muted);
  font-size: 0.74rem;
  font-weight: 700;
  text-align: center;
}

/* 曜日表示: 日曜は赤系、土曜は青系、平日は通常色（Issue #318要件）。
   記号・色だけに依存しないよう、選択可否・状態自体はbuttonのaria-labelで別途示す。 */
.ba-calendar-grid th.ba-cal-sun { color: #c0392b; }
.ba-calendar-grid th.ba-cal-sat { color: #2c5aa0; }

.ba-calendar-grid td {
  padding: 2px;
  text-align: center;
  vertical-align: middle;
}

.ba-cal-day {
  width: 100%;
  min-height: 44px;
  padding: 4px 2px;
  border: 1px solid var(--ba-border);
  border-radius: var(--ba-radius);
  background: var(--ba-surface-2);
  color: var(--ba-text);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.3;
  cursor: pointer;
}

.ba-cal-day:hover:not(:disabled) { border-color: var(--ba-accent); }

.ba-cal-day[aria-pressed="true"] {
  border-color: var(--ba-accent);
  background: var(--ba-accent);
  color: var(--ba-bg);
}

.ba-cal-day:disabled {
  color: var(--ba-muted);
  background: transparent;
  border-style: dashed;
  cursor: not-allowed;
  opacity: 0.7;
}

/* 空き状況の確認中／取得失敗: 日付のみ表示し、薄いグレーの「未確定」状態にする。 */
.ba-cal-day--pending:disabled {
  opacity: 0.55;
  cursor: default;
}

/* 読み込み表示の出入りでカレンダーがずれないよう、非表示時も領域を確保する。 */
#ba-calendar-loading {
  min-height: 1.4em;
}
/* .booking-app [hidden]（display: none !important）より詳細度を上げて上書きする。 */
.booking-app #ba-calendar-loading[hidden] {
  display: block !important;
  visibility: hidden;
}

.ba-calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
  color: var(--ba-muted);
  font-size: 0.76rem;
}

.ba-calendar-selected {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--ba-text);
}

/* ── 開始時刻の選択 ── */
/* Step1のカレンダー直後の開始時刻エリア。日付クリック後もカレンダーは残し、
   この領域だけをローディング→時刻一覧/空き無し/エラーへ切り替える。 */
/* 日付未選択の間の事前案内。日付クリック後は同じ位置で開始時刻エリアに入れ替わる。 */
.ba-start-time-hint {
  margin: 16px 0 18px;
  padding: 12px 14px;
  color: var(--ba-muted);
  font-size: 0.86rem;
  line-height: 1.7;
  border: 1px dashed var(--ba-border);
  border-radius: 8px;
  min-width: 0;
}

.ba-start-time-area {
  margin: 16px 0 18px;
  padding: 14px 0 0;
  border-top: 1px solid var(--ba-border);
  min-width: 0;
}

.ba-start-time-title {
  margin: 0 0 6px;
  font-size: 1rem;
}

.ba-start-time-area .ba-loading {
  padding: 14px 0;
}

.ba-time-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 10px;
  margin: 0 0 8px;
}

.ba-time-slot {
  min-height: 46px;
  padding: 10px 6px;
  border: 1px solid var(--ba-border);
  border-radius: var(--ba-radius);
  background: var(--ba-surface-2);
  color: var(--ba-text);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
}

.ba-time-slot:hover { border-color: var(--ba-accent); }

.ba-time-slot[aria-pressed="true"] {
  border-color: var(--ba-accent);
  background: var(--ba-accent);
  color: var(--ba-bg);
}

.ba-time-empty {
  padding: 16px;
  color: var(--ba-muted);
  font-size: 0.86rem;
  line-height: 1.8;
  text-align: center;
  border: 1px dashed var(--ba-border);
  border-radius: var(--ba-radius);
}

/* ── 確認画面 ── */
.ba-summary {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 8px;
}

.ba-summary th,
.ba-summary td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--ba-border);
  text-align: left;
  font-size: 0.86rem;
  vertical-align: top;
  word-break: break-word;
}

.ba-summary th {
  width: 34%;
  color: var(--ba-muted);
  font-weight: 700;
  white-space: nowrap;
}

/* ── 完了画面 ── */
.ba-complete {
  text-align: center;
}

.ba-complete-icon {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--ba-accent);
  color: var(--ba-bg);
  font-size: 1.6rem;
  font-weight: 800;
}

.ba-complete h2 { font-size: 1.3rem; }

.ba-complete-pending-notice {
  margin: 18px 0;
  padding: 16px;
  border: 1px solid var(--ba-error);
  border-radius: var(--ba-radius);
  color: var(--ba-error);
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.8;
  text-align: left;
}

.ba-booking-id {
  display: inline-block;
  margin: 10px 0;
  padding: 8px 14px;
  border: 1px solid var(--ba-border);
  border-radius: var(--ba-radius);
  background: var(--ba-surface-2);
  font-family: monospace;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
}

/* ── ボタン ── */
.ba-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.ba-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 12px 26px;
  border: 1px solid var(--ba-accent);
  border-radius: var(--ba-radius);
  background: transparent;
  color: var(--ba-accent);
  font: inherit;
  font-weight: 800;
  font-size: 0.88rem;
  letter-spacing: 0.03em;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.ba-btn:hover:not(:disabled) {
  background: var(--ba-accent);
  color: var(--ba-bg);
}

.ba-btn-primary {
  background: var(--ba-accent);
  color: var(--ba-bg);
}

.ba-btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.ba-btn-ghost {
  border-color: var(--ba-border);
  color: var(--ba-text);
}

.ba-btn-ghost:hover:not(:disabled) {
  background: var(--ba-surface-2);
  color: var(--ba-text);
}

.ba-btn:disabled {
  cursor: wait;
  opacity: 0.6;
}

.ba-loading {
  color: var(--ba-muted);
  font-size: 0.86rem;
}

/* ── モバイル（375px前後を想定） ── */
@media (max-width: 480px) {
  .ba-actions { flex-direction: column; }
  .ba-actions .ba-btn { width: 100%; }
  .ba-summary th { width: 40%; }
  .ba-time-grid { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }
  /* table-layout: fixedで既に7列固定幅のため横スクロールは発生しないが、
     セル内余白・文字サイズを狭幅端末向けにさらに詰める（Issue #318要件）。 */
  .ba-cal-day { min-height: 38px; padding: 3px 1px; font-size: 0.72rem; }
  .ba-calendar-nav-btn { padding: 8px 10px; font-size: 0.76rem; }
}
