/* ==========================================================
   ACÁ — Componentes reutilizables
   Botones, header, buscador, tarjetas, modal de ubicación,
   bottom nav y footer. Se usan en todas las páginas.
   ========================================================== */

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px;
  border-radius: var(--r-full);
  font-weight: 600; font-size: var(--fs-md); white-space: nowrap;
  transition: background-color .15s ease, transform .1s ease, box-shadow .15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primario { background: var(--azul); color: var(--blanco); box-shadow: var(--sombra-azul); }
.btn-primario:hover { background: var(--azul-oscuro); }
.btn-naranja { background: var(--naranja); color: var(--blanco); }
.btn-naranja:hover { background: var(--naranja-oscuro); }
.btn-secundario { background: var(--blanco); color: var(--negro); border: 2px solid var(--gris-100); }
.btn-secundario:hover { border-color: var(--gris-300); }
.btn-fantasma { background: transparent; color: var(--azul); padding: 0 8px; min-height: 40px; }
.btn-fantasma:hover { background: var(--azul-suave); }
.btn-bloque { width: 100%; }
.btn-grande { min-height: 56px; font-size: var(--fs-lg); padding: 0 28px; }

/* Botón WhatsApp (producto y tienda) */
.btn-whatsapp { background: #25D366; color: #fff; }
.btn-whatsapp:hover { background: #1EBE5A; }
.btn-whatsapp svg { width: 20px; height: 20px; }

/* Botón icono redondo (favoritos, carrito, cuenta) */
.btn-icono {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: var(--r-full);
  color: var(--negro); background: transparent;
  transition: background-color .15s ease;
}
.btn-icono:hover { background: var(--gris-100); }
.btn-icono svg { width: 22px; height: 22px; }
.btn-icono .badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--r-full); background: var(--naranja); color: var(--blanco);
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}

/* ---------- Header ---------- */
.header { position: sticky; top: 0; z-index: 50; }

.header-main {
  background: rgba(243, 239, 230, 0.94);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(28, 30, 37, 0.06);
}
.header-row { height: var(--alto-header); display: flex; align-items: center; gap: 12px; }
.header-logo { display: flex; align-items: center; flex-shrink: 0; }
.header-logo img { height: 34px; width: auto; }
@media (min-width: 768px) { .header-logo img { height: 38px; } }

/* "Estás comprando en" (desktop) */
.comprando-en {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0;
  padding: 4px 12px; border-radius: var(--r-md); flex-shrink: 0;
  transition: background-color .15s ease;
}
.comprando-en:hover { background: rgba(28,30,37,0.05); }
.comprando-en .rotulo { font-size: 11px; color: var(--gris-500); line-height: 1; }
.comprando-en .lugar { display: flex; align-items: center; gap: 4px; font-weight: 600; font-size: var(--fs-sm); }
.comprando-en .lugar svg:first-child { width: 16px; height: 16px; color: var(--naranja); }
.comprando-en .lugar svg:last-child { width: 15px; height: 15px; color: var(--gris-500); }

/* Buscador central desktop */
.header-buscador { flex: 1; min-width: 0; max-width: 520px; }

/* Acciones */
.header-acciones { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.header-acciones .solo-desktop-inline { display: none; }
.btn-icono.con-texto { width: auto; padding: 0 10px; gap: 6px; font-size: var(--fs-sm); font-weight: 500; }
.btn-vender { min-height: 42px; padding: 0 18px; box-shadow: none; margin-left: 6px; }
.btn-vender svg { width: 18px; height: 18px; }
@media (min-width: 768px) {
  .header-acciones .solo-desktop-inline { display: inline-flex; }
}

/* Sub-barra de ubicación + buscador (celular) */
.header-sub { background: var(--blanco); border-bottom: 1px solid rgba(28,30,37,0.06); padding: 8px 0 10px; }
.header-sub .contenedor { display: flex; flex-direction: column; gap: 8px; }
.comprando-en-mobile {
  display: flex; align-items: center; gap: 8px; align-self: flex-start;
  background: var(--azul-suave); color: var(--azul); border-radius: var(--r-full);
  padding: 6px 12px; font-size: var(--fs-xs);
}
.comprando-en-mobile .rotulo { display: none; }
.comprando-en-mobile .lugar { display: flex; align-items: center; gap: 4px; font-weight: 600; }
.comprando-en-mobile .lugar svg:first-child { width: 15px; height: 15px; color: var(--naranja); }
.comprando-en-mobile .lugar svg:last-child { width: 14px; height: 14px; }

/* Barra de categorías (desktop) */
.header-cats { background: var(--blanco); border-bottom: 1px solid rgba(28,30,37,0.06); }
.header-cats-row { display: flex; align-items: center; gap: 4px; height: 46px; overflow-x: auto; scrollbar-width: none; }
.header-cats-row::-webkit-scrollbar { display: none; }
.cat-link {
  white-space: nowrap; padding: 7px 12px; border-radius: var(--r-full);
  font-size: var(--fs-sm); font-weight: 500; color: var(--gris-700);
  transition: background-color .15s ease, color .15s ease;
}
.cat-link:hover { background: var(--azul-suave); color: var(--azul); }
.cat-todas { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--negro); }
.cat-todas svg { width: 17px; height: 17px; }
.cat-mas { color: var(--azul); font-weight: 600; }

/* ---------- Drawer (menú lateral celular) ---------- */
.drawer-fondo {
  position: fixed; inset: 0; z-index: 100; background: rgba(28,30,37,0.45);
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.drawer-fondo.abierto { opacity: 1; pointer-events: auto; }
.drawer {
  position: absolute; top: 0; left: 0; bottom: 0; width: 84%; max-width: 340px;
  background: var(--blanco); padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  overflow-y: auto; transform: translateX(-100%); transition: transform .22s ease;
  display: flex; flex-direction: column; gap: 4px;
}
.drawer-fondo.abierto .drawer { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.drawer-logo { height: 34px; }
.drawer-ubic {
  display: flex; align-items: center; gap: 10px; text-align: left;
  background: var(--azul-suave); border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 8px;
}
.drawer-ubic svg { width: 22px; height: 22px; color: var(--naranja); flex-shrink: 0; }
.drawer-ubic .rotulo { display: block; font-size: 11px; color: var(--gris-500); }
.drawer-ubic .txt { display: block; font-weight: 600; font-size: var(--fs-sm); color: var(--azul); }
.drawer-links { display: flex; flex-direction: column; }
.drawer-links a { display: flex; align-items: center; gap: 12px; padding: 12px 8px; border-radius: var(--r-sm); font-weight: 500; }
.drawer-links a:hover { background: var(--gris-100); }
.drawer-links svg { width: 20px; height: 20px; color: var(--gris-700); }
.drawer-cats-titulo { font-size: var(--fs-xs); font-weight: 600; color: var(--gris-500); text-transform: uppercase; letter-spacing: .04em; margin: 14px 8px 6px; }
.drawer-cats { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.drawer-cats a { display: flex; align-items: center; gap: 8px; padding: 10px 8px; border-radius: var(--r-sm); font-size: var(--fs-sm); }
.drawer-cats a:hover { background: var(--gris-100); }
.drawer-cats a span { font-size: 18px; }
.drawer-vender { margin-top: 16px; }
.drawer-vender svg { width: 18px; height: 18px; }

/* ---------- Buscador ---------- */
.buscador {
  display: flex; align-items: center; gap: 8px;
  background: var(--blanco); border-radius: var(--r-full);
  border: 1.5px solid var(--gris-100);
  padding: 4px 4px 4px 16px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.buscador:focus-within { border-color: var(--azul); box-shadow: 0 0 0 4px var(--azul-suave); }
.buscador svg { width: 20px; height: 20px; color: var(--gris-500); flex-shrink: 0; }
.buscador input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  height: 40px; font-size: var(--fs-md);
}
.buscador input::placeholder { color: var(--gris-500); }
.buscador .btn { min-height: 40px; padding: 0 18px; box-shadow: none; }
.buscador-grande { padding: 6px 6px 6px 20px; }
.buscador-grande input { height: 48px; font-size: var(--fs-lg); }
.buscador-grande .btn { min-height: 48px; }
.buscador-grande .btn-txt { display: none; }
@media (min-width: 480px) { .buscador-grande .btn-txt { display: inline; } }

/* ---------- Encabezado de sección ---------- */
.seccion { padding: 28px 0; }
@media (min-width: 768px) { .seccion { padding: 44px 0; } }
.seccion-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin-bottom: 16px;
}
.seccion-head h2 { font-size: var(--fs-xl); }
@media (min-width: 768px) {
  .seccion-head { margin-bottom: 22px; }
  .seccion-head h2 { font-size: var(--fs-2xl); }
}
.seccion-head .sub { color: var(--gris-500); font-size: var(--fs-sm); margin-top: 2px; }
.ver-todo { color: var(--azul); font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; }
.ver-todo:hover { text-decoration: underline; }

/* ---------- Grillas y carruseles ---------- */
/* En celular las filas de productos scrollean horizontal; en desktop son grilla */
.fila-scroll {
  display: flex; gap: 12px; overflow-x: auto;
  scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
  padding: 4px var(--pad-x) 12px;
  margin: 0 calc(-1 * var(--pad-x));
  scrollbar-width: none;
}
.fila-scroll::-webkit-scrollbar { display: none; }
.fila-scroll > * { flex: 0 0 168px; scroll-snap-align: start; }
@media (min-width: 768px) {
  .fila-scroll {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px;
    overflow: visible; padding: 4px 0; margin: 0;
  }
  .fila-scroll > * { flex: none; }
}
@media (min-width: 1024px) { .fila-scroll { grid-template-columns: repeat(5, 1fr); } }
.fila-scroll.ofertas { grid-template-columns: repeat(4, 1fr); }
@media (min-width: 1024px) { .fila-scroll.ofertas { grid-template-columns: repeat(4, 1fr); } }

/* ---------- Tarjeta de producto ---------- */
.card-producto {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--blanco); border-radius: var(--r-md);
  box-shadow: var(--sombra-1); overflow: hidden;
  transition: box-shadow .15s ease;
}
.card-producto:hover { box-shadow: var(--sombra-2); }
.card-producto .foto {
  position: relative; aspect-ratio: 1 / 1; background: var(--gris-100); overflow: hidden;
}
.card-producto .foto img { width: 100%; height: 100%; object-fit: cover; }
.card-producto .foto .fallback {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 44px; background: var(--azul-suave);
}
.card-producto .fav {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 34px; height: 34px; border-radius: var(--r-full);
  background: rgba(255,255,255,0.92); display: flex; align-items: center; justify-content: center;
  color: var(--negro); box-shadow: var(--sombra-1);
}
.card-producto .fav svg { width: 18px; height: 18px; }
.card-producto .fav.activo { color: var(--naranja); }
.card-producto .fav.activo svg { fill: currentColor; }
.card-producto .descuento {
  position: absolute; top: 8px; left: 8px;
  background: var(--naranja); color: var(--blanco);
  font-size: var(--fs-xs); font-weight: 700; padding: 3px 8px; border-radius: var(--r-full);
}
.card-producto .info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; }
.card-producto .nombre {
  font-size: var(--fs-sm); font-weight: 500; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.6em;
}
.card-producto .precio { font-weight: 600; font-size: var(--fs-md); margin-top: 4px; }
.card-producto .precio .anterior {
  font-weight: 400; font-size: var(--fs-xs); color: var(--gris-500);
  text-decoration: line-through; margin-left: 6px;
}
.card-producto .comercio {
  font-size: var(--fs-xs); color: var(--gris-500);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-producto .comercio strong { color: var(--gris-700); font-weight: 500; }
.card-producto .envio {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 6px;
  font-size: var(--fs-xs); color: var(--azul); font-weight: 500;
}
.card-producto .envio svg { width: 14px; height: 14px; }

/* ---------- Tarjeta de comercio ---------- */
.card-comercio {
  display: block; background: var(--blanco); border-radius: var(--r-md);
  box-shadow: var(--sombra-1); overflow: hidden;
  transition: box-shadow .15s ease;
}
.card-comercio:hover { box-shadow: var(--sombra-2); }
.card-comercio .portada { height: 84px; background: var(--gris-100); }
.card-comercio .portada img { width: 100%; height: 100%; object-fit: cover; }
.card-comercio .cuerpo { padding: 0 14px 14px; }
.card-comercio .logo {
  width: 56px; height: 56px; border-radius: var(--r-md);
  margin-top: -28px; border: 3px solid var(--blanco);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: var(--fs-lg); color: var(--blanco);
  box-shadow: var(--sombra-1);
}
.card-comercio .nombre { font-weight: 600; font-size: var(--fs-md); margin-top: 8px; }
.card-comercio .rubro { color: var(--gris-500); font-size: var(--fs-sm); }
.card-comercio .meta {
  display: flex; align-items: center; gap: 4px; margin-top: 8px;
  color: var(--gris-700); font-size: var(--fs-xs);
}
.card-comercio .meta svg { width: 14px; height: 14px; color: var(--naranja); }
.card-comercio .abierto {
  display: inline-block; margin-left: auto; padding: 2px 8px; border-radius: var(--r-full);
  background: #E4F5EA; color: #1E7B45; font-weight: 600;
}
.card-comercio .cerrado { background: var(--gris-100); color: var(--gris-500); }

/* ---------- Chips de categoría ---------- */
.categorias-lista {
  display: flex; gap: 14px; overflow-x: auto;
  padding: 4px var(--pad-x) 12px; margin: 0 calc(-1 * var(--pad-x));
  scrollbar-width: none;
}
.categorias-lista::-webkit-scrollbar { display: none; }
.cat {
  flex: 0 0 auto; width: 76px;
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
}
.cat .icono {
  width: 60px; height: 60px; border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center; font-size: 27px;
  transition: transform .15s ease;
}
.cat .icono.tono-azul   { background: var(--azul-suave); }
.cat .icono.tono-naranja{ background: var(--naranja-suave); }
.cat:hover .icono { transform: translateY(-3px); }
.cat .cat-nombre { font-size: var(--fs-xs); font-weight: 500; color: var(--gris-700); line-height: 1.2; }
@media (min-width: 768px) {
  .categorias-lista { gap: 18px; padding: 4px 0; margin: 0; }
  .cat { width: 84px; }
  .cat .icono { width: 66px; height: 66px; font-size: 29px; }
}

/* ---------- Modal de ubicación ---------- */
.modal-fondo {
  position: fixed; inset: 0; z-index: 100; background: rgba(28,30,37,0.45);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.modal-fondo.abierto { opacity: 1; pointer-events: auto; }
.modal {
  width: 100%; max-width: 460px; background: var(--blanco);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(20px); transition: transform .2s ease;
  max-height: 88vh; display: flex; flex-direction: column;
}
.modal-fondo.abierto .modal { transform: translateY(0); }
@media (min-width: 768px) {
  .modal-fondo { align-items: center; padding: 20px; }
  .modal { border-radius: var(--r-lg); max-height: 80vh; }
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-head h2 { font-size: var(--fs-xl); display: flex; align-items: center; gap: 8px; }
.modal-head h2 svg { width: 24px; height: 24px; color: var(--naranja); }
.modal .ayuda { color: var(--gris-500); margin: 4px 0 14px; font-size: var(--fs-sm); }

.buscador-loc { margin-bottom: 8px; }
.buscador-loc input { border: 0; outline: 0; background: transparent; height: 44px; flex: 1; min-width: 0; font-size: var(--fs-md); }

.loc-bloque { overflow-y: auto; }
.loc-titulo {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--fs-xs); font-weight: 600; color: var(--gris-500);
  text-transform: uppercase; letter-spacing: .04em; margin: 12px 4px 6px;
}
.loc-titulo svg { width: 14px; height: 14px; }
.loc-lista { display: flex; flex-direction: column; }
.loc-item {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 12px 10px; border-radius: var(--r-md);
  transition: background-color .12s ease;
}
.loc-item:hover { background: var(--azul-suave); }
.loc-item svg { width: 20px; height: 20px; color: var(--naranja); flex-shrink: 0; }
.loc-item .loc-nombre { display: block; font-weight: 600; font-size: var(--fs-md); }
.loc-item .loc-prov { display: block; font-size: var(--fs-xs); color: var(--gris-500); }
.loc-vacio { color: var(--gris-500); font-size: var(--fs-sm); padding: 16px 10px; }

/* ---------- Bottom navigation (solo celular) ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  height: calc(var(--alto-bottomnav) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--blanco);
  border-top: 1px solid rgba(28, 30, 37, 0.06);
  display: grid; grid-template-columns: repeat(5, 1fr);
}
@media (min-width: 768px) { .bottom-nav { display: none; } }
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 500; color: var(--gris-500);
}
.bottom-nav a svg { width: 24px; height: 24px; }
.bottom-nav a.activo { color: var(--azul); }
.bottom-nav a.activo svg { stroke-width: 2.4; }

/* ---------- Footer ---------- */
.footer {
  background: var(--negro); color: rgba(255,255,255,0.75);
  padding: 40px 0 28px; margin-top: 24px;
}
.footer .grid { display: grid; gap: 28px; }
@media (min-width: 768px) { .footer .grid { grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 40px; } }
.footer .marca img { height: 40px; }
.footer .marca p { margin-top: 12px; font-size: var(--fs-sm); max-width: 32ch; }
.footer h4 { color: var(--blanco); font-size: var(--fs-sm); font-weight: 600; margin-bottom: 12px; }
.footer li { margin-bottom: 8px; font-size: var(--fs-sm); }
.footer li a:hover { color: var(--blanco); }
.footer .legal {
  margin-top: 32px; padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px;
  font-size: var(--fs-xs); color: rgba(255,255,255,0.5);
}

/* ---------- Toast (mensajes breves) ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--alto-bottomnav) + 16px);
  transform: translate(-50%, 12px); z-index: 90;
  background: var(--negro); color: var(--blanco);
  padding: 12px 18px; border-radius: var(--r-full);
  font-size: var(--fs-sm); font-weight: 500; box-shadow: var(--sombra-2);
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 768px) { .toast { bottom: 24px; } }

/* Fila de comercios: tarjetas más anchas */
.fila-scroll.comercios > * { flex-basis: 220px; }
@media (min-width: 768px) { .fila-scroll.comercios { grid-template-columns: repeat(3, 1fr); } }
.card-comercio .meta > span:first-of-type { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-comercio .abierto { flex-shrink: 0; }


/* ---- Volver / breadcrumb (producto y tienda) ---- */
.volver {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 14px 0; color: var(--gris-700); font-size: var(--fs-sm); font-weight: 500;
}
.volver svg { width: 18px; height: 18px; flex-shrink: 0; }
.volver:hover { color: var(--azul); }

/* ---------- Footer: ubicación y redes ---------- */
.footer .marca p { margin-top: 8px; }
.footer-ubic { display: inline-flex; align-items: center; gap: 6px; margin-top: 14px; font-size: var(--fs-sm); color: rgba(255,255,255,0.85); }
.footer-ubic svg { width: 16px; height: 16px; color: var(--naranja); }
.footer-redes { display: flex; gap: 8px; margin-top: 16px; }
.footer-redes a {
  width: 38px; height: 38px; border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.85);
  transition: background-color .15s ease;
}
.footer-redes a:hover { background: var(--azul); color: var(--blanco); }
.footer-redes svg { width: 19px; height: 19px; }

/* ---------- Header: corte propio a 1024px ----------
   Tablets (768–1023) usan el header simple de celular para que
   nunca se desborde. El header completo aparece desde 1024. */
@media (max-width: 1023px) {
  .header .solo-desktop { display: none !important; }
  .header .header-acciones .solo-desktop-inline { display: none !important; }
  .header .solo-mobile { display: flex !important; }
  .header-sub.solo-mobile { display: block !important; }
}
@media (min-width: 1024px) {
  .header .solo-mobile,
  .header-sub.solo-mobile { display: none !important; }
  .header .solo-desktop { display: block !important; }
  .header .header-cats.solo-desktop { display: block !important; }
  .header .header-acciones .solo-desktop-inline { display: inline-flex !important; }
}

/* Íconos SVG de categoría dentro del chip */
.cat .icono svg { width: 30px; height: 30px; }
.cat .icono.tono-azul   svg { color: var(--azul); }
.cat .icono.tono-naranja svg { color: var(--naranja); }

/* Íconos SVG de categoría en menú lateral y chips */
.drawer-cats a span svg { width: 18px; height: 18px; color: var(--azul); vertical-align: middle; }
.chip-cat .ico svg { width: 16px; height: 16px; vertical-align: -3px; }
