﻿*, *::before, *::after { box-sizing: border-box; }

:root {
  --primary: #1e3a5f;
  --primary-dark: #152a45;
  --accent: #2563eb;
  --accent-light: #eff6ff;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --page-bg: #f0f4f8;
  --surface: #ffffff;
  --text: #0f172a;
  --text-secondary: #475569;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-soft: #f1f5f9;
  --white: #fff;
  --line-green: #059669;
  --header-h: 56px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 6px 20px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.14);
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Microsoft JhengHei", "PingFang TC", sans-serif;
  background: var(--page-bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body.menu-open { overflow: hidden; }

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

/* ── Header ── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--header-h);
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.logo-slot {
  flex: 0 1 auto;
  display: flex;
  align-items: center;
  min-width: 0;
}

.site-logo {
  display: block;
  height: 40px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
}

.menu-btn {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  min-height: 44px;
  min-width: 44px;
  padding: 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  transition: background 0.2s;
}

.menu-btn:hover { background: var(--accent-light); }

.menu-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--primary);
  border-radius: 2px;
}

/* ── Side menu ── */
.side-menu {
  position: fixed;
  top: 0;
  right: 0;
  width: min(300px, 88vw);
  height: 100%;
  max-height: 100dvh;
  background: var(--surface);
  z-index: 200;
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 0.28s ease;
  overflow-y: auto;
}

.side-menu.is-open { transform: translateX(0); }

.side-menu[hidden] {
  display: block !important;
  visibility: hidden;
  pointer-events: none;
}

.side-menu.is-open[hidden] {
  visibility: visible;
  pointer-events: auto;
}

.side-menu-inner { padding: calc(var(--header-h) + 16px) 24px 28px; }

.side-menu-inner h3 {
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--accent-light);
  color: var(--primary);
  font-size: 1.0625rem;
  font-weight: 700;
}

.side-menu-inner p { margin: 10px 0; font-size: 0.9375rem; color: var(--text-secondary); }

.menu-hours { color: var(--muted) !important; font-size: 0.875rem !important; }

.menu-close {
  margin-top: 24px;
  width: 100%;
  min-height: 48px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--white);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.menu-close:hover { background: var(--primary-dark); }

.menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 150;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.menu-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.menu-overlay[hidden] { display: block !important; }

/* ── Page layout ── */
.page {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 0 32px;
  min-height: calc(100dvh - var(--header-h));
}

.load-error {
  margin: 16px;
  padding: 12px 16px;
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
}

/* ── Hero / 頁面標題 ── */
.product-banner {
  margin: 16px 16px 0;
  padding: 28px 24px;
  background: linear-gradient(135deg, var(--primary) 0%, #2d4a6f 50%, var(--accent) 100%);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.page-title {
  margin: 0;
  color: var(--white);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.page-subtitle {
  margin: 8px 0 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.875rem;
  font-weight: 400;
}

/* ── 卡片區塊 ── */
.table-section {
  margin: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-section-head {
  margin: 0;
  padding: 14px 16px;
  background: var(--accent-light);
  color: var(--primary);
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-section-head::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 16px;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}

/* ── 寄件人資料 ── */
.data-table {
  padding: 4px 0;
}

.data-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
}

.data-row:last-child { border-bottom: none; }

.data-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0.02em;
}

.data-value {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
  word-break: break-word;
}

.kv-amount { color: var(--danger); font-weight: 700; }

/* ── 表單欄位 ── */
.form-field-stack {
  border-bottom: 1px solid var(--border-soft);
}

.form-field-stack:last-of-type { border-bottom: none; }

.field-head {
  margin: 0;
  padding: 14px 16px 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.field-head em {
  font-style: normal;
  color: var(--danger);
  font-weight: 500;
  font-size: 0.75rem;
  margin-left: 4px;
}

.form-field-body { padding: 2px 16px 14px; }

.form-field-body input,
.form-field-body select,
.address-fields input,
.address-fields select {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-field-body input::placeholder,
.address-fields input::placeholder {
  color: #94a3b8;
}

.form-field-body input:focus,
.form-field-body select:focus,
.address-fields input:focus,
.address-fields select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-field-body select,
.address-fields select {
  background-color: var(--surface);
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) calc(50% + 2px), calc(100% - 14px) calc(50% + 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 40px;
}

.address-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.address-select-label { display: block; }

.address-select-title {
  display: block;
  margin-bottom: 5px;
  font-size: 0.8125rem;
  color: var(--muted);
  font-weight: 600;
}

/* ── 條款區 ── */
.terms-block {
  margin: 0 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.terms-open-btn {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 44px;
  margin-bottom: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--accent-light);
  color: var(--primary);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s, border-color 0.2s;
}

.terms-open-btn:hover:not(:disabled) {
  background: #dbeafe;
  border-color: var(--accent);
}

.agree-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.agree-row input {
  width: 17px;
  height: 17px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--accent);
}

/* ── 按鈕 ── */
.btn-primary,
.btn-outline,
.btn-line {
  display: block;
  width: 100%;
  min-height: 50px;
  padding: 13px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
}

.btn-block { margin-left: 16px; margin-right: 16px; width: calc(100% - 32px); }

.btn-primary {
  background: var(--primary);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(30, 58, 95, 0.28);
}

.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-primary:active:not(:disabled) { transform: scale(0.985); }

.btn-primary:disabled {
  background: #cbd5e1;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-red {
  background: var(--danger) !important;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.25) !important;
}

.btn-red:hover:not(:disabled) { background: #b91c1c !important; }

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-line {
  background: var(--line-green);
  color: var(--white);
}

.btn-line:hover { background: #047857; }

#booking-form .btn-primary { margin-top: 16px; margin-bottom: 8px; }

.error-msg {
  margin: 0 16px 12px;
  color: var(--danger);
  font-size: 0.875rem;
}

.error-msg[hidden] { display: none !important; }

/* ── 注意事項 ── */
.reminder-box {
  margin: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 0.875rem;
}

.reminder-box summary {
  padding: 14px 16px;
  cursor: pointer;
  font-weight: 600;
  color: var(--primary);
  list-style: none;
  user-select: none;
}

.reminder-box summary::-webkit-details-marker { display: none; }

.reminder-box[open] summary {
  border-bottom: 1px solid var(--border-soft);
}

.reminder-box ul {
  margin: 0;
  padding: 12px 16px 14px 32px;
  color: var(--text-secondary);
}

.reminder-box li { margin-bottom: 6px; }

.reminder-box li:last-child { margin-bottom: 0; }

/* ── Footer ── */
.page-footer {
  margin-top: 8px;
  padding: 20px 16px 12px;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 4px 8px;
  margin-bottom: 10px;
}

.footer-links span { color: var(--border); }

.footer-links a {
  color: var(--accent);
  font-size: 0.8125rem;
}

.footer-note { margin: 8px 0; line-height: 1.55; }

.copyright { margin: 8px 0 0; font-size: 0.75rem; color: #94a3b8; }

/* ── 完成彈窗 ── */
.completion-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.5);
  pointer-events: none;
}

.completion-modal-overlay[hidden] { display: none !important; }

.completion-modal {
  pointer-events: auto;
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.completion-modal-header {
  padding: 14px 16px;
  background: var(--primary);
  text-align: center;
}

.completion-modal-header h3 {
  margin: 0;
  color: var(--white);
  font-size: 1.0625rem;
  font-weight: 600;
}

.completion-modal-body {
  padding: 24px 20px 20px;
  text-align: center;
}

.completion-congrats-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 10px;
}

.completion-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--white);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}

.completion-modal-congrats {
  margin: 0;
  color: var(--primary);
  font-size: 1.0625rem;
  font-weight: 700;
}

.completion-modal-notice {
  margin: 0 0 20px;
  color: var(--danger);
  font-size: 0.9375rem;
  line-height: 1.65;
  text-align: left;
}

.completion-modal-body .btn-block {
  margin: 0;
  width: 100%;
}

/* ── Dialog 彈窗 ── */
.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  max-width: min(420px, calc(100vw - 32px));
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  background: var(--primary);
  color: var(--white);
}

.modal-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.modal-close {
  border: none;
  background: transparent;
  color: var(--white);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.modal-body {
  padding: 16px;
  max-height: min(60vh, 420px);
  overflow-y: auto;
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--text-secondary);
}

.text-modal-body h4 {
  margin: 14px 0 8px;
  font-size: 0.9375rem;
  color: var(--primary);
}

.text-modal-body h4:first-child { margin-top: 0; }

.text-modal-body p { margin: 0 0 10px; }

.modal-footer { padding: 0 16px 16px; }

/* ── Desktop ── */
@media (min-width: 481px) {
  body { background: #dde3ea; }

  .page {
    margin-top: 12px;
    margin-bottom: 12px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    background: var(--page-bg);
    overflow: hidden;
  }
}
