/* ---------------------------------------------------------------------------
   Estilos de la PWA del cliente. Mobile-first (entran por QR desde el celular).
   Los colores de marca llegan por variables CSS que setea app.js desde /api/config.
--------------------------------------------------------------------------- */
:root {
  --brand: #e63946;
  --accent: #1d3557;
  --bg: #f7f7f8;
  --card: #ffffff;
  --text: #1b1b1e;
  --muted: #6b7280;
  --radius: 16px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  /* Tipografia: la setea app.js desde theme.tokens.font (presets de theme.js). */
  --font-heading: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  padding-bottom: 96px;
  -webkit-font-smoothing: antialiased;
}
/* Si el tema define imagen de fondo, la fijamos detras del contenido. */
body.has-bg { background-size: cover; background-position: center; background-attachment: fixed; }

h1, h2, h3, .cat-title, .hero-heading { font-family: var(--font-heading); }

/* --- Topbar --- */
.topbar {
  background: var(--accent);
  color: #fff;
  padding: 20px 18px calc(20px + env(safe-area-inset-top, 0));
  padding-top: max(20px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 40px; line-height: 1; }
.logo-img { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; flex-shrink: 0; }
.topbar h1 { font-size: 20px; font-weight: 800; }
.tagline { font-size: 13px; opacity: 0.8; margin-top: 2px; }
.table-badge {
  background: var(--brand);
  color: #fff;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}

/* --- Categorias (chips) --- */
.cats {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  display: flex;
  gap: 8px;
  padding: 12px 18px;
  overflow-x: auto;
  scrollbar-width: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}
.cats::-webkit-scrollbar { display: none; }
.chip {
  border: none;
  background: #fff;
  color: var(--text);
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.1s;
}
.chip.active { background: var(--brand); color: #fff; }
.chip:active { transform: scale(0.95); }

/* --- Menu --- */
.menu { padding: 8px 18px; }
.cat-section { padding-top: 18px; scroll-margin-top: 64px; }
.cat-title { font-size: 18px; margin-bottom: 12px; }
.items { display: grid; gap: 12px; }

.item {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  gap: 14px;
  padding: 14px;
  transition: transform 0.12s;
}
.item.bump { animation: bump 0.3s ease; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.02); } 100% { transform: scale(1); } }

/* --- Promociones (destacadas en el menu) --- */
.item.is-promo {
  position: relative;
  border: 2px solid var(--brand);
  background: color-mix(in srgb, var(--brand) 5%, var(--card));
}
.promo-badge {
  position: absolute;
  top: -9px; left: 12px;
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  letter-spacing: 0.02em;
}
.price-was {
  color: var(--muted);
  font-weight: 600;
  text-decoration: line-through;
  font-size: 0.85em;
  margin-right: 2px;
}
.item-emoji {
  font-size: 40px;
  width: 56px; height: 56px;
  display: grid; place-items: center;
  background: var(--bg);
  border-radius: 12px;
  flex-shrink: 0;
}
/* Foto real del platillo (cuando el restaurante subio una). */
.item-photo {
  width: 72px; height: 72px;
  object-fit: cover;
  border-radius: 12px;
  flex-shrink: 0;
  background: var(--bg);
}
.item-body { flex: 1; display: flex; flex-direction: column; }
.item-body h3 { font-size: 16px; }
.item-desc { color: var(--muted); font-size: 13px; margin: 4px 0 10px; }
.item-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; }
.price { font-weight: 800; color: var(--accent); }
.add-btn {
  border: none;
  background: var(--brand);
  color: #fff;
  padding: 8px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.add-btn:active { transform: scale(0.94); }

/* --- Cart FAB --- */
.cart-fab {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(18px + env(safe-area-inset-bottom, 0));
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 15px 28px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 800;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  z-index: 30;
}
.cart-fab:active { transform: translateX(-50%) scale(0.96); }

/* --- Bottom sheet del carrito --- */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 40;
}
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: #fff;
  border-radius: 24px 24px 0 0;
  padding: 12px 20px calc(24px + env(safe-area-inset-bottom, 0));
  z-index: 50;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-handle { width: 40px; height: 4px; background: #ddd; border-radius: 999px; margin: 4px auto 14px; }
.sheet h2 { margin-bottom: 14px; }

.cart-lines { display: grid; gap: 10px; margin-bottom: 16px; }
.empty { color: var(--muted); text-align: center; padding: 20px 0; }
.cart-line { display: flex; align-items: center; gap: 12px; }
.cl-emoji { font-size: 28px; }
.cl-info { flex: 1; display: flex; flex-direction: column; }
.cl-info span { color: var(--muted); font-size: 13px; }
.qty { display: flex; align-items: center; gap: 12px; }
.qty button {
  width: 32px; height: 32px;
  border: none; border-radius: 50%;
  background: var(--bg); font-size: 18px; font-weight: 700;
  cursor: pointer;
}
.qty span { min-width: 18px; text-align: center; font-weight: 700; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  font-size: 15px;
}

.cart-total-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 0; font-size: 18px;
  border-top: 1px dashed #e5e7eb;
  margin-top: 6px;
}
.cart-total-row strong { color: var(--accent); font-size: 22px; }

.btn-primary {
  width: 100%;
  border: none;
  background: var(--brand);
  color: #fff;
  padding: 16px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}
.btn-primary:disabled { opacity: 0.6; }
.btn-secondary {
  width: 100%;
  margin-top: 10px;
  border: 2px solid var(--brand);
  background: #fff;
  color: var(--brand);
  padding: 14px;
  border-radius: 14px;
  font-weight: 800;
  cursor: pointer;
}
.pay-note { text-align: center; color: var(--muted); font-size: 13px; margin-top: 12px; }

/* --- Metodo de pago (segmented control) --- */
.pay-method { margin: 4px 0 14px; }
.pay-method-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.seg-btn {
  border: 2px solid #e5e7eb;
  background: #fff;
  color: var(--text);
  padding: 12px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.1s;
}
.seg-btn:active { transform: scale(0.97); }
.seg-btn.active { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, #fff); color: var(--brand); }

/* --- Toast --- */
.toast {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(100px + env(safe-area-inset-bottom, 0));
  background: var(--accent);
  color: #fff;
  padding: 14px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  z-index: 60;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* ===========================================================================
   BLOQUES DEL CMS ("Legos"). Cada tipo de theme.blocks tiene su estilo aqui.
   =========================================================================== */

/* --- Bloque: portada (hero) --- */
.hero {
  padding: 40px 20px;
  background: var(--accent);
  color: #fff;
}
.hero.has-img { background-size: cover; background-position: center; min-height: 200px; display: flex; align-items: center; }
.hero--center { text-align: center; }
.hero--center .hero-inner { margin: 0 auto; }
.hero-inner { max-width: 640px; }
.hero-heading { font-size: 28px; font-weight: 800; line-height: 1.15; }
.hero-sub { font-size: 15px; opacity: 0.9; margin-top: 8px; }

/* --- Bloque: franja de promocion --- */
.promo-banner {
  background: color-mix(in srgb, var(--brand) 12%, var(--card));
  color: var(--text);
  border-left: 4px solid var(--brand);
  margin: 12px 18px;
  padding: 12px 16px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
}
.promo-banner-emoji { font-size: 22px; }

/* --- Bloque: pie de pagina --- */
.footer {
  margin-top: 24px;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 0));
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.footer-wa {
  display: inline-block;
  margin-bottom: 10px;
  background: #25d366;
  color: #fff;
  text-decoration: none;
  padding: 10px 20px;
  border-radius: 999px;
  font-weight: 700;
}

/* --- Foto en linea del carrito --- */
.cl-photo { width: 44px; height: 44px; object-fit: cover; border-radius: 10px; flex-shrink: 0; }

/* ===========================================================================
   ESTILOS DE TARJETA del menu (theme.blocks[menu].cardStyle). La clase vive en
   #menu (menu--classic | menu--glass | menu--minimal | menu--photo).
   =========================================================================== */

/* glass: tarjetas translucidas con desenfoque (luce sobre fondo con imagen). */
.menu--glass .item {
  background: color-mix(in srgb, var(--card) 70%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

/* minimal: plano, sin sombras, separado por lineas. */
.menu--minimal .item {
  box-shadow: none;
  border-radius: 0;
  border-bottom: 1px solid #e5e7eb;
  background: transparent;
  padding-left: 0; padding-right: 0;
}
.menu--minimal .item.is-promo { border: none; border-bottom: 2px solid var(--brand); background: transparent; }

/* photo: la foto manda (grande arriba, texto debajo). Ideal con fotos reales. */
.menu--photo .items { grid-template-columns: repeat(2, 1fr); }
.menu--photo .item { flex-direction: column; padding: 0; overflow: hidden; }
.menu--photo .item-photo,
.menu--photo .item-emoji { width: 100%; height: 130px; border-radius: 0; }
.menu--photo .item-body { padding: 12px; }
.menu--photo .promo-badge { top: 8px; left: 8px; }

/* ===========================================================================
   MODO EDICIÓN INLINE (solo dentro del editor del panel; body.cms-edit).
   Clic en el texto para editarlo; botones para agregar/borrar.
   =========================================================================== */
body.cms-edit [contenteditable] {
  cursor: text;
  border-radius: 6px;
  padding: 1px 4px;
  margin: -1px -4px;
  transition: box-shadow 0.1s, background 0.1s;
}
body.cms-edit [contenteditable]:hover { box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 40%, transparent); }
body.cms-edit [contenteditable]:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--brand);
  background: color-mix(in srgb, var(--brand) 7%, var(--card));
}
/* Placeholder para descripción vacía. */
body.cms-edit .item-desc:empty::before { content: attr(data-placeholder); color: var(--muted); font-style: italic; }
.edit-price { color: var(--accent); font-weight: 800; }
.edit-num { min-width: 16px; display: inline-block; }

/* Borrar platillo */
.item-del {
  border: none;
  background: color-mix(in srgb, #ef4444 12%, #fff);
  color: #ef4444;
  width: 30px; height: 30px;
  border-radius: 50%;
  font-size: 15px; font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
}
.item-del:active { transform: scale(0.9); }

/* Agregar platillo / categoría */
.add-item-btn, .add-cat-btn {
  border: 2px dashed color-mix(in srgb, var(--muted) 60%, transparent);
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.1s, color 0.1s;
}
.add-item-btn { width: 100%; padding: 12px; border-radius: 14px; margin-top: 4px; }
.add-cat-btn { display: block; width: calc(100% - 36px); margin: 18px; padding: 16px; border-radius: 16px; font-size: 15px; }
.add-item-btn:hover, .add-cat-btn:hover { border-color: var(--brand); color: var(--brand); }
