/* ================================================
   CAFETOS - Carta Digital
   Paleta: Crema cálida + Verde bosque + Cobre
   ================================================ */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&family=Playfair+Display:ital,wght@0,500;0,700;1,500&display=swap');

:root {
  --bg:           #F9F6F1;
  --card:         #FFFFFF;
  --primary:      #2C5F2E;
  --primary-d:    #1E4320;
  --primary-l:    #EAF2EB;
  --accent:       #BF7C3E;
  --accent-l:     #FDF0E3;
  --text:         #1C1C1C;
  --text-mid:     #555555;
  --text-muted:   #8A8A8A;
  --border:       #E5DDD4;
  --shadow-s:     0 1px 6px rgba(0,0,0,.07);
  --shadow-m:     0 4px 16px rgba(0,0,0,.1);
  --shadow-l:     0 12px 32px rgba(0,0,0,.14);
  --r:            14px;
  --header-h:     60px;
  --footer-h:     56px;
  --transition:   .22s ease;
}

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

html { -webkit-tap-highlight-color: transparent; }

body {
  font-family: 'Poppins', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overscroll-behavior-y: none;
}

/* ── HEADER ─────────────────────────────────── */

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
}

.header-logo { flex: 1; display: flex; justify-content: center; }

.header-logo img {
  height: 34px;
  filter: brightness(0) invert(1);
  object-fit: contain;
}

.btn-icon {
  background: none;
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: background var(--transition);
  flex-shrink: 0;
}

.btn-icon:hover { background: rgba(255,255,255,.15); }
.btn-icon svg   { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.btn-icon.invisible { opacity: 0; pointer-events: none; }

/* ── VIEWS ───────────────────────────────────── */

.main { padding-bottom: calc(var(--footer-h) + 16px); }

.view { display: none; animation: fadeUp .28s ease; }
.view.active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── CATEGORIES VIEW ─────────────────────────── */

.section-title {
  font-family: 'Playfair Display', serif;
  font-size: 24px;
  color: var(--primary);
  padding: 22px 16px 14px;
  font-weight: 700;
}

.categories-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 0 12px;
}

.cat-card {
  border-radius: var(--r);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  aspect-ratio: 1 / 0.9;
  box-shadow: var(--shadow-s);
  transition: transform var(--transition), box-shadow var(--transition);
}

.cat-card:active { transform: scale(.96); }

.cat-card-bg {
  position: absolute;
  inset: 0;
  background: var(--cc, var(--primary));
  transition: filter .2s;
}

.cat-card:hover .cat-card-bg { filter: brightness(1.08); }

.cat-card-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
}

.cat-icon {
  font-size: 30px;
  line-height: 1;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,.3));
}

.cat-name {
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: .6px;
  text-align: center;
  line-height: 1.25;
  text-shadow: 0 1px 4px rgba(0,0,0,.35);
}

/* ── PRODUCTS VIEW ───────────────────────────── */

.products-header {
  padding: 20px 16px 14px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: var(--header-h);
  z-index: 10;
}

.products-header h2 {
  font-family: 'Playfair Display', serif;
  font-size: 21px;
  color: var(--primary);
  font-weight: 700;
}

.products-header .cat-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 3px;
  font-style: italic;
  line-height: 1.5;
}

.price-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-muted);
}

.price-legend span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.price-legend .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
}

.products-list { padding: 10px 12px; }

.product-item {
  background: var(--card);
  border-radius: var(--r);
  padding: 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-s);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
  border: 1px solid transparent;
}

.product-item:active {
  transform: scale(.99);
  box-shadow: var(--shadow-m);
  border-color: var(--border);
}

.product-item.featured {
  border-left: 3px solid var(--accent);
}

.product-thumb {
  width: 68px;
  height: 68px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}

.product-thumb-placeholder {
  width: 68px;
  height: 68px;
  border-radius: 10px;
  background: var(--primary-l);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.product-info { flex: 1; min-width: 0; }

.product-name {
  font-weight: 600;
  font-size: 14.5px;
  color: var(--text);
  line-height: 1.3;
}

.product-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.45;
}

.product-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.tag {
  font-size: 10px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 20px;
}

.tag-sin-tacc    { background: #FFF3CD; color: #856404; }
.tag-destacado   { background: var(--accent-l); color: var(--accent); }
.tag-frio        { background: #D6EAF8; color: #1A5276; }
.tag-caliente    { background: #FDEDEC; color: #943126; }
.tag-vegano      { background: #D5F5E3; color: #196F3D; }
.tag-vegetariano { background: #E8F8F5; color: #0E6655; }

.product-price-col {
  flex-shrink: 0;
  text-align: right;
}

.price-row {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

.price-chip {
  background: var(--primary-l);
  color: var(--primary);
  font-weight: 700;
  font-size: 13px;
  padding: 3px 10px;
  border-radius: 20px;
}

.price-chip.alt {
  background: var(--accent-l);
  color: var(--accent);
}

.price-label {
  font-size: 9px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 2px;
}

/* ── PRODUCT MODAL ───────────────────────────── */

.modal-wrap {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
}

.modal-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.5);
  animation: scrimIn .2s ease;
}

@keyframes scrimIn { from { opacity: 0; } to { opacity: 1; } }

.modal-sheet {
  position: relative;
  background: var(--card);
  border-radius: 22px 22px 0 0;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  animation: sheetUp .26s ease;
}

@keyframes sheetUp {
  from { transform: translateY(40px); opacity: .6; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 22px 22px 0 0;
}

.modal-img-placeholder {
  width: 100%;
  height: 120px;
  background: var(--primary-l);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  border-radius: 22px 22px 0 0;
}

.modal-body { padding: 20px 20px 36px; }

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(0,0,0,.35);
  border: none;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  transition: background var(--transition);
}

.modal-close:hover { background: rgba(0,0,0,.5); }

.modal-cat-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-l);
  padding: 2px 10px;
  border-radius: 20px;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.modal-name {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  color: var(--text);
  line-height: 1.25;
}

.modal-desc {
  font-size: 13.5px;
  color: var(--text-mid);
  margin-top: 8px;
  line-height: 1.6;
}

.modal-prices {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.modal-price-block {
  background: var(--primary-l);
  border-radius: 12px;
  padding: 10px 16px;
  text-align: center;
  flex: 1;
  min-width: 90px;
}

.modal-price-block.alt { background: var(--accent-l); }

.modal-price-block .amount {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.modal-price-block.alt .amount { color: var(--accent); }

.modal-price-block .size-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 1px;
}

.modal-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

/* ── SEARCH OVERLAY ──────────────────────────── */

.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(28,28,28,.6);
  backdrop-filter: blur(2px);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow-l);
}

.search-bar svg { width: 18px; height: 18px; color: var(--text-muted); flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.search-bar input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 15px;
  font-family: 'Poppins', sans-serif;
  color: var(--text);
  background: transparent;
}

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

.search-bar button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  padding: 2px 4px;
}

.search-results {
  background: #fff;
  border-radius: 14px;
  overflow-y: auto;
  flex: 1;
  max-height: calc(100vh - 120px);
  box-shadow: var(--shadow-m);
}

.search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
}

.search-item:last-child { border-bottom: none; }
.search-item:active { background: var(--bg); }

.search-item-text { flex: 1; }
.search-item-name { font-size: 14px; font-weight: 500; color: var(--text); }
.search-item-cat  { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.search-item-price {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
  margin-left: 12px;
}

/* ── FOOTER ──────────────────────────────────── */

.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--footer-h);
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 50;
}

.footer-links { display: flex; gap: 18px; }

.footer-link {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-mid);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: color var(--transition);
}

.footer-link:hover { color: var(--primary); }

.footer-link svg { width: 20px; height: 20px; flex-shrink: 0; }

.footer-by {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: .8px;
}

/* ── LOADING / EMPTY ─────────────────────────── */

.loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 52px 20px;
  color: var(--text-muted);
  font-size: 13px;
}

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

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

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ── HIDDEN ──────────────────────────────────── */

.hidden { display: none !important; }

/* ── RESPONSIVE ──────────────────────────────── */

@media (min-width: 480px) {
  .categories-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 768px) {
  .categories-grid { grid-template-columns: repeat(4, 1fr); }
  .products-list { max-width: 640px; margin: 0 auto; }
}
