/* El header, el banner de descuentos y el nav de categorías van juntos dentro de
   .sticky-head, que es el único elemento con position:sticky (top:0). Así el bloque
   se pega al tope como una sola pieza, sin importar cuánto crezca el header en pantallas
   angostas (texto que se parte en 2 líneas, botones de idioma que bajan de fila, etc.) —
   evita que el nav de categorías quede tapado por un header más alto de lo previsto. */
.sticky-head {
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: 0 4px 18px rgba(27, 24, 21, 0.3);
}

.top-bar {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
  color: var(--cream-light);
  padding: 1.3rem 0;
}
.top-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.header-logo { width: 44px; height: 44px; }
.header-logo img { width: 30px; height: 30px; }
.brand-name {
  color: var(--cream-light);
  font-size: clamp(1.25rem, 3.4vw, 1.7rem);
  margin: 0;
  font-style: normal;
  font-weight: 500;
}
.brand-name .brand-script { font-size: 1.7em; color: var(--cream-light); margin-right: 0.15em; }
.brand-tagline {
  color: var(--piedra);
  margin: 0.15em 0 0;
  font-size: 0.82rem;
  font-family: var(--font-body);
  letter-spacing: 0.03em;
}
.lang-switch { display: flex; gap: 0.4rem; }
.lang-btn {
  padding: 0.45em 0.85em;
  border-radius: var(--radius-sm);
  color: var(--cream-light);
  border: 1.5px solid rgba(251,248,242,0.4);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}
.lang-btn.active { background: var(--cream-light); color: var(--blue-dark); border-color: var(--cream-light); }

.discounts-banner {
  background: var(--cream-2);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.discounts-inner {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.55rem 1.25rem;
  flex-wrap: wrap;
  font-size: 0.86rem;
}
.discounts-label { font-weight: 700; text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.72rem; color: var(--blue); font-family: var(--font-body); }
.discounts-list { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.discount-chip {
  background: var(--cream-light);
  border: 1px solid var(--line);
  padding: 0.25em 0.75em;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-family: var(--font-body);
  font-size: 0.82rem;
}

.category-nav {
  background: var(--cream);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.category-nav::-webkit-scrollbar { display: none; }
.category-nav-inner {
  display: flex;
  gap: 0.5rem;
  padding: 0.7rem 1.25rem;
  min-width: max-content;
}
.category-pill {
  padding: 0.5em 1.05em;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  font-weight: 500;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  color: var(--ink);
  background: var(--cream-light);
  white-space: nowrap;
  font-family: var(--font-body);
}
.category-pill.active { background: var(--blue); color: var(--cream-light); border-color: var(--blue); }

#menu-main { padding-top: 1.5rem; padding-bottom: 6rem; min-height: 60vh; }

.loading-state { display: flex; justify-content: center; padding: 4rem 0; }
.spinner {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 4px solid var(--line);
  border-top-color: var(--terracotta);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.menu-section { margin-bottom: 2.6rem; scroll-margin-top: calc(var(--sticky-h, 140px) + 14px); }
.menu-section-title {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--lemon);
  display: inline-block;
  padding-bottom: 0.15em;
}

.dish-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.1rem;
}

.dish-card {
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  display: flex;
  flex-direction: column;
}
.dish-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.dish-card.unavailable { opacity: 0.55; cursor: default; }
.dish-card.unavailable:hover { transform: none; }

.dish-photo {
  aspect-ratio: 4/3;
  width: 100%;
  background: linear-gradient(135deg, var(--ink) 0%, var(--blue-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.dish-photo img { width: 100%; height: 100%; object-fit: cover; }
.dish-photo-placeholder {
  font-family: var(--font-display);
  font-style: italic;
  color: rgba(255,255,255,0.85);
  font-size: 1.1rem;
  text-align: center;
  padding: 0 1rem;
}
.sold-out-badge {
  position: absolute; top: 0.6rem; right: 0.6rem;
  background: var(--blue); color: var(--cream-light);
  padding: 0.25em 0.7em; border-radius: var(--radius-sm);
  font-size: 0.68rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  font-family: var(--font-body);
}

.dish-card-body { padding: 0.95rem 1.05rem 1.1rem; display: flex; flex-direction: column; gap: 0.3rem; flex: 1; }
.dish-name { font-size: 1.08rem; margin: 0; }
.dish-desc { font-size: 0.85rem; margin: 0; flex: 1; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dish-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 0.4rem; }
.dish-price { font-size: 1.15rem; }
.dish-price-note { font-size: 0.72rem; color: var(--ink-soft); font-weight: 600; }
.add-quick-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--terracotta); color: white; font-size: 1.3rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-soft);
}

.dish-detail-media {
  aspect-ratio: 16/10;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: linear-gradient(135deg, var(--ink), var(--blue-dark));
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 1rem;
  clear: both;
}
.dish-detail-media img, .dish-detail-media video { width: 100%; height: 100%; object-fit: cover; }
.dish-detail-media .dish-photo-placeholder { font-size: 1.4rem; }

.dish-detail-title { font-size: 1.7rem; }
.dish-detail-desc { font-size: 0.98rem; }
.dish-detail-allergens {
  font-size: 0.82rem;
  background: rgba(85,107,65,0.1);
  color: var(--olive);
  padding: 0.6em 0.9em;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

.option-group { margin-bottom: 1.2rem; }
.option-group-title { font-weight: 800; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.4px; color: var(--blue-dark); margin-bottom: 0.6rem; }

.variant-options { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.variant-option {
  padding: 0.6em 1.1em;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  font-weight: 600;
  background: var(--cream-light);
}
.variant-option.selected { border-color: var(--terracotta); background: rgba(156,107,62,0.1); color: var(--terracotta); }

.topping-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.5rem; }
.topping-chip {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.55em 0.8em;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  text-align: left;
}
.topping-chip.selected { border-color: var(--olive); background: rgba(85,107,65,0.1); }
.topping-chip-price { color: var(--ink-soft); font-weight: 500; font-size: 0.8rem; }

.gluten-free-toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.7em 1rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
}

.qty-control { display: flex; align-items: center; gap: 0.8rem; }
.qty-btn {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1.5px solid var(--line); background: var(--cream-light);
  font-size: 1.2rem; font-weight: 700; color: var(--blue-dark);
}
.qty-value { font-size: 1.1rem; font-weight: 700; min-width: 1.5em; text-align: center; }

.notes-textarea { width: 100%; min-height: 70px; resize: vertical; }

.dish-detail-footer {
  position: sticky; bottom: -2rem;
  background: var(--cream-light);
  margin: 1.2rem -1.4rem -2rem;
  padding: 1rem 1.4rem calc(1rem + env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid var(--line);
}
.dish-detail-total { font-size: 1.3rem; }

/* ---------- cart ---------- */
.cart-fab {
  position: fixed; bottom: 1.2rem; right: 1.2rem; z-index: 60;
  background: var(--terracotta); color: white;
  border-radius: 999px;
  padding: 0.85em 1.3em;
  display: flex; align-items: center; gap: 0.6rem;
  box-shadow: 0 8px 24px rgba(156,107,62,0.4);
  font-weight: 700;
}
.cart-fab-count {
  background: white; color: var(--terracotta);
  border-radius: 50%; width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.82rem;
}

.cart-item {
  display: flex; gap: 0.8rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--line);
}
.cart-item-info { flex: 1; }
.cart-item-name { font-weight: 700; margin: 0 0 0.2em; }
.cart-item-meta { font-size: 0.8rem; color: var(--ink-soft); margin: 0 0 0.2em; }
.cart-item-notes { font-size: 0.8rem; color: var(--olive); font-style: italic; margin: 0; }
.cart-item-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 0.5rem; }
.cart-item-remove { color: var(--blue); font-size: 0.78rem; font-weight: 700; }

.cart-empty { text-align: center; padding: 2.5rem 1rem; color: var(--ink-soft); }
.cart-empty-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }

.cart-footer { margin-top: 1rem; }
.table-number-field { margin-bottom: 1rem; }
.table-number-field label { display: block; font-weight: 700; margin-bottom: 0.4rem; font-size: 0.88rem; }
.table-number-field input { width: 100%; }
.cart-total-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; font-size: 1.2rem; }
.cart-error { color: var(--blue); font-size: 0.85rem; margin-bottom: 0.8rem; font-weight: 600; }

/* ---------- confirmation ---------- */
.confirmation-overlay { align-items: center; justify-content: center; }
.confirmation-box {
  background: var(--cream-light);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  text-align: center;
  max-width: 420px;
  width: 90%;
}
.confirmation-check {
  width: 70px; height: 70px; border-radius: 50%;
  background: var(--olive); color: white;
  font-size: 2rem;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
}
.confirmation-order-number { font-weight: 700; color: var(--blue-dark); margin-bottom: 1.5rem; }

/* ---------- móvil ---------- */
@media (max-width: 640px) {
  .top-bar { padding: 0.9rem 0; }
  .top-bar-inner { gap: 0.6rem; }
  .header-logo { width: 36px; height: 36px; }
  .header-logo img { width: 24px; height: 24px; }
  .brand-name { font-size: 1.15rem; }
  .brand-tagline { font-size: 0.72rem; }
  .lang-btn { padding: 0.4em 0.65em; font-size: 0.72rem; }

  .discounts-inner { padding: 0.5rem 1rem; gap: 0.6rem; font-size: 0.78rem; }
  .discounts-label { font-size: 0.66rem; }
  .discount-chip { font-size: 0.74rem; padding: 0.2em 0.6em; }

  .category-nav-inner { padding: 0.6rem 1rem; gap: 0.4rem; }
  .category-pill { padding: 0.45em 0.85em; font-size: 0.78rem; }

  .container { padding: 0 1rem; }
  #menu-main { padding-top: 1.1rem; padding-bottom: 5.5rem; }
  .menu-section { margin-bottom: 2rem; }
  .menu-section-title { margin-bottom: 0.8rem; }

  .dish-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.8rem; }
  .dish-card-body { padding: 0.75rem 0.85rem 0.9rem; }
  .dish-name { font-size: 1rem; }
  .dish-desc { font-size: 0.8rem; }
  .dish-price { font-size: 1.05rem; }

  .cart-fab { bottom: 0.9rem; right: 0.9rem; padding: 0.75em 1.05em; }

  .topping-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .dish-detail-footer { flex-wrap: wrap; }

  .confirmation-box { padding: 2rem 1.4rem; }
}

@media (max-width: 380px) {
  .dish-grid { grid-template-columns: 1fr 1fr; }
}
