/* ─── TIENDA — estilos específicos de la tienda online ── */

/* ── Layout principal ──────────────────────────────────── */
.tienda-wrap {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 0;
  max-width: 1400px;
  margin: 0 auto;
  min-height: calc(100vh - var(--nav-h));
  align-items: start;
}

/* ── Header de tienda ──────────────────────────────────── */
.tienda-hero {
  background: var(--blue-dark);
  padding: calc(var(--nav-h) + 32px) 24px 0;
  position: relative;
  overflow: hidden;
}
.tienda-hero::before {
  content: '';
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(135deg, rgba(255,255,255,.04) 25%, transparent 25%) -14px 0,
    linear-gradient(225deg, rgba(255,255,255,.04) 25%, transparent 25%) -14px 0,
    linear-gradient(315deg, rgba(249,168,37,.04)  25%, transparent 25%),
    linear-gradient(45deg,  rgba(249,168,37,.04)  25%, transparent 25%);
  background-size: 28px 28px;
}
.tienda-hero-inner {
  max-width: 1400px; margin: 0 auto;
  position: relative; z-index: 1;
  padding-bottom: 0;
}
.tienda-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  color: #fff; font-weight: 700;
  margin-bottom: 6px;
}
.tienda-hero p {
  color: rgba(255,255,255,.65);
  font-size: .92rem; margin-bottom: 24px;
}
.tienda-hero .delivery-note {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(249,168,37,.15); border: 1px solid rgba(249,168,37,.3);
  color: var(--maize); border-radius: 40px;
  padding: 6px 16px; font-size: .78rem; font-weight: 700;
  font-family: var(--font-heading); letter-spacing: .08em;
  margin-bottom: 28px;
}

/* ── Categorías (pills) ────────────────────────────────── */
.cat-bar {
  position: sticky; top: var(--nav-h); z-index: 100;
  background: var(--blue-dark);
  border-bottom: 1px solid rgba(255,255,255,.1);
  padding: 0 24px;
}
.cat-bar::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 3px;
  background: repeating-linear-gradient(to right,
    #1565C0 0 18px, #00ACC1 18px 26px, #2E7D32 26px 44px,
    #F9A825 44px 52px, #C62828 52px 70px, #E91E63 70px 78px,
    #6A1B9A 78px 96px, #F9A825 96px 104px, #1565C0 104px 122px
  );
}
#catPills {
  display: flex; gap: 6px; padding: 12px 0;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; scroll-snap-type: x mandatory;
}
#catPills::-webkit-scrollbar { display: none; }
.cat-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: 40px; white-space: nowrap;
  font-family: var(--font-heading); font-size: .72rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  background: rgba(255,255,255,.08); color: rgba(255,255,255,.65);
  border: 1.5px solid rgba(255,255,255,.12);
  cursor: pointer; transition: background-color .18s, color .18s, border-color .18s;
  scroll-snap-align: start; flex-shrink: 0;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.cat-pill:hover  { background: rgba(255,255,255,.14); color: #fff; }
.cat-pill.active {
  background: var(--maize); color: #1A1208;
  border-color: var(--maize);
}
.cat-pill i { font-size: .8rem; }

/* ── Área de productos ─────────────────────────────────── */
.products-area {
  background: var(--cream);
  padding: 28px 24px 80px;
  min-height: 600px;
}
#productGrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* ── Tarjeta de producto ───────────────────────────────── */
.prod-card {
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: transform .22s, box-shadow .22s;
  contain: layout style;
}
.prod-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.prod-card--caja .prod-icon-wrap { background: linear-gradient(135deg, #E65100, #F57F17); }

.prod-icon-wrap {
  height: 100px; display: flex; align-items: center; justify-content: center;
  position: relative; font-size: 2rem; color: #fff;
  background: linear-gradient(135deg, #0D47A1, #1565C0);
}
.prod-icon-wrap.cat-snacks     { background: linear-gradient(135deg, #4A148C, #6A1B9A); }
.prod-icon-wrap.cat-bebidas    { background: linear-gradient(135deg, #006064, #0097A7); }
.prod-icon-wrap.cat-basicos    { background: linear-gradient(135deg, #1B5E20, #2E7D32); }
.prod-icon-wrap.cat-condimentos{ background: linear-gradient(135deg, #880E4F, #C62828); }
.prod-icon-wrap.cat-dulces     { background: linear-gradient(135deg, #4A148C, #AD1457); }
.prod-icon-wrap.cat-helados    { background: linear-gradient(135deg, #006064, #00ACC1); }
.prod-icon-wrap.cat-medicinas  { background: linear-gradient(135deg, #880E4F, #AD1457); }
.prod-icon-wrap.cat-cajas      { background: linear-gradient(135deg, #E65100, #F57F17); }

.prod-badge {
  position: absolute; top: 8px; right: 8px;
  background: rgba(255,255,255,.2); color: #fff;
  font-size: .6rem; font-weight: 700; font-family: var(--font-heading);
  letter-spacing: .12em; padding: 2px 8px; border-radius: 20px;
  border: 1px solid rgba(255,255,255,.35);
}

.prod-info { padding: 12px 14px 4px; flex: 1; }
.prod-name { font-family: var(--font-heading); font-size: .82rem; font-weight: 700;
             color: var(--ink); letter-spacing: .03em; margin-bottom: 4px; }
.prod-desc { font-size: .75rem; color: var(--ink-light); line-height: 1.5; }

.prod-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px 14px;
}
.prod-price { font-family: var(--font-display); font-size: 1.05rem;
              font-weight: 700; color: var(--blue-dark); }
.add-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--blue-dark); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem; cursor: pointer;
  transition: background-color .18s, transform .15s;
  border: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.add-btn:hover  { background: var(--blue); }
.add-btn:active { transform: scale(.9); }

/* ── Separador de sección ──────────────────────────────── */
.cat-sep {
  grid-column: 1/-1;
  display: flex; align-items: center; gap: 16px;
  padding: 20px 0 8px;
}
.cat-sep-line { flex: 1; height: 1px; background: var(--border); }
.cat-sep span {
  font-family: var(--font-heading); font-size: .72rem; font-weight: 700;
  color: var(--ink-light); letter-spacing: .14em; text-transform: uppercase;
  white-space: nowrap;
}

/* ── Sidebar del carrito (desktop) ─────────────────────── */
.cart-sidebar {
  position: sticky; top: calc(var(--nav-h) + 52px);
  height: calc(100vh - var(--nav-h) - 52px);
  background: #fff;
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.cart-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.cart-header h3 {
  font-family: var(--font-heading); font-size: .88rem; font-weight: 700;
  color: var(--ink); letter-spacing: .08em; text-transform: uppercase;
}
.cart-count-badge {
  background: var(--blue-dark); color: #fff;
  font-size: .7rem; font-weight: 700; font-family: var(--font-heading);
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

.cart-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; color: var(--ink-light); text-align: center; padding: 32px;
}
.cart-empty i { font-size: 2rem; opacity: .3; }
.cart-empty p { font-size: .84rem; line-height: 1.5; }

.cart-body {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden;
}
.cart-list {
  flex: 1; overflow-y: auto; padding: 12px 16px;
  display: flex; flex-direction: column; gap: 8px;
  scrollbar-width: thin;
}
.cart-item {
  display: grid; grid-template-columns: 1fr auto auto;
  align-items: center; gap: 8px;
  padding: 8px 10px; background: var(--cream);
  border-radius: 10px;
}
.cart-item-name { font-size: .8rem; font-weight: 600; color: var(--ink); line-height: 1.35; }
.cart-item-controls { display: flex; align-items: center; gap: 6px; }
.qty-btn {
  width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--border);
  background: #fff; color: var(--ink); font-size: .7rem;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background-color .15s; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.qty-btn:hover { background: var(--cream); border-color: var(--blue); color: var(--blue); }
.qty-num { font-size: .82rem; font-weight: 700; color: var(--ink); min-width: 18px; text-align: center; }
.cart-item-price { font-size: .82rem; font-weight: 700; color: var(--blue-dark); white-space: nowrap; }

.cart-summary {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 6px;
}
.cart-row { display: flex; justify-content: space-between; font-size: .82rem; color: var(--ink-light); }
.cart-total { font-weight: 800; color: var(--ink); font-size: .92rem; margin-top: 4px;
              padding-top: 8px; border-top: 1.5px solid var(--border); }
.text-tbd { color: var(--maize); font-weight: 700; }

.checkout-btn {
  margin: 12px 16px 6px;
  padding: 14px; border-radius: 14px;
  background: linear-gradient(135deg, #0D47A1, #1565C0);
  color: #fff; font-family: var(--font-heading);
  font-size: .82rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; border: none; transition: background-color .2s, transform .15s;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.checkout-btn:hover  { background: linear-gradient(135deg, #1565C0, #1976D2); }
.checkout-btn:active { transform: scale(.98); }
.clear-btn {
  margin: 0 16px 16px; padding: 8px;
  background: none; border: none; color: var(--ink-light);
  font-size: .75rem; cursor: pointer; text-decoration: underline;
  touch-action: manipulation;
}

/* ── FAB carrito (móvil) ────────────────────────────────── */
.cart-fab {
  display: none;
  position: fixed; bottom: 24px; right: 20px; z-index: 500;
  width: 60px; height: 60px; border-radius: 50%;
  background: linear-gradient(135deg, #0D47A1, #1565C0);
  color: #fff; font-size: 1.4rem;
  align-items: center; justify-content: center;
  box-shadow: 0 6px 28px rgba(13,71,161,.45);
  border: none; cursor: pointer;
  transition: transform .2s, box-shadow .2s;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.cart-fab.pop  { transform: scale(1.18); }

.cart-badge {
  position: absolute; top: -4px; right: -4px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--maize); color: #1A1208;
  font-size: .68rem; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
}

/* ── Panel carrito (móvil, slide-in) ──────────────────── */
#cartPanel {
  display: none;
  position: fixed; inset: 0; z-index: 900;
  background: rgba(8,16,32,.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
#cartPanel.open { display: flex; align-items: flex-end; }
.cart-panel-inner {
  background: #fff;
  width: 100%; border-radius: 24px 24px 0 0;
  max-height: 88vh; display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.cart-panel-handle {
  width: 40px; height: 4px; background: var(--border);
  border-radius: 2px; margin: 12px auto 4px;
}

/* ── Modal checkout ─────────────────────────────────────── */
#checkoutModal {
  display: none;
  position: fixed; inset: 0; z-index: 1100;
  background: rgba(8,16,32,.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  align-items: center; justify-content: center; padding: 20px;
}
#checkoutModal.open { display: flex; }
.checkout-inner {
  background: #fff; border-radius: 24px;
  width: 100%; max-width: 540px;
  max-height: 92vh; overflow-y: auto;
  padding: 32px 28px;
  box-shadow: 0 24px 80px rgba(8,16,32,.35);
}
.checkout-inner h2 {
  font-family: var(--font-display);
  font-size: 1.4rem; color: var(--blue-dark);
  margin-bottom: 4px;
}
.checkout-inner .checkout-sub {
  font-size: .84rem; color: var(--ink-light); margin-bottom: 24px;
}

#modalSummary {
  background: var(--cream); border-radius: 14px;
  padding: 16px; margin-bottom: 24px;
  display: flex; flex-direction: column; gap: 8px;
}
.mo-row { display: flex; justify-content: space-between; font-size: .85rem; color: var(--ink-light); }
.mo-total { font-weight: 800; color: var(--ink); font-size: .95rem;
            padding-top: 8px; border-top: 1.5px solid var(--border); margin-top: 4px; }
.mo-divider { height: 1px; background: var(--border); margin: 4px 0; }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-family: var(--font-heading);
  font-size: .72rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-mid); margin-bottom: 6px;
}
.form-group input, .form-group textarea {
  width: 100%; padding: 13px 16px; border-radius: 12px;
  border: 1.5px solid var(--border); background: var(--cream);
  font-family: var(--font-body); font-size: 16px; color: var(--ink);
  outline: none; transition: border-color .18s;
  -webkit-appearance: none;
}
.form-group input:focus, .form-group textarea:focus { border-color: var(--blue); }
.form-group textarea { resize: vertical; min-height: 72px; }

.checkout-note {
  display: flex; align-items: flex-start; gap: 10px;
  background: #FFF8E1; border: 1px solid #F9A825;
  border-radius: 12px; padding: 12px 14px;
  font-size: .78rem; color: var(--ink-mid); line-height: 1.55;
  margin-bottom: 20px;
}
.checkout-note i { color: var(--maize); margin-top: 1px; flex-shrink: 0; }

.submit-order-btn {
  width: 100%; padding: 16px;
  background: linear-gradient(135deg, #25D366, #128C7E);
  color: #fff; font-family: var(--font-heading);
  font-size: .88rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  border: none; border-radius: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: opacity .2s; touch-action: manipulation;
}
.submit-order-btn:hover  { opacity: .92; }
.submit-order-btn:active { opacity: .8; }

.modal-close {
  float: right; background: none; border: none; cursor: pointer;
  color: var(--ink-light); font-size: 1.2rem; padding: 4px;
  touch-action: manipulation;
}

/* ── Banner de confirmación ─────────────────────────────── */
#confirmBanner {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #25D366; color: #fff; z-index: 2000;
  border-radius: 40px; padding: 14px 28px;
  font-family: var(--font-heading); font-size: .82rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 8px 32px rgba(37,211,102,.4);
  opacity: 0; pointer-events: none;
  transition: opacity .3s, transform .3s;
  white-space: nowrap;
}
#confirmBanner.show {
  opacity: 1; pointer-events: auto;
  transform: translateX(-50%) translateY(-4px);
}

/* ── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 1100px) {
  .tienda-wrap { grid-template-columns: 1fr 300px; }
  #productGrid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 800px) {
  .tienda-wrap      { grid-template-columns: 1fr; }
  .cart-sidebar     { display: none; }
  .cart-fab         { display: flex; }
  #cartPanel        { display: none; }
  #cartPanel.open   { display: flex; }
  #productGrid      { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .products-area    { padding: 20px 16px 100px; }
}

@media (max-width: 480px) {
  #productGrid      { grid-template-columns: 1fr; }
  .prod-icon-wrap   { height: 80px; font-size: 1.6rem; }
  .checkout-inner   { padding: 24px 18px; border-radius: 20px; }
  .tienda-hero      { padding-top: calc(var(--nav-h) + 20px); }

  @media (max-width: 700px) {
    .cat-bar, #catPills { backdrop-filter: none; -webkit-backdrop-filter: none; }
    #cartPanel { backdrop-filter: none; -webkit-backdrop-filter: none; }
    #checkoutModal { backdrop-filter: none; -webkit-backdrop-filter: none; }
  }
}
