/* Tokens — escala slate + blue de Tailwind. Si hace falta un tono nuevo, sale de acá. */
:root {
    /* Marca */
    --primary-color: #2563eb;
    /* blue-600 */
    --primary-hover: #1d4ed8;
    /* blue-700 */
    --accent: #3b82f6;
    /* blue-500 */

    /* Superficies */
    --bg-color: #f8fafc;
    /* slate-50 */
    --card-bg: #ffffff;
    --surface-alt: #f1f5f9;
    /* slate-100 — inputs, botones neutros */
    --hero-wash: #dbeafe;
    /* blue-100 — tinte del hero (antes era #e0e7ff, indigo: fuera de la escala) */
    --glass-bg: rgba(255, 255, 255, 0.75);
    /* solo navbar */

    /* Texto */
    --text-main: #0f172a;
    /* slate-900 */
    --text-strong: #475569;
    /* slate-600 — secundario legible al sol (7.5:1) */
    --text-muted: #64748b;
    /* slate-500 — 4.55:1, solo texto grande o no esencial */
    --text-on-dark: #cbd5e1;
    /* slate-300 — sobre --text-main */
    --text-on-dark-muted: #94a3b8;
    /* slate-400 — sobre --text-main */

    /* Bordes */
    --border-color: #e2e8f0;
    /* slate-200 */
    --border-subtle: #f1f5f9;
    /* slate-100 */

    /* Estado */
    --success: #10b981;
    --danger: #e11d48;
    /* rose-600 */
    --danger-soft: #fff1f2;
    /* rose-50 */

    /* Movimiento — product register: 150-250ms, sin rebote */
    --dur-fast: 120ms;
    --dur: 200ms;
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

    /* Capas — nombra los valores que ya usaba el tema, no inventa banda nueva
       (Bootstrap: offcanvas 1045, modal 1055 — quedan por encima de --z-nav) */
    --z-card-overlay: 10;
    --z-badge: 2;
    --z-nav: 1000;

    /* Alto real de la navbar: sticky, offsets y scroll-margin salen de acá */
    --nav-h: 72px;
}

body {
    background-color: var(--bg-color);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-main);
    /* NO sacar sin probar en el navegador: hoy tapa algún desborde real en mobile.
       Sacarlo a ciegas te muestra scroll horizontal en los N VPS. Ver nota del audit. */
    overflow-x: hidden;
}

/* Foco de teclado — el mayorista que carga 30 ítems usa Tab, no el mouse.
   :where() mantiene especificidad 0: no pelea con nada, pero tampoco lo pisa nadie por accidente. */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Navegación — único lugar del tema donde el glass se justifica: hay contenido
   moviéndose debajo y la translucidez comunica profundidad. No replicarlo en paneles. */
.modern-navbar {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: var(--z-nav);
    transition: background-color var(--dur) var(--ease-out),
        box-shadow var(--dur) var(--ease-out);
    padding: 1rem 0;
}

.modern-navbar .navbar-brand {
    font-weight: 800;
    font-size: 1.5rem;
    letter-spacing: -0.02em;
    color: var(--primary-color);
}

.nav-link {
    font-weight: 500;
    color: var(--text-main);
    margin: 0 0.5rem;
    position: relative;
    transition: color var(--dur) var(--ease-out);
}

.nav-link:hover {
    color: var(--primary-color);
}

.nav-link::after {
    content: '';
    position: absolute;
    inset-inline: 0;
    height: 2px;
    bottom: 0;
    background-color: var(--primary-color);
    /* scaleX en vez de width: compone en GPU, no dispara layout */
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--dur) var(--ease-out);
}

.nav-link:hover::after,
.nav-link:focus-visible::after {
    transform: scaleX(1);
}

.icon-btn {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    color: var(--text-main);
    /* 44px: se toca con el pulgar */
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.icon-btn:hover {
    transform: scale(1.1);
    color: var(--primary-color);
}

/* Hero Section */
.hero-section {
    padding: 6rem 0;
    background: radial-gradient(circle at top right, var(--hero-wash), var(--bg-color));
    border-radius: 0 0 3rem 3rem;
    margin-bottom: 4rem;
    text-align: center;
}

.hero-title {
    font-size: 4rem;
    font-weight: 900;
    /* em, no rem: no se descalibra al bajar el tamaño en mobile */
    letter-spacing: -0.025em;
    line-height: 1.1;
    margin-bottom: 1.5rem;
    color: var(--text-main);
    text-wrap: balance;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--text-muted);
    font-weight: 400;
    max-width: 600px;
    margin: 0 auto 2.5rem auto;
}

.btn-modern {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
    padding: 1rem 2.5rem;
    min-height: 44px;
    border-radius: 50px;
    border: none;
    box-shadow: 0 10px 25px -5px rgba(37, 99, 235, 0.4);
    transition: background-color var(--dur) var(--ease-out),
        transform var(--dur) var(--ease-out),
        box-shadow var(--dur) var(--ease-out);
}

.btn-modern:hover {
    background-color: var(--primary-hover);
    transform: translateY(-3px);
    box-shadow: 0 15px 35px -5px rgba(37, 99, 235, 0.5);
    color: white;
}

/* Product Cards */
.section-title {
    font-weight: 800;
    font-size: 2rem;
    margin-bottom: 2rem;
    text-wrap: balance;
}

.product-card {
    background: var(--card-bg);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    /* arriba | izquierda y derecha | abajo */
    padding: 1rem 0.5rem 0.5rem 1rem;
    transition: transform var(--dur) var(--ease-out),
        box-shadow var(--dur) var(--ease-out),
        border-color var(--dur) var(--ease-out);
    height: 100%;
    position: relative;
    overflow: hidden;
    /* Sin cursor:pointer — la card no es clickeable, los links son internos
       (imagen, SKU, título). Prometer un target que no existe confunde. */
}

.product-card:hover,
.product-card:focus-within {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.1);
    border-color: transparent;
}

.product-image-wrapper {
    border-radius: 12px;
    overflow: hidden;
    background: transparent;
    /* Desktop queda igual que antes (250px); en mobile baja a 180 en vez de comerse la pantalla */
    height: clamp(180px, 40vw, 250px);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.product-image-wrapper img {
    width: 100%;
    height: 100%;
    /* cover deliberado: uniforma la grilla del listado */
    object-fit: cover;
    transition: transform 400ms var(--ease-out);
}

.product-card:hover .product-image-wrapper img {
    transform: scale(1.08);
}

.tag-new {
    position: absolute;
    top: 10px;
    left: 10px;
    background: var(--success);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    z-index: var(--z-badge);
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

.product-info {
    padding: 1.5rem 0.5rem 0.5rem 0.5rem;
}

.product-category {
    font-size: 0.8rem;
    text-transform: uppercase;
    /* El SKU es dato, no decoración: --text-strong (7.5:1) para que se lea al sol */
    color: var(--text-strong);
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.product-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 1rem;
    line-height: 1.4;
}

.product-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* sin margin-top:auto — .product-info no es flex container, no hacía nada */
}

.product-price {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-main);
}

.cart-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--surface-alt);
    color: var(--text-main);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}

.product-card:hover .cart-btn,
.product-card:focus-within .cart-btn {
    background: var(--primary-color);
    color: white;
}

/* En touch no hay hover: el botón tiene que verse activo siempre */
@media (hover: none) {
    .cart-btn {
        background: var(--primary-color);
        color: white;
    }
}

/* .cart-btn a veces es <button> (vista rápida) y a veces <a> (producto con variantes → detalle).
   Sin esto el <a> sale subrayado y las dos variantes no se ven iguales. */
a.cart-btn,
a.action-btn {
    text-decoration: none;
}

/* Footer Section */
.modern-footer {
    background: var(--text-main);
    color: white;
    padding: 4rem 0 2rem 0;
    border-radius: 3rem 3rem 0 0;
    margin-top: 4rem;
}

.footer-logo {
    font-size: 1.8rem;
    font-weight: 800;
    color: white;
    text-decoration: none;
    margin-bottom: 1.5rem;
    display: inline-block;
}

.footer-text {
    color: var(--text-on-dark-muted);
    line-height: 1.6;
    text-wrap: pretty;
}

.footer-link {
    color: var(--text-on-dark);
    text-decoration: none;
    transition: color var(--dur) var(--ease-out);
    display: block;
    /* 44px de alto: son los links que más se erran con el pulgar */
    padding: 0.5rem 0;
    margin-bottom: 0;
}

.footer-link:hover {
    color: white;
}

/* Tablet */
@media (max-width: 991.98px) {
    .hero-title {
        font-size: 3rem;
    }

    .hero-section {
        padding: 4.5rem 1.5rem;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .hero-title {
        font-size: 2.5rem;
    }

    .hero-section {
        padding: 4rem 1rem;
        border-radius: 0 0 2rem 2rem;
    }
}

/* Offcanvas Sidebar — sólido a propósito: acá el glass era decorativo y un
   blur(16px) a pantalla completa cuesta caro en celulares gama baja. */
.offcanvas-glass {
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.05);
}

.offcanvas-title {
    font-weight: 800;
    color: var(--primary-color);
    font-size: 1.5rem;
}

/* Category Tree Accordion */
.category-accordion {
    --bs-accordion-bg: transparent;
    --bs-accordion-border-color: transparent;
    --bs-accordion-btn-focus-box-shadow: none;
    --bs-accordion-active-bg: rgba(37, 99, 235, 0.05);
    --bs-accordion-active-color: var(--primary-color);
}

.category-accordion .accordion-item {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    margin-bottom: 0.25rem;
}

.category-accordion .accordion-button {
    font-weight: 600;
    padding: 1rem 0;
    min-height: 44px;
    color: var(--text-main);
    background: transparent;
    transition: color var(--dur) var(--ease-out);
}

.category-accordion .accordion-button:not(.collapsed) {
    color: var(--primary-color);
    background: transparent;
    box-shadow: none;
}

.category-accordion .accordion-button::after {
    background-size: 1rem;
    transition: transform var(--dur) var(--ease-out);
}

.category-tree-link {
    display: block;
    /* padding fijo: antes el hover animaba padding-left y hacía reflow en cada ítem del árbol */
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    color: var(--text-strong);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color var(--dur) var(--ease-out), background-color var(--dur) var(--ease-out);
    margin-bottom: 0.25rem;
}

/* Sin border-left de acento: se marca con fondo, que no empuja el layout */
.category-tree-link:hover {
    color: var(--primary-color);
    background: rgba(37, 99, 235, 0.06);
}



/* Unified Quick View Overlay — solo envuelve el botón (no tapa toda la imagen)
   Los !important son legacy y están peleando especificidad con 35 archivos:
   no los saco a ciegas, se limpian junto con el markup. */
.vista-rapida-overlay {
    transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out) !important;
    opacity: 0 !important;
    transform: scale(0.8) !important;
    /* auto: el área clicable es solo el botón; con "none" el clic atravesaba al <a> de la imagen */
    pointer-events: auto !important;
    z-index: var(--z-card-overlay) !important;
    position: absolute !important;
}

/* focus-within: por teclado también se revela, no solo con el mouse */
.product-card:hover .vista-rapida-overlay,
.product-card:focus-within .vista-rapida-overlay {
    opacity: 1 !important;
    transform: scale(1) !important;
    animation: none !important;
}

/* En touch no hay hover — sin esto la vista rápida no existe para la mayoría del tráfico */
@media (hover: none) {
    .vista-rapida-overlay {
        opacity: 1 !important;
        transform: none !important;
    }
}

.product-card:hover .product-image-wrapper::after {
    display: none !important;
}

/* Cart Page Specific Styles */
.cart-table th {
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.1em;
    color: var(--text-strong);
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 1rem;
}

/* Column widths - th has colspan=2 for product, so index shifts */
.cart-table th:nth-child(1) {
    width: 100px;
}

/* Producto (colspan=2: thumb) */
.cart-table th:nth-child(2) {
    width: auto;
}

/* Precio */
.cart-table th:nth-child(3) {
    width: 140px;
    text-align: center;
}

/* Cantidad — 150px para que entre el control de 132px con targets de 44px */
.cart-table th:nth-child(4) {
    width: 150px;
    text-align: right;
}

/* Subtotal */
.cart-table th:nth-child(5) {
    width: 60px;
}

/* Eliminar */

.cart-table td {
    vertical-align: middle;
    border-bottom: 1px solid var(--border-subtle);
    padding: 1rem 0.5rem;
}

/* Force thumbnail column width */
.cart-table td:first-child {
    width: 100px;
    padding-left: 0;
}

/* Force subtotal col */
.cart-table td.text-end:last-child {
    width: 50px;
}

.product-thumbnail-cart {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 0.75rem;
    border: 1px solid var(--border-subtle);
    display: block;
}

.qty-input-group {
    /* 44 + 44 + 44 = 132px: los tres targets llegan al mínimo táctil */
    width: 132px;
    max-width: 132px;
    background: var(--bg-color);
    border-radius: 2rem;
    border: 1px solid var(--border-color);
    display: inline-flex;
    align-items: center;
    transition: border-color var(--dur) var(--ease-out);
}

/* El foco se marca en el grupo entero, no en el input pelado:
   el input no tiene borde propio y el ring quedaba flotando adentro de la píldora */
.qty-input-group:focus-within {
    border-color: var(--primary-color);
    outline: 2px solid var(--primary-color);
    outline-offset: 1px;
}

.qty-input-group input {
    background: transparent;
    border: none;
    min-width: 0;
    text-align: center;
    font-weight: 700;
    padding: 0;
    flex: 0 0 44px;
}

/* El ring lo pone .qty-input-group:focus-within, no el input */
.qty-input-group input:focus {
    outline: none;
    box-shadow: none;
}

.qty-input-group button {
    background: transparent;
    border: none;
    color: var(--text-strong);
    /* 44x44 — es el control que más se toca en toda la tienda */
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
    transition: color var(--dur) var(--ease-out);
}

.qty-input-group button:hover {
    color: var(--primary-color);
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.summary-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
    position: sticky;
    /* atado al alto real de la navbar, no a un 100px mágico */
    top: calc(var(--nav-h) + 1rem);
}

/* En mobile el sticky no sirve: la columna va apilada y se roba pantalla */
@media (max-width: 991.98px) {
    .summary-card {
        position: static;
    }
}

.btn-modern-outline {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    color: var(--text-strong);
    min-height: 44px;
}

.btn-modern-outline:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--bg-color);
}

.btn-remove-item {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--danger-soft);
    color: var(--danger);
    border: none;
    transition: background-color var(--dur) var(--ease-out),
        color var(--dur) var(--ease-out),
        transform var(--dur) var(--ease-out);
}

.btn-remove-item:hover {
    background: var(--danger);
    color: white;
    transform: scale(1.1);
}

/* Movimiento reducido — misma convención que blocks/pg-hero.css y pg-categorias-final.css.
   Se respeta el estado final: nada queda invisible ni a medio revelar. */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .product-card:hover,
    .product-card:focus-within,
    .btn-modern:hover,
    .btn-remove-item:hover,
    .icon-btn:hover {
        transform: none;
    }

    .product-card:hover .product-image-wrapper img {
        transform: none;
    }

    .nav-link::after {
        transition: none;
    }
}