/* ─── Variables ─────────────────────────────────────────────── */
:root {
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body:    'Outfit', system-ui, sans-serif;

  --bg:           #F9F4EE;
  --surface:      #FFFFFF;
  --text:         #1A1008;
  --text-muted:   #7A6855;
  --text-light:   #A89880;

  --accent:       #D4651C;
  --accent-light: #FEF2E7;
  --accent-dark:  #B5521A;

  --green:        #2E5D2C;
  --green-light:  #EAF2E9;

  --border:       #EBE0D5;
  --border-focus: #D4651C;

  --shadow-sm:  0 1px 4px rgba(26,16,8,.06);
  --shadow-md:  0 4px 16px rgba(26,16,8,.10);
  --shadow-lg:  0 12px 40px rgba(26,16,8,.15);
  --shadow-xl:  0 24px 64px rgba(26,16,8,.18);

  --radius-sm:  8px;
  --radius-md:  14px;
  --radius-lg:  20px;
  --radius-xl:  28px;
  --radius-full: 999px;

  --transition: 0.22s cubic-bezier(.4,0,.2,1);

  --header-h: 64px;
  --tab-h:    52px;
  --cart-bar: 80px;
}

/* ─── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea { font-family: inherit; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }

/* ─── Loading screen ────────────────────────────────────────── */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  gap: 20px;
}

.loading-logo {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.loading-logo span { color: var(--accent); }

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── App layout ────────────────────────────────────────────── */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ─── Header ────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-shadow: var(--shadow-sm);
}

.header-logo {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1;
}
.header-logo span { color: var(--accent); }

.header-tagline {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}

.cart-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  padding: 9px 16px;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 600;
  transition: background var(--transition), transform var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.cart-btn:active { transform: scale(0.96); }
.cart-btn:hover  { background: var(--accent-dark); }

.cart-btn-icon { font-size: 1.1rem; }
.cart-badge {
  background: var(--text);
  color: #fff;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cart-btn.empty { background: var(--border); color: var(--text-muted); pointer-events: none; }

/* ─── Category tabs ─────────────────────────────────────────── */
.category-tabs {
  position: sticky;
  top: var(--header-h);
  z-index: 90;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.category-tabs::-webkit-scrollbar { display: none; }

.tabs-inner {
  display: flex;
  gap: 0;
  padding: 0 12px;
  white-space: nowrap;
  min-width: min-content;
}

.tab-btn {
  padding: 0 16px;
  height: var(--tab-h);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ─── Menu items ────────────────────────────────────────────── */
.menu-content {
  flex: 1;
  padding: 16px 16px calc(var(--cart-bar) + 24px);
}

.category-section { margin-bottom: 32px; }
.category-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 14px;
  letter-spacing: -0.01em;
}

.items-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.item-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: box-shadow var(--transition), transform var(--transition);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
}
.item-card:active { transform: scale(0.97); box-shadow: var(--shadow-md); }

.item-img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
}

.item-img-placeholder {
  width: 100%;
  aspect-ratio: 4/3;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.item-body {
  padding: 10px 12px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.item-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.item-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 8px;
}

.item-price {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
}
.item-price-range { color: var(--text-muted); font-size: 0.8rem; }

.item-add {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background var(--transition);
}
.item-card:active .item-add { background: var(--accent-dark); }

/* ─── Cart bar (sticky bottom) ──────────────────────────────── */
.cart-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(26,16,8,.08);
}

.cart-bar-btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background var(--transition), transform var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.cart-bar-btn:active  { transform: scale(0.98); }
.cart-bar-btn:hover   { background: var(--accent-dark); }

.cart-bar-left  { display: flex; align-items: center; gap: 10px; }
.cart-bar-count {
  background: rgba(255,255,255,0.25);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
}

/* ─── Modal overlay ─────────────────────────────────────────── */
#modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(26,16,8,.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  padding: 0;
  animation: fadeIn 0.2s ease;
}
#modal-overlay.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-sheet {
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 0 0 calc(env(safe-area-inset-bottom) + 24px);
  max-height: 92dvh;
  overflow-y: auto;
  animation: slideUp 0.3s cubic-bezier(.4,0,.2,1);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.modal-drag-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: var(--radius-full);
  margin: 12px auto 0;
}

.modal-img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  margin-top: 12px;
}

.modal-img-placeholder {
  width: calc(100% - 32px);
  height: 160px;
  margin: 16px 16px 0;
  background: var(--accent-light);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}

.modal-body { padding: 20px 20px 0; }
.modal-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.modal-price {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: 4px;
}
.modal-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 10px;
  line-height: 1.55;
}

/* Variant selector */
.modal-section { margin-top: 20px; }
.modal-section-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.variant-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.variant-btn {
  padding: 8px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.variant-btn.selected {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

/* Quantity selector */
.qty-selector {
  display: flex;
  align-items: center;
  gap: 20px;
}
.qty-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  font-size: 1.3rem;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.qty-btn:active { background: var(--accent-light); border-color: var(--accent); }
.qty-count {
  font-size: 1.3rem;
  font-weight: 600;
  min-width: 30px;
  text-align: center;
}

/* Note input */
.note-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  color: var(--text);
  resize: none;
  background: var(--bg);
  transition: border-color var(--transition);
  outline: none;
}
.note-input:focus { border-color: var(--border-focus); background: var(--surface); }
.note-input::placeholder { color: var(--text-light); }

.modal-add-btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  padding: 16px;
  border-radius: var(--radius-lg);
  font-size: 1rem;
  font-weight: 600;
  margin-top: 24px;
  transition: background var(--transition), transform var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.modal-add-btn:active  { transform: scale(0.98); }
.modal-add-btn:hover   { background: var(--accent-dark); }
.modal-add-btn:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; }

/* ─── Cart screen ───────────────────────────────────────────── */
.cart-screen, .checkout-screen, .payment-screen, .success-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.screen-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.back-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--text);
  transition: all var(--transition);
  flex-shrink: 0;
}
.back-btn:active { background: var(--accent-light); border-color: var(--accent); }

.screen-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

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

/* Cart items */
.cart-item {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.cart-item:last-child { border-bottom: none; }

.cart-item-info { flex: 1; }
.cart-item-name { font-size: 0.95rem; font-weight: 600; }
.cart-item-variant { font-size: 0.8rem; color: var(--text-muted); margin-top: 1px; }
.cart-item-note { font-size: 0.8rem; color: var(--text-muted); font-style: italic; margin-top: 2px; }
.cart-item-price { font-size: 0.95rem; font-weight: 600; color: var(--accent); }

.cart-item-qty {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cart-qty-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
.cart-qty-btn:active { background: var(--accent-light); border-color: var(--accent); }
.cart-qty-num { font-weight: 600; min-width: 20px; text-align: center; }

.cart-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.cart-empty-icon { font-size: 3rem; margin-bottom: 12px; }
.cart-empty-text { font-size: 1rem; }

/* Cart totals */
.cart-totals {
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 16px;
}
.cart-total-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--text-muted);
  padding: 3px 0;
}
.cart-total-row.grand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding-top: 10px;
}

/* Screen footer */
.screen-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.primary-btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  padding: 17px;
  border-radius: var(--radius-lg);
  font-size: 1rem;
  font-weight: 600;
  transition: background var(--transition), transform var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.primary-btn:active  { transform: scale(0.98); }
.primary-btn:hover   { background: var(--accent-dark); }
.primary-btn:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; transform: none; }

/* ─── Checkout form ─────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.form-input {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color var(--transition);
}
.form-input:focus { border-color: var(--border-focus); }
.form-input::placeholder { color: var(--text-light); }

.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 5px; }

/* ─── Payment method select ─────────────────────────────────── */
.payment-options { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }

.payment-option {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.payment-option:active { border-color: var(--accent); background: var(--accent-light); }

.payment-option-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.payment-option-icon.promptpay { background: #F0FAF0; }
.payment-option-icon.card { background: var(--accent-light); }

.payment-option-info { flex: 1; }
.payment-option-name { font-size: 1rem; font-weight: 600; }
.payment-option-desc { font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; }
.payment-option-arrow { font-size: 1.2rem; color: var(--text-muted); }

.order-summary-card {
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 24px;
}
.order-summary-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.order-summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  padding: 3px 0;
}
.order-summary-total {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding-top: 10px;
  display: flex;
  justify-content: space-between;
}

/* ─── PromptPay QR screen ───────────────────────────────────── */
.promptpay-screen { text-align: center; padding: 24px 20px; }

.qr-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 28px 20px 24px;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
}
.qr-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.qr-amount { font-size: 2rem; font-weight: 700; color: var(--accent); margin-bottom: 20px; }
.qr-img {
  width: 220px;
  height: 220px;
  margin: 0 auto;
  border-radius: var(--radius-md);
}
.qr-img-loading {
  width: 220px;
  height: 220px;
  margin: 0 auto;
  background: var(--bg);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-instructions { font-size: 0.9rem; color: var(--text-muted); margin-top: 16px; line-height: 1.5; }

.countdown-bar-wrap { margin-top: 16px; }
.countdown-label { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 6px; }
.countdown-bar {
  height: 4px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.countdown-fill {
  height: 100%;
  background: var(--green);
  border-radius: var(--radius-full);
  transition: width 1s linear, background 0.5s;
}
.countdown-fill.warning { background: var(--accent); }

.polling-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 16px;
}
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

/* ─── Success screen ────────────────────────────────────────── */
.success-screen {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
  gap: 0;
}

.success-icon {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--green-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  margin-bottom: 24px;
  animation: popIn 0.4s cubic-bezier(.4,0,.2,1);
}
@keyframes popIn {
  0%   { transform: scale(0.4); opacity: 0; }
  80%  { transform: scale(1.1); }
  100% { transform: scale(1);   opacity: 1; }
}

.success-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.success-msg { font-size: 1rem; color: var(--text-muted); line-height: 1.5; max-width: 280px; }
.success-receipt {
  margin-top: 24px;
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  width: 100%;
  max-width: 320px;
}
.success-receipt-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.success-receipt-num { font-size: 1.2rem; font-weight: 700; color: var(--text); margin-top: 2px; }

.success-new-order-btn {
  margin-top: 32px;
  padding: 14px 32px;
  border-radius: var(--radius-full);
  border: 2px solid var(--accent);
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 600;
  transition: all var(--transition);
}
.success-new-order-btn:active { background: var(--accent-light); }

/* ─── Error / toast ─────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--cart-bar) + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 300;
  white-space: nowrap;
  animation: toastIn 0.25s ease, toastOut 0.25s ease 2.5s forwards;
  pointer-events: none;
}
@keyframes toastIn  { from { opacity:0; transform: translateX(-50%) translateY(12px); } }
@keyframes toastOut { to   { opacity:0; transform: translateX(-50%) translateY(12px); } }

/* ─── Utility ───────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.section-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 16px;
  line-height: 1.5;
}

/* ─── Stripe card element focus ring ────────────────────────── */
#stripe-card-element { transition: border-color 0.22s; }
#stripe-card-element.StripeElement--focus { border-color: var(--accent) !important; }
#stripe-card-element.StripeElement--invalid { border-color: #c0392b !important; }
