/* Narrow.TV Scan & Order: mobile order page. Colors come from the theme
   (see applyTheme in scan.js); these are the Narrow.TV defaults. */
:root {
  --primary: #0e95d9;
  --on-primary: #ffffff;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #667085;
  --line: #e1e6ec;
  --soft: #e8f4fb;
  --header: #052b46;
  --header-text: #ffffff;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --radius: 14px;
  --gutter: 16px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
}

button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }

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

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand > div { display: flex; flex-direction: column; min-width: 0; }
.brand strong { overflow: hidden; font-size: 18px; text-overflow: ellipsis; white-space: nowrap; }
.logo img { display: block; max-width: 96px; max-height: 40px; object-fit: contain; }

.table-badge {
  align-self: flex-start;
  margin-top: 2px;
  padding: 1px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--header-text) 18%, transparent);
  color: var(--header-text);
  font-size: 13px;
  font-weight: 700;
}

.language-select {
  flex: none;
  max-width: 130px;
  padding: 6px 8px;
  border: 1px solid color-mix(in srgb, var(--header-text) 35%, transparent);
  border-radius: 8px;
  background: transparent;
  color: var(--header-text);
}
.language-select option { color: #17202a; }

.view { display: none; }
.view.is-active { display: block; }

/* Categories */
.category-bar {
  position: sticky;
  top: calc(60px + env(safe-area-inset-top));
  z-index: 4;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px var(--gutter);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.category-bar::-webkit-scrollbar { display: none; }
.category-bar button {
  flex: none;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-weight: 600;
  white-space: nowrap;
}
.category-bar button.is-active { border-color: var(--primary); background: var(--primary); color: var(--on-primary); }

/* Products: "grid" = two columns, "list" = rows with a small photo, "large" = one big card per row. */
.product-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px var(--gutter) 110px;
}
body[data-layout="list"] .product-list,
body[data-layout="large"] .product-list { grid-template-columns: minmax(0, 1fr); }

.loading, .empty { grid-column: 1 / -1; margin: 32px 0; color: var(--muted); text-align: center; }

.product-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  text-align: left;
}
.product-image { display: block; aspect-ratio: 4 / 3; background: var(--soft); }
.product-image img { display: block; width: 100%; height: 100%; object-fit: cover; }
.product-text { display: flex; flex: 1; flex-direction: column; gap: 4px; padding: 10px 12px 12px; }
.product-name { font-weight: 700; }
.product-description {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.product-price { margin-top: auto; color: var(--primary); font-weight: 700; }
.product-card.is-sold-out { opacity: .5; }
.product-card.is-sold-out .product-price { color: var(--muted); }

body[data-layout="list"] .product-card { flex-direction: row-reverse; align-items: stretch; }
body[data-layout="list"] .product-image { flex: none; width: 104px; aspect-ratio: 1; }
body[data-layout="large"] .product-image { aspect-ratio: 16 / 9; }
body[data-layout="large"] .product-name { font-size: 18px; }

/* Buttons */
.big-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 12px 18px;
  border: 0;
  border-radius: 12px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 17px;
  font-weight: 700;
}
.big-button:disabled { opacity: .5; }
.big-button.is-secondary { border: 2px solid var(--primary); background: var(--panel); color: var(--primary); }

.cart-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 6;
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.cart-bar .big-button { justify-content: space-between; box-shadow: 0 10px 30px rgba(0, 0, 0, .18); }

/* Cart */
.view-header { display: flex; align-items: center; gap: 8px; padding: 12px var(--gutter) 4px; }
.view-header h1 { margin: 0; font-size: 22px; }
.back-button { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--panel); font-size: 28px; line-height: 1; }

.cart-lines { display: grid; gap: 10px; padding: 10px var(--gutter); }
.cart-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.cart-line div:first-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cart-line span { color: var(--muted); font-size: 14px; }
.cart-line em { font-style: normal; font-weight: 700; }

.stepper { display: flex; flex: none; align-items: center; gap: 10px; }
.stepper button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  font-size: 20px;
  line-height: 1;
}
.stepper strong { min-width: 18px; text-align: center; }

.checkout { display: grid; gap: 10px; padding: 8px var(--gutter) calc(24px + env(safe-area-inset-bottom)); }
.checkout-total { display: flex; justify-content: space-between; font-size: 20px; }
.pay-buttons { display: grid; gap: 10px; }
.form-error { margin: 0; color: #c62828; font-weight: 600; }

/* Product sheet (bottom sheet) */
.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 90dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 20px 20px 0 0;
  background: var(--panel);
  color: var(--ink);
}
.sheet::backdrop { background: rgba(0, 0, 0, .45); }
.product-sheet { position: relative; padding: 0 var(--gutter) calc(16px + env(safe-area-inset-bottom)); }
.sheet-image { display: block; width: calc(100% + 2 * var(--gutter)); max-height: 240px; margin: 0 calc(-1 * var(--gutter)); object-fit: cover; }
.product-sheet h2 { margin: 16px 40px 4px 0; font-size: 22px; }
.sheet-description { margin: 0 0 8px; color: var(--muted); }
.sheet-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 24px;
  line-height: 1;
}
.option-group { margin: 14px 0 0; padding: 0; border: 0; }
.option-group legend { margin-bottom: 6px; font-weight: 700; }
.option-group legend small { margin-left: 6px; color: var(--muted); font-weight: 400; }
.option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.option input { width: 20px; height: 20px; margin: 0; accent-color: var(--primary); }
.option span { flex: 1; }
.option small { color: var(--muted); }
.option.is-sold-out { opacity: .5; }
.sheet-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  background: var(--panel);
}

/* Order status */
.status-body { display: grid; justify-items: center; gap: 10px; padding: 40px var(--gutter); text-align: center; }
.status-body h1 { margin: 0; font-size: 22px; }
.status-body p { margin: 0; max-width: 420px; }
.status-body .big-button { max-width: 420px; margin-top: 16px; }
.thank-you { color: var(--muted); font-weight: 600; }
.order-number { color: var(--primary); font-size: 88px; line-height: 1; }
.status-total { font-size: 28px; font-weight: 700; }
.hint { color: var(--muted); }
.ready-text { font-size: 20px; font-weight: 700; }
.pay-note { padding: 10px 14px; border-radius: 10px; background: var(--soft); font-weight: 700; }

.progress {
  display: flex;
  gap: 6px;
  width: 100%;
  max-width: 420px;
  margin: 18px 0 8px;
  padding: 0;
  list-style: none;
}
.progress li {
  flex: 1;
  padding-top: 10px;
  border-top: 6px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.progress li.is-done { border-color: var(--primary); color: var(--ink); }
.progress li.is-current { color: var(--primary); }

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

@media (min-width: 720px) {
  .product-list { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 960px; margin: 0 auto; }
  body[data-layout="list"] .product-list, body[data-layout="large"] .product-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cart-lines, .checkout { max-width: 640px; margin: 0 auto; }
}
