﻿/* ========== SIDEBAR DE FILTROS ACCESIBLE ========== */
.products-sidebar {
    width: 100%;
    flex: 1 1;
    max-width: 24.5rem;
    min-width: 17.5rem;
    height: 100%;
    padding: 20px;
    padding-top: 0;
    position: sticky;
    flex-shrink: 0;
}

.sidebar-header {
    display: none;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #d1d5db; /* Gris más visible */
}

.sidebar-title {
    font-size: 20px;
    font-weight: 700; /* Más peso para mejor legibilidad */
    color: var(--neutral-foreground-rest, #1f2937);
    margin: 0;
}

.sidebar-close-btn {
    display: none;
    background: none;
    border: 2px solid transparent; /* Preparado para focus */
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    color: var(--neutral-foreground-rest, #1f2937);
    line-height: 1;
    border-radius: 4px;
}

    .sidebar-close-btn:focus-visible {
        outline: 2px solid var(--color-blue, #2563eb);
        background-color: #f3f4f6;
    }

.filter-count {
    background: var(--color-blue, #2563eb); /* Azul accesible */
    color: white;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    min-width: 24px;
    text-align: center;
}

/* ========== FORMULARIO DE FILTROS ========== */
.filter-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.filter-section {
    border: 1px solid #d1d5db; /* Borde más visible */
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background-color: #f8f9fa;
    color: #1f2937;
    cursor: pointer;
    transition: background-color 0.2s ease;
    user-select: none;
    border: none;
    width: 100%; /* Asegura que sea clickeable como botón */
    text-align: left;
}

    .filter-header:hover {
        background-color: #e5e7eb;
    }

    .filter-header:focus-visible {
        outline: 2px solid var(--color-blue, #2563eb);
        outline-offset: -2px;
        background-color: #e5e7eb;
    }

.filter-title {
    font-weight: 600;
    color: var(--neutral-foreground-rest, #1f2937);
    font-size: 14px;
}

.toggle-icon {
    transition: transform 0.3s ease;
    color: #4b5563; /* Gris más oscuro (AA Pass) */
    font-size: 12px;
}

.filter-section.collapsed .toggle-icon i {
    transform: rotate(-90deg);
}

.filter-content {
    padding: 16px;
    background-color: white;
    border-top: 1px solid #e5e7eb;
}

.filter-section.collapsed .filter-content {
    display: none;
}

.filter-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600; /* Más peso */
    color: #374151; /* Gris oscuro para etiquetas */
    font-size: 13px;
}

.search-input,
.filter-form select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #9ca3af; /* Borde inputs más visible (3:1) */
    border-radius: 6px;
    font-size: 14px;
    color: #1f2937;
    background-color: white;
}

    .search-input:focus,
    .filter-form select:focus {
        outline: none;
        border-color: var(--color-blue, #2563eb);
        box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
    }

.price-range-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.price-input {
    flex: 1;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #9ca3af;
    border-radius: 6px;
    font-size: 14px;
    color: #1f2937;
}

    .price-input:focus {
        outline: none;
        border-color: var(--color-blue, #2563eb);
        box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
    }

.price-separator {
    color: #4b5563;
    font-weight: 500;
}

.checkbox-group,
.radio-group {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    cursor: pointer;
    min-height: 24px; /* Área de toque mínima */
}

.checkbox-input,
.radio-input {
    margin-right: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--color-blue, #2563eb);
}

    /* Fallback para navegadores antiguos que no soportan accent-color */
    .checkbox-input:focus,
    .radio-input:focus {
        outline: 2px solid var(--color-blue, #2563eb);
        outline-offset: 2px;
    }

.checkbox-label,
.radio-label {
    cursor: pointer;
    font-size: 14px;
    color: #374151; /* Texto legible */
    user-select: none;
}

.rating-stars {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
}

.star {
    color: #d97706; /* Naranja más oscuro para contraste en blanco */
    font-size: 14px;
}

.rating-value {
    margin-left: 8px;
    font-weight: 600;
    color: #1f2937;
    font-size: 13px;
}

/* Botones */
.buttons-container {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    text-decoration: none;
}

    .btn:focus-visible {
        outline: 3px solid #fbbf24; /* Focus ring visible */
        outline-offset: 2px;
    }

.btn-primary {
    background-color: var(--color-blue, #2563eb);
    color: white;
}

    .btn-primary:hover {
        background-color: #1d4ed8;
    }

.btn-secondary {
    background-color: #f3f4f6;
    color: #1f2937;
    border: 1px solid #d1d5db;
}

    .btn-secondary:hover {
        background-color: #e5e7eb;
        border-color: #9ca3af;
    }

/* ========== MODO ALTO CONTRASTE (AAA) ========== */
body.high-contrast-mode .products-sidebar {
    background: #ffffff;
    border-right: 2px solid #000000;
}

body.high-contrast-mode .filter-section {
    border: 2px solid #000000;
}

body.high-contrast-mode .filter-header {
    background-color: #000000;
    color: #ffffff;
    border-bottom: 1px solid #ffffff;
}

body.high-contrast-mode .filter-title,
body.high-contrast-mode .toggle-icon {
    color: #ffffff !important;
}

body.high-contrast-mode .filter-content {
    background-color: #ffffff;
    border-top: 2px solid #000000;
}

body.high-contrast-mode .filter-label,
body.high-contrast-mode .checkbox-label,
body.high-contrast-mode .radio-label,
body.high-contrast-mode .sidebar-title {
    color: #000000 !important;
    font-weight: 700;
}

body.high-contrast-mode .search-input,
body.high-contrast-mode .price-input,
body.high-contrast-mode select {
    border: 2px solid #000000 !important;
    color: #000000 !important;
    font-weight: 600;
}

body.high-contrast-mode .btn-primary {
    background-color: #000000 !important;
    border: 2px solid #000000 !important;
    color: #ffffff !important;
    text-decoration: underline;
}

    body.high-contrast-mode .btn-primary:hover {
        background-color: #333333 !important;
    }

body.high-contrast-mode .btn-secondary {
    background-color: #ffffff !important;
    border: 2px solid #000000 !important;
    color: #000000 !important;
    font-weight: 700;
}


/* ========== RESPONSIVE PARA FILTROS ========== */
@media (max-width: 1024px) {
    .products-sidebar {
        width: 100vw;
        max-width: unset;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 100vh;
        z-index: 999;
        display: none;
        transform: translateY(-100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 20px 20px 20px;
        border-radius: 0;
        box-shadow: none;
        background: white;
    }

        .products-sidebar.mobile-active {
            transform: translateY(0);
        }

    .sidebar-header {
        display: flex;
        position: relative;
        top: 0;
        margin-top: 2rem;
        left: 0;
        width: 100%;
        background: white;
        z-index: 1000;
        padding: 16px 20px;
        margin-bottom: 0;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        border-bottom: 1px solid #e9ecef;
    }

    .sidebar-close-btn {
        display: block;
    }

    .mobile-filter-floating-btn {
        display: flex;
    }
}

@media (max-width: 576px) {
    .price-range-container {
        flex-direction: column;
        gap: 12px;
    }

    .buttons-container {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}
