/* 
  QR Menu Frontend - Premium Redesign
  Modern food delivery app aesthetic, mobile-first, rich light theme
*/

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
  --primary: #f97316;
  --primary-dark: #ea580c;
  --primary-light: #fff7ed;
  --primary-glow: rgba(249, 115, 22, 0.18);
  --accent: #0ea5e9;
  --bg-page: #f9f8f6;
  --bg-card: #ffffff;
  --bg-header: #ffffff;
  --text-title: #111827;
  --text-body: #374151;
  --text-muted: #9ca3af;
  --border: #f3f4f6;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.09);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  font-family: var(--font);
  background: var(--bg-page);
  color: var(--text-body);
  line-height: 1.55;
  padding-bottom: 40px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== HERO HEADER ===== */
.app-header {
  background: var(--bg-header);
  position: relative;
  overflow: hidden;
}

.header-hero {
  background: linear-gradient(145deg, #1c1917 0%, #292524 50%, #1c1917 100%);
  padding: 36px 20px 28px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.header-hero::before {
  content: '';
  position: absolute;
  top: -60px; left: -60px;
  width: 280px; height: 280px;
  background: radial-gradient(circle, rgba(249,115,22,0.25) 0%, transparent 70%);
  pointer-events: none;
}

.header-hero::after {
  content: '';
  position: absolute;
  bottom: -80px; right: -40px;
  width: 240px; height: 240px;
  background: radial-gradient(circle, rgba(249,115,22,0.12) 0%, transparent 70%);
  pointer-events: none;
}

.brand-logo-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.brand-logo-ring {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: #fff;
  box-shadow: 0 0 0 4px rgba(249,115,22,0.25), 0 8px 24px rgba(249,115,22,0.35);
}

.brand-logo-img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 4px rgba(249,115,22,0.3), 0 8px 24px rgba(0,0,0,0.25);
}

.header-live-badge {
  position: absolute;
  top: -4px; right: -4px;
  width: 18px; height: 18px;
  background: #22c55e;
  border-radius: 50%;
  border: 3px solid #1c1917;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.8; }
}

.brand-name {
  font-size: 22px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.brand-tagline {
  font-size: 13px;
  font-weight: 400;
  color: rgba(255,255,255,0.55);
  margin-top: 4px;
}

/* Header Badges Row */
.header-badges {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
}

.badge-table {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 30px;
  letter-spacing: 0.01em;
}

.badge-table .dot-online {
  width: 7px; height: 7px;
  background: #22c55e;
  border-radius: 50%;
  display: inline-block;
  animation: pulse-dot 2s infinite;
}

.badge-wifi {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid rgba(249,115,22,0.2);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.badge-wifi:active {
  transform: scale(0.97);
  background: #ffedd5;
}

/* ===== SEARCH BAR ===== */
.search-wrap {
  padding: 16px 16px 6px;
}

.search-box {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 15px;
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 48px;
  padding: 0 16px 0 44px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-title);
  outline: none;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input::placeholder { color: var(--text-muted); }

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* ===== FILTER CHIPS ===== */
.filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 16px 14px;
  scrollbar-width: none;
}
.filter-row::-webkit-scrollbar { display: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 15px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 30px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-body);
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.chip:active { transform: scale(0.96); }

.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 3px 12px var(--primary-glow);
}

/* ===== STICKY CATEGORY NAV ===== */
.category-nav-wrap {
  position: sticky;
  top: 0;
  z-index: 90;
  background: var(--bg-card);
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  border-bottom: 1px solid var(--border);
}

.category-nav {
  display: flex;
  overflow-x: auto;
  padding: 0;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  gap: 0;
}
.category-nav::-webkit-scrollbar { display: none; }

/* Mobile: icon-only items that expand when active */
.cat-item {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 10px 12px;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
  border-bottom: 2.5px solid transparent;
  border-top: 2.5px solid transparent; /* balance layout */
  transition: all 0.2s;
  flex-shrink: 0;
  /* Fixed width for even layout */
  min-width: 56px;
}

.cat-item i {
  font-size: 18px;
  color: inherit;
  transition: color 0.2s;
}

/* Label hidden by default on mobile */
.cat-item .cat-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: inherit;
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: none; /* hidden on mobile */
}

.cat-item.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  border-top-color: transparent;
}

/* Show label only for active item on mobile */
.cat-item.active .cat-label {
  display: block;
}

/* On desktop show all labels */
@media (min-width: 600px) {
  .cat-item { min-width: 80px; padding: 10px 14px; }
  .cat-item .cat-label { display: block; font-size: 9.5px; }
}

/* ===== MAIN CONTENT ===== */
.main-content {
  padding: 0 12px;
  max-width: 680px;
  margin: 0 auto;
  box-sizing: border-box;
}

/* ===== CATEGORY SECTION ===== */
.category-section {
  padding-top: 22px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
  /* Prevent title overflow on mobile */
  min-width: 0;
  overflow: hidden;
}

.section-icon {
  width: 32px;
  height: 32px;
  min-width: 32px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.section-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-title);
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.section-count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-page);
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ===== PRODUCT GRID ===== */
.product-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ===== PRODUCT CARD ===== */
.product-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  gap: 0;
  cursor: pointer;
  position: relative;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  /* Prevent cards from overflowing the container */
  min-width: 0;
  width: 100%;
}

.product-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.product-card:active {
  transform: scale(0.99);
}

.product-card.out-of-stock {
  opacity: 0.55;
}

/* Image */
.product-img-col {
  width: 105px;
  min-width: 105px;
  max-width: 105px;
  position: relative;
  overflow: hidden;
  background: #f3f4f6;
  flex-shrink: 0;
}

.product-img {
  width: 100%;
  height: 100%;
  min-height: 105px;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.product-card:hover .product-img {
  transform: scale(1.04);
}

.product-img-placeholder {
  width: 100%;
  height: 105px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #d1d5db;
  font-size: 24px;
}

/* Stock overlay */
.stockout-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stockout-label {
  background: #6b7280;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transform: rotate(-8deg);
}

/* Content */
.product-body {
  flex: 1;
  padding: 11px 12px 11px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  overflow: hidden;
}

.product-top { display: flex; flex-direction: column; gap: 4px; }

.product-title {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-title);
  line-height: 1.3;
  letter-spacing: -0.2px;
  /* Allow 2 lines on mobile */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
}

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

/* Tags */
.product-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 4px;
  /* Critical: prevent overflow on mobile */
  overflow: hidden;
  max-height: 42px; /* max 2 lines of tags */
}

.tag {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 2.5px 6px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.tag-popular  { background: #fff7ed; color: #c2410c; }
.tag-chef     { background: #eff6ff; color: #1d4ed8; }
.tag-vegan    { background: #f0fdf4; color: #15803d; }
.tag-spicy    { background: #fef2f2; color: #b91c1c; }
.tag-stockout { background: #f3f4f6; color: #4b5563; }

/* Bottom Row: Price + Button */
.product-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  gap: 6px;
}

.price-group {
  display: flex;
  align-items: baseline;
  gap: 4px;
  flex-wrap: wrap;
  min-width: 0;
  flex: 1;
}

.price-current {
  font-size: 15px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.3px;
  white-space: nowrap;
}

.price-old {
  font-size: 10.5px;
  color: var(--text-muted);
  text-decoration: line-through;
  white-space: nowrap;
}

.discount-badge {
  font-size: 9.5px;
  font-weight: 800;
  background: #fef2f2;
  color: #b91c1c;
  padding: 2px 5px;
  border-radius: 4px;
  white-space: nowrap;
}

.btn-add {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--primary-glow);
  flex-shrink: 0;
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-add:active {
  transform: scale(0.9);
  box-shadow: 0 2px 6px var(--primary-glow);
}



/* ===== MODAL OVERLAY ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-sheet {
  background: var(--bg-card);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  border-radius: 20px 20px 0 0;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 0 16px max(24px, env(safe-area-inset-bottom, 24px));
  /* Critical: contain scroll within sheet, don't let it bubble to body */
  overscroll-behavior: contain;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  /* Prevent touch events leaking through sheet to page */
  touch-action: pan-y;
}

.modal-overlay.active .modal-sheet {
  transform: translateY(0);
}

.modal-drag-handle {
  width: 36px;
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  margin: 12px auto 16px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #f3f4f6;
  border: none;
  font-size: 14px;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
}

/* Modal sheet image banner */
.modal-img-banner {
  width: calc(100% + 40px);
  margin: 0 -20px 18px;
  height: 220px;
  object-fit: cover;
}

/* Product modal options */
.option-section {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 14px;
}

.option-section-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-title);
  margin-bottom: 10px;
}

.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #f9fafb;
  font-size: 13px;
}

.option-row label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-body);
}

.option-extra { font-weight: 700; color: var(--primary); font-size: 13px; }

/* Note Textarea */
.note-textarea {
  width: 100%;
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  color: var(--text-body);
  height: 72px;
  resize: none;
  outline: none;
  background: var(--bg-page);
  transition: border-color 0.2s;
}

.note-textarea:focus { border-color: var(--primary); }

/* Waiter Modal Type Selectors */
.call-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.call-type-card {
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.call-type-card:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
}

.call-type-card input { display: none; }
.call-type-emoji { font-size: 26px; display: block; margin-bottom: 6px; }
.call-type-label { font-size: 13px; font-weight: 700; color: var(--text-title); }

/* WiFi modal */
.wifi-code {
  font-family: 'Courier New', monospace;
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.05em;
  word-break: break-all;
}

/* Submit button */
.btn-submit {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-xl);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px var(--primary-glow);
  margin-top: 18px;
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-submit:active {
  transform: scale(0.98);
  box-shadow: 0 3px 10px var(--primary-glow);
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #111827;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 22px;
  border-radius: 30px;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== SCROLL ANIMATIONS ===== */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.product-card {
  animation: fadeSlideUp 0.35s ease both;
}

.category-section:nth-child(1) .product-card { animation-delay: 0.05s; }
.category-section:nth-child(2) .product-card { animation-delay: 0.08s; }
.category-section:nth-child(3) .product-card { animation-delay: 0.11s; }
