/* ---- Storefront: theming por tenant + mobile-first responsive ----
   Este archivo solo se carga en paginas de storefront (storefront:true en head.ejs),
   nunca en /admin, asi que puede sobreescribir reglas de style.css sin riesgo
   de regresion visual en el panel. */

:root {
  --tienda-primario-suave: color-mix(in srgb, var(--tienda-primario) 10%, #fff);
  --tienda-secundario-suave: color-mix(in srgb, var(--tienda-secundario) 14%, #fff);
}

body { font-family: var(--tienda-fuente, inherit); background: var(--tienda-fondo, var(--bg)); }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; }
}

/* ---- Nav ---- */

.topbar-tienda {
  background: var(--tienda-primario);
  padding: 0;
}
.topbar-tienda-fila {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand-tienda { font-weight: 700; font-size: 1.05rem; }
.brand-tienda a { color: #fff; display: flex; align-items: center; }
.brand-tienda a:hover { text-decoration: none; opacity: .9; }
.brand-logo { max-height: 40px; max-width: 160px; display: block; }

/* ---- Posicion y tamano del logo/nombre en el encabezado (configurable por tienda) ----
   'izquierda' es el layout historico, sin overrides -- cero regresion para
   tiendas que nunca tocan esta opcion nueva. */
body[data-logo-posicion="derecha"] .topbar-tienda-fila { flex-direction: row-reverse; }
body[data-logo-posicion="centro"] .topbar-tienda-fila { flex-wrap: wrap; justify-content: center; }
body[data-logo-posicion="centro"] .brand-tienda { order: -1; flex-basis: 100%; display: flex; justify-content: center; }

body[data-logo-tamano="chico"] .brand-logo { max-height: 26px; max-width: 110px; }
body[data-logo-tamano="grande"] .brand-logo { max-height: 60px; max-width: 240px; }

.nav-tienda { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.nav-tienda a { color: #fff; font-size: 0.9rem; opacity: .92; }
.nav-tienda a:hover { text-decoration: none; opacity: 1; }

.nav-tienda-movil { display: none; position: relative; }
.nav-tienda-movil summary {
  list-style: none;
  color: #fff;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
}
.nav-tienda-movil summary::-webkit-details-marker { display: none; }
.nav-tienda-movil[open] summary { opacity: .8; }
.nav-tienda-movil .nav-tienda {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--tienda-primario);
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 6px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  min-width: 180px;
  z-index: 20;
}
.nav-tienda-movil .nav-tienda a { padding: 8px 12px; border-radius: 6px; width: 100%; }
.nav-tienda-movil .nav-tienda a:hover { background: rgba(255,255,255,.12); }

.buscador-tienda { max-width: 1100px; margin: 0 auto; padding: 16px 20px 0; }
.buscador-tienda-form { max-width: 420px; }
.buscador-tienda-form input[type=text] { flex: 1; }

@media (max-width: 767px) {
  .nav-tienda-escritorio { display: none; }
  .nav-tienda-movil { display: block; }
  .buscador-tienda-form { max-width: none; }
}

/* ---- Catalogo ---- */

@media (max-width: 480px) {
  .grid-productos { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
}

.producto-card {
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  transition: transform .15s ease, box-shadow .15s ease;
}
.producto-card:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0,0,0,.1); }
.producto-card .miniatura { aspect-ratio: 1/1; }
.producto-card .info { gap: 6px; }
.producto-card .nombre { line-height: 1.3; }

/* ---- Producto detalle: columna unica en movil ---- */

@media (max-width: 720px) {
  main.wide .row { flex-direction: column; }
  main.wide .row > * { min-width: 0 !important; width: 100%; }
}

/* ---- Carrito: tabla -> tarjetas en movil ---- */

@media (max-width: 640px) {
  main table { border: none; }
  main table thead { display: none; }
  main table, main table tbody, main table tr, main table td { display: block; width: 100%; }
  main table tr {
    margin-bottom: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px 12px;
    background: var(--panel);
  }
  main table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    text-align: right;
  }
  main table td:last-child { border-bottom: none; }
  main table td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--muted);
    text-align: left;
  }
  main table td:empty::before,
  main table td:has(form:only-child)::before { content: ''; }
}

/* ---- Checkout: resumen arriba del formulario en movil ---- */

@media (max-width: 899px) {
  .checkout-layout { flex-direction: column; }
  .checkout-layout > * { min-width: 0 !important; width: 100%; }
  .checkout-layout .resumen-pedido { order: 1; }
  .checkout-layout .checkout-form { order: 2; }
}

/* ---- Plantilla "editorial" ---- */

body[data-plantilla="editorial"] .hero-editorial {
  padding: 40px 0 32px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
body[data-plantilla="editorial"] .hero-editorial h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  letter-spacing: -.02em;
  max-width: 16ch;
}
body[data-plantilla="editorial"] .producto-card .miniatura { aspect-ratio: 3/4; }
body[data-plantilla="editorial"] .producto-card .nombre { font-size: 1rem; }
body[data-plantilla="editorial"] .grid-productos {
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 24px;
}

/* ---- Plantilla "minimalista": mucho espacio en blanco, sin sombras/bordes redondeados ---- */

body[data-plantilla="minimalista"] .hero-minimalista { padding: 48px 0 30px; }
body[data-plantilla="minimalista"] .hero-eyebrow {
  text-transform: uppercase;
  letter-spacing: .16em;
  font-size: .72rem;
  color: var(--muted);
  margin: 0 0 8px;
}
body[data-plantilla="minimalista"] .hero-minimalista h1 { font-weight: 500; letter-spacing: -.01em; }
body[data-plantilla="minimalista"] .grid-productos {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 36px;
}
body[data-plantilla="minimalista"] .producto-card {
  border-radius: 0;
  box-shadow: none;
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}
body[data-plantilla="minimalista"] .producto-card:hover { transform: none; box-shadow: none; }
body[data-plantilla="minimalista"] .producto-card .miniatura { border-radius: 0; }
body[data-plantilla="minimalista"] .producto-card .nombre { font-weight: 400; font-size: .92rem; }
body[data-plantilla="minimalista"] .precio-actual { font-weight: 500; }

/* ---- Plantilla "vibrante": color, insignias y tarjetas con mas presencia ---- */

body[data-plantilla="vibrante"] .hero-vibrante { padding: 36px 0 26px; }
body[data-plantilla="vibrante"] .hero-badge {
  display: inline-block;
  background: var(--tienda-secundario);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 5px 14px;
  border-radius: 999px;
  margin-bottom: 12px;
}
body[data-plantilla="vibrante"] .hero-vibrante h1 { font-weight: 800; letter-spacing: -.01em; }
body[data-plantilla="vibrante"] .grid-productos {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}
body[data-plantilla="vibrante"] .producto-card {
  border-radius: 20px;
  background: var(--tienda-primario-suave);
  border: 2px solid transparent;
  box-shadow: none;
}
body[data-plantilla="vibrante"] .producto-card:hover {
  transform: translateY(-4px) scale(1.01);
  border-color: var(--tienda-secundario);
  box-shadow: 0 12px 28px rgba(0,0,0,.12);
}
body[data-plantilla="vibrante"] .producto-card .miniatura { border-radius: 16px 16px 0 0; }
body[data-plantilla="vibrante"] .producto-card .info { padding: 4px 10px 10px; }
body[data-plantilla="vibrante"] .producto-card .nombre { font-weight: 700; }
body[data-plantilla="vibrante"] .precio-actual { color: var(--tienda-secundario); font-weight: 800; }

/* ---- Plantilla "boutique": franja oscura de marca, imagenes verticales, tono editorial de lujo ---- */

body[data-plantilla="boutique"] .hero-boutique {
  background: var(--tienda-primario);
  color: #fff;
  text-align: center;
  padding: 56px 24px;
  margin: 0 calc(50% - 50vw) 28px;
  width: 100vw;
}
body[data-plantilla="boutique"] .hero-boutique h1 {
  font-family: Georgia, "Times New Roman", Times, serif;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-weight: 400;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  position: relative;
  display: inline-block;
  padding-bottom: 18px;
}
body[data-plantilla="boutique"] .hero-boutique h1::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 2px;
  background: var(--tienda-secundario);
}
body[data-plantilla="boutique"] .hero-boutique .muted { color: rgba(255,255,255,.75); }
body[data-plantilla="boutique"] .grid-productos {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 30px;
}
body[data-plantilla="boutique"] .producto-card { border-radius: 2px; box-shadow: none; }
body[data-plantilla="boutique"] .producto-card:hover { transform: none; box-shadow: none; }
body[data-plantilla="boutique"] .producto-card .miniatura { aspect-ratio: 4/5; transition: transform .4s ease; }
body[data-plantilla="boutique"] .producto-card > a {
  display: block;
  border-radius: 2px;
  overflow: hidden;
}
body[data-plantilla="boutique"] .producto-card > a:hover .miniatura { transform: scale(1.04); }
body[data-plantilla="boutique"] .producto-card .nombre {
  font-family: Georgia, "Times New Roman", Times, serif;
  font-size: .95rem;
}

/* ---- Banner de portada (opcional, cualquier plantilla): foto de fondo del hero ---- */

.hero-con-banner {
  position: relative;
  background-size: cover;
  background-position: center;
  border-radius: 14px;
  overflow: hidden;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
body[data-banner-altura="medio"] .hero-con-banner { min-height: 340px; }
body[data-banner-altura="alto"] .hero-con-banner { min-height: 480px; }
.hero-con-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,.25), rgba(0,0,0,.55));
}
.hero-con-banner > * { position: relative; z-index: 1; }
.hero-con-banner h1 { color: #fff; }
.hero-con-banner .muted { color: rgba(255,255,255,.85); }
body .hero-con-banner .hero-eyebrow { color: rgba(255,255,255,.85); }
.hero-clasica.hero-con-banner {
  padding: 48px 24px;
  text-align: center;
  margin-bottom: 20px;
}

/* ---- Plantilla "calida": paleta terracota, serif, filtros pildora, foto redondeada con zoom ---- */

body[data-plantilla="calida"] h1,
body[data-plantilla="calida"] h2,
body[data-plantilla="calida"] .catalogo-titulo {
  font-family: Georgia, "Times New Roman", Times, serif;
  font-weight: 700;
}
body[data-plantilla="calida"] .hero-calida {
  background: var(--tienda-fondo);
  border-radius: 16px;
  padding: 48px 24px;
  text-align: center;
  margin-bottom: 24px;
}
body[data-plantilla="calida"] .hero-calida h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  letter-spacing: -.01em;
}

body[data-plantilla="calida"] .filtro-categorias {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 4px 0 22px;
}
body[data-plantilla="calida"] .filtro-pill {
  display: inline-block;
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: .86rem;
}
body[data-plantilla="calida"] .filtro-pill:hover { text-decoration: none; border-color: var(--tienda-secundario); }
body[data-plantilla="calida"] .filtro-pill.activo {
  background: var(--tienda-secundario);
  border-color: var(--tienda-secundario);
  color: #fff;
}

body[data-plantilla="calida"] .catalogo-encabezado {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
body[data-plantilla="calida"] .catalogo-titulo {
  font-size: 1.4rem;
  position: relative;
  padding-bottom: 10px;
  margin: 0;
}
body[data-plantilla="calida"] .catalogo-titulo::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 42px;
  height: 3px;
  background: var(--tienda-secundario);
}
body[data-plantilla="calida"] .vista-toggle { display: flex; gap: 4px; }
body[data-plantilla="calida"] .vista-btn {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel); color: var(--muted); display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
body[data-plantilla="calida"] .vista-btn:hover { border-color: var(--tienda-secundario); color: var(--tienda-secundario); }
body[data-plantilla="calida"] .vista-btn.activo {
  background: var(--tienda-secundario); border-color: var(--tienda-secundario); color: #fff;
}
@media (max-width: 480px) {
  body[data-plantilla="calida"] .catalogo-encabezado { flex-wrap: wrap; }
}

body[data-plantilla="calida"] .grid-productos.cols-2 { grid-template-columns: repeat(2, 1fr); }
body[data-plantilla="calida"] .grid-productos.cols-3 { grid-template-columns: repeat(3, 1fr); }
body[data-plantilla="calida"] .grid-productos.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 640px) {
  body[data-plantilla="calida"] .grid-productos.cols-3,
  body[data-plantilla="calida"] .grid-productos.cols-4 { grid-template-columns: repeat(2, 1fr); }
}

body[data-plantilla="calida"] .producto-card {
  border-radius: 18px;
  border-color: var(--border);
  box-shadow: none;
}
body[data-plantilla="calida"] .producto-card .miniatura { border-radius: 18px 18px 0 0; }
body[data-plantilla="calida"] .producto-card .nombre { font-family: Georgia, "Times New Roman", Times, serif; font-weight: 700; }
body[data-plantilla="calida"] .precio-actual { color: var(--tienda-secundario); font-weight: 700; }
body[data-plantilla="calida"] .insignia-destacado,
body[data-plantilla="calida"] .insignia-nuevo,
body[data-plantilla="calida"] .insignia-oferta { background: var(--tienda-secundario); }

/* Galeria de producto: flechas/zoom heredan el color de acento de la paleta de la tienda en esta plantilla */
body[data-plantilla="calida"] .imagen-principal-wrap img,
body[data-plantilla="calida"] .galeria-miniatura { border-radius: 16px; }
body[data-plantilla="calida"] .galeria-flecha:hover,
body[data-plantilla="calida"] .galeria-zoom-btn:hover { color: var(--tienda-secundario); }

/* Boton flotante de WhatsApp: fijo en la esquina inferior derecha, en todas las
   plantillas y paginas del storefront (incluido via partials/foot.ejs). El
   verde es el de marca de WhatsApp, no el de la paleta de la tienda, para que
   siga siendo reconocible como el icono de WhatsApp sin importar la paleta. */
.whatsapp-flotante {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #25d366;
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.whatsapp-flotante:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}
@media (max-width: 480px) {
  .whatsapp-flotante { width: 50px; height: 50px; right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); }
}
