/* =============================================
   LOHAS · Booking Modal
   --------------------------------------------
   依賴：tokens, base, components
   --------------------------------------------
   驗光師 → 服務項目 → 日期 → 時段 → 確認資料
   ============================================= */

/* === Overlay === */
.bm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(45, 36, 24, 0.6);
  z-index: var(--z-modal);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.bm-overlay.open { opacity: 1; pointer-events: auto; }

/* === Dialog === */
.bm-dialog {
  background: #fff;
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 780px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--sh-modal);
  transform: translateY(40px) scale(0.96);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}
.bm-overlay.open .bm-dialog {
  transform: translateY(0) scale(1);
}

/* === Header === */
.bm-head {
  padding: 18px 24px 16px;
  border-bottom: 1px solid var(--lohas-bd);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}
.bm-head-info {
  flex: 1;
  min-width: 0;
}
.bm-head-info .tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  padding: 3px 10px;
  background: var(--lohas-bd);
  color: var(--lohas-brand);
  border-radius: var(--r-pill);
  letter-spacing: 1px;
  font-weight: 600;
  margin-bottom: 6px;
}
.bm-head-info h2 {
  font-family: var(--font-tc);
  font-size: 18px;
  color: var(--lohas-brand);
  font-weight: 700;
  letter-spacing: 1px;
}
.bm-head-info p {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.bm-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-warm);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  border: 0;
  font-family: inherit;
  transition: background 0.2s;
}
.bm-close:hover { background: var(--lohas-bd); }

/* === Step indicator === */
.bm-steps {
  display: flex;
  padding: 12px 24px;
  gap: 4px;
  border-bottom: 1px solid var(--lohas-bd);
  background: var(--bg-warm);
  flex-shrink: 0;
}
.bm-step {
  flex: 1;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  letter-spacing: 0.3px;
  transition: color 0.2s;
}
.bm-step-num {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--lohas-bd);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
}
.bm-step.active { color: var(--lohas-brand); font-weight: 600; }
.bm-step.active .bm-step-num { background: var(--lohas-brand); color: #fff; }
.bm-step.done { color: var(--ok); }
.bm-step.done .bm-step-num { background: var(--ok); color: #fff; }

/* === Body (可捲) === */
.bm-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

/* === 區段標題 === */
.bm-sec {
  margin-bottom: 22px;
}
.bm-sec:last-child { margin-bottom: 0; }
.bm-sec-title {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  font-weight: 700;
  margin-bottom: 10px;
}

/* === 驗光師選擇（大頭像卡片版） === */
.bm-staff-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.bm-staff-pick {
  background: #fff;
  border: 2px solid var(--lohas-bd);
  border-radius: var(--r-lg);
  padding: 18px 16px 18px 20px;
  display: grid;
  grid-template-columns: 80px 1fr 28px;
  gap: 16px;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.bm-staff-pick:hover {
  border-color: var(--lohas-light);
  background: var(--bg-warm);
  transform: translateY(-1px);
}
.bm-staff-pick.active {
  border-color: var(--lohas-brand);
  background: #fff;
  box-shadow: 0 8px 24px rgba(80, 66, 45, 0.12);
}
.bm-staff-pick-photo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--lohas-light) 0%, var(--lohas-hover) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(80, 66, 45, 0.08);
  position: relative;
}
.bm-staff-pick-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
}
.bm-staff-pick-photo .bm-staff-pick-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bm-staff-pick-photo .bm-staff-pick-fallback i {
  font-size: 32px;
  color: rgba(255, 255, 255, 0.85);
}
.bm-staff-pick-photo .initial {
  font-size: 32px;
  color: rgba(255, 255, 255, 0.85);
}
.bm-staff-pick-info {
  min-width: 0;
}
.bm-staff-pick-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--lohas-brand);
  letter-spacing: 2px;
  margin-bottom: 4px;
  line-height: 1.2;
}
.bm-staff-pick-role {
  font-size: 12px;
  color: var(--text-sub);
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.bm-staff-pick-honor {
  font-size: 11px;
  color: #B5743A;
  letter-spacing: 0.3px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.bm-staff-pick-honor i { font-size: 10px; }
.bm-staff-pick-check {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all 0.2s;
}
.bm-staff-pick.active .bm-staff-pick-check {
  background: var(--lohas-brand);
  color: #fff;
}

/* === 服務 chips === */
.bm-required {
  color: #c0392b;
  font-weight: 700;
  margin-left: 2px;
}
.bm-svc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.bm-svc-pick {
  padding: 14px 12px;
  background: #fff;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--lohas-brand);
  border: 1px solid var(--lohas-bd);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-tc, inherit);
  letter-spacing: 1px;
  text-align: center;
}
.bm-svc-pick:hover {
  background: var(--bg-warm);
  border-color: var(--lohas-brand);
}
.bm-svc-pick.active {
  background: var(--lohas-brand);
  color: #fff;
  border-color: var(--lohas-brand);
  font-weight: 600;
}
@media (max-width: 480px) {
  .bm-svc-pick { padding: 12px 8px; font-size: 13px; }
}

/* === 日期選擇 === */
.bm-date-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  /* 留出 8px 給捲軸 + 4px 視覺空間 */
  padding-bottom: 12px;
  scroll-snap-type: x mandatory;
  /* Firefox：顯示細捲軸 + 品牌色 */
  scrollbar-width: thin;
  scrollbar-color: var(--lohas-light) transparent;
}
/* WebKit/Blink：保留可見的細捲軸（桌機可用滑鼠拖動） */
.bm-date-row::-webkit-scrollbar {
  height: 6px;
}
.bm-date-row::-webkit-scrollbar-track {
  background: transparent;
}
.bm-date-row::-webkit-scrollbar-thumb {
  background: var(--lohas-light);
  border-radius: var(--r-pill);
}
.bm-date-row::-webkit-scrollbar-thumb:hover {
  background: var(--lohas-hover);
}
.bm-date-pick {
  flex-shrink: 0;
  width: 60px;
  padding: 10px 4px;
  background: var(--bg-warm);
  border-radius: 10px;
  text-align: center;
  border: 2px solid transparent;
  cursor: pointer;
  scroll-snap-align: start;
  transition: all 0.15s;
}
/* hover 排除 active：避免已選中的日期被淡化背景蓋掉 */
.bm-date-pick:hover:not(.full):not(.active) { background: var(--bg-soft); }
.bm-date-pick.active {
  background: var(--lohas-brand);
  color: #fff;
  border-color: var(--lohas-brand);
  box-shadow: 0 4px 12px rgba(80, 66, 45, 0.22);
}
/* active 即使被 hover 也維持選中外觀 */
.bm-date-pick.active:hover {
  background: var(--lohas-brand);
  border-color: var(--lohas-brand);
}
.bm-date-pick.full {
  opacity: 0.4;
  cursor: not-allowed;
}
.bm-date-pick .dw {
  font-size: 10px;
  color: var(--text-muted);
}
.bm-date-pick.active .dw { color: rgba(255, 255, 255, 0.7); }
.bm-date-pick .dn {
  font-size: 18px;
  font-weight: 800;
  margin: 2px 0;
  font-family: var(--font-tc);
}
.bm-date-pick .da {
  font-size: 9px;
  color: var(--text-muted);
}
.bm-date-pick.active .da { color: rgba(255, 255, 255, 0.6); }
.bm-date-pick.full .da { color: var(--err); }

/* === 時段選擇 === */
.bm-time-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.bm-time-pick {
  padding: 11px 4px;
  text-align: center;
  background: var(--bg-warm);
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  border: 1px solid transparent;
  font-family: inherit;
  transition: all 0.15s;
}
.bm-time-pick:hover:not(.full):not(.active) { background: var(--bg-soft); }
.bm-time-pick.active {
  border-color: var(--lohas-light);
  box-shadow: 0 0 0 1px var(--lohas-light);
}
.bm-time-pick.full {
  opacity: 0.35;
  text-decoration: line-through;
  cursor: not-allowed;
}

/* === 表單 === */
.bm-form-row {
  margin-bottom: 12px;
}
.bm-form-row label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  letter-spacing: 0.5px;
}
.bm-form-row input,
.bm-form-row textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-warm);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--text-main);
  outline: 0;
  transition: border-color 0.15s;
}
.bm-form-row input:focus,
.bm-form-row textarea:focus {
  border-color: var(--lohas-brand);
  background: #fff;
}
.bm-form-row textarea {
  min-height: 60px;
  resize: vertical;
}

/* === Footer === */
.bm-foot {
  border-top: 1px solid var(--lohas-bd);
  padding: 14px 24px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
  background: #fff;
}
.bm-foot-summary {
  flex: 1;
  font-size: 12px;
  color: var(--text-sub);
  line-height: 1.5;
  min-width: 0;
}
.bm-foot-summary b {
  color: var(--lohas-brand);
  font-size: 14px;
  font-weight: 700;
  display: block;
  margin-bottom: 2px;
}
.bm-foot-actions {
  display: flex;
  gap: 6px;
}
.bm-btn {
  padding: 11px 18px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 0;
  font-family: inherit;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.bm-btn.ghost {
  background: var(--bg-warm);
  color: var(--text-sub);
}
.bm-btn.ghost:hover { background: var(--lohas-bd); }
.bm-btn.primary {
  background: var(--lohas-brand);
  color: #fff;
}
.bm-btn.primary:hover { background: var(--lohas-hover); }
.bm-btn.primary:disabled {
  background: var(--lohas-brand);
  cursor: not-allowed;
  opacity: 0.4;          /* 維持品牌色但明顯變淡,讓使用者知道「按鈕在這、但還不能按」 */
}

/* === Loading / Error 區塊 === */
.bm-state {
  text-align: center;
  padding: 40px 20px;
}
.bm-state .spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
  border: 3px solid var(--bg-soft);
  border-top-color: var(--lohas-brand);
  border-radius: 50%;
  animation: bm-spin 0.7s linear infinite;
}
@keyframes bm-spin { to { transform: rotate(360deg); } }
.bm-state-title {
  font-size: 14px;
  color: var(--text-sub);
  margin-top: 12px;
}
.bm-state-msg {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.6;
}

/* === Success === */
.bm-success {
  text-align: center;
  padding: 30px 24px;
}
.bm-success-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--ok-bg);
  color: var(--ok);
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}
.bm-success-title {
  font-family: var(--font-tc);
  font-size: 20px;
  color: var(--lohas-brand);
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.bm-success-msg {
  font-size: 13px;
  color: var(--text-sub);
  line-height: 1.7;
  max-width: 380px;
  margin: 0 auto 20px;
}
.bm-success-detail {
  background: var(--bg-warm);
  border-radius: var(--r-md);
  padding: 14px 18px;
  text-align: left;
  font-size: 12px;
  color: var(--text-sub);
  max-width: 360px;
  margin: 0 auto;
}
.bm-success-detail div { padding: 4px 0; }
.bm-success-detail b { color: var(--lohas-brand); font-weight: 600; }

/* === 響應式 === */
@media (max-width: 600px) {
  /* modal 不貼螢幕絕對最底,底部留空間,避免 footer 被 APP 導覽列/隱私條/瀏覽器工具列蓋住 */
  .bm-overlay { padding: 0; align-items: flex-end; }
  .bm-dialog {
    max-width: none;
    max-height: 90vh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
  }
  .bm-staff-grid { grid-template-columns: 1fr; }
  .bm-staff-pick { padding: 14px 12px 14px 14px; gap: 12px; grid-template-columns: 64px 1fr 24px; }
  .bm-staff-pick-photo { width: 64px; height: 64px; }
  .bm-staff-pick-name { font-size: 16px; }
  .bm-time-grid { grid-template-columns: repeat(3, 1fr); }

  /* 手機 footer:上下兩層 — summary 在上、按鈕獨佔下面整行(滿版) */
  .bm-foot {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 16px calc(20px + env(safe-area-inset-bottom, 0px));
    gap: 10px;
  }
  /* 商城模式(webview,底部有 APP 原生導覽列)→ footer 留更大底部空間閃過它 */
  .bm-dialog--cart .bm-foot {
    padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }
  .bm-foot-summary {
    font-size: 12px;
    text-align: center;
  }
  .bm-foot-summary b { font-size: 14px; }
  .bm-foot-actions {
    display: flex;
    gap: 10px;
    width: 100%;
  }
  .bm-btn {
    padding: 15px 18px;
    font-size: 15px;
    flex: 1;
    justify-content: center;
  }
  .bm-btn.primary {
    flex: 2;                /* 主按鈕占 2/3,更突出 */
    box-shadow: 0 3px 12px rgba(80, 66, 45, 0.3);
    font-weight: 700;
  }
  .bm-btn.ghost { flex: 1; }
}

/* === 商城取貨：選門市清單 === */
.bm-store-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-warm);
  border-radius: var(--r-pill, 999px);
  margin-bottom: 12px;
}
.bm-store-search i { color: var(--text-sub); font-size: 14px; }
.bm-store-search input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  color: inherit;
}
.bm-store-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 52vh;
  overflow-y: auto;
  padding-right: 4px;
}
.bm-store-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  background: var(--bg-warm);
  border: 1px solid transparent;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.bm-store-item:hover {
  background: var(--bg-soft);
  border-color: var(--lohas-light, #CDBEA2);
}
.bm-store-item-main { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bm-store-item-name { font-size: 15px; font-weight: 700; color: var(--lohas-brand, #50422D); }
.bm-store-item-addr { font-size: 12px; color: var(--text-sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm-store-item-meta {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--lohas-brand, #50422D);
  background: #fff;
  border-radius: 999px;
  padding: 3px 9px;
}
.bm-store-item > i { color: var(--text-sub); font-size: 13px; flex: 0 0 auto; }
.bm-store-empty { padding: 24px; text-align: center; color: var(--text-sub); font-size: 14px; }

/* 已選門市條 */
.bm-picked-store {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--lohas-light, #CDBEA2);
  color: var(--lohas-brand, #50422D);
  border-radius: 12px;
  margin-bottom: 14px;
  font-size: 13px;
}
.bm-picked-store b { font-weight: 700; }
.bm-link {
  background: none;
  border: none;
  color: var(--lohas-brand, #50422D);
  text-decoration: underline;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  flex: 0 0 auto;
}
