/* Sidebar de filtros — catálogo (index.html). Fase 4b.1. */

.cat-page {
    font-family: var(--font-family-base);
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px 56px 100px;
}

/* ─── BOTÓN MOBILE "Filtros (N)" ─────────────────────
   Nav sticky de layout.css: ~85px desktop / ~68px mobile, z-index 50. */
.cat-filtros-mobile-toggle {
    display: none;
    align-items: center;
    gap: 8px;
    position: sticky;
    top: 68px;
    z-index: 40;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    font-size: 14px;
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
    cursor: pointer;
    width: 100%;
    margin-bottom: 20px;
}

.cat-filtros-mobile-toggle:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.cat-filtros-mobile-toggle__count {
    color: var(--color-primary);
    font-weight: var(--font-weight-bold);
}

/* ─── LAYOUT: SIDEBAR + CONTENIDO ────────────────────*/
.cat-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 48px;
    align-items: start;
}

/* ─── SIDEBAR ─────────────────────────────────────────
   Sin card contenedora (estilo Bershka): los filtros viven al
   margen, sin borde ni fondo, full-height con scroll propio.
   Nav sticky real: 85px desktop (layout.css) → top = 85+20 = 105,
   height = 100vh - (85+40) = 100vh - 125. */
.cat-sidebar {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0 24px 0 0;
    position: sticky;
    top: 105px;
    height: calc(100vh - 125px);
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.cat-sidebar::-webkit-scrollbar {
    display: none;
}

.cat-sidebar__mobile-header {
    display: none;
}

.cat-sidebar__mobile-title {
    font-size: 20px;
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
}

.cat-sidebar__mobile-close {
    background: none;
    border: none;
    padding: 4px;
    font-size: 20px;
    cursor: pointer;
    color: var(--color-text-muted);
}

.cat-sidebar__mobile-close:hover { color: var(--color-primary); }

.cat-sidebar__group {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--color-border);
}

.cat-sidebar__group:last-of-type {
    border-bottom: none;
}

.cat-sidebar__label {
    display: block;
    font-size: var(--font-size-caption);
    font-weight: var(--font-weight-bold);
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
}

/* ─── BÚSQUEDA ────────────────────────────────────────*/
.cat-sidebar__search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.cat-sidebar__search-icon {
    position: absolute;
    left: 12px;
    width: 16px;
    height: 16px;
    color: var(--color-text-muted);
    pointer-events: none;
}

.cat-sidebar__search-input {
    width: 100%;
    padding: 10px 36px 10px 38px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font-family-base);
    color: var(--color-text);
    background: var(--color-surface);
}

.cat-sidebar__search-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(10, 37, 89, 0.08);
}

.cat-sidebar__search-clear {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    padding: 4px 8px !important;
    cursor: pointer;
    color: var(--color-text-muted);
    font-size: 14px;
    text-transform: none;
    letter-spacing: normal;
    font-family: var(--font-family-base);
}

.cat-sidebar__search-clear:hover { color: var(--color-primary); }
.cat-sidebar__search-clear.hidden { display: none; }

/* ─── SELECTS ─────────────────────────────────────────*/
.cat-sidebar__select {
    width: 100%;
    padding: 10px 34px 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font-family-base);
    color: var(--color-text);
    background-color: var(--color-surface);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B6863' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
}

.cat-sidebar__select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(10, 37, 89, 0.08);
}

/* ─── FOOTER / LIMPIAR TODO ───────────────────────────*/
.cat-sidebar__footer {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
}

.cat-sidebar__clear-all {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-muted);
    cursor: pointer;
    font-family: var(--font-family-base);
    text-transform: none;
    letter-spacing: normal;
}

.cat-sidebar__clear-all:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* ─── CONTENIDO PRINCIPAL ─────────────────────────────*/
.cat-content {
    min-width: 0;
}

/* .catalogo es una clase COMPARTIDA con ofertas.html (ofertas.js /
   carrusel.js reusan el mismo grid para "Más ofertas" y el toggle
   "Mostrar más"). No tocamos esa regla base ni sus breakpoints
   (1400/1100/768/480 en catalogo.css) para no romper Fase 4a ya
   validada — en su lugar la sobreescribimos acá con especificidad
   más alta, solo dentro de .cat-content. */
.cat-content .catalogo {
    grid-template-columns: repeat(4, 1fr);
    max-width: none;
    margin: 0;
    padding: 24px 0;
}

@media (max-width: 860px) {
    .cat-content .catalogo {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 12px 0;
    }
}

.cat-content__toolbar {
    position: sticky;
    top: 84px; /* 1px de solape con el nav (~84.67px real) — cero franja aun con redondeo sub-pixel */
    z-index: 50;
    background: var(--color-bg);
    display: flex;
    justify-content: space-between; /* contador izq, orden+toggle der */
    align-items: center;
    padding: 12px 20px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

/* El HTML ya trae class="cat-content__count" (reemplazó por completo
   a .contador-resultados/#contadorResultados de catalogo.css — esa
   clase vieja ya no se usa en este elemento). El.style.display=''
   del JS (→ block) es compatible: no pisa estas reglas. */
.cat-content__count {
    font-size: 15px;
    color: var(--color-text);
    font-weight: var(--font-weight-medium);
    font-family: var(--font-family-base);
}

.cat-content__actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cat-content__sort-label {
    font-size: 14px;
    color: var(--color-text-muted);
    font-weight: var(--font-weight-medium);
    font-family: var(--font-family-base);
}

.cat-content__sort-select {
    padding: 8px 32px 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background-color: var(--color-surface);
    font-size: 14px;
    font-family: var(--font-family-base);
    color: var(--color-text);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B6863' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px;
}

.cat-content__sort-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(10, 37, 89, 0.08);
}

.cat-content__view-toggle {
    display: flex;
    gap: 4px;
}

/* ─── CHIPS DE FILTROS APLICADOS ──────────────────────*/
.cat-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
    padding: 12px 0;
}

.cat-chips.hidden {
    display: none;
}

.cat-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px 6px 14px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-family: var(--font-family-base);
    color: var(--color-text);
    transition: all 0.15s;
}

.cat-chip:hover {
    border-color: var(--color-primary);
}

.cat-chip__label {
    font-weight: var(--font-weight-medium);
}

.cat-chip__value {
    color: var(--color-text-muted);
}

.cat-chip__remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0 !important;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 14px;
    text-transform: none;
    letter-spacing: normal;
    font-family: var(--font-family-base);
    transition: all 0.15s;
}

.cat-chip__remove:hover {
    background: var(--color-primary);
    color: var(--color-bg);
}

.cat-chip--limpiar {
    background: transparent;
    border-color: var(--color-primary);
    color: var(--color-primary);
    cursor: pointer;
    padding: 6px 14px;
    font-weight: var(--font-weight-semibold);
}

.cat-chip--limpiar:hover {
    background: var(--color-primary);
    color: var(--color-bg);
}

/* ─── OVERLAY MOBILE ──────────────────────────────────*/
.cat-sidebar-overlay {
    display: none;
}

/* ─── RESPONSIVE (<=860px): DRAWER ────────────────────*/
@media (max-width: 860px) {
    .cat-page {
        padding: 20px;
    }

    .cat-filtros-mobile-toggle {
        display: flex;
    }

    .cat-layout {
        display: block;
    }

    .cat-sidebar {
        /* El drawer SÍ necesita fondo — es un panel dedicado, no el
           margen "sin card" de desktop (PASO 3 del fix Bershka). */
        background: var(--color-surface);
        padding: 24px 20px;
        position: fixed;
        inset: 0;
        z-index: 100;
        border-radius: 0;
        height: 100vh;
        max-height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.3s ease-out;
        width: 85%;
        max-width: 340px;
        overflow-y: auto;
    }

    body.cat-sidebar-open .cat-sidebar {
        transform: translateX(0);
    }

    .cat-sidebar__mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding-bottom: 16px;
        margin-bottom: 20px;
        border-bottom: 1px solid var(--color-border);
    }

    .cat-sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(10, 20, 40, 0.5);
        z-index: 99;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s;
    }

    body.cat-sidebar-open .cat-sidebar-overlay {
        opacity: 1;
        visibility: visible;
    }

    .cat-content__toolbar {
        position: static;
        align-items: flex-start;
    }

    .cat-chips {
        margin-bottom: 16px;
        padding: 8px 0;
    }

    .cat-chip {
        font-size: 12px;
        padding: 5px 6px 5px 12px;
    }
}
