/* ============================================================
   products.css — Catálogo de productos
   Visión Uno Óptica · Paleta: #FFFFFF · #0A0A0A · #C9A96E
   ============================================================ */

/* ─── BREADCRUMB ─────────────────────────────────────────── */
.breadcrumb-bar {
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border, #EBEBEB);
    padding: 12px 0;
}
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 0.8125rem;
    color: var(--color-muted, #888);
}
.breadcrumb a {
    color: var(--color-muted, #888);
    text-decoration: none;
    transition: color 0.2s;
}
.breadcrumb a:hover { color: var(--color-gold, #C9A96E); }
.bc-sep { color: var(--color-border, #EBEBEB); }
.breadcrumb [aria-current="page"] { color: var(--color-text, #0A0A0A); font-weight: 500; }

/* ─── LAYOUT PRINCIPAL ───────────────────────────────────── */
.products-page { background: var(--color-bg, #FFFFFF); min-height: 80vh; }

.products-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 40px;
    padding-top: 32px;
    padding-bottom: 64px;
    align-items: start;
}

/* ════════════════════════════════════════════════════════════
   SIDEBAR DE FILTROS
   ════════════════════════════════════════════════════════════ */
.filters-sidebar {
    position: sticky;
    top: 88px; /* altura del header */
    max-height: calc(100vh - 108px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border, #EBEBEB) transparent;
}
.filters-sidebar::-webkit-scrollbar { width: 4px; }
.filters-sidebar::-webkit-scrollbar-thumb {
    background: var(--color-border, #EBEBEB);
    border-radius: 2px;
}

/* Header del sidebar */
.filters-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--color-border, #EBEBEB);
}
.filters-title {
    font-family: var(--font-display, 'Cormorant Garamond', serif);
    font-size: 1.375rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--color-text, #0A0A0A);
    margin: 0;
}
.filters-clear {
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 0.75rem;
    color: var(--color-gold, #C9A96E);
    padding: 4px 0;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: opacity 0.2s;
}
.filters-clear:hover { opacity: 0.7; }
.filters-clear[hidden] { display: none; }

/* Grupos de filtro */
.filter-group {
    border-bottom: 1px solid var(--color-border, #EBEBEB);
    padding: 16px 0;
}
.filter-group:last-child { border-bottom: none; }

.filter-group__toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text, #0A0A0A);
    margin-bottom: 14px;
}
.filter-group__toggle .toggle-icon {
    transition: transform 0.25s ease;
    flex-shrink: 0;
}
.filter-group__toggle[aria-expanded="false"] .toggle-icon {
    transform: rotate(-90deg);
}
.filter-group__body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.25s ease;
    max-height: 400px;
    opacity: 1;
}
.filter-group__body.collapsed {
    max-height: 0;
    opacity: 0;
}

/* Checkboxes personalizados */
.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}
.filter-checkbox .filter-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}
.checkbox-custom {
    width: 16px;
    height: 16px;
    border: 1.5px solid #CCCCCC;
    border-radius: 3px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s, background 0.2s;
    position: relative;
}
.checkbox-custom::after {
    content: '';
    width: 9px;
    height: 5px;
    border-left: 2px solid #FFF;
    border-bottom: 2px solid #FFF;
    transform: rotate(-45deg) scale(0);
    transition: transform 0.15s ease;
    margin-top: -2px;
}
.filter-input:checked ~ .checkbox-custom {
    background: var(--color-gold, #C9A96E);
    border-color: var(--color-gold, #C9A96E);
}
.filter-input:checked ~ .checkbox-custom::after { transform: rotate(-45deg) scale(1); }
.filter-input:focus-visible ~ .checkbox-custom {
    outline: 2px solid var(--color-gold, #C9A96E);
    outline-offset: 2px;
}
.checkbox-label {
    font-size: 0.875rem;
    color: var(--color-text, #0A0A0A);
    flex: 1;
}
.checkbox-count {
    font-size: 0.75rem;
    color: var(--color-muted, #888);
    min-width: 20px;
    text-align: right;
}

/* Toggles (solo disponibles, con descuento...) */
.filter-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}
.toggle-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}
.toggle-track {
    width: 36px;
    height: 20px;
    background: #DDDDDD;
    border-radius: 10px;
    flex-shrink: 0;
    position: relative;
    transition: background 0.2s;
}
.toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    background: #FFFFFF;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle-input:checked ~ .toggle-track { background: var(--color-gold, #C9A96E); }
.toggle-input:checked ~ .toggle-track .toggle-thumb { transform: translateX(16px); }
.toggle-input:focus-visible ~ .toggle-track {
    outline: 2px solid var(--color-gold, #C9A96E);
    outline-offset: 2px;
}
.toggle-label { font-size: 0.875rem; color: var(--color-text, #0A0A0A); }

/* Slider de precio */
.price-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text, #0A0A0A);
    margin-bottom: 16px;
    gap: 4px;
}
.price-slider-wrap {
    position: relative;
    height: 4px;
    margin: 20px 0 8px;
}
.price-track {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: #E8E8E8;
    border-radius: 2px;
}
.price-track__fill {
    position: absolute;
    height: 100%;
    background: var(--color-gold, #C9A96E);
    border-radius: 2px;
    transition: left 0.05s, width 0.05s;
}
.price-range {
    position: absolute;
    top: -8px;
    width: 100%;
    height: 20px;
    opacity: 0;
    cursor: pointer;
    pointer-events: none;
    -webkit-appearance: none;
    z-index: 3;
}
#priceMin { pointer-events: auto; z-index: 4; }
#priceMax { pointer-events: auto; z-index: 4; }

/* Thumb visibles */
.price-slider-wrap::before,
.price-slider-wrap::after {
    content: '';
    position: absolute;
    top: -6px;
    width: 16px;
    height: 16px;
    background: #FFFFFF;
    border: 2px solid var(--color-gold, #C9A96E);
    border-radius: 50%;
    z-index: 2;
    pointer-events: none;
    transition: transform 0.15s;
}
/* Los thumbs reales se manejan via JS moviendo pseudoelement a través de custom props */
.price-slider-wrap::before { left: var(--thumb-min, 0%); transform: translateX(-50%); }
.price-slider-wrap::after  { left: var(--thumb-max, 100%); transform: translateX(-50%); }

/* ════════════════════════════════════════════════════════════
   TOOLBAR SUPERIOR
   ════════════════════════════════════════════════════════════ */
.products-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0 20px;
    border-bottom: 1px solid var(--color-border, #EBEBEB);
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.toolbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.products-count {
    font-size: 0.875rem;
    color: var(--color-muted, #888);
    margin: 0;
}
.products-count #countNumber {
    font-weight: 600;
    color: var(--color-text, #0A0A0A);
}

/* Botón filtros mobile (oculto en desktop) */
.btn-filters-mobile {
    display: none;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px solid var(--color-border, #EBEBEB);
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--color-text, #0A0A0A);
    transition: border-color 0.2s;
    position: relative;
}
.btn-filters-mobile:hover { border-color: var(--color-gold, #C9A96E); }

.active-filters-badge {
    position: absolute;
    top: -7px;
    right: -7px;
    min-width: 18px;
    height: 18px;
    background: var(--color-gold, #C9A96E);
    color: #fff;
    border-radius: 9px;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}
.active-filters-badge:empty { display: none; }

/* Select wrapper */
.sort-label,
.per-page-label {
    font-size: 0.8125rem;
    color: var(--color-muted, #888);
    white-space: nowrap;
}
.select-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.sort-select {
    appearance: none;
    -webkit-appearance: none;
    background: var(--color-bg, #FFFFFF);
    border: 1px solid var(--color-border, #EBEBEB);
    border-radius: 6px;
    padding: 8px 32px 8px 12px;
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 0.8125rem;
    color: var(--color-text, #0A0A0A);
    cursor: pointer;
    min-width: 160px;
    transition: border-color 0.2s;
}
.per-page-select { min-width: 70px; }
.sort-select:focus { outline: none; border-color: var(--color-gold, #C9A96E); }
.select-wrap .select-caret {
    position: absolute;
    right: 10px;
    pointer-events: none;
    color: var(--color-muted, #888);
}
.sort-wrap,
.per-page-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Botones vista grid/lista */
.view-toggle {
    display: flex;
    border: 1px solid var(--color-border, #EBEBEB);
    border-radius: 6px;
    overflow: hidden;
}
.view-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 10px;
    color: var(--color-muted, #888);
    display: flex;
    align-items: center;
    transition: background 0.2s, color 0.2s;
}
.view-btn + .view-btn { border-left: 1px solid var(--color-border, #EBEBEB); }
.view-btn.active,
.view-btn[aria-pressed="true"] {
    background: var(--color-text, #0A0A0A);
    color: #FFFFFF;
}

/* ─── CHIPS DE FILTROS ACTIVOS ───────────────────────────── */
.active-filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    min-height: 0;
}
.active-filters-bar:empty { margin-bottom: 0; }

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #F5F0E8;
    border: 1px solid #E8DCC8;
    border-radius: 20px;
    padding: 4px 10px 4px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text, #0A0A0A);
    animation: chipIn 0.2s ease;
}
@keyframes chipIn {
    from { opacity: 0; transform: scale(0.85); }
    to   { opacity: 1; transform: scale(1); }
}
.filter-chip__remove {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-muted, #888);
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}
.filter-chip__remove:hover {
    background: var(--color-gold, #C9A96E);
    color: #FFF;
}

/* ════════════════════════════════════════════════════════════
   GRID Y LISTA DE PRODUCTOS
   ════════════════════════════════════════════════════════════ */

/* ── VISTA GRID ── */
.products-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
}
.products-grid.view-4col { grid-template-columns: repeat(4, 1fr); gap: 20px; }
.products-grid.view-2col { grid-template-columns: repeat(2, 1fr); }

/* ── TARJETA DE PRODUCTO (grid) ── */
.product-card {
    position: relative;
    background: var(--color-bg, #FFFFFF);
    border: 1px solid var(--color-border, #EBEBEB);
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.3s, box-shadow 0.3s;
    display: flex;
    flex-direction: column;
}
.product-card:hover {
    border-color: #D4C4A8;
    box-shadow: 0 8px 32px rgba(201,169,110,0.12);
}

/* Imagen */
.product-card__img-wrap {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #F9F7F4;
}
.product-card__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: block;
}
.product-card:hover .product-card__img { transform: scale(1.06); }

/* Placeholder sin imagen */
.product-card__img-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #F5F0E8 0%, #EDE5D5 100%);
    color: var(--color-gold, #C9A96E);
    gap: 8px;
}
.product-card__img-placeholder span {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0.6;
}

/* Badges (nuevo, bestseller) */
.product-card__badges {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 2;
}
.card-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 2px;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    line-height: 1;
}
.card-badge--new      { background: var(--color-text, #0A0A0A); color: #FFF; }
.card-badge--best     { background: var(--color-gold, #C9A96E); color: #FFF; }
.card-badge--discount { background: #E84848; color: #FFF; }

/* Descuento en esquina */
.product-card__discount {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #E84848;
    color: #FFF;
    font-size: 0.6875rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 2px;
    z-index: 2;
}

/* Acciones rápidas */
.product-card__actions {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    z-index: 3;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.product-card:hover .product-card__actions { transform: translateY(0); }

@media (max-width: 768px) {
    .products-grid:not(.view-list) .product-card__actions {
        transform: translateY(0);
    }
}

.quick-action {
    width: 100%;
    height: 38px;
    border: none;
    border-radius: 0;
    background: var(--color-text, #0A0A0A);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    color: #FFF;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    transition: background 0.2s;
    flex-shrink: 0;
}
.quick-action:hover {
    background: var(--color-gold, #C9A96E);
}

/* Info de la tarjeta */
.product-card__info {
    padding: 14px 16px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.product-card__brand {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--color-gold, #C9A96E);
}
.product-card__name {
    font-family: var(--font-display, 'Cormorant Garamond', serif);
    font-size: 1.0625rem;
    font-weight: 500;
    color: var(--color-text, #0A0A0A);
    line-height: 1.3;
    margin: 0;
    /* Truncar en 2 líneas */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.product-card__pricing {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
}
.price-current {
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-text, #0A0A0A);
}
.price-original {
    font-size: 0.8125rem;
    color: var(--color-muted, #888);
    text-decoration: line-through;
}
.product-card__stock-out {
    font-size: 0.75rem;
    font-weight: 600;
    color: #E84848;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-top: 2px;
}

/* ── VISTA LISTA ── */
.products-grid.view-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.products-grid.view-list .product-card {
    flex-direction: row;
    min-height: 160px;
}
.products-grid.view-list .product-card__img-wrap {
    width: 200px;
    min-width: 200px;
    aspect-ratio: unset;
    border-radius: 0;
}
.products-grid.view-list .product-card__actions {
    flex-direction: column;
    background: linear-gradient(to left, rgba(255,255,255,0.95) 0%, transparent 100%);
    top: 0;
    right: 0;
    left: auto;
    width: 120px;
    transform: translateX(100%);
    padding: 16px 10px;
    justify-content: center;
}
.products-grid.view-list .product-card:hover .product-card__actions {
    transform: translateX(0);
}
.products-grid.view-list .product-card__info {
    padding: 20px 24px;
    justify-content: center;
}
.products-grid.view-list .product-card__name {
    font-size: 1.25rem;
    -webkit-line-clamp: 1;
}
.products-grid.view-list .product-card__badges {
    top: 14px;
    left: 14px;
}

/* ─── ESTADO VACÍO ───────────────────────────────────────── */
.products-empty {
    text-align: center;
    padding: 80px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.products-empty[hidden] {
    display: none !important;
}

.products-empty svg { opacity: 0.5; margin-bottom: 8px; }
.empty-title {
    font-family: var(--font-display, 'Cormorant Garamond', serif);
    font-size: 1.5rem;
    font-weight: 500;
    margin: 0;
    color: var(--color-text, #0A0A0A);
}
.empty-sub {
    font-size: 0.9375rem;
    color: var(--color-muted, #888);
    margin: 0;
    max-width: 340px;
}

/* ════════════════════════════════════════════════════════════
   PAGINACIÓN
   ════════════════════════════════════════════════════════════ */
.products-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 40px 0 0;
    flex-wrap: wrap;
}

.page-btn {
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-border, #EBEBEB);
    border-radius: 4px;
    background: none;
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text, #0A0A0A);
    cursor: pointer;
    padding: 0 6px;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.page-btn:hover:not([disabled]) {
    border-color: var(--color-gold, #C9A96E);
    color: var(--color-gold, #C9A96E);
}
.page-btn.active,
.page-btn[aria-current="page"] {
    background: var(--color-text, #0A0A0A);
    border-color: var(--color-text, #0A0A0A);
    color: #FFFFFF;
}
.page-btn[disabled] {
    opacity: 0.35;
    cursor: not-allowed;
}
.page-ellipsis {
    font-size: 0.875rem;
    color: var(--color-muted, #888);
    padding: 0 4px;
    user-select: none;
}

/* ════════════════════════════════════════════════════════════
   MOBILE OVERLAY Y DRAWER
   ════════════════════════════════════════════════════════════ */
.filters-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    opacity: 0;
    transition: opacity 0.3s;
}
.filters-overlay.visible {
    display: block;
    opacity: 1;
}

/* ════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════ */

/* Tablet grande */
@media (max-width: 1200px) {
    .products-layout { grid-template-columns: 220px 1fr; gap: 28px; }
    .products-grid { grid-template-columns: repeat(3, 1fr); gap: 20px; }
}

/* Tablet */
@media (max-width: 960px) {
    .products-layout {
        grid-template-columns: 1fr;
        gap: 0;
    }

    /* Sidebar como drawer lateral en mobile */
    .filters-sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: min(300px, 85vw);
        height: 100vh;
        max-height: 100vh;
        background: var(--color-bg, #FFFFFF);
        z-index: 201;
        padding: 24px 20px;
        transition: left 0.32s cubic-bezier(0.25, 0.46, 0.45, 0.94);
        box-shadow: 4px 0 24px rgba(0,0,0,0.12);
    }
    .filters-sidebar.open {
        left: 0;
    }

    .btn-filters-mobile { display: flex; }
    .products-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }

    /* Vista lista en tablet */
    .products-grid.view-list .product-card__img-wrap { width: 140px; min-width: 140px; }
}

/* Mobile */
@media (max-width: 600px) {
    .products-toolbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .toolbar-right {
        width: 100%;
        justify-content: space-between;
    }
    .sort-label,
    .per-page-label { display: none; }
    .sort-select { min-width: 130px; }

    .products-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .product-card__info { padding: 10px 12px 12px; }
    .product-card__name { font-size: 0.9375rem; }

    /* Lista en mobile: columna */
    .products-grid.view-list .product-card { flex-direction: column; min-height: unset; }
    .products-grid.view-list .product-card__img-wrap { width: 100%; min-width: 0; aspect-ratio: 1/1; }
    .products-grid.view-list .product-card__actions {
        flex-direction: row;
        width: auto;
        transform: translateY(0);
        top: auto;
        right: 0;
        left: 0;
        bottom: 0;
        padding: 0;
        background: none;
    }
}

@media (max-width: 380px) {
    .products-grid { grid-template-columns: 1fr; }
}
