/* 設計系統元件 — 依 tokens.css 變數 */

/* hidden 屬性一律隱藏（修：.field{display:flex} 等會蓋過 UA 的 [hidden]{display:none}）*/
[hidden] { display: none !important; }

/* 按鈕 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--touch);
  padding: 0 var(--sp-4);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-size: var(--fs-md);
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, background 0.15s;
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn--primary {
  background: var(--c-accent);
  color: var(--c-on-accent);
}
.btn--primary:hover {
  filter: brightness(0.97);
}
.btn--secondary {
  background: var(--c-primary);
  color: var(--c-on-primary);
}
.btn--ghost {
  background: transparent;
  color: var(--c-primary);
  border-color: var(--c-line);
}
/* 危險操作的實心確認鈕（取消訂單/結案/停權等 confirm 的 OK 鍵） */
.btn--danger-solid {
  background: var(--c-danger);
  color: #fff;
  border-color: var(--c-danger);
}
.btn--danger-solid:hover { filter: brightness(0.95); }
/* 危險操作的 outline 版（LIFF 也會用到，從 admin.css 上移共用） */
.btn--danger { color: var(--c-danger); border-color: var(--c-danger); }
.btn--danger:hover { background: var(--c-danger-bg, #fbeae6); }
.btn--block {
  display: flex;
  width: 100%;
}
/* 小按鈕的單一定義（後台/LIFF 共用；勿在 page CSS 重複定義造成漂移） */
.btn--sm {
  min-height: 36px;
  padding: 0 12px;
  font-size: var(--fs-sm);
}

/* 卡片 */
.card {
  background: var(--c-card);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  padding: var(--sp-4);
}
.card__title {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--c-primary);
}

/* 表單欄位 */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}
.field__label {
  font-size: var(--fs-sm);
  color: var(--c-muted);
  font-weight: 600;
}
.field__input,
.field__select {
  min-height: var(--touch);
  padding: 0 var(--sp-3);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  font-size: var(--fs-md);
  background: var(--c-card);
  color: var(--c-ink);
  width: 100%;
}
textarea.field__input {
  min-height: 72px;
  padding-top: var(--sp-2);
  resize: vertical;
}
.field__input:focus,
.field__select:focus {
  outline: 2px solid var(--c-primary-l);
  outline-offset: -1px;
  border-color: var(--c-primary-l);
}

/* 分段切換（即時 / 預約）*/
.segmented {
  display: flex;
  background: var(--c-bg);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  padding: 3px;
}
.segmented__btn {
  flex: 1;
  min-height: 38px;
  border: 0;
  background: transparent;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--c-muted);
  cursor: pointer;
}
.segmented__btn.is-active {
  background: var(--c-primary);
  color: var(--c-on-primary);
  font-weight: 700;
}

/* 數量加減 */
.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--c-card);
}
.stepper__btn {
  width: var(--touch);
  height: var(--touch);
  border: 0;
  background: var(--c-card);
  font-size: var(--fs-xl);
  color: var(--c-primary);
  cursor: pointer;
}
.stepper__val {
  min-width: 44px;
  text-align: center;
  font-weight: 700;
}

/* 狀態標籤（文字色加深至 WCAG 4.5:1；13px 顧及年長客服） */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  font-weight: 700;
}
.chip--pending {
  background: var(--c-warn-bg);
  color: #8A5A00;          /* 4.5:1 on #fbefd9 */
}
.chip--confirmed {
  background: var(--c-success-bg);
  color: #1E6B54;          /* 4.9:1 on #e3f3ec */
}
.chip--dispatched {
  background: #e7eef6;
  color: var(--c-primary); /* 9.8:1 */
}
.chip--done {
  background: var(--c-info-bg);
  color: #0A6169;          /* 5.3:1 on #e7f1f1 */
}
.chip--danger {
  background: var(--c-danger-bg);
  color: #A93A31;          /* 4.9:1 on #fbeae6 */
}

/* 頂列 app bar */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: var(--appbar-h);
  padding: 0 var(--sp-4);
  background: var(--c-primary);
  color: #fff;
}
.app-bar__title {
  font-size: var(--fs-lg);
  font-weight: 700;
}
.app-bar__sub {
  font-size: var(--fs-xs);
  color: #cfe0ea;
}

/* 底部動作列 */
.bottom-bar {
  position: sticky;
  bottom: 0;
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-card);
  border-top: 1px solid var(--c-line);
}

/* 清單項 */
.list-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--c-line);
}
.list-item:last-child {
  border-bottom: 0;
}
.list-item__main {
  flex: 1;
  min-width: 0;
}
.list-item__title {
  font-weight: 600;
}

/* 地圖佔位（Maps 金鑰到位前）*/
.map-placeholder {
  height: 180px;
  border-radius: var(--r-md);
  border: 1px dashed var(--c-line);
  background: repeating-linear-gradient(
    45deg,
    #eef2f6,
    #eef2f6 10px,
    #e8edf2 10px,
    #e8edf2 20px
  );
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-muted);
  font-size: var(--fs-sm);
}

/* 浮動提示 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--c-primary-d);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  box-shadow: var(--shadow-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 100;
}
.toast.is-show {
  opacity: 1;
}

/* app bar 內的文字連結（LIFF 導覽用）*/
.app-bar__link {
  color: #fff;
  font-size: var(--fs-sm);
  font-weight: 600;
  padding: 6px 10px;
  border-radius: var(--r-md);
  border: 1px solid #3c6488;
}

/* toast 變體 */
.toast--error {
  background: var(--c-danger);
}
.toast--success {
  background: var(--c-success);
}

/* 對話框（confirm / prompt，取代原生 dialog）*/
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 45, 64, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: var(--sp-4);
}
.dialog {
  background: var(--c-card);
  border-radius: var(--r-lg);
  width: min(360px, 92vw);
  padding: var(--sp-5);
  box-shadow: var(--shadow-2);
}
.dialog__title {
  font-weight: 700;
  color: var(--c-primary);
  margin-bottom: var(--sp-2);
}
.dialog__msg {
  color: var(--c-ink);
}
.dialog__input {
  margin-top: var(--sp-3);
}
.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
}

/* ============================================================
   質感優化：陰影 / 過場 / 微互動（集中疊加，不改上方原規則）
   ============================================================ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

/* 按鈕：hover 微抬升 + 陰影，focus 光環 */
.btn { transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur) var(--ease), filter var(--dur-fast), background var(--dur-fast); }
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn--primary { box-shadow: 0 2px 6px rgba(239, 161, 60, 0.28); }
.btn--primary:hover:not(:disabled) { filter: brightness(1.02); box-shadow: var(--shadow-accent); }
.btn--secondary { box-shadow: 0 2px 8px rgba(31, 59, 92, 0.22); }
.btn--secondary:hover:not(:disabled) { box-shadow: 0 6px 16px rgba(31, 59, 92, 0.30); }
.btn--ghost:hover:not(:disabled) { background: var(--c-bg); border-color: var(--c-primary-l); }

/* 卡片：過場 */
.card { transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease); }

/* 輸入：柔和焦點光環取代硬邊 outline */
.field__input, .field__select { transition: border-color var(--dur-fast), box-shadow var(--dur-fast); }
.field__input:focus, .field__select:focus { outline: none; border-color: var(--c-primary-l); box-shadow: var(--shadow-focus); }

/* 分段切換 / 加減鈕 */
.segmented__btn { transition: background var(--dur-fast), color var(--dur-fast), box-shadow var(--dur-fast); }
.segmented__btn.is-active { box-shadow: var(--shadow-1); }
.stepper__btn { transition: background var(--dur-fast); }
.stepper__btn:hover { background: var(--c-bg); }

/* app bar 陰影 */
.app-bar { box-shadow: 0 2px 10px rgba(28, 45, 64, 0.18); }

/* Toast 滑入 */
.toast { box-shadow: var(--shadow-2); }
.toast.is-show { animation: toastIn var(--dur) var(--ease); }

/* 對話框進場 + 背景毛玻璃 */
.dialog-backdrop { animation: fadeIn var(--dur-fast) var(--ease); backdrop-filter: blur(2px); }
.dialog { animation: popIn var(--dur) var(--ease); box-shadow: var(--shadow-2); }

/* 尊重使用者「減少動態」偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* 地址自動完成建議面板 */
.geo-suggest {
  position: absolute;
  left: 0; right: 0; top: 100%;
  z-index: 50;
  background: var(--c-card);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  max-height: 260px;
  overflow-y: auto;
  margin-top: 2px;
}
.geo-suggest__row {
  display: flex;
  gap: var(--sp-2);
  align-items: flex-start;
  padding: 10px var(--sp-3);
  cursor: pointer;
  border-bottom: 1px solid var(--c-line);
  font-size: var(--fs-md);
}
.geo-suggest__row:last-child { border-bottom: 0; }
.geo-suggest__row:hover { background: var(--c-bg); }
.geo-suggest__ic { color: var(--c-accent); flex: 0 0 auto; }
.geo-suggest__t small { color: var(--c-muted); }

/* 地圖選點覆蓋層 */
.map-picker {
  position: fixed;
  inset: 0;
  background: rgba(28, 45, 64, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  padding: var(--sp-3);
}
.map-picker__panel {
  background: var(--c-card);
  border-radius: var(--r-lg);
  width: min(600px, 96vw);
  height: min(92vh, 760px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-2);
}
/* 手機：地圖選點全螢幕，視野最大 */
@media (max-width: 640px) {
  .map-picker { padding: 0; }
  .map-picker__panel { width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
}
.map-picker__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-primary);
  color: #fff;
}
.map-picker__title { font-weight: 700; }
.map-picker__x {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: var(--fs-xl);
  cursor: pointer;
  line-height: 1;
}
.map-picker__canvas {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 240px;
  background: #eef2f6;
}
/* 搜尋框：輸入地點快速定位 */
.map-picker__search { padding: var(--sp-2) var(--sp-3); background: var(--c-card); border-bottom: 1px solid var(--c-line); flex: 0 0 auto; }
.map-picker__searchinput {
  width: 100%; box-sizing: border-box; min-height: 44px;
  padding: 0 var(--sp-3); font-size: 16px; color: var(--c-ink);
  border: 1px solid var(--c-line); border-radius: var(--r-md); background: var(--c-bg);
}
/* Google 地址建議下拉：需高於地圖選點覆蓋層（z-index 400）*/
.pac-container { z-index: 500 !important; }

/* 起訖分行路線（乘客訂單 + 司機任務共用）：上車綠點 → 連接線 → 下車紅點 */
.route__pt { display: flex; gap: 10px; position: relative; padding-bottom: 12px; }
.route__pt:last-child { padding-bottom: 0; }
.route__dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; margin-top: 3px; position: relative; z-index: 1; }
.route__dot--o { background: var(--c-success); box-shadow: 0 0 0 3px var(--c-success-bg); }
.route__dot--d { background: var(--c-danger); box-shadow: 0 0 0 3px var(--c-danger-bg); }
.route__pt:not(:last-child)::before {
  content: ""; position: absolute; left: 5px; top: 15px; bottom: 0; width: 2px; background: var(--c-line);
}
.route__txt { font-size: var(--fs-md); color: var(--c-ink); font-weight: 600; line-height: 1.35; }
.route__lbl { font-size: var(--fs-xs); color: var(--c-muted); font-weight: 600; margin-right: 6px; }
.route__map {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 8px;
  font-size: var(--fs-sm); color: var(--c-info); font-weight: 700; text-decoration: none;
}
.route__map:active { opacity: 0.7; }

/* 地圖實際渲染層（獨立 div，pin 才不會被 Google 蓋掉）*/
.map-picker__map { position: absolute; inset: 0; }
/* 中心固定準心：地圖在底下移動，準心永遠指向畫面中心 */
.map-picker__pin {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 26px;
  height: 26px;
  z-index: 5;
  pointer-events: none;
  border-radius: 50%;
  border: 3px solid var(--c-accent);
  background: rgba(239, 161, 60, 0.18);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9), 0 2px 6px rgba(0, 0, 0, 0.3);
}
.map-picker__pin-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c-accent);
  border: 2px solid #fff;
}
.map-picker__loc {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 3;
  background: var(--c-card);
}
.map-picker__foot {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--c-line);
}
.map-picker__addr { flex: 1; min-width: 0; }

/* 地址輸入 + 地圖鈕（同列；建議面板仍掛在此列下方）*/
.input-with-btn {
  display: flex;
  gap: var(--sp-2);
  align-items: stretch;
}
.input-with-btn .field__input { flex: 1; min-width: 0; }
.input-with-btn .map-pick { flex: 0 0 auto; white-space: nowrap; }

/* 起訖對調列（叫車單上下車之間）*/
.swap-row {
  display: flex;
  justify-content: flex-end;
  margin: -2px 0;
}

/* 用車時間快捷鈕列 */
.quick-times {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
