/* ============================================================================
   LETTERA — Diseños de la tienda pública ("Mi diseño")
   ----------------------------------------------------------------------------
   Se carga SOLO en el storefront (_StoreLayout), no en el panel ni en el admin.

   Cómo funciona:
     1. Los valores por defecto de las variables son EXACTAMENTE el diseño actual,
        así que el tema "clasico" no cambia nada.
     2. Cada tema redefine variables (data-theme="…").
     3. Las reglas genéricas de abajo consumen esas variables.

   La paleta (--accent, --accent-dark, --accent-rgb, --accent-contrast) la inyecta
   StoreTheme.Css() con el color ya resuelto y el contraste calculado por luminancia.
   ============================================================================ */

/* ── Valores por defecto = diseño clásico (el que ya existía) ─────────────── */
:root {
    --accent-contrast: #ffffff;
    --card-radius: 16px;
    --card-shadow: 0 1px 4px rgba(0, 0, 0, .07);
    --card-shadow-hover: 0 6px 18px rgba(0, 0, 0, .12);
    --card-border: 1px solid #e2e8f0;
    --img-ratio: 1 / 1;
    --product-name-font: inherit;
    --product-name-size: .9rem;
    --card-bg: #ffffff;
    --page-bg: #f8fafc;
    --text-strong: #0f172a;
    --text-muted: #64748b;
    /* Texto secundario sobre superficies teñidas (chips, barras, pies): --text-muted
       se queda en 4,34:1 ahí. Este gris pasa AA sobre --surface-2. */
    --text-soft: #475569;
    --info-padding: .75rem;
    --grid-gutter: 1rem;
    /* Superficies de la cabecera y las barras (deben seguir al tema) */
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --surface-3: #f8fafc;
    --surface-hover: #e8f5f8;
    --border-color: #e2e8f0;
}

/* ── Reglas genéricas que consumen las variables ──────────────────────────── */
body.store-body { background: var(--page-bg); }

.product-card {
    background: var(--card-bg);
    border: var(--card-border);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
}
.product-card:hover { box-shadow: var(--card-shadow-hover); }

.product-img-wrap,
.product-img-placeholder { aspect-ratio: var(--img-ratio); }

.product-info { padding: var(--info-padding); }
.product-name { font-family: var(--product-name-font); font-size: var(--product-name-size); }
.product-desc { color: var(--text-muted); }

/* El texto sobre el acento lo decide el servidor, no el tema. */
.btn-add-cart,
.btn-accent,
.pdsh-add-btn,
.cat-tab.active { color: var(--accent-contrast) !important; }

/* ── Superficies: cabecera, barra de categorías, chips y paneles ────────────
   site.css y el <style> de Store/Index las tienen con colores fijos en claro.
   Solo se tocan fondos y bordes: con los valores por defecto el resultado es
   idéntico al diseño anterior, y los temas oscuros redefinen las variables.
   Se prefija con body.store-body para ganar en especificidad sin !important. */
body.store-body .store-header-card,
body.store-body .store-category-tabs,
body.store-body .store-panel {
    background: var(--surface);
    border-color: var(--border-color);
}
body.store-body .store-panel {
    border: 1.5px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
}
body.store-body .store-meta-chip,
body.store-body .hours-chip { background: var(--surface-2); }
body.store-body .promo-store-card,
body.store-body .promo-product-card {
    background: var(--surface);
    border-color: var(--border-color);
}
body.store-body #storeLoyaltyBanner .loy-toggle { background: var(--surface); }
body.store-body #storeLoyaltyBanner .loy-toggle:hover { border-color: var(--accent); }
body.store-body .promo-stock-bar-wrap { background: var(--surface-2); }
body.store-body .product-img-wrap { background: var(--surface-3); }
body.store-body .product-img-placeholder { background: var(--surface-2); }
body.store-body .promo-store-title { color: var(--text-strong); }
body.store-body .promo-coupon-code { background: var(--surface-2); }
body.store-body .store-loy-title { color: var(--text-strong); }
body.store-body .store-loy-sub { color: var(--text-muted); }
body.store-body .grev-sub,
body.store-body .grev-count { color: var(--text-muted); }
/* Sobre fondos teñidos el acento puro se queda corto: para texto va la variante oscura. */
body.store-body .store-footer .text-accent { color: var(--accent-dark) !important; }
body.store-body .cat-tab:not(.active) {
    background: var(--surface-2);
    color: var(--text-soft);
}
body.store-body .cat-tab:not(.active):hover {
    background: var(--surface-hover);
    border-color: var(--accent);
    color: var(--accent);
}
/* .text-dark de Bootstrap lleva !important, hay que igualarlo. */
body.store-body .store-panel .text-dark { color: var(--text-strong) !important; }
body.store-body .store-panel-hint { color: var(--text-muted); }

/* Densidad de la grilla (Bootstrap consume estas variables en .row.g-*). */
.row.g-3 { --bs-gutter-x: var(--grid-gutter); }

/* ── 1. CLÁSICO ──────────────────────────────────────────────────────────────
   Sin overrides: cualquier regla que se agregue acá cambiaría el look de todas
   las tiendas que nunca eligieron tema. */

/* ── 2. BOUTIQUE — elegante y espacioso ──────────────────────────────────── */
[data-theme="boutique"] {
    --card-radius: 4px;
    --card-shadow: 0 2px 10px rgba(60, 40, 20, .06);
    --card-shadow-hover: 0 10px 26px rgba(60, 40, 20, .14);
    --card-border: 1px solid #eee6dc;
    --img-ratio: 4 / 5;
    --product-name-font: Georgia, 'Times New Roman', serif;
    --product-name-size: 1rem;
    --info-padding: .9rem .85rem;
    --page-bg: #fbf8f4;
    --text-strong: #2b2118;
    --text-muted: #756757;
    --text-soft: #5a4a3a;
}
[data-theme="boutique"] .product-price {
    font-family: Georgia, 'Times New Roman', serif;
    font-weight: 600;
}
[data-theme="boutique"] .btn-add-cart { border-radius: 4px; }
[data-theme="boutique"] .section-title {
    text-transform: uppercase;
    letter-spacing: .12em;
    font-size: 1.05rem;
    font-weight: 700;
}

/* ── 3. MERCADO — cálido y directo ───────────────────────────────────────── */
[data-theme="mercado"] {
    --card-radius: 18px;
    --card-shadow: 0 2px 0 rgba(0, 0, 0, .05);
    --card-shadow-hover: 0 8px 20px rgba(120, 50, 10, .16);
    --card-border: 1px solid #f3e3d7;
    --page-bg: #fdf7f1;
    --text-strong: #2b1a0e;
    --text-muted: #7d5f4b;
    --text-soft: #5c4227;
}
[data-theme="mercado"] .product-price { font-size: 1.25rem; font-weight: 900; }
[data-theme="mercado"] .product-name { font-weight: 700; }
[data-theme="mercado"] .btn-add-cart { width: 40px; height: 40px; font-size: 1.15rem; }
[data-theme="mercado"] .section-title { font-weight: 800; }

/* ── 4. NOCTURNO — fondo oscuro, acento brillante ────────────────────────── */
/* ── Paleta oscura: la comparten el tema Nocturno y el modo noche ────────────
   El modo noche (data-night) reusa esta paleta pero NO la forma: el dueño
   conserva la tipografía, el radio y la proporción de foto de su tema. */
[data-theme="nocturno"],
[data-night="1"] {
    --card-bg: #151d25;
    --page-bg: #0d1319;
    --text-strong: #e8eef4;
    --text-muted: #93a3b3;
    --text-soft: #93a3b3;
    --surface: #151d25;
    --surface-2: #1e2a34;
    --surface-3: #1a232c;
    --surface-hover: #26303c;
    --border-color: #26303c;
    --card-border: 1px solid var(--border-color);
    --card-shadow: none;
    --card-shadow-hover: none;
}

/* ── 4. NOCTURNO — además cambia la forma ────────────────────────────────── */
[data-theme="nocturno"] {
    --card-radius: 10px;
    --img-ratio: 16 / 9;
}
[data-theme="nocturno"] body.store-body,
[data-night="1"] body.store-body { color: var(--text-strong); }
[data-theme="nocturno"] .product-card:hover,
[data-night="1"] .product-card:hover {
    transform: none;
    box-shadow: 0 0 0 1px var(--accent);
}
[data-theme="nocturno"] .product-name,
[data-theme="nocturno"] .section-title,
[data-night="1"] .product-name,
[data-night="1"] .section-title { color: var(--text-strong); }
[data-theme="nocturno"] .product-price,
[data-night="1"] .product-price { color: var(--accent); }
[data-theme="nocturno"] .text-muted,
[data-night="1"] .text-muted { color: var(--text-muted) !important; }

/* Sobre superficies oscuras los grises fijos de site.css no alcanzan AA. */
[data-theme="nocturno"] body.store-body .store-meta-chip,
[data-theme="nocturno"] body.store-body .hours-chip,
[data-theme="nocturno"] body.store-body .store-description,
[data-theme="nocturno"] body.store-body .promo-store-desc,
[data-theme="nocturno"] body.store-body .promo-coupon-label,
[data-theme="nocturno"] body.store-body .promo-stock-label,
[data-theme="nocturno"] body.store-body #storeLoyaltyBanner .loy-chev,
[data-theme="nocturno"] body.store-body .promo-coupon-code,
[data-night="1"] body.store-body .store-meta-chip,
[data-night="1"] body.store-body .hours-chip,
[data-night="1"] body.store-body .store-description,
[data-night="1"] body.store-body .promo-store-desc,
[data-night="1"] body.store-body .promo-coupon-label,
[data-night="1"] body.store-body .promo-stock-label,
[data-night="1"] body.store-body #storeLoyaltyBanner .loy-chev,
[data-night="1"] body.store-body .promo-coupon-code { color: var(--text-muted); }

[data-theme="nocturno"] body.store-body .product-img-placeholder,
[data-night="1"] body.store-body .product-img-placeholder { color: var(--text-muted); }
[data-theme="nocturno"] body.store-body .store-status-badge.open,
[data-night="1"] body.store-body .store-status-badge.open { color: #4ade80; }
[data-theme="nocturno"] body.store-body .store-status-badge.closed,
[data-night="1"] body.store-body .store-status-badge.closed { color: #f87171; }

/* Secciones y capas que en site.css nacen blancas (reseñas, pie, ficha y carrito).
   Estas sí se sobrescriben solo de noche: en los temas claros manda el diseño original. */
[data-theme="nocturno"] body.store-body .grev-section,
[data-night="1"] body.store-body .grev-section {
    background: var(--surface-3);
    border-top-color: var(--border-color);
}
[data-theme="nocturno"] body.store-body .grev-summary,
[data-theme="nocturno"] body.store-body .grev-card,
[data-theme="nocturno"] body.store-body .grev-gicon,
[data-theme="nocturno"] body.store-body .store-footer,
[data-theme="nocturno"] body.store-body .powered-by-lettera,
[data-theme="nocturno"] body.store-body .pdsh,
[data-theme="nocturno"] body.store-body .cart-drawer,
[data-night="1"] body.store-body .grev-summary,
[data-night="1"] body.store-body .grev-card,
[data-night="1"] body.store-body .grev-gicon,
[data-night="1"] body.store-body .store-footer,
[data-night="1"] body.store-body .powered-by-lettera,
[data-night="1"] body.store-body .pdsh,
[data-night="1"] body.store-body .cart-drawer {
    background: var(--surface);
    border-color: var(--border-color);
}
[data-theme="nocturno"] body.store-body .store-footer,
[data-theme="nocturno"] body.store-body .powered-by-lettera,
[data-theme="nocturno"] body.store-body .pdsh,
[data-theme="nocturno"] body.store-body .cart-drawer,
[data-night="1"] body.store-body .store-footer,
[data-night="1"] body.store-body .powered-by-lettera,
[data-night="1"] body.store-body .pdsh,
[data-night="1"] body.store-body .cart-drawer { color: var(--text-strong); }
[data-theme="nocturno"] body.store-body .grev-title,
[data-theme="nocturno"] body.store-body .grev-score,
[data-theme="nocturno"] body.store-body .grev-name,
[data-theme="nocturno"] body.store-body .grev-text,
[data-theme="nocturno"] body.store-body .pdsh-opt-item-name,
[data-night="1"] body.store-body .grev-title,
[data-night="1"] body.store-body .grev-score,
[data-night="1"] body.store-body .grev-name,
[data-night="1"] body.store-body .grev-text,
[data-night="1"] body.store-body .pdsh-opt-item-name { color: var(--text-strong); }
[data-theme="nocturno"] body.store-body .grev-sub,
[data-theme="nocturno"] body.store-body .grev-count,
[data-theme="nocturno"] body.store-body .grev-when,
[data-theme="nocturno"] body.store-body .pdsh-opt-item-price,
[data-theme="nocturno"] body.store-body .pdsh-opt-group-label,
[data-night="1"] body.store-body .grev-sub,
[data-night="1"] body.store-body .grev-count,
[data-night="1"] body.store-body .grev-when,
[data-night="1"] body.store-body .pdsh-opt-item-price,
[data-night="1"] body.store-body .pdsh-opt-group-label { color: var(--text-muted); }
[data-theme="nocturno"] body.store-body .grev-cta,
[data-night="1"] body.store-body .grev-cta {
    background: var(--surface-2);
    border-color: var(--accent);
    color: var(--accent);
}
[data-theme="nocturno"] body.store-body .pdsh-opt-item,
[data-night="1"] body.store-body .pdsh-opt-item {
    background: var(--surface-2);
    border-color: var(--border-color);
}
[data-theme="nocturno"] body.store-body .pdsh-opt-item:has(input:checked),
[data-night="1"] body.store-body .pdsh-opt-item:has(input:checked) {
    border-color: var(--accent);
    background: rgba(var(--accent-rgb), .14);
}
[data-theme="nocturno"] body.store-body .pdsh-footer,
[data-theme="nocturno"] body.store-body .cart-drawer-footer,
[data-theme="nocturno"] body.store-body .cart-qty-row,
[data-night="1"] body.store-body .pdsh-footer,
[data-night="1"] body.store-body .cart-drawer-footer,
[data-night="1"] body.store-body .cart-qty-row { border-color: var(--border-color); }
[data-theme="nocturno"] body.store-body .cart-item-img,
[data-theme="nocturno"] body.store-body .cart-drawer-handle,
[data-night="1"] body.store-body .cart-item-img,
[data-night="1"] body.store-body .cart-drawer-handle { background: var(--surface-2); }
[data-theme="nocturno"] body.store-body .store-footer-dev,
[data-theme="nocturno"] body.store-body .store-footer-dev strong,
[data-night="1"] body.store-body .store-footer-dev,
[data-night="1"] body.store-body .store-footer-dev strong { color: var(--text-muted); }
[data-theme="nocturno"] body.store-body .store-footer-dev:hover,
[data-theme="nocturno"] body.store-body .store-footer-dev:hover strong,
[data-theme="nocturno"] body.store-body .powered-by-lettera a,
[data-night="1"] body.store-body .store-footer-dev:hover,
[data-night="1"] body.store-body .store-footer-dev:hover strong,
[data-night="1"] body.store-body .powered-by-lettera a { color: var(--accent); }

/* ── 5. VIBRANTE — denso y enérgico ──────────────────────────────────────── */
[data-theme="vibrante"] {
    --card-radius: 22px;
    --card-shadow: 0 2px 12px rgba(190, 24, 93, .08);
    --card-shadow-hover: 0 10px 24px rgba(190, 24, 93, .20);
    --card-border: 1px solid #fce7f3;
    --img-ratio: 4 / 3;
    --product-name-size: .82rem;
    --info-padding: .6rem .65rem;
    --page-bg: #fff5fa;
    --text-strong: #1f0a14;
    --text-muted: #8c5f75;
    --text-soft: #6b3a52;
    --grid-gutter: .6rem;
}
[data-theme="vibrante"] .product-name { font-weight: 700; line-height: 1.25; }
/* Prioriza densidad: se oculta la descripción en la tarjeta (sigue en la ficha). */
[data-theme="vibrante"] .product-desc { display: none; }
[data-theme="vibrante"] .product-price { font-size: 1rem; }
[data-theme="vibrante"] .btn-add-cart { width: 38px; height: 38px; border-radius: 14px; }
[data-theme="vibrante"] .section-title { font-weight: 900; letter-spacing: -.01em; }

/* ── Contraste WCAG AA en elementos heredados de site.css ────────────────────
   Varios grises (#94a3b8, #64748b, #9ca3af) quedaban entre 2,3:1 y 4,3:1 sobre
   fondos claros, y el botón de WhatsApp usaba blanco sobre verde brillante
   (1,98:1). Se corrigen acá porque este archivo es el último del storefront. */
body.store-body .hours-chip.closed-day { color: var(--text-soft); }
body.store-body .cart-close-btn { color: var(--text-soft); }
body.store-body .cart-close-btn:hover { color: #b91c1c; }
body.store-body .store-footer-dev,
body.store-body .store-footer-dev strong { color: var(--text-soft); }
body.store-body .grev-when,
body.store-body .grev-foot { color: var(--text-soft); }
body.store-body .powered-by-lettera { color: var(--text-soft); }

/* Verde de WhatsApp con texto oscuro: 6,84:1 (antes blanco, 1,98:1). */
body.store-body .btn-wa-contact { color: #04361a; }

/* El velo de "Agotado" al 45% dejaba el texto en 3,36:1 sobre fotos claras. */
body.store-body .sold-out-overlay { background: rgba(0, 0, 0, .55); }

[data-theme="nocturno"] body.store-body .cart-close-btn {
    background: var(--surface-2);
    border-color: var(--border-color);
}
[data-theme="nocturno"] body.store-body .cart-close-btn:hover {
    background: rgba(248, 113, 113, .15);
    border-color: #f87171;
    color: #fca5a5;
}

/* ── Banner de anuncio ────────────────────────────────────────────────────── */
.store-banner {
    display: flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .55rem 1rem; text-align: center;
    font-size: .84rem; font-weight: 600; line-height: 1.35;
    background: var(--banner-bg, var(--accent));
    color: var(--banner-fg, var(--accent-contrast));
    text-decoration: none;
}
a.store-banner:hover { text-decoration: underline; color: var(--banner-fg, var(--accent-contrast)); }

/* ── Etiquetas de producto ────────────────────────────────────────────────── */
.product-tag {
    display: inline-block;
    font-size: .63rem; font-weight: 800; letter-spacing: .02em;
    padding: .1rem .45rem; border-radius: 6px; line-height: 1.5;
    background: rgba(var(--accent-rgb), .12);
    color: var(--accent-dark);
}
[data-theme="nocturno"] .product-tag,
[data-night="1"] .product-tag {
    background: rgba(var(--accent-rgb), .18);
    color: var(--accent);
}

/* ── Respeto por "reducir movimiento" ────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .product-card { transition: none; }
    .product-card:hover { transform: none; }
}
