/* =============================================================================
 *  base.css — Design system compartido (white-label).
 * =============================================================================
 *  Todos los colores/fuentes provienen de las variables que inyecta theme.js
 *  desde CONFIG. NO poner colores de marca aquí: usar var(--accent), etc.
 *  El modo claro se activa con la clase .light en <html> (lo hace theme.js).
 * ===========================================================================*/

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  background: var(--base);
  color: var(--text);
  font-family: var(--font-body, system-ui, sans-serif);
  line-height: 1.6;
  min-height: 100vh;
  /* Sin transition de background/color: Chrome no reinicia una transicion cuando
     el valor cambia porque cambio la custom property que la alimenta (--base /
     --text al togglear .light), y el body se quedaba pegado en los colores del
     tema anterior: fondo blanco y titulos ilegibles en modo oscuro. El cambio de
     tema es instantaneo a proposito. */
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; }
h1, h2, h3, h4 {
  font-family: var(--font-display, inherit); line-height: 1.15;
  font-weight: var(--font-display-weight, 600);
  letter-spacing: -.01em;
}
:root { --radius: 14px; --radius-sm: 9px; --maxw: 1240px; --nav-h: 66px; }

/* ---- Utilidades ---- */
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.mono { font-family: var(--font-mono, monospace); }
.muted { color: var(--muted); }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.hidden { display: none !important; }
.section { padding: 64px 0; }
.section-title { font-size: clamp(1.5rem, 3vw, 2.2rem); margin-bottom: 8px; }
.section-sub { color: var(--muted); margin-bottom: 32px; }

/* ---- Botones ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: var(--radius-sm); font-weight: 600; font-size: .95rem;
  transition: transform .15s ease, filter .2s ease, background .2s ease, border-color .2s ease;
  white-space: nowrap; border: 1px solid transparent;
}
.btn:active { transform: translateY(1px) scale(.985); }
.btn-primary { background: var(--accent); color: var(--on-accent, #fff); }
.btn-primary:hover { filter: brightness(1.1); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: var(--surface); color: var(--text); }
.btn-ghost:hover { background: color-mix(in srgb, var(--surface) 70%, var(--accent) 30%); }
.btn-wa { background: #25D366; color: #fff; }
.btn-wa:hover { filter: brightness(1.08); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-icon {
  width: 42px; height: 42px; padding: 0; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border);
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px;
  border-radius: 999px; font-size: .72rem; font-weight: 600; letter-spacing: .02em;
  background: rgba(var(--accent-rgb), .15); color: var(--accent);
}
.badge-out { background: rgba(220,60,60,.15); color: #e35d5d; }
.badge-new { background: rgba(80,200,120,.15); color: #4cc47a; }
.badge-pedido { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }

/* ---- Origen: stock local / bajo pedido ---- */
.pc-delivery, .ci-delivery { font-size: .74rem; color: var(--muted); margin-top: 4px; }
.pc-delivery-local, .ci-delivery-local { color: #4cc47a; }
.pc-ref { position: absolute; left: 6px; bottom: 6px; font-size: .64rem; padding: 2px 6px; border-radius: 4px; background: rgba(0,0,0,.55); color: #fff; pointer-events: none; }
.price-quote { font-family: var(--font-body, inherit); font-size: .95rem; color: var(--muted); font-weight: 600; }
.product-card .pc-actions .btn-wa { white-space: normal; line-height: 1.2; text-align: center; gap: 6px; }
.prod-ref-note { font-size: .78rem; color: var(--muted); margin-top: 6px; }
.delivery-note { font-size: .82rem; color: var(--muted); border-left: 2px solid var(--accent); padding: 6px 10px; margin: 10px 0; }

/* ---- Nav ---- */
.nav {
  position: sticky; top: 0; z-index: 100;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--base) 85%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
}
.nav-inner { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; width: 100%;
  display: flex; align-items: center; gap: 22px; }
.nav-brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: var(--font-display-weight, 700); font-size: 1.15rem; }
.nav-brand img { height: 34px; width: auto; }
.brand-text { font-family: var(--font-display); font-weight: var(--font-display-weight, 700); }
.nav-links { display: flex; gap: 6px; margin-left: 8px; }
.nav-links a { padding: 8px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; font-size: .95rem; transition: color .2s, background .2s; }
.nav-links a:hover, .nav-links a.active { color: var(--text); background: var(--surface); }
.nav-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.nav-cart { position: relative; }
.cart-count {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--accent); color: var(--on-accent, #fff); border-radius: 999px; font-size: .68rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.nav-toggle { display: none; }

/* ============================================================
   CardNav — barra tipo tarjeta que se despliega en tarjetas
   ============================================================ */
.card-nav-wrap {
  position: sticky; top: 0; z-index: 200;
  padding: 14px 20px 0;
  pointer-events: none;
}
.card-nav {
  pointer-events: auto;
  max-width: var(--maxw); margin: 0 auto;
  background: var(--base);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(15,22,38,.10);
  overflow: hidden;
  transition: box-shadow .3s ease;
}
.card-nav.open { box-shadow: 0 18px 50px rgba(15,22,38,.18); }

.card-nav-bar {
  height: 62px;
  display: flex; align-items: center; gap: 12px;
  padding: 0 12px;
}
.card-nav-burger {
  flex: none;
  display: flex; flex-direction: column; gap: 5px;
  background: none; border: 0; cursor: pointer; padding: 8px;
}
.card-nav-burger span {
  display: block; width: 22px; height: 2px; border-radius: 2px;
  background: var(--text); transition: transform .3s ease, opacity .3s ease;
}
.card-nav.open .card-nav-burger span:first-child { transform: translateY(3.5px) rotate(45deg); }
.card-nav.open .card-nav-burger span:last-child  { transform: translateY(-3.5px) rotate(-45deg); }

/* Barra de búsqueda (reemplaza el logo central) */
.card-nav-search { flex: 1; max-width: 560px; position: relative; display: flex; align-items: center; }
.card-nav-search input {
  width: 100%; padding: 9px 16px 9px 40px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); font-size: .9rem;
}
.card-nav-search input:focus { outline: none; border-color: var(--accent); }
.card-nav-search .cnav-search-ic {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--muted); display: flex; pointer-events: none;
}

.card-nav-actions { flex: none; margin-left: auto; display: flex; align-items: center; gap: 8px; }
.card-nav-cta { padding: 9px 16px; font-size: .9rem; }

/* Zona desplegable (animación de altura con grid 0fr→1fr) */
.card-nav-drop {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows .45s cubic-bezier(.25,1,.5,1);
}
.card-nav.open .card-nav-drop { grid-template-rows: 1fr; }
.card-nav-cards { overflow: hidden; min-height: 0; }
.card-nav .card-nav-cards {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  padding: 0 14px 14px;
}
.cnav-card {
  background: var(--cnav-bg, var(--accent));
  color: #fff; border-radius: 14px; padding: 16px 18px;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 130px;
  opacity: 0; transform: translateY(14px);
  transition: opacity .4s ease, transform .4s ease;
}
.card-nav.open .cnav-card { opacity: 1; transform: none; }
.card-nav.open .cnav-card:nth-child(2) { transition-delay: .06s; }
.card-nav.open .cnav-card:nth-child(3) { transition-delay: .12s; }
.cnav-card-label { font-family: var(--font-display); font-weight: var(--font-display-weight, 700); font-size: 1.05rem; letter-spacing: .01em; }
.cnav-card-links { display: flex; flex-direction: column; gap: 6px; margin-top: auto; }
.cnav-card-links a {
  display: flex; align-items: center; gap: 7px;
  color: #fff; opacity: .92; font-size: .92rem; font-weight: 500;
  transition: opacity .2s ease, transform .2s ease;
}
.cnav-card-links a:hover { opacity: 1; transform: translateX(3px); }
.cnav-arrow { display: inline-flex; }

@media (max-width: 720px) {
  .card-nav-cta { display: none; }
  .card-nav .card-nav-cards { grid-template-columns: 1fr; }
  .cnav-card { min-height: 0; }
}

/* ---- Search bar en nav ---- */
.nav-search { flex: 1; max-width: 420px; position: relative; }
.nav-search input {
  width: 100%; padding: 9px 14px 9px 38px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); font-size: .9rem;
}
.nav-search input:focus { outline: none; border-color: var(--accent); }
.nav-search .search-ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }

/* ---- Cards de producto ---- */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
.product-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; position: relative;
  transition: transform .18s ease, border-color .2s ease, box-shadow .2s ease;
}
.product-card:hover { transform: translateY(-4px); border-color: var(--accent);
  box-shadow: 0 12px 30px -12px rgba(var(--accent-rgb), .35); }
.product-card .pc-img { aspect-ratio: 1; background: var(--void); position: relative; overflow: hidden; }
.product-card .pc-img img { width: 100%; height: 100%; object-fit: cover; }
.product-card .pc-body { padding: 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.product-card .pc-cat { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.product-card .pc-name { font-weight: 600; font-size: .98rem; line-height: 1.35; }
.product-card .pc-price { font-family: var(--font-mono); font-size: 1.15rem; font-weight: 600; color: var(--accent); margin-top: auto; }
.product-card .pc-price small { color: var(--muted); font-size: .78rem; display: block; font-weight: 400; }
.product-card .pc-actions { display: flex; gap: 6px; padding: 0 14px 14px; }
.product-card .pc-actions .btn { flex: 1; padding: 9px 12px; font-size: .85rem; }
.pc-fav, .pc-compare {
  position: absolute; top: 10px; width: 34px; height: 34px; border-radius: 50%;
  background: color-mix(in srgb, var(--base) 70%, transparent); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; color: var(--text); z-index: 2;
}
.pc-fav { right: 10px; }
.pc-compare { right: 52px; }
.pc-fav.active { color: #e35d5d; }
.pc-compare.active { color: var(--accent); }
.pc-badges { position: absolute; top: 10px; left: 10px; display: flex; flex-direction: column; gap: 5px; z-index: 2; }
.rating-stars { display: inline-flex; gap: 1px; color: #f5b301; font-size: .8rem; align-items: center; }
.rating-stars .rc { color: var(--muted); margin-left: 4px; font-size: .75rem; }

/* ---- Forms ---- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm);
  background: var(--void); border: 1px solid var(--border); color: var(--text); font-size: .95rem;
  transition: border-color .2s;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 90px; }
.field .hint { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: .9rem; margin-bottom: 14px; }
.alert-error { background: rgba(220,60,60,.12); color: #e35d5d; border: 1px solid rgba(220,60,60,.3); }
.alert-ok { background: rgba(80,200,120,.12); color: #4cc47a; border: 1px solid rgba(80,200,120,.3); }
.alert-info { background: rgba(var(--accent-rgb), .1); color: var(--accent); border: 1px solid rgba(var(--accent-rgb), .3); }

/* ---- Panel de carrito deslizable ---- */
.cart-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 200;
  opacity: 0; visibility: hidden; transition: opacity .3s;
}
.cart-overlay.open { opacity: 1; visibility: visible; }
.cart-panel {
  position: fixed; top: 0; right: 0; height: 100%; width: min(400px, 90vw); z-index: 201;
  background: var(--base); border-left: 1px solid var(--border);
  transform: translateX(100%); transition: transform .32s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
}
.cart-panel.open { transform: translateX(0); }
.cart-head { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.cart-head h3 { font-size: 1.1rem; }
.cart-items { flex: 1; overflow-y: auto; padding: 14px 20px; display: flex; flex-direction: column; gap: 12px; }
.cart-item { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; }
.cart-item img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; background: var(--surface); }
.cart-item .ci-name { font-size: .88rem; font-weight: 600; }
.cart-item .ci-var { font-size: .75rem; color: var(--muted); }
.cart-item .ci-price { font-family: var(--font-mono); color: var(--accent); font-size: .9rem; }
.qty-ctrl { display: inline-flex; align-items: center; gap: 8px; }
.qty-ctrl button { width: 26px; height: 26px; border-radius: 6px; background: var(--surface); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; }
.cart-foot { padding: 18px 20px; border-top: 1px solid var(--border); }
.cart-foot .ct-total { display: flex; justify-content: space-between; font-weight: 700; font-size: 1.1rem; margin-bottom: 14px; }
.cart-empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---- Toast ---- */
.wl-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px);
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  padding: 13px 20px; border-radius: 999px; font-size: .9rem; font-weight: 500;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,.5); z-index: 300; opacity: 0;
  transition: opacity .3s, transform .3s; pointer-events: none;
}
.wl-toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* ---- Barra flotante de comparación ---- */
#compareBar {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 150;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  box-shadow: 0 12px 34px -12px rgba(0,0,0,.55); max-width: 92vw;
}
.cmpbar-inner { display: flex; align-items: center; gap: 14px; padding: 10px 16px; }
.cmpbar-label { font-weight: 600; font-size: .85rem; white-space: nowrap; }
.cmpbar-thumbs { display: flex; gap: 8px; }
.cmpbar-thumb { position: relative; width: 42px; height: 42px; border-radius: 8px; overflow: hidden; background: var(--void); border: 1px solid var(--border); }
.cmpbar-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cmpbar-thumb span { display: flex; align-items: center; justify-content: center; height: 100%; }
.cmpbar-thumb button { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); color: var(--on-accent, #fff); font-size: .7rem; display: flex; align-items: center; justify-content: center; }
.cmpbar-actions { display: flex; gap: 8px; align-items: center; }
.cmpbar-clear { color: var(--muted); font-size: .82rem; }
.cmpbar-go { background: var(--accent); color: var(--on-accent, #fff); padding: 8px 16px; border-radius: 999px; font-size: .85rem; font-weight: 600; }

/* ---- Modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 250;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; visibility: hidden; transition: opacity .25s; }
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--base); border: 1px solid var(--border); border-radius: var(--radius);
  max-width: 480px; width: 100%; max-height: 90vh; overflow-y: auto; padding: 26px;
  transform: scale(.96); transition: transform .25s;
}
.modal-overlay.open .modal { transform: scale(1); }

/* ---- Footer ---- */
.footer { background: var(--void); border-top: 1px solid var(--border); padding: 48px 0 24px; margin-top: 64px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 40px; margin-bottom: 32px; }
.footer h4 { font-size: .95rem; margin-bottom: 14px; }
.footer-links { display: flex; flex-direction: column; gap: 8px; }
.footer-links a { color: var(--muted); font-size: .9rem; transition: color .2s; }
.footer-links a:hover { color: var(--accent); }
.footer-social { display: flex; gap: 10px; margin-top: 14px; }
.footer-social a { width: 38px; height: 38px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; color: var(--muted); transition: all .2s; }
.footer-social a:hover { color: var(--accent); border-color: var(--accent); }
.footer-bottom { border-top: 1px solid var(--border); padding-top: 20px; text-align: center; color: var(--muted); font-size: .85rem; }

/* ---- Botón flotante de WhatsApp ---- */
.wa-float {
  position: fixed; bottom: 22px; right: 22px; width: 56px; height: 56px; border-radius: 50%;
  background: #25D366; color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px -6px rgba(37,211,102,.6); z-index: 140; transition: transform .2s;
}
.wa-float:hover { transform: scale(1.08); }

/* ---- Breadcrumb ---- */
.breadcrumb { display: flex; gap: 6px; align-items: center; font-size: .82rem; color: var(--muted); margin-bottom: 20px; flex-wrap: wrap; }
.breadcrumb a:hover { color: var(--accent); }

/* ---- Skeleton loader ---- */
.skeleton { background: linear-gradient(90deg, var(--surface) 25%, var(--border) 50%, var(--surface) 75%);
  background-size: 200% 100%; animation: sk 1.3s infinite; border-radius: var(--radius-sm); }
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---- Cambio de tema sin transiciones colgadas ----
   Chrome no reinicia una transición cuando el valor cambia porque cambió la
   custom property que la alimenta: la propiedad se queda clavada en el color
   del tema anterior. Ya pasó con el `body` y volvía a pasar con .btn,
   .nav-links a, .footer-links a y los campos de formulario. En vez de borrar
   esas transiciones (y perder los hovers), theme.js pone esta clase durante el
   cambio y la quita en el siguiente frame. */
html.theme-switching,
html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after { transition: none !important; }

/* ---- Animación de scroll reveal ---- */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .6s ease, transform .6s ease; }
.reveal.visible { opacity: 1; transform: none; }

/* ---- Responsive ---- */
@media (max-width: 860px) {
  .footer-grid { grid-template-columns: 1fr; gap: 28px; }
  .form-row { grid-template-columns: 1fr; }
  .nav-links { display: none; }
  .nav-search { display: none; }
  .nav-toggle { display: inline-flex; }
}
