/* ─── Agave Villas — Grocery Store ──────────────────────────────────────────
   Co-marca: identidad Agave Villas (verde #2b5431), operado por Pantry.       */
:root {
  color-scheme: light;
  --agave:       #2b5431;
  --agave-dark:  #1d3b23;
  --agave-soft:  #eaf1ec;
  --agave-tint:  #f4f8f5;
  --bg:          #faf8f4;
  --ink:         #1a1c1e;
  --ink-2:       #3c3f42;
  --muted:       #6f6a62;
  --line:        #e2ddd3;
  --panel:       #ffffff;
  --warning:     #b3412e;
  --warn-bg:     #fdf0ee;
  --shadow-sm:   0 1px 3px rgba(20,22,24,.07);
  --shadow-md:   0 6px 24px rgba(20,22,24,.10);
  --shadow-lg:   0 20px 50px rgba(20,22,24,.16);
  --radius:      14px;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100svh;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
img { display: block; }

.eyebrow {
  margin: 0;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--agave);
}

.primary-btn {
  background: var(--agave);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 16px 22px;
  font-size: 1rem;
  font-weight: 700;
  width: 100%;
  box-shadow: var(--shadow-sm);
  transition: background .15s;
}
.primary-btn:hover  { background: var(--agave-dark); }
.primary-btn:disabled { opacity: .5; cursor: default; }

.ghost-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 9px 16px;
  font-weight: 600;
  font-size: .88rem;
}
.ghost-btn:hover { background: var(--agave-tint); }

/* ─── Pantalla de acceso ────────────────────────────────────────────────── */
.gate-screen { display: grid; place-items: center; min-height: 100svh; padding: 24px; }

.gate-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  padding: 44px 36px;
  width: min(440px, 100%);
  text-align: center;
}
.gate-logo { width: 128px; margin: 0 auto 26px; }
.gate-title { margin: 0 0 10px; font-size: 1.15rem; font-weight: 800; }
.gate-msg { margin: 0; color: var(--muted); font-size: .92rem; line-height: 1.6; }

.spinner {
  width: 30px; height: 30px;
  margin: 0 auto 14px;
  border: 3px solid var(--agave-soft);
  border-top-color: var(--agave);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Encabezado ────────────────────────────────────────────────────────── */
.shop-screen { max-width: 1240px; margin: 0 auto; padding: 0 20px 80px; }

.shop-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(250,248,244,.94);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}

.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-logo { width: 62px; flex-shrink: 0; }
.brand-text { min-width: 0; }
.brand h1 {
  margin: 2px 0 0;
  font-size: 1.24rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stay-info { margin: 2px 0 0; font-size: .8rem; color: var(--muted); }

.cart-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--agave);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.cart-btn:hover { background: var(--agave-dark); }

.cart-badge {
  position: absolute;
  top: -6px; right: -6px;
  background: var(--warning);
  color: #fff;
  font-size: .74rem;
  font-weight: 800;
  min-width: 23px; height: 23px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  padding: 0 6px;
  border: 2px solid var(--bg);
}

/* ─── Buscador y categorías ─────────────────────────────────────────────── */
.toolbar { display: grid; gap: 12px; margin-bottom: 20px; }

.search-wrap { position: relative; }
.search-icon {
  position: absolute;
  left: 18px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
#searchInput {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  padding: 14px 20px 14px 46px;
  font-size: 1rem;
  outline: none;
  box-shadow: var(--shadow-sm);
}
#searchInput:focus { border-color: var(--agave); }

/* ─── Categorías en bento grid ──────────────────────────────────────────────── */
.chips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 9px;
}

.cat-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 88px;
  padding: 12px 8px 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
  color: var(--ink-2);
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: border-color .12s, background .12s, transform .09s, box-shadow .12s;
}
.cat-tile:hover {
  border-color: var(--agave);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* "All products" ancla el bento ocupando dos columnas */
.cat-tile-wide { grid-column: span 2; }

.cat-ico  { font-size: 1.6rem; line-height: 1; }
.cat-name {
  font-size: .78rem; font-weight: 700; line-height: 1.2;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cat-n {
  font-size: .7rem; font-weight: 800;
  color: var(--muted); background: var(--agave-tint);
  border-radius: 999px; padding: 1px 9px;
}

.cat-tile.active {
  background: var(--agave);
  border-color: var(--agave);
  color: #fff;
}
.cat-tile.active .cat-n { background: rgba(255,255,255,.24); color: #fff; }

.status-msg { text-align: center; color: var(--muted); padding: 50px 20px; }

/* ─── Menús del chef ────────────────────────────────────────────────────── */
.menu-section { margin-bottom: 30px; }

.section-head { margin-bottom: 14px; }
.section-head h2 { margin: 3px 0 2px; font-size: 1.18rem; font-weight: 900; }
.section-sub { margin: 0; color: var(--muted); font-size: .87rem; }

.recipe-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(238px, 1fr);
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x mandatory;
}
.recipe-strip::-webkit-scrollbar { height: 6px; }
.recipe-strip::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.recipe-tile {
  scroll-snap-align: start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s, transform .1s;
}
.recipe-tile:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.recipe-tile img { width: 100%; height: 136px; object-fit: cover; background: var(--agave-tint); }
.recipe-tile .rt-body { padding: 11px 13px 14px; }
.recipe-tile h3 { margin: 0 0 3px; font-size: .96rem; font-weight: 800; }
.recipe-tile p  { margin: 0; font-size: .78rem; color: var(--muted); }

/* ─── Modal de receta ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(26,28,30,.5);
  display: grid; place-items: center;
  padding: 20px; overflow-y: auto;
}
.modal {
  position: relative;
  background: var(--panel);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  width: min(520px, 100%);
  max-height: 92svh;
  overflow-y: auto;
}
.modal-close {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 34px; height: 34px; border-radius: 50%;
  border: none; background: rgba(255,255,255,.92);
  font-size: .95rem; color: var(--ink-2);
  box-shadow: var(--shadow-sm);
}
.rm-image { width: 100%; height: 190px; object-fit: cover; background: var(--agave-tint); }
.rm-body  { padding: 20px 22px 24px; }
.rm-body h2 { margin: 3px 0 6px; font-size: 1.3rem; font-weight: 900; }
.rm-desc  { margin: 0 0 18px; color: var(--muted); font-size: .9rem; line-height: 1.55; }

.servings {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; background: var(--agave-tint);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 18px;
}
.servings-label { font-weight: 700; font-size: .9rem; }
.servings-ctl { display: flex; align-items: center; gap: 12px; }
.servings-ctl button {
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel);
  font-size: 1.2rem; font-weight: 700; color: var(--agave-dark);
}
.servings-ctl button:hover { background: var(--agave-soft); }
.servings-ctl span { font-weight: 900; font-size: 1.1rem; min-width: 28px; text-align: center; }

.rm-sub { margin: 0 0 10px; font-size: .82rem; font-weight: 800;
          text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.rm-list { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 7px; }
.rm-list li {
  display: flex; align-items: center; gap: 10px;
  font-size: .88rem; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 9px;
}
.rm-list img { width: 34px; height: 34px; object-fit: contain; border-radius: 6px; background: #fff; }
.rm-list .li-qty { margin-left: auto; font-weight: 700; color: var(--agave-dark); white-space: nowrap; }

.rm-total {
  display: flex; justify-content: space-between; align-items: center;
  border-top: 1px solid var(--line); padding-top: 12px; margin-bottom: 14px;
  font-size: 1rem;
}
.rm-total strong { font-size: 1.15rem; font-weight: 900; color: var(--agave-dark); }

/* ─── Productos ─────────────────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s, border-color .15s, transform .1s;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card.in-cart { border-color: var(--agave); background: var(--agave-tint); }

.card-img-wrap { position: relative; margin-bottom: 10px; }
.card-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #fff;
  border-radius: 10px;
}

.card-qty {
  position: absolute;
  top: 6px; right: 6px;
  background: var(--agave);
  color: #fff;
  font-weight: 800;
  font-size: .88rem;
  min-width: 28px; height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  padding: 0 8px;
  box-shadow: var(--shadow-sm);
}

.card-name {
  margin: 0 0 3px;
  font-size: .9rem;
  font-weight: 700;
  line-height: 1.28;
  min-height: 2.3em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-unit  { margin: 0; font-size: .78rem; color: var(--muted); }
.card-price { margin: 6px 0 10px; font-size: 1.02rem; font-weight: 800; color: var(--agave-dark); }

.card .add-btn {
  margin-top: auto;
  border: 1px solid var(--agave);
  background: var(--panel);
  color: var(--agave);
  border-radius: 10px;
  padding: 9px;
  font-weight: 700;
  font-size: .88rem;
}
.card .add-btn:hover { background: var(--agave); color: #fff; }

.stepper, .row-stepper { display: flex; align-items: center; justify-content: center; gap: 10px; }
.stepper { margin-top: auto; }

.stepper button, .row-stepper button {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--agave-dark);
  display: grid;
  place-items: center;
}
.stepper button:hover, .row-stepper button:hover { background: var(--agave-soft); }
.stepper .qty { font-weight: 800; min-width: 30px; text-align: center; }

.more-btn {
  display: block;
  margin: 24px auto 0;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  padding: 12px 30px;
  font-weight: 600;
  color: var(--ink-2);
}
.more-btn:hover { border-color: var(--agave); }

/* ─── Carrito ───────────────────────────────────────────────────────────── */
.cart-screen {
  position: fixed;
  inset: 0;
  background: rgba(26,28,30,.4);
  display: grid;
  justify-items: end;
  z-index: 60;
}

.cart-panel {
  background: var(--bg);
  width: min(560px, 100vw);
  height: 100svh;
  overflow-y: auto;
  padding: 22px 24px 28px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

.cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.cart-header h2 { margin: 0; font-size: 1.2rem; font-weight: 900; }

.cart-items { display: grid; gap: 10px; }

.cart-row {
  display: grid;
  grid-template-columns: 52px 1fr auto auto auto;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
.row-img {
  width: 52px; height: 52px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
}
.row-info { min-width: 0; display: grid; }
.row-name { font-size: .92rem; line-height: 1.25; }
.row-unit { color: var(--muted); font-size: .78rem; }
.row-qty {
  width: 56px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 2px;
  font-weight: 700;
}
.row-total { font-weight: 800; font-size: .92rem; min-width: 66px; text-align: right; }
.row-remove { border: none; background: none; color: var(--muted); font-size: 1rem; padding: 6px; }
.row-remove:hover { color: var(--warning); }

.cart-empty { text-align: center; color: var(--muted); padding: 40px 10px; }

#cartFooter { margin-top: auto; padding-top: 18px; }

.totals {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.total-row { display: flex; justify-content: space-between; font-size: .92rem; padding: 3px 0; color: var(--ink-2); }
.total-row.grand {
  border-top: 1px solid var(--line);
  margin-top: 8px;
  padding-top: 10px;
  font-size: 1.1rem;
}
.total-row.grand strong { color: var(--agave-dark); font-weight: 900; }
.fx-note { margin: 8px 0 0; font-size: .74rem; color: var(--muted); }

.field { display: grid; gap: 6px; margin-bottom: 14px; font-size: .86rem; font-weight: 600; color: var(--ink-2); }
.field input, .field textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1rem;
  font-weight: 400;
  background: var(--panel);
  resize: none;
  outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--agave); }
.field-hint { font-size: .76rem; font-weight: 400; color: var(--muted); }

.error-msg { min-height: 1.2em; margin: 0 0 10px; color: var(--warning); font-size: .86rem; font-weight: 600; }

/* ─── Confirmación ──────────────────────────────────────────────────────── */
.done-screen { display: grid; place-items: center; min-height: 100svh; padding: 24px; }
.done-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  padding: 46px 38px;
  width: min(460px, 100%);
  text-align: center;
}
.done-check {
  width: 80px; height: 80px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: var(--agave-soft);
  color: var(--agave);
  font-size: 2.4rem;
  font-weight: 900;
  display: grid;
  place-items: center;
}
.done-card h1 { margin: 0 0 8px; font-size: 1.4rem; font-weight: 900; }
.done-summary { color: var(--ink-2); font-weight: 600; margin: 0 0 6px; }
.done-note { color: var(--muted); margin: 0 0 26px; font-size: .9rem; line-height: 1.6; }

/* ─── Pie ───────────────────────────────────────────────────────────────── */
.powered {
  text-align: center;
  padding: 22px;
  font-size: .76rem;
  color: var(--muted);
  letter-spacing: .04em;
}
.powered strong { color: var(--agave); font-weight: 700; }

/* ─── Móvil ─────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px; }
  .brand-logo { width: 46px; }
  .brand h1 { font-size: 1.05rem; }
  .cart-label { display: none; }
  .cart-btn { padding: 12px 16px; }
  .cart-row { grid-template-columns: 44px 1fr auto; row-gap: 8px; }
  .row-total { grid-column: 2 / 4; text-align: left; }
  .shop-screen { padding: 0 14px 70px; }
}

/* ─── Bienvenida y acceso por código ────────────────────────────────────────── */
.code-form { display: grid; gap: 10px; margin-top: 22px; }

#codeInput {
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 15px 18px;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-align: center;
  text-transform: uppercase;
  background: var(--panel);
  outline: none;
}
#codeInput:focus { border-color: var(--agave); }
#codeInput::placeholder { color: #c3c8c4; font-weight: 500; letter-spacing: .06em; }

.code-error {
  min-height: 1.2em;
  margin: 10px 0 0;
  color: var(--warning);
  font-size: .86rem;
  font-weight: 600;
}
.gate-foot { margin: 16px 0 0; font-size: .8rem; color: var(--muted); }
.gate-card .eyebrow { margin-bottom: 6px; }

@media (max-width: 600px) {
  .chips { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 7px; }
  .cat-tile { min-height: 78px; }
  .cat-ico { font-size: 1.35rem; }
}
