/* 病患端樣式。
   設計取向：這是病人在手機上、可能站在診所門口、可能是長輩在用。
   所以字要大、按鈕要好按（最小 48px 高）、一次只問一件事、不要有需要橫向捲動的東西。 */

:root {
  --brand: #1F6F8B;
  --brand-dark: #175468;
  --brand-tint: #E8F2F6;
  --ink: #16202A;
  --sub: #64748B;
  --line: #E2E8F0;
  --bg: #F4F6F8;
  --surface: #FFFFFF;
  --green: #15803D;
  --amber: #B45309;
  --red: #B91C1C;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Noto Sans TC", "Microsoft JhengHei", -apple-system, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.65;
}

/* 在桌機上收成手機寬度，方便彩排與投影 */
.phone {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.07);
}

/* ── 頂欄 ── */
.app-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--brand); color: #fff;
  padding: 12px 12px calc(12px + env(safe-area-inset-top, 0px));
  padding-top: max(12px, env(safe-area-inset-top, 12px));
  position: sticky; top: 0; z-index: 10;
}
.app-bar h1 { flex: 1; margin: 0; font-size: 1.05rem; font-weight: 700; text-align: center; }
.app-bar button {
  background: transparent; border: 0; color: #fff;
  font-size: 1.4rem; line-height: 1; width: 36px; height: 36px;
  cursor: pointer; border-radius: 8px; font-family: inherit;
}
.app-bar button:active { background: rgba(255, 255, 255, 0.18); }
.app-bar button[hidden] { visibility: hidden; display: block; }

/* ── 示範聲明（合規要求：首行必須明講）── */
.disclaimer {
  background: #FEF3C7; color: #78350F;
  font-size: 0.78rem; line-height: 1.5;
  padding: 8px 16px; text-align: center;
  border-bottom: 1px solid #FCD34D;
}

main { flex: 1; padding: 20px 16px 32px; }

.view { display: none; animation: fade 0.18s ease-out; }
.view.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.view-title { font-size: 1.25rem; margin: 0 0 6px; }
.sub-title { font-size: 0.95rem; margin: 22px 0 8px; color: var(--sub); }
.hint { color: var(--sub); font-size: 0.88rem; margin: 0 0 18px; }
.fineprint { color: var(--sub); font-size: 0.78rem; margin-top: 14px; text-align: center; }
.err { color: var(--red); font-size: 0.88rem; margin-top: 12px; }
.empty { color: var(--sub); text-align: center; padding: 32px 0; }

/* ── 歡迎頁 ── */
.hero { text-align: center; padding: 12px 0 24px; }
.hero-icon {
  width: 68px; height: 68px; margin: 0 auto 14px;
  border-radius: 20px; background: var(--brand); color: #fff;
  font-size: 2.2rem; line-height: 68px; font-weight: 300;
}
.hero h2 { margin: 0 0 8px; font-size: 1.5rem; }
.lede { color: var(--sub); font-size: 0.92rem; margin: 0; }

.feature-list { list-style: none; padding: 0; margin: 0 0 26px; }
.feature-list li {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 13px 16px; margin-bottom: 9px;
  font-size: 0.9rem; color: var(--sub);
}
.feature-list b { color: var(--ink); margin-right: 8px; }

/* ── 隱私權告知 ── */
.policy-box {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
  max-height: 46vh; overflow-y: auto;
  font-size: 0.86rem; line-height: 1.75;
  -webkit-overflow-scrolling: touch;
}
.policy-box h3 { font-size: 0.92rem; margin: 18px 0 4px; color: var(--brand-dark); }
.policy-box h3:first-child { margin-top: 0; }
.policy-box p { margin: 0; white-space: pre-wrap; color: #334155; }

.read-check {
  display: flex; align-items: flex-start; gap: 10px;
  margin: 18px 0; font-size: 0.9rem; cursor: pointer;
}
.read-check input { width: 22px; height: 22px; margin: 1px 0 0; flex: none; accent-color: var(--brand); }

/* ── 表單 ── */
.field { display: block; margin-bottom: 18px; }
.field > span { display: block; font-size: 0.85rem; color: var(--sub); margin-bottom: 6px; }
.field em { font-style: normal; font-size: 0.78rem; }
.field input {
  width: 100%; font-family: inherit; font-size: 1.05rem;
  padding: 13px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink);
}
.field input:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.code-input { letter-spacing: 0.5em; text-align: center; font-size: 1.5rem; font-variant-numeric: tabular-nums; }

.sms-note {
  background: #FFFBEB; border: 1px solid #FDE68A; color: #92400E;
  border-radius: 10px; padding: 11px 14px; font-size: 0.82rem; margin-bottom: 16px;
}

/* ── 按鈕（最小 48px 高，長輩也按得到）── */
.btn {
  font-family: inherit; font-size: 1rem; font-weight: 600;
  min-height: 50px; padding: 13px 20px;
  border: 1px solid transparent; border-radius: 12px; cursor: pointer;
}
.btn-block { display: block; width: 100%; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:active { background: var(--brand-dark); }
.btn-primary:disabled { background: #CBD5E1; color: #fff; cursor: not-allowed; }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-text { background: transparent; color: var(--sub); font-weight: 400; font-size: 0.9rem; min-height: 44px; }

/* ── 主選單 ── */
.greeting { margin-bottom: 18px; }
.greeting span { font-size: 1.4rem; font-weight: 700; }
.greeting small { color: var(--sub); margin-left: 6px; }

.next-appt {
  background: var(--brand); color: #fff;
  border-radius: var(--radius); padding: 16px; margin-bottom: 18px;
}
.next-appt .label { font-size: 0.78rem; opacity: 0.85; }
.next-appt .big { font-size: 1.15rem; font-weight: 700; margin: 4px 0; }
.next-appt .meta { font-size: 0.85rem; opacity: 0.9; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.tile {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 14px;
  text-align: left; cursor: pointer; font-family: inherit;
  display: flex; flex-direction: column; gap: 2px; min-height: 108px;
}
.tile:active { background: var(--brand-tint); }
.tile i { font-size: 1.5rem; font-style: normal; margin-bottom: 4px; }
.tile b { font-size: 1rem; color: var(--ink); }
.tile small { font-size: 0.75rem; color: var(--sub); line-height: 1.4; }

/* ── 選項清單 ── */
.choice-list { display: flex; flex-direction: column; gap: 10px; }
.choice {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 15px 16px;
  text-align: left; cursor: pointer; font-family: inherit; font-size: 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  color: var(--ink); width: 100%;
}
.choice:active { background: var(--brand-tint); }
.choice:disabled { opacity: 0.55; cursor: not-allowed; background: #F8FAFC; }
.choice .main { display: flex; flex-direction: column; gap: 2px; }
.choice .name { font-weight: 600; }
.choice .desc { font-size: 0.8rem; color: var(--sub); }
.choice .tail { font-size: 0.8rem; color: var(--sub); text-align: right; flex: none; }
.choice .tail.warn { color: var(--amber); }
.choice .tail.full { color: var(--red); }

/* ── 日期橫捲 ── */
.date-strip {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px;
  -webkit-overflow-scrolling: touch;
}
.date-chip {
  flex: none; min-width: 62px; padding: 10px 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  text-align: center; cursor: pointer; font-family: inherit;
}
.date-chip .wd { font-size: 0.72rem; color: var(--sub); }
.date-chip .dd { font-size: 1.15rem; font-weight: 700; }
.date-chip.is-on { background: var(--brand); border-color: var(--brand); color: #fff; }
.date-chip.is-on .wd { color: rgba(255, 255, 255, 0.85); }
.date-chip:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── 摘要與票卡 ── */
.summary, .ticket {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 18px;
}
.summary .row, .ticket .row {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 0.92rem;
}
.summary .row:last-child, .ticket .row:last-child { border-bottom: 0; }
.summary .k, .ticket .k { color: var(--sub); flex: none; }
.summary .v, .ticket .v { text-align: right; font-weight: 600; }

.ticket .number { text-align: center; padding: 8px 0 16px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.ticket .number small { display: block; color: var(--sub); font-size: 0.8rem; }
.ticket .number strong { font-size: 3rem; color: var(--brand); line-height: 1.1; font-variant-numeric: tabular-nums; }

.done { text-align: center; padding: 16px 0 22px; }
.done-mark {
  width: 62px; height: 62px; margin: 0 auto 12px; border-radius: 50%;
  background: var(--green); color: #fff; font-size: 2rem; line-height: 62px;
}
.done h2 { margin: 0; font-size: 1.35rem; }

/* ── 我的預約 ── */
.appt-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.appt-card .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.appt-card .when { font-size: 1.05rem; font-weight: 700; }
.appt-card .where { font-size: 0.85rem; color: var(--sub); margin-top: 2px; }
.appt-card .no { text-align: right; flex: none; }
.appt-card .no small { display: block; font-size: 0.72rem; color: var(--sub); }
.appt-card .no strong { font-size: 1.7rem; color: var(--brand); font-variant-numeric: tabular-nums; }
.appt-card .actions { display: flex; gap: 8px; margin-top: 14px; }
.appt-card .actions .btn { flex: 1; min-height: 44px; font-size: 0.9rem; padding: 10px; }

.badge {
  display: inline-block; font-size: 0.75rem; padding: 3px 10px;
  border-radius: 999px; margin-top: 8px; font-weight: 600;
}
.badge-booked { background: #FEE2E2; color: var(--red); }
.badge-confirmed { background: #DCFCE7; color: var(--green); }
.badge-reschedule { background: #FEF3C7; color: var(--amber); }
.badge-other { background: #F1F5F9; color: var(--sub); }

/* ── 候診進度 ── */
.progress-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px 18px; text-align: center;
}
.progress-card .now-label { font-size: 0.85rem; color: var(--sub); }
.progress-card .now { font-size: 3.4rem; font-weight: 700; color: var(--brand); line-height: 1.1; font-variant-numeric: tabular-nums; }
.progress-card .divider { height: 1px; background: var(--line); margin: 18px 0; }
.progress-card .mine { font-size: 0.85rem; color: var(--sub); }
.progress-card .mine b { font-size: 1.6rem; color: var(--ink); display: block; font-variant-numeric: tabular-nums; }
.progress-card .eta { margin-top: 14px; font-size: 1rem; color: var(--ink); }
.progress-card .eta b { color: var(--brand); }
.progress-card.called { border-color: var(--green); }
.progress-card.called .now { color: var(--green); }

/* ── 院所資訊 ── */
.info-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.info-card h3 { margin: 0 0 4px; font-size: 1rem; }
.info-card p { margin: 2px 0; font-size: 0.85rem; color: var(--sub); }
.info-card a { color: var(--brand); text-decoration: none; font-weight: 600; }

/* ── 頁尾（合規要求：每頁角落標示）── */
.app-foot {
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  text-align: center; color: var(--sub); font-size: 0.72rem;
}

/* ── 提示訊息 ── */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px;
  border-radius: 10px; font-size: 0.88rem; z-index: 99;
  max-width: 88vw; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
