/* Mobile-first customer ordering page. No external fonts or assets —
   this must load fast on a phone over restaurant Wi-Fi. */

:root {
  --accent: #c2410c;
  --accent-press: #9a3412;
  --bg: #faf7f2;
  --surface: #ffffff;
  --text: #292524;
  --text-dim: #78716c;
  --line: #e7e0d8;
  --danger: #b91c1c;
  --ok: #15803d;
  --radius: 14px;
  --shadow: 0 1px 3px rgb(0 0 0 / 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #fb923c;
    --accent-press: #f97316;
    --bg: #1c1917;
    --surface: #292524;
    --text: #f5f5f4;
    --text-dim: #a8a29e;
    --line: #44403c;
    --shadow: 0 1px 3px rgb(0 0 0 / 0.4);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Thai",
    "Sarabun", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ---- layout states ---- */

.center-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
  color: var(--text-dim);
}

.center-screen h1 { color: var(--text); font-size: 1.35rem; }
.center-screen .big-emoji { font-size: 3.5rem; }

.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- header ---- */

.top-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--accent);
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.top-bar .store-name {
  font-weight: 700;
  font-size: 1.05rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-badge {
  flex-shrink: 0;
  background: rgb(255 255 255 / 0.22);
  border-radius: 999px;
  padding: 4px 14px;
  font-weight: 700;
  font-size: 0.95rem;
}

/* ---- category chips ---- */

.chips {
  position: sticky;
  top: calc(env(safe-area-inset-top) + 56px);
  z-index: 9;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 16px;
  background: var(--bg);
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.9rem;
  color: var(--text-dim);
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---- menu ---- */

main { padding: 0 16px 120px; }

.category-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 18px 2px 10px;
}

.product-card {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: start;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.product-card .name { font-weight: 600; }
.product-card .hint { font-size: 0.8rem; color: var(--text-dim); }
.product-card .price { font-weight: 700; color: var(--accent); white-space: nowrap; }

/* ---- bottom cart bar ---- */

.cart-bar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 10;
  padding: 12px 16px calc(env(safe-area-inset-bottom) + 12px);
  background: linear-gradient(transparent, var(--bg) 40%);
}

.cart-bar button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 1rem;
  font-weight: 700;
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.18);
}
.cart-bar button:active { background: var(--accent-press); }

.cart-bar .count-pill {
  background: rgb(255 255 255 / 0.25);
  border-radius: 999px;
  padding: 2px 10px;
  margin-right: 10px;
  font-size: 0.9rem;
}

/* ---- sheets (product picker / cart) ---- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgb(0 0 0 / 0.45);
  display: flex;
  align-items: flex-end;
}

.sheet {
  background: var(--bg);
  width: 100%;
  max-height: 88dvh;
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  animation: rise 0.22s ease-out;
}
@keyframes rise { from { transform: translateY(40px); opacity: 0.6; } }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 8px;
}
.sheet-head h2 { font-size: 1.1rem; }
.sheet-close {
  font-size: 1.3rem;
  line-height: 1;
  color: var(--text-dim);
  padding: 6px 10px;
}

.sheet-body { overflow-y: auto; padding: 0 16px; flex: 1; }

.sheet-foot {
  padding: 12px 16px calc(env(safe-area-inset-bottom) + 14px);
  border-top: 1px solid var(--line);
  background: var(--surface);
  border-radius: 0 0 0 0;
}

.option-group { margin-bottom: 16px; }
.option-group > .group-name {
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 8px;
}
.group-name .requirement { color: var(--text-dim); font-weight: 400; font-size: 0.8rem; }
.group-name.unmet .requirement { color: var(--danger); }

.option-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  text-align: start;
}
.option-row.selected { border-color: var(--accent); }
.option-row .tick {
  width: 20px; height: 20px;
  flex-shrink: 0;
  border: 2px solid var(--line);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: transparent;
}
.option-row.selected .tick { background: var(--accent); border-color: var(--accent); color: #fff; }
.option-row.checkbox .tick { border-radius: 5px; }
.option-row .grow { flex: 1; }
.option-row .adj { color: var(--text-dim); font-size: 0.88rem; white-space: nowrap; }

.note-input {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
.note-input:focus { outline: none; border-color: var(--accent); }

.qty-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 8px 0 12px;
}

.qty-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-size: 1.3rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.qty-btn:disabled { opacity: 0.35; }
.qty-value { font-size: 1.15rem; font-weight: 700; min-width: 2ch; text-align: center; }

.primary-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 1rem;
  font-weight: 700;
}
.primary-btn:active { background: var(--accent-press); }
.primary-btn:disabled { opacity: 0.45; }
.primary-btn.center { justify-content: center; }

.ghost-btn {
  width: 100%;
  text-align: center;
  padding: 12px;
  color: var(--accent);
  font-weight: 700;
}

/* ---- cart lines ---- */

.cart-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.cart-line .grow { flex: 1; min-width: 0; }
.cart-line .name { font-weight: 600; }
.cart-line .detail { font-size: 0.82rem; color: var(--text-dim); }
.cart-line .price { font-weight: 700; color: var(--accent); white-space: nowrap; }
.cart-line .qty-mini {
  display: flex; align-items: center; gap: 12px; margin-top: 6px;
}
.cart-line .qty-mini .qty-btn { width: 30px; height: 30px; font-size: 1rem; }

.cart-summary {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 10px 2px 12px;
}

.notice {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 10px 14px;
  margin: 4px 0 12px;
}

.error-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  border-radius: var(--radius);
  font-size: 0.9rem;
  padding: 10px 14px;
  margin-bottom: 12px;
}
@media (prefers-color-scheme: dark) {
  .error-banner { background: #451a1a; border-color: #7f1d1d; color: #fca5a5; }
}

/* ---- sent / status screen ---- */

.sent-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 46px 24px 26px;
  text-align: center;
}

.sent-hero .check {
  width: 84px; height: 84px;
  border-radius: 50%;
  background: var(--ok);
  color: #fff;
  font-size: 2.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pop 0.35s ease-out;
}
@keyframes pop { from { transform: scale(0.4); opacity: 0; } }

.sent-hero h1 { font-size: 1.5rem; }
.sent-hero p { color: var(--text-dim); }

.order-history { padding: 0 16px 140px; }
.order-history h2 { font-size: 0.95rem; color: var(--text-dim); margin: 14px 2px 8px; }

.order-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  margin-bottom: 8px;
  font-size: 0.9rem;
}
.order-entry .status-sent { color: var(--ok); font-weight: 700; }
.order-entry .status-rejected { color: var(--danger); font-weight: 700; }
.order-entry .reason { font-size: 0.8rem; color: var(--text-dim); }

/* Pickup stage timeline (M6) */
.sent-hero .check.rejected { background: #fee2e2; color: var(--danger); }

.timeline {
  display: flex;
  justify-content: space-between;
  padding: 0 24px 8px;
  position: relative;
}

.timeline-step {
  flex: 1;
  text-align: center;
  position: relative;
}

.timeline-step .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--line);
  margin: 0 auto 6px;
}

.timeline-step::before {
  content: "";
  position: absolute;
  top: 6px;
  left: -50%;
  width: 100%;
  height: 2px;
  background: var(--line);
  z-index: -1;
}

.timeline-step:first-child::before { display: none; }

.timeline-step.done .dot,
.timeline-step.done::before { background: var(--accent); }

.timeline-step.current .label { font-weight: 700; color: var(--accent); }

.timeline-step .label { font-size: 12px; color: var(--text-dim); }

/* PromptPay payment box (M6 slice 3) */
.payment-box {
  margin: 0 24px 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: center;
}

.payment-box .payment-qr {
  width: min(220px, 60vw);
  margin: 10px auto;
}

.payment-box .payment-qr svg { width: 100%; height: auto; display: block; }

.notice.payment-paid { color: var(--ok); font-weight: 600; }
