/* ธีมตามโลโก้ Sampaothai: แดงเรือ #902014 · ทองแดง #af6e4b · ครีมกระดาษ
   (ชื่อตัวแปร --pink/--magenta คงไว้จากธีมเดิม: --magenta = สีหลัก, --pink = สีรอง) */
:root {
  --pink: #b9774f;
  --magenta: #902014;
  --hotpink: #a8321f;
  --soft: #ecd9c4;
  --cream: #faf4ea;
  --yellow: #e0b25c;
  --copper: #af6e4b;
  --ink: #3b2418;
  --muted: #8a6450;
  --line: #ecd9c4;
  --card: #fffdf9;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --bad: #dc2626;
  --bad-soft: #fef2f2;
  --info: #0369a1;
  --info-soft: #f0f9ff;
  --shadow: 0 4px 20px -4px rgb(144 32 20 / 18%);
  color-scheme: only light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; overflow-x: hidden; color: var(--ink);
  background: radial-gradient(1200px 500px at 50% -10%, #f3e2cc 0%, transparent 60%), var(--cream);
  font: 15px/1.6 "Noto Sans Thai", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { line-height: 1.3; margin: 0; }
a { color: var(--magenta); }
button, input, select, textarea { font: inherit; color: inherit; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px 56px; }
.wide { max-width: 860px; }

.hero { text-align: center; padding: 30px 16px 18px; }
.hero .logo { font-size: 2.6rem; line-height: 1; display: inline-block; }
.hero .logo-img { width: min(200px, 56vw); height: auto; display: block; margin: 0 auto; filter: drop-shadow(0 6px 14px rgb(144 32 20 / 22%)); }
.hero h1 { font-size: 1.6rem; font-weight: 800; color: var(--magenta); margin-top: 6px; }
.hero p { margin: 4px 0 0; color: var(--muted); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 24px;
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px;
}
.card h2 { font-size: 1.08rem; font-weight: 800; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; color: var(--magenta); }
.step {
  width: 26px; height: 26px; border-radius: 50%; background: var(--magenta); color: #fff;
  display: inline-grid; place-items: center; font-size: .85rem; flex: none;
}
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.help {
  display: flex; gap: 10px; align-items: center; background: #fff; border: 1px solid var(--line);
  border-radius: 20px; padding: 12px 14px; margin-bottom: 14px; font-size: .93rem;
}
.help a { font-weight: 700; white-space: nowrap; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.chip {
  display: inline-flex; align-items: center; border: 1px solid var(--pink); background: #fff; color: var(--magenta);
  border-radius: 999px; padding: 6px 14px; cursor: pointer; font-weight: 600; font-size: .9rem;
}
.chip[aria-pressed="true"] { background: var(--magenta); color: #fff; border-color: var(--magenta); }
.tag { display: inline-flex; align-items: center; border-radius: 999px; background: var(--soft); color: var(--magenta); padding: 3px 12px; font-size: .78rem; font-weight: 700; }

label { display: block; font-weight: 600; margin: 12px 0 6px; }
input[type="text"], input[type="tel"], input[type="date"], input[type="number"], input[type="password"], select, textarea {
  width: 100%; padding: 12px 16px; border: 1px solid var(--line); border-radius: 16px; background: #fff; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #c9ab92; }
input:focus, select:focus, textarea:focus { border-color: var(--pink); box-shadow: 0 0 0 3px rgb(185 119 79 / 25%); }
button:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }
textarea { min-height: 70px; resize: vertical; }

.rounds-title { font-weight: 700; margin: 14px 0 8px; color: var(--muted); font-size: .88rem; }
.rounds { display: grid; grid-template-columns: repeat(auto-fill, minmax(94px, 1fr)); gap: 8px; }
.round {
  border: 1.5px solid var(--line); background: #fff; border-radius: 18px; padding: 10px 6px;
  text-align: center; cursor: pointer; min-height: 64px; transition: transform .1s;
}
.round:active { transform: scale(.97); }
.round b { display: block; font-size: 1.05rem; color: var(--ink); }
.round span { font-size: .78rem; color: var(--ok); font-weight: 600; }
.round.low span { color: var(--warn); }
.round:disabled { opacity: .45; cursor: not-allowed; background: #f6eee2; }
.round:disabled span { color: var(--muted); }
.round[aria-pressed="true"] { border-color: var(--magenta); background: var(--soft); box-shadow: inset 0 0 0 1px var(--magenta); }

.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button, .food .qty button {
  width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--pink); background: #fff; color: var(--magenta);
  font-size: 1.3rem; font-weight: 700; cursor: pointer; line-height: 1; display: grid; place-items: center;
}
.stepper button:active, .food .qty button:active { transform: scale(.95); }
.stepper button:disabled, .food .qty button:disabled { opacity: .3; cursor: not-allowed; }
.raft-auto { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 6px; font-weight: 700; color: var(--magenta); padding: 10px 0; }
.raft-auto output { font-size: 1.4rem; font-weight: 800; }
.raft-auto small { flex-basis: 100%; font-weight: 400; color: var(--muted); font-size: .8rem; }
.stepper output { min-width: 48px; text-align: center; font-size: 1.4rem; font-weight: 800; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }

.split { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.split span { background: var(--soft); color: var(--magenta); border-radius: 999px; padding: 3px 12px; font-size: .85rem; font-weight: 600; }

.food-list { display: grid; gap: 8px; }
.food { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 18px; padding: 10px 12px; }
.food .info { flex: 1; min-width: 0; }
.food .info b { display: block; }
.food .info small { color: var(--muted); display: block; }
.food .qty { display: flex; align-items: center; gap: 6px; }
.food .qty button { width: 34px; height: 34px; font-size: 1.1rem; }
.food .qty output { min-width: 22px; text-align: center; font-weight: 800; }
details summary { cursor: pointer; font-weight: 700; color: var(--magenta); }

.summary { width: 100%; border-collapse: collapse; }
.summary td { padding: 5px 0; vertical-align: top; }
.summary td:last-child { text-align: right; white-space: nowrap; }
.summary tr.total td { border-top: 1px dashed var(--soft); font-weight: 800; font-size: 1.2rem; padding-top: 10px; color: var(--magenta); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 999px;
  padding: 12px 24px; font-weight: 700; cursor: pointer; background: var(--magenta); color: #fff; text-decoration: none;
  box-shadow: var(--shadow); transition: filter .15s, transform .1s;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: scale(.98); }
.btn.block { width: 100%; font-size: 1.08rem; }
.btn.ghost { background: #fff; color: var(--magenta); border: 1px solid var(--pink); box-shadow: none; }
.btn.danger { background: #fff; color: var(--bad); border: 1px solid #fecaca; box-shadow: none; }
.btn.sm { padding: 7px 14px; font-size: .88rem; }
.btn:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }

.error { background: var(--bad-soft); color: var(--bad); border-radius: 14px; padding: 10px 12px; margin-top: 10px; font-weight: 600; }
.note { background: var(--cream); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.hidden { display: none !important; }

/* QR ชำระเงิน */
.pay { text-align: center; }
.qr-frame {
  display: inline-block; background: #fff; border: 1px solid var(--line); border-radius: 22px; overflow: hidden; box-shadow: var(--shadow);
}
.qr-head { background: #1e3a5f; color: #fff; font-weight: 800; letter-spacing: .04em; padding: 8px 18px; font-size: .9rem; }
.qr-box { padding: 12px; }
.qr-box svg, .qr-box img { display: block; width: 220px; height: 220px; margin: 0 auto; }
.qr-amount { font-size: 1.5rem; font-weight: 800; color: var(--magenta); margin-top: 8px; }
.qr-payee { font-size: .85rem; color: var(--muted); }
.pay-tip { margin: 10px auto 0; max-width: 380px; font-size: .85rem; }

.slip-drop {
  display: flex; align-items: center; gap: 12px; border: 2px dashed var(--pink); border-radius: 18px; padding: 14px;
  cursor: pointer; background: var(--cream); font-weight: 600;
}
.slip-drop img { width: 64px; height: 64px; object-fit: cover; border-radius: 12px; }
.slip-drop input { display: none; }

.ticket { text-align: center; }
.ticket .code { font: 800 1.9rem/1.1 ui-monospace, monospace; letter-spacing: .08em; color: var(--magenta); margin: 8px 0; }
.phone-key { background: var(--cream); border: 1.5px solid var(--soft); border-radius: 18px; padding: 12px; margin: 10px auto 14px; max-width: 340px; font-size: .9rem; color: var(--muted); }
.phone-key b { display: block; font-size: 1.7rem; letter-spacing: .04em; color: var(--magenta); margin: 2px 0; }
.phone-key span { font-size: .8rem; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.confirmed { background: var(--info-soft); color: var(--info); }
.badge.done { background: var(--ok-soft); color: var(--ok); }
.badge.cancelled { background: #f3f4f6; color: #6b7280; }
.badge.slip { background: var(--soft); color: var(--magenta); }

footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 20px 16px 32px; }

/* วิซาร์ดจองทีละหน้า */
.progress { margin: 0 0 14px; }
.plabel { display: flex; gap: 10px; align-items: baseline; margin-bottom: 6px; }
.plabel span { color: var(--muted); font-size: .85rem; }
.plabel b { color: var(--magenta); font-size: 1.05rem; }
.pbar { height: 8px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.pbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--pink), var(--magenta)); border-radius: 999px; transition: width .3s; }
body:has(.wizbar:not(.hidden)) { padding-bottom: 88px; }
.wizbar {
  position: fixed; inset: auto 0 0 0; z-index: 20; background: rgb(255 255 255 / 95%); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line); padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.wizbar-in { max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 10px; }
.wizbar .btn { padding: 11px 18px; }
.wizbar #nextBtn { min-width: 120px; }
.wiztotal { flex: 1; text-align: center; line-height: 1.2; }
.wiztotal b { display: block; font-size: 1.15rem; color: var(--magenta); }
#stepErr { margin: 0 0 14px; }

/* เตือนอาหารสั่งล่วงหน้า 3 ชม. */
.food-alert { background: var(--warn-soft); border: 1.5px solid #fcd34d; color: #92400e; border-radius: 16px; padding: 10px 14px; margin-bottom: 8px; font-size: .92rem; }
.food-alert.off { background: var(--bad-soft); border-color: #fecaca; color: var(--bad); }
.warn-dlg { border: 0; border-radius: 28px; padding: 24px 20px 18px; width: min(400px, calc(100vw - 32px)); text-align: center; color: var(--ink); box-shadow: 0 20px 60px -10px rgb(144 32 20 / 35%); }
.warn-dlg::backdrop { background: rgb(59 36 24 / 55%); }
.warn-dlg .warn-icon { font-size: 2.6rem; line-height: 1; }
.warn-dlg h2 { color: var(--magenta); font-size: 1.15rem; font-weight: 800; margin: 8px 0 12px; }
.warn-dlg p { margin: 6px 0; }
.warn-time { background: var(--soft); color: var(--magenta); border-radius: 14px; padding: 10px; font-size: 1.05rem; }
.warn-time.off { background: var(--bad-soft); color: var(--bad); font-weight: 700; }
.warn-acts { display: grid; gap: 8px; margin-top: 16px; }

/* ---------- มือถือ ---------- */
/* ช่องกรอก 16px: กัน iPhone ซูมหน้าเองตอนแตะช่อง */
input[type="text"], input[type="tel"], input[type="date"], input[type="number"], input[type="password"], input[type="search"], select, textarea { font-size: 16px; }
button, .btn, .chip, .round, a { touch-action: manipulation; }

/* แถบบนหน้าจอง */
.topbar {
  position: sticky; top: 0; z-index: 15; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px; background: rgb(250 244 234 / 94%); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); margin-bottom: 14px;
}
.tb-home { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); min-width: 0; }
.tb-back { font-size: 1.9rem; line-height: 1; color: var(--magenta); margin-right: -2px; font-weight: 300; }
.tb-home img { width: 40px; height: 40px; object-fit: contain; flex: none; }
.tb-home b { display: block; color: var(--magenta); font-size: 1.05rem; line-height: 1.2; }
.tb-home small { display: block; color: var(--muted); font-size: .75rem; line-height: 1.2; }
.tb-call { display: inline-flex; align-items: center; gap: 6px; flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--pink); background: #fff; color: var(--magenta); font-weight: 700; font-size: .85rem; text-decoration: none; }
.tb-call svg { width: 16px; height: 16px; fill: currentColor; }
@media (min-width: 700px) { .topbar { padding-left: max(16px, calc(50vw - 304px)); padding-right: max(16px, calc(50vw - 304px)); } }

.wizbar #nextBtn.confirm { min-width: 150px; background: var(--ok); }

@media (max-width: 480px) {
  .hero { padding: 16px 16px 10px; }
  .hero .logo-img { width: min(150px, 42vw); }
  .hero h1 { font-size: 1.35rem; }
  .card { padding: 16px 14px; border-radius: 20px; }
  .rounds { grid-template-columns: repeat(3, 1fr); }
  .round { min-height: 58px; padding: 8px 4px; }
  .wizbar { padding-left: 12px; padding-right: 12px; }
  .wizbar .btn { padding: 11px 14px; }
  .wizbar #nextBtn { min-width: 104px; }
  .qr-box svg { width: 200px; height: 200px; }
  footer { font-size: .78rem; line-height: 1.7; }
}

/* ขั้นชำระเงิน */
.pay-steps { margin: 14px 0 0; padding-left: 22px; font-size: .9rem; color: var(--muted); }
.pay-steps li { margin: 2px 0; }
.req { color: var(--bad); font-size: .8rem; font-weight: 700; }

.qr-save { margin-top: 10px; }

/* รูปให้กดค้างบันทึก (เบราว์เซอร์ในแอป LINE/FB ดาวน์โหลดไฟล์ไม่ได้) */
.img-dlg { border: 0; border-radius: 22px; padding: 0; width: min(440px, calc(100vw - 24px)); max-height: calc(100vh - 24px); color: var(--ink); background: #fff; overflow: hidden; }
.img-dlg::backdrop { background: rgb(59 36 24 / 60%); }
.img-dlg-head { background: var(--magenta); color: #fff; padding: 12px 16px; text-align: center; font-size: 1.05rem; }
.img-dlg img { display: block; width: 100%; max-height: calc(100vh - 220px); object-fit: contain; background: var(--cream); -webkit-touch-callout: default; user-select: auto; -webkit-user-select: auto; }
.img-dlg-tip { margin: 0; padding: 10px 16px; font-size: .85rem; color: var(--muted); text-align: center; }
.img-dlg-foot { display: flex; gap: 8px; justify-content: center; padding: 0 16px 14px; }
.ext-bar { position: fixed; left: 12px; right: 12px; top: 12px; z-index: 50; background: #fff; border: 2px solid var(--magenta); border-radius: 18px; padding: 12px 14px; box-shadow: var(--shadow); }
.ext-bar p { margin: 0 0 8px; font-size: .9rem; }
.ext-bar div { display: flex; gap: 8px; justify-content: flex-end; }

/* ช่องวันที่: iOS ไม่ยอมหดตามความกว้าง → บังคับ (ใช้ในหลังบ้านด้วย) */
input[type="date"] { -webkit-appearance: none; appearance: none; min-width: 0; max-width: 100%; display: block; min-height: 46px; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
/* ปุ่มเลือกวันหน้าจอง */
.date-pick { position: relative; display: flex; align-items: center; gap: 12px; margin: 0; padding: 12px 14px; border: 1.5px solid var(--pink); border-radius: 16px; background: #fff; cursor: pointer; font-weight: 400; overflow: hidden; }
.date-pick .dp-icon { font-size: 1.5rem; line-height: 1; }
.date-pick .dp-text { flex: 1; min-width: 0; }
.date-pick b { display: block; color: var(--magenta); font-size: 1.05rem; }
.date-pick small { display: block; color: var(--muted); font-size: .78rem; }
.date-pick input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }

/* เมนูที่ครัวปิด */
.food.soldout { opacity: .55; }
.food.soldout .info b::after { content: ' · หมด'; color: var(--bad); }
.left-tag { color: var(--warn); font-weight: 700; }
.serves { display: inline-block; font-size: .78rem; font-weight: 600; color: var(--magenta); background: var(--soft); border-radius: 999px; padding: 1px 8px; margin-left: 4px; white-space: nowrap; }
