/* public/css/main.css — Estilos globales MaxTodo */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

/* ── Variables ── */
:root {
  --marca-rojo:   #e8001d;
  --marca-negro:  #1a1a1a;
  --marca-oscuro: #b0001a;  
  --verde:        #1a7a3c;
  --verde-oscuro: #135e2d;
  --verde-claro:  #e8f5ee;
  --rojo:         #e8001d;
  --rojo-bg:      #ffeaed;
  --amarillo:     #ffc300;
  --gris-texto:   #333;
  --gris-suave:   #666;
  --gris-borde:   #e0e0e0;
  --gris-fondo:   #f5f5f5;
  --blanco:       #fff;
  --sombra:       0 2px 12px rgba(0,0,0,.09);
  --radio:        12px;
}

/* ── Base ── */
body {
  font-family: 'Inter', sans-serif;
  background: var(--gris-fondo);
  color: var(--gris-texto);
  min-height: 100vh;
}

/* ══════════════════════════════════════
   HEADER
══════════════════════════════════════ */
.site-header {
  background: var(--marca-negro);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.header-inner {
  max-width: 1280px;
  margin: auto;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 64px;
}

/* Logo texto */
.logo { font-size:1.6rem; font-weight:800; color:#fff; text-decoration:none; }
.logo span { color: var(--amarillo); }

/* Logo imagen */
.logo-img-link {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
}
.logo-img {
  height: 54px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.35));
  animation: flotar 3s ease-in-out infinite;
}
@keyframes flotar {
  0%   { transform: translateY(0px);  }
  50%  { transform: translateY(-5px); }
  100% { transform: translateY(0px);  }
}

/* Buscador */
.search-bar {
  flex: 1;
  display: flex;
  align-items: center;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  max-width: 560px;
}
.search-bar input {
  border: none;
  outline: none;
  padding: 0 14px;
  height: 40px;
  flex: 1;
  font-size: .95rem;
  color: #333;
}
.search-bar button {
  background: var(--marca-rojo); 
  color: #fff;
  border: none;
  padding: 0 16px;
  height: 40px;
  cursor: pointer;
  font-size: 1.1rem;
}

/* Nav */
.header-nav { display:flex; gap:20px; font-size:.85rem; }
.header-nav a { color:rgba(255,255,255,.85); text-decoration:none; }
.header-nav a:hover { color:#fff; }

/* Dirección / ubicación */
.header-location {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  flex-shrink: 0;
  border-left: 1px solid rgba(255,255,255,.2);
  padding-left: 20px;
}
.location-label {
  font-size: .78rem;
  color: rgba(255,255,255,.55);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.location-address {
  font-size: .82rem;
  color: var(--amarillo);
  font-weight: 700;
}
.location-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: #fff;
  border-radius: 50%;
  flex-shrink: 0;
  transition: transform .2s, box-shadow .2s;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.location-link:hover {
  transform: scale(1.15);
  box-shadow: 0 3px 8px rgba(0,0,0,.35);
}

/* ══════════════════════════════════════
   HERO
══════════════════════════════════════ */
.hero {
  background: linear-gradient(135deg, var(--marca-negro) 0%, #2a2a2a 100%);
  color: #fff;
  text-align: center;
  padding: 36px 24px;
}
.hero h1 { font-size:2.2rem; font-weight:800; letter-spacing:-1px; }
.hero h1 span { color: var(--amarillo); }
.hero p { margin-top:8px; opacity:.85; }
.hero-count {
  display: inline-block;
  margin-top: 16px;
  background: rgba(255,255,255,.15);
  border-radius: 20px;
  padding: 6px 18px;
  font-size: .9rem;
  font-weight: 600;
}

/* ══════════════════════════════════════
   CHIPS CATEGORÍA
══════════════════════════════════════ */
.cats-wrap {
  background: #fff;
  border-bottom: 1px solid var(--gris-borde);
  padding: 0 24px;
}
.cats-inner {
  max-width: 1280px;
  margin: auto;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 14px 0;
  scrollbar-width: none;
}
.cats-inner::-webkit-scrollbar { display:none; }
.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--gris-borde);
  background: #fff;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all .2s;
  user-select: none;
}
.chip:hover, .chip.active {
  border-color:var(--marca-rojo); 
  background:#ffeaed; 
  color:var(--marca-oscuro);
}
.chip.active { font-weight:700; }

/* ══════════════════════════════════════
   LAYOUT PRINCIPAL
══════════════════════════════════════ */
.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  align-items: start;
}

/* NOTA: existió aquí un parche ".main:has(#grid) { display:block
   !important; ... }" pensado solo para ofertas_distri.php (que no
   tiene sidebar). Se eliminó porque ofertas.php TAMBIÉN usa id="grid"
   en su grilla de productos (mismo id, páginas distintas), y ese
   !important terminaba aplastando el layout de 2 columnas
   (sidebar + contenido) de ofertas.php a una sola columna en bloque,
   causando que el sidebar de filtros chocara con el despliegue de
   productos. ofertas_distri.php ya no necesita este parche: su propio
   style="display:block;grid-template-columns:1fr" en línea sobre el
   <div class="main"> funciona correctamente por sí solo (confirmado).
   Si en el futuro se necesita un hook CSS específico para una sola
   página que comparta id="grid" con otra, usar una clase distintiva
   en el body (ej. body.pagina-ofertas-distri) en vez de :has(#grid). */

/* ══════════════════════════════════════
   SIDEBAR FILTROS
══════════════════════════════════════ */
.sidebar {
  background: #fff;
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  overflow: hidden;
  position: sticky;
  top: 88px;
}
.sidebar-title {
  background: var(--marca-negro); 
  color: var(--amarillo);
  padding: 14px 18px;
  font-weight: 700;
  font-size: .95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-toggle-icon { display: none; }
.filter-section {
  padding: 16px 18px;
  border-bottom: 1px solid var(--gris-borde);
}
.filter-section:last-child { border-bottom:none; }
.filter-label {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--gris-suave);
  margin-bottom: 10px;
}
.filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  cursor: pointer;
  font-size: .9rem;
}
.filter-option input { accent-color:var(--marca-rojo); width:16px; height:16px; }
.filter-count {
  margin-left: auto;
  font-size: .78rem;
  color: var(--gris-suave);
  background: var(--gris-fondo);
  padding: 1px 7px;
  border-radius: 10px;
}
.range-slider { width:100%; accent-color:var(--marca-rojo); margin-top:6px; }
.range-vals {
  display: flex;
  justify-content: space-between;
  font-size: .82rem;
  color: var(--gris-suave);
  margin-top: 4px;
}
.btn-apply {
  width: calc(100% - 36px);
  margin: 14px 18px;
  background: var(--marca-rojo);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s;
}
.btn-apply:hover { background: var(--marca-oscuro); }

/* ══════════════════════════════════════
   TOOLBAR
══════════════════════════════════════ */
.toolbar { display:flex; align-items:center; gap:12px; margin-bottom:18px; }
.toolbar-left { flex:1; font-size:.9rem; color:var(--gris-suave); }
.toolbar-left strong { color:var(--gris-texto); }
.sort-select {
  padding: 8px 12px;
  border: 1.5px solid var(--gris-borde);
  border-radius: 8px;
  background: #fff;
  font-size: .88rem;
  cursor: pointer;
}

/* ══════════════════════════════════════
   GRID PRODUCTOS
══════════════════════════════════════ */
.products-grid {
  display: grid !important;
  width: 100% !important;
  box-sizing: border-box !important;
  /* Base (móvil/tablet, hasta 900px): auto-fill con mínimo 150px por
     tarjeta, se ajusta solo según el ancho disponible. En PC
     (>900px) se fuerza un número FIJO de columnas más abajo — ver el
     @media (min-width:901px) — así no depende de adivinar el ancho
     real del contenedor. */
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important;
  gap: 12px !important;
}

/* PC (>900px): 6 columnas FIJAS — "extender horizontalmente al doble"
   pedido, sin importar el ancho real que termine teniendo el
   contenedor de la grilla (repeat(6,1fr) siempre reparte el ancho
   disponible en exactamente 6 columnas iguales). No toca el
   comportamiento en tablet/móvil (esos siguen usando el auto-fill de
   arriba y el @media(max-width:560px) más abajo). */
@media (min-width: 901px) {
  .products-grid {
    grid-template-columns: repeat(6, 1fr) !important;
  }

  /* Con 6 columnas cada tarjeta es más angosta que antes — se reduce
     un poco más el padding/tipografía SOLO en PC (no toca tablet/móvil,
     donde las tarjetas ya son más anchas al haber menos columnas). */
  .card-img img { padding: 6px; }
  .card-body { padding: 8px; gap: 2px; }
  .card-brand { font-size: .62rem; }
  .card-name { font-size: .72rem; line-height: 1.2; }
  .price-normal { font-size: .66rem; }
  .price-oferta { font-size: .98rem; }
  .price-unit { font-size: .62rem; }
  .dcto-pill { font-size: .62rem; padding: 2px 5px; }
  .badge { font-size: .6rem; padding: 2px 6px; top: 6px; left: 6px; }
  .badge-nuevo { font-size: .6rem; padding: 2px 6px; top: 6px; right: 6px; }
  .promo-tag { font-size: .58rem; padding: 2px 6px; }
}

/* ══════════════════════════════════════
   CARD PRODUCTO
══════════════════════════════════════ */
.card {
  background: #fff;
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform .2s, box-shadow .2s;
  position: relative;
}
.card:hover { transform:translateY(-4px); box-shadow:0 8px 24px rgba(0,0,0,.14); }

.badge {
  position: absolute;
  top: 8px; left: 8px;
  background: var(--rojo);
  color: #fff;
  font-size: .66rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
}
.badge--lleva { background:#e07000; }
.badge--2x1   { background:#7b2d8b; }

.badge-nuevo {
  position: absolute;
  top: 8px; right: 8px;
  background: #1D9E75;
  color: #fff;
  font-size: .66rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  z-index: 1;
}

.card-img {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f9f9f9;
  overflow: hidden;
}
.card-img img { width:100%; height:100%; object-fit:contain; padding:8px; }
.card-img .emoji-fallback { font-size:3.2rem; }

.card-body { padding:10px; flex:1; display:flex; flex-direction:column; gap:3px; }
.card-brand { font-size:.68rem; color:var(--verde); font-weight:700; text-transform:uppercase; }
.card-name  { font-size:.8rem; font-weight:500; line-height:1.25; }

.prices { margin-top:auto; padding-top:6px; }
.price-normal { font-size:.72rem; color:var(--gris-suave); text-decoration:line-through; }
.price-oferta { font-size:1.1rem; font-weight:800; color:var(--rojo); line-height:1; }
.price-unit   { font-size:.68rem; color:var(--gris-suave); }
.dcto-pill {
  display: inline-block;
  background: var(--rojo-bg);
  color: var(--rojo);
  font-size: .68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 2px;
}
.promo-tag {
  display: inline-block;
  font-size: .66rem; /* mitad de 1.32rem */
  color: #fff;
  font-weight: 800;
  margin-top: 4px;
  padding: 2px 7px;
  background: #e07000;
  border-radius: 5px;
  line-height: 1.25;
}

/* ══════════════════════════════════════
   SPINNER / LOADING
══════════════════════════════════════ */
.spinner {
  text-align: center;
  padding: 60px 0;
  color: var(--gris-suave);
  font-size: 1.1rem;
}

/* ══════════════════════════════════════
   PAGINACIÓN
══════════════════════════════════════ */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 32px 0 16px;
}
.page-btn {
  min-width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1.5px solid var(--gris-borde);
  background: #fff;
  font-size: .9rem;
  cursor: pointer;
  padding: 0 10px;
  transition: all .15s;
}
.page-btn.active { background:var(--marca-rojo); border-color:var(--marca-rojo); }
.page-btn:hover:not(.active) { border-color:var(--marca-rojo); color:var(--marca-rojo); }
/* ══════════════════════════════════════
   FOOTER
══════════════════════════════════════ */
.site-footer {
  background: var(--verde-oscuro);
  color: rgba(255,255,255,.7);
  text-align: center;
  padding: 10px;
  font-size: .62rem;
  margin-top: 0px;
}
.site-footer strong { color:#fff; }

/* ══════════════════════════════════════
   SELECTOR DE LOCALES (index.php)
══════════════════════════════════════ */
.local-selector {
  display: flex;
  justify-content: center;
  gap: 32px;
  padding: 48px 24px;
  flex-wrap: wrap;
}
.local-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,.10);
  padding: 40px 36px;
  text-align: center;
  text-decoration: none;
  color: var(--gris-texto);
  width: 260px;
  transition: transform .2s, box-shadow .2s;
  border: 2px solid transparent;
}
.local-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 32px rgba(0,0,0,.15);
  border-color: var(--verde);
}
.local-icon   { font-size:3.5rem; margin-bottom:12px; }
.local-nombre { font-size:1.3rem; font-weight:800; color:var(--verde); }
.local-ciudad { font-size:1rem; font-weight:600; color:var(--gris-texto); margin:4px 0 10px; }
.local-dir    { font-size:.8rem; color:var(--gris-suave); margin-bottom:20px; }
.local-btn {
  display: inline-block;
  background: var(--verde);
  color: #fff;
  padding: 10px 24px;
  border-radius: 8px;
  font-weight: 700;
  font-size: .9rem;
}
.local-card:hover .local-btn { background: var(--verde-oscuro); }

.site-footer { background: var(--marca-negro); }
.site-footer strong { color: var(--amarillo); }

.hero-index {
  background: var(--marca-negro);
  color: #fff;
  text-align: center;
  padding: 40px 24px 20px;
}
.hero-index h1 { font-size:2rem; font-weight:800; }
.hero-index h1 span { color: var(--amarillo); }
.hero-index p { margin-top:8px; opacity:.75; }

.local-nombre { color: var(--marca-rojo); }
.local-btn { background: var(--marca-rojo); }
.local-card:hover .local-btn { background: var(--marca-oscuro); }

/* ══════════════════════════════════════
   RESPONSIVE — TABLET (max 900px)
══════════════════════════════════════ */
@media (max-width:900px) {
  .main { grid-template-columns:1fr; }
  .sidebar { position:static; }
  .hero h1 { font-size:1.5rem; }

  /* Filtros colapsables — cerrados por defecto, el usuario los expande */
  .sidebar-title { cursor: pointer; }
  .sidebar-toggle-icon {
    display: inline-block;
    font-size: .8rem;
    transition: transform .25s ease;
  }
  .sidebar.is-open .sidebar-toggle-icon { transform: rotate(180deg); }

  .sidebar-body { display: none; }
  .sidebar.is-open .sidebar-body { display: block; }
}

/* ══════════════════════════════════════
   RESPONSIVE — MÓVIL (max 560px)
══════════════════════════════════════ */
@media (max-width:560px) {

  /* Grid productos */
  .products-grid { grid-template-columns:repeat(2,1fr); }

  /* Header contenedor */
  .site-header {
    padding: 10px 12px;
    background: var(--marca-negro);  
  }
  .header-inner {
    flex-wrap: wrap;
    align-items: center;
    min-height: auto;
    padding: 0;
    gap: 8px;
  }

  /* Logo */
  .logo-img-link {
    order: 1;
    flex-shrink: 0;
  }
  .logo-img {
    height: 42px;
    width: auto;
  }
  .logo {
    order: 1;
    font-size: 1.3rem;
    flex-shrink: 0;
  }

  /* Dirección — misma fila que logo, sin caja propia */
  .header-location {
    order: 3;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 4px;
    border-left: none;
    padding-left: 6px;
    white-space: nowrap;
    overflow: hidden;
    /* Sin background propio — hereda el verde del site-header */
  }
  .location-label  { display:none; }
  .location-address {
    font-size: .72rem;
    color: var(--amarillo);
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 150px;
  }
  .location-link {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
  }

  /* Accesos rápidos — misma fila que logo, antes de la dirección */
  .header-contacto {
    order: 2;
    flex-shrink: 0;
    gap: 6px;
    margin-left: 0;
  }
  .header-contacto a { width: 28px; height: 28px; }
  .header-contacto svg { width: 14px; height: 14px; }

  /* Ocultar nav */
  .header-nav { display:none; }

  /* Buscador — segunda fila completa */
  .search-bar {
    order: 4;
    flex: none;
    width: 100%;
    max-width: 100%;
    margin-top: 2px;
  }
}

/* ══════════════════════════════════════
   INDEX EN PC — ocupa todo el alto disponible,
   sin scroll, repartiendo el espacio con flexbox
   (no afecta el responsive móvil)
══════════════════════════════════════ */
@media (min-width: 901px) {
  body.page-index {
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .page-index .site-header { flex: 0 0 auto; }
  .page-index .header-inner { min-height: 58px; }
  .page-index .logo-img { height: 46px; }

  .page-index .hero-index {
    flex: 0 0 auto;
    padding: 20px 24px 12px;
  }
  .page-index .hero-index h1 { font-size: 1.7rem; }
  .page-index .hero-index p { margin-top: 6px; font-size: .95rem; }

  /* Esta zona absorbe todo el espacio restante y centra la tarjeta */
  .page-index .local-selector {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
  }
  .page-index .local-card {
    width: 260px;
    padding: 26px 30px;
  }
  .page-index .local-icon   { margin-bottom: 10px; }
  .page-index .local-nombre { font-size: 1.2rem; }
  .page-index .local-ciudad { margin: 3px 0 8px; font-size: .95rem; }
  .page-index .local-dir    { margin-bottom: 12px; font-size: .78rem; }
  .page-index .local-btn    { padding: 9px 22px; font-size: .88rem; }

  .page-index .site-footer { flex: 0 0 auto; margin-top: 0; }
}

/* ══════════════════════════════════════
   ACCESOS RÁPIDOS EN EL HEADER — correo y Facebook
══════════════════════════════════════ */
.header-contacto {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}
.header-contacto a {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, transform .2s;
}
.header-contacto a:hover {
  background: var(--marca-rojo);
  transform: scale(1.08);
}
.header-contacto svg { width: 17px; height: 17px; }
