/**
 * TodoChen - Frontend CSS
 * Paleta: Azul fuerte + Rojo + Amarillo/Dorado
 */

:root {
    --color-primary: #1a3a8a;
    --color-primary-dark: #0f2460;
    --color-primary-light: #e8edf8;
    --color-accent: #d4202c;
    --color-accent-light: #fde8e8;
    --color-yellow: #f5c518;
    --color-yellow-light: #fef9e7;
    --color-danger: #d4202c;
    --color-success: #38a169;
    --color-warning: #f5c518;
    --color-dark: #111827;
    --color-gray: #6b7280;
    --color-gray-light: #e5e7eb;
    --color-bg: #f3f4f6;
    --color-white: #ffffff;
    --font-main: 'Nunito', sans-serif;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,.12);
    --shadow-lg: 0 10px 30px rgba(0,0,0,.15);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all .25s ease;
}

* { box-sizing: border-box; }
body {
    font-family: var(--font-main);
    background: var(--color-bg);
    color: var(--color-dark);
    margin: 0;
}

/* ======================== TOP BAR ======================== */
.topbar {
    background: var(--color-primary-dark);
    color: rgba(255,255,255,.9);
    font-size: .85rem;
}
.topbar-link {
    color: rgba(255,255,255,.9);
    text-decoration: none;
    transition: var(--transition);
}
.topbar-link:hover { color: var(--color-yellow); }

/* ======================== NAVBAR ======================== */
.navbar-main {
    background: var(--color-white);
    box-shadow: var(--shadow-sm);
    padding: .75rem 0;
    z-index: 1030;
}
.navbar-brand {
    font-weight: 800;
    font-size: 1.5rem;
    color: var(--color-primary) !important;
}
.navbar-brand:hover { color: var(--color-primary-dark) !important; }
.navbar-brand i { font-size: 1.6rem; color: var(--color-accent); }

.navbar-main .nav-link {
    color: var(--color-dark);
    font-weight: 600;
    padding: .5rem 1rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.navbar-main .nav-link:hover { background: var(--color-primary-light); color: var(--color-primary); }
.navbar-toggler { border: none; font-size: 1.5rem; color: var(--color-dark); }

/* Search */
.search-form .form-control {
    border-radius: var(--radius) 0 0 var(--radius);
    border: 2px solid var(--color-gray-light);
    padding: .6rem 1rem;
    transition: var(--transition);
}
.search-form .form-control:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(26,141,78,.15);
}
.btn-search {
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 0 1.2rem;
}
.btn-search:hover { background: var(--color-primary-dark); color: white; }

/* Buttons */
.btn-carrito {
    background: var(--color-primary-light);
    color: var(--color-primary);
    border: none;
    border-radius: var(--radius-sm);
    padding: .5rem .75rem;
    font-size: 1.2rem;
    position: relative;
}
.badge-carrito {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--color-accent);
    color: white;
    font-size: .65rem;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}
.btn-whatsapp {
    background: #25d366;
    color: white !important;
    border: none;
    border-radius: var(--radius-sm);
    padding: .5rem .75rem;
    font-size: 1.1rem;
}
.btn-whatsapp:hover { background: #1fb855; }

/* ======================== BOTÓN FLOTANTE WHATSAPP ======================== */
.whatsapp-float {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    background: #25d366;
    color: #fff !important;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
    z-index: 1050;
    text-decoration: none;
    transition: transform .2s ease, box-shadow .2s ease;
    animation: whatsapp-pulse 2.5s infinite;
}
.whatsapp-float:hover {
    background: #1fb855;
    color: #fff !important;
    transform: scale(1.08);
    box-shadow: 0 6px 22px rgba(0,0,0,.3);
}
@keyframes whatsapp-pulse {
    0%   { box-shadow: 0 4px 16px rgba(0,0,0,.25), 0 0 0 0 rgba(37,211,102,.6); }
    70%  { box-shadow: 0 4px 16px rgba(0,0,0,.25), 0 0 0 16px rgba(37,211,102,0); }
    100% { box-shadow: 0 4px 16px rgba(0,0,0,.25), 0 0 0 0 rgba(37,211,102,0); }
}
@media (max-width: 768px) {
    .whatsapp-float {
        width: 54px;
        height: 54px;
        font-size: 28px;
        bottom: 18px;
        right: 18px;
    }
}

/* ======================== INSTAGRAM EMBEDS ======================== */
.instagram-embeds {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    align-items: start;
    justify-items: center;
}
.instagram-embed-item {
    width: 100%;
    max-width: 340px;
    display: flex;
    justify-content: center;
}
/* El blockquote de Instagram trae estilos propios; lo dejamos centrar */
.instagram-embed-item .instagram-media {
    margin: 0 auto !important;
    min-width: 0 !important;
}
@media (max-width: 992px) {
    .instagram-embeds { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 576px) {
    .instagram-embeds { grid-template-columns: 1fr; }
}

.btn-primary-custom {
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    padding: .6rem 1.5rem;
    transition: var(--transition);
}
.btn-primary-custom:hover { background: var(--color-primary-dark); color: white; transform: translateY(-1px); }
.btn-outline-primary-custom {
    border: 2px solid var(--color-primary);
    color: var(--color-primary);
    border-radius: var(--radius-sm);
    font-weight: 600;
    background: transparent;
}
.btn-outline-primary-custom:hover { background: var(--color-primary); color: white; }

/* ======================== HERO BANNER ======================== */
.hero-banner .carousel-item img {
    width: 100%;
    height: auto;        /* el alto se calcula según el ancho, sin recortar */
    display: block;
}
.hero-banner .carousel-caption {
    background: rgba(0,0,0,.5);
    border-radius: var(--radius);
    padding: 1.5rem 2rem;
    bottom: 2rem;
}
.hero-banner .carousel-caption h2 { font-weight: 800; margin-bottom: .5rem; }
@media (max-width: 768px) {
    .hero-banner .carousel-caption { padding: .75rem 1rem; }
    .hero-banner .carousel-caption h2 { font-size: 1.1rem; }
}

/* ======================== SECTIONS ======================== */
.section-title {
    font-weight: 800;
    font-size: 1.5rem;
    position: relative;
    margin-bottom: 1.5rem;
    color: var(--color-dark);
}
.section-title::after {
    content: '';
    display: block;
    width: 50px;
    height: 4px;
    background: var(--color-accent);
    border-radius: 2px;
    margin-top: .5rem;
}
.section-ofertas { background: var(--color-accent-light); }

/* ======================== CATEGORY CARDS ======================== */
.category-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-height: 140px;
    padding: 1.25rem .75rem;
    background: var(--color-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    text-align: center;
}
.category-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}
.category-icon {
    width: 56px;
    height: 56px;
    background: var(--color-primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--color-primary);
    transition: var(--transition);
}
.category-card:hover .category-icon {
    background: var(--color-primary);
    color: white;
}
/* Categoría con imagen propia: la foto va de fondo de toda la tarjeta,
   con una capa translúcida encima para que el texto se lea siempre. */
.category-card-img {
    position: relative;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    /* El texto va abajo, apoyado sobre la franja oscura */
    justify-content: flex-end;
    gap: .1rem;
    padding-bottom: .85rem;
}
.category-card-img::before {
    content: "";
    position: absolute;
    inset: 0;
    /* Arriba la foto queda limpia; se oscurece solo abajo, donde va el texto */
    background: linear-gradient(to bottom,
                rgba(15, 36, 96, 0) 38%,
                rgba(15, 36, 96, .50) 70%,
                rgba(15, 36, 96, .88) 100%);
    transition: var(--transition);
}
.category-card-img:hover::before {
    background: linear-gradient(to bottom,
                rgba(15, 36, 96, .10) 30%,
                rgba(15, 36, 96, .60) 68%,
                rgba(15, 36, 96, .94) 100%);
}
/* El texto va por encima de la capa */
.category-card-img > * {
    position: relative;
    z-index: 1;
}
.category-card-img .category-name {
    color: #fff;
    text-shadow: 0 1px 4px rgba(0, 0, 0, .75), 0 0 2px rgba(0, 0, 0, .5);
}
.category-card-img .category-count {
    color: rgba(255, 255, 255, .92);
    font-size: .78rem;
    text-shadow: 0 1px 4px rgba(0, 0, 0, .75), 0 0 2px rgba(0, 0, 0, .5);
}
.category-name {
    font-weight: 700;
    font-size: .9rem;
    color: var(--color-dark);
}

/* ======================== PRODUCT CARD ======================== */
.product-card {
    background: var(--color-white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
}
.product-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
}
.product-card.sin-stock { opacity: .7; }

.product-link { text-decoration: none; color: inherit; flex: 1; display: flex; flex-direction: column; }

.product-badges {
    position: absolute;
    top: .75rem;
    left: .75rem;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* cada badge toma solo el ancho de su contenido */
    gap: .25rem;
}
.badge-oferta {
    background: var(--color-danger);
    color: white;
    padding: .2rem .6rem;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 700;
}
.badge-destacado {
    background: var(--color-yellow);
    color: #111;
    padding: .2rem .5rem;
    border-radius: 20px;
    font-size: .7rem;
}
.badge-sinstock {
    background: var(--color-gray);
    color: white;
    padding: .2rem .6rem;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
}

.product-img {
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #f8f9fa;
    padding: 1rem;
}
.product-img img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: var(--transition);
}
.product-card:hover .product-img img { transform: scale(1.05); }
.product-img-placeholder {
    color: var(--color-gray-light);
    font-size: 3rem;
}

.product-info {
    padding: .75rem 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.product-marca {
    font-size: .7rem;
    text-transform: uppercase;
    color: var(--color-gray);
    font-weight: 700;
    letter-spacing: .5px;
}
.product-name {
    font-size: .9rem;
    font-weight: 600;
    margin: .25rem 0 .5rem;
    color: var(--color-dark);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
}

.product-price { margin-top: auto; }
.price-old {
    text-decoration: line-through;
    color: var(--color-gray);
    font-size: .8rem;
    margin-right: .25rem;
}
.price-current {
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--color-dark);
}
.price-current.price-oferta { color: var(--color-accent); }
.price-current.price-mayorista { color: #198754; } /* verde para precio mayorista */
.product-detail-price.price-mayorista { color: #198754; }
.badge-mayorista {
    background: #198754;
    color: #fff;
    font-size: .7rem;
    padding: .25rem .5rem;
    border-radius: 4px;
    font-weight: 700;
    margin-left: .25rem;
}
.mayorista-banner {
    background: #198754;
    color: #fff;
    text-align: center;
}
.mayorista-banner strong { color: #fff; }

.btn-agregar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    width: 100%;
    padding: .65rem;
    background: var(--color-primary);
    color: white;
    border: none;
    font-weight: 700;
    font-size: .85rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-main);
}
.btn-agregar:hover { background: var(--color-accent); }
.btn-agregar i { font-size: 1.1rem; }

@media (max-width: 576px) {
    .product-img { height: 140px; }
    .product-name { font-size: .82rem; }
    .price-current { font-size: 1rem; }
    .btn-agregar span { display: none; }
}

/* ======================== INFO BAR ======================== */
.info-bar { background: var(--color-white); }
.info-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .75rem;
}
.info-item i {
    font-size: 1.8rem;
    color: var(--color-primary);
}
.info-item strong { display: block; font-size: .85rem; }
.info-item small { color: var(--color-gray); font-size: .75rem; }

/* ======================== OFFCANVAS CARRITO ======================== */
#carritoOffcanvas { max-width: 400px; }
.cart-item {
    display: flex;
    gap: .75rem;
    padding: .75rem 0;
    border-bottom: 1px solid var(--color-gray-light);
    align-items: center;
}
.cart-item-img {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-sm);
    object-fit: contain;
    background: #f8f9fa;
    flex-shrink: 0;
}
.cart-item-name { font-weight: 600; font-size: .85rem; line-height: 1.2; }
.cart-item-price { color: var(--color-primary); font-weight: 700; font-size: .9rem; }
.cart-qty {
    display: flex;
    align-items: center;
    gap: .25rem;
}
.cart-qty button {
    width: 28px;
    height: 28px;
    border: 1px solid var(--color-gray-light);
    background: white;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: .8rem;
}
.cart-qty span { font-weight: 700; min-width: 24px; text-align: center; }
.cart-item-remove { color: var(--color-danger); cursor: pointer; font-size: 1.1rem; }

/* ======================== FOOTER ======================== */
.footer-main {
    background: var(--color-primary-dark);
    color: rgba(255,255,255,.9);
}
.footer-logo {
    max-height: 240px;
    width: auto;
    filter: brightness(1.1);
    margin-top: -30px;
    display: block;
}
@media (max-width: 768px) {
    .footer-logo {
        margin-left: auto;
        margin-right: auto;
    }
    .footer-main .col-lg-4 {
        text-align: center;
    }
    .footer-main .col-lg-4 .d-flex {
        justify-content: center;
    }
}
.footer-title {
    color: white;
    font-weight: 700;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}
.footer-links { list-style: none; padding: 0; }
.footer-links li { margin-bottom: .5rem; }
.footer-links a {
    color: rgba(255,255,255,.7);
    text-decoration: none;
    transition: var(--transition);
}
.footer-links a:hover { color: var(--color-yellow); }
.btn-social {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,.1);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: var(--transition);
}
.btn-social:hover { background: var(--color-accent); color: white; }

/* ======================== PAGES ======================== */
/* Catálogo */
.filter-sidebar .form-check { margin-bottom: .5rem; }
/* Cabeceras plegables del costado: en celular abren/cierran, en escritorio son solo títulos */
.filtro-toggle {
    display: flex;
    align-items: center;
    gap: .5rem;
    width: 100%;
    background: none;
    border: 0;
    padding: .5rem 0;
    color: inherit;
    font: inherit;
    text-align: left;
}
.filtro-actual {
    margin-left: auto;
    font-size: .8rem;
    font-weight: 600;
    color: var(--color-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.filtro-chevron { margin-left: auto; transition: transform .2s; }
.filtro-actual + .filtro-chevron { margin-left: 0; }
.filtro-toggle:not(.collapsed) .filtro-chevron { transform: rotate(180deg); }
@media (max-width: 991.98px) {
    .filter-sidebar .card-admin {
        background: white;
        border-radius: var(--radius);
        padding: 0 .75rem;
        box-shadow: 0 1px 3px rgba(0,0,0,.06);
    }
}
@media (min-width: 992px) {
    .filtro-toggle { pointer-events: none; cursor: default; }
    .filtro-chevron { display: none; }
}
.filter-title { font-weight: 700; font-size: .95rem; margin-bottom: .75rem; }
.active-filters .badge {
    background: var(--color-primary-light);
    color: var(--color-primary);
    font-weight: 600;
}
.product-grid { min-height: 400px; }

/* Producto detalle */
.product-detail-img {
    border-radius: var(--radius);
    overflow: hidden;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 350px;
}
.product-detail-img img { max-width: 100%; max-height: 400px; object-fit: contain; }
.product-detail-name { font-weight: 800; font-size: 1.5rem; }
.product-detail-price { font-size: 2rem; font-weight: 800; color: var(--color-primary); }
.qty-selector {
    display: inline-flex;
    align-items: center;
    border: 2px solid var(--color-gray-light);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.qty-selector button {
    width: 40px;
    height: 40px;
    background: var(--color-bg);
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
}
.qty-selector input {
    width: 50px;
    height: 40px;
    border: none;
    text-align: center;
    font-weight: 700;
    font-size: 1rem;
}

/* Checkout */
.checkout-summary {
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 100px;
}

/* Auth pages */
.auth-card {
    max-width: 480px;
    margin: 3rem auto;
    background: white;
    border-radius: var(--radius);
    padding: 2.5rem;
    box-shadow: var(--shadow-md);
}
.auth-card h2 { font-weight: 800; text-align: center; margin-bottom: 1.5rem; }

/* Mi Cuenta */
.account-sidebar .list-group-item.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
}
.order-status {
    display: inline-block;
    padding: .2rem .75rem;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
}
.order-status.pendiente { background: #fff3cd; color: #856404; }
.order-status.confirmado { background: #cce5ff; color: #004085; }
.order-status.preparando { background: #d4edda; color: #155724; }
.order-status.listo { background: #d1ecf1; color: #0c5460; }
.order-status.enviado { background: #e2d5f1; color: #4a148c; }
.order-status.entregado { background: #d4edda; color: #155724; }
.order-status.cancelado { background: #f8d7da; color: #721c24; }

/* ======================== UTILITIES ======================== */
.bg-primary-custom { background: var(--color-primary) !important; }
.text-primary-custom { color: var(--color-primary) !important; }
.text-accent { color: var(--color-accent) !important; }

/* Breadcrumb */
.breadcrumb-custom {
    background: white;
    padding: .75rem 1.25rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}
.breadcrumb-custom .breadcrumb-item a {
    color: var(--color-primary);
    text-decoration: none;
}

/* ============== Descripción del producto (Quill HTML) ============== */
.product-descripcion {
    line-height: 1.6;
}
.product-descripcion p { margin: 0 0 .6rem 0; }
.product-descripcion strong, .product-descripcion b { font-weight: 700; color: var(--color-dark); }

/* Listas de Quill v2:
   Quill guarda TODAS las listas como <ol> y distingue el tipo con data-list en cada <li>.
   Reseteamos el estilo por defecto y usamos contadores CSS para simular ambos tipos. */
.product-descripcion ul,
.product-descripcion ol {
    padding-left: 1.5rem;
    margin: .5rem 0;
    list-style: none;
    counter-reset: list-0;
}
.product-descripcion ul li,
.product-descripcion ol li {
    margin-bottom: .25rem;
    position: relative;
    padding-left: 1.2rem;
}

/* Bullets tradicionales de <ul> (por si vienen así) */
.product-descripcion ul li::before {
    content: "•";
    position: absolute;
    left: 0;
    font-weight: bold;
    color: var(--color-dark);
}

/* Quill: <li data-list="bullet"> = viñeta */
.product-descripcion ol li[data-list="bullet"]::before {
    content: "•";
    position: absolute;
    left: 0;
    font-weight: bold;
    color: var(--color-dark);
}

/* Quill: <li data-list="ordered"> = numerada con contador CSS */
.product-descripcion ol li[data-list="ordered"] {
    counter-increment: list-0;
}
.product-descripcion ol li[data-list="ordered"]::before {
    content: counter(list-0) ".";
    position: absolute;
    left: 0;
    font-weight: 600;
    color: var(--color-dark);
}

/* Quill inserta un <span class="ql-ui"> vacío al inicio de cada <li>. Ocultarlo. */
.product-descripcion li .ql-ui { display: none; }

.product-descripcion h2, .product-descripcion h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: .75rem 0 .35rem;
    color: var(--color-dark);
}
.product-descripcion a {
    color: var(--color-primary);
    text-decoration: underline;
}
.product-descripcion blockquote {
    border-left: 3px solid var(--color-primary);
    padding-left: .75rem;
    margin: .5rem 0;
    color: var(--color-gray);
    font-style: italic;
}

/* Alineaciones de Quill */
.product-descripcion .ql-align-center  { text-align: center; }
.product-descripcion .ql-align-right   { text-align: right; }
.product-descripcion .ql-align-justify { text-align: justify; }
.product-descripcion .ql-align-left    { text-align: left; }
