/* =====================================================
   PRODUCT LIST PAGE - Django Styles
   static/css/pages/product-list.css
   Version optimisée avec filtres améliorés
   ===================================================== */


/* =====================================================
   PAGE HEADER
   ===================================================== */
.page-header {
    padding: 1.5rem 0;
    background: var(--color-white);
    border-bottom: 1px solid var(--color-stone-100);
}

.page-header__title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-stone-850);
    margin: 0 0 0.25rem;
}

@media (min-width: 768px) {
    .page-header__title {
        font-size: 2rem;
    }
}

.page-header__subtitle {
    color: var(--color-stone-500);
    margin: 0;
    font-size: 0.9375rem;
}

/* =====================================================
   CATALOG LAYOUT
   ===================================================== */
.catalog {
    padding: 1.5rem 0 4rem;
    background: var(--color-off-white);
}

.catalog__layout {
    display: flex;
    gap: 2rem;
    position: relative;
}

.catalog__products {
    flex: 1;
    min-width: 0;
}

/* =====================================================
   FILTERS SIDEBAR - OPTIMIZED
   ===================================================== */
.filters-sidebar {
    /* Mobile: Hidden by default, shown as drawer */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    max-width: 320px;
    height: 100vh;
    height: 100dvh;
    background: var(--color-white);
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.filters-sidebar.active {
    transform: translateX(0);
}

@media (min-width: 1024px) {
    .filters-sidebar {
        /* Desktop: Sticky sidebar */
        position: sticky;
        top: 140px;
        width: 280px;
        height: auto;
        max-height: calc(100vh - 120px);
        transform: none;
        border-radius: 1rem;
        border: 1px solid var(--color-stone-100);
        flex-shrink: 0;
    }
}

/* Sidebar Header */
.filters-sidebar__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-stone-100);
    background: var(--color-white);
    flex-shrink: 0;
}

.filters-sidebar__title {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0;
    color: var(--color-stone-850);
}

.filters-sidebar__close {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-stone-500);
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.filters-sidebar__close:hover {
    background: var(--color-stone-100);
    color: var(--color-stone-800);
}

.filters-sidebar__close svg {
    width: 1.25rem;
    height: 1.25rem;
}

@media (min-width: 1024px) {
    .filters-sidebar__close {
        display: none;
    }
}

/* Sidebar Footer (Mobile only) */
.filters-sidebar__footer {
    padding: 1rem 1.25rem;
    background: var(--color-white);
    border-top: 1px solid var(--color-stone-100);
    flex-shrink: 0;
}

@media (min-width: 1024px) {
    .filters-sidebar__footer {
        display: none;
    }
}

.btn-block {
    width: 100%;
}

/* Filter Overlay */
.filter-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.filter-overlay.active {
    display: block;
}

@media (min-width: 1024px) {
    .filter-overlay {
        display: none !important;
    }
}

/* =====================================================
   FILTERS FORM - SINGLE SCROLL CONTAINER
   ===================================================== */
.filters-form {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Filter Groups Container - THE ONLY SCROLLABLE AREA */
.filters-groups {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    
    /* Custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--color-stone-300) transparent;
}

.filters-groups::-webkit-scrollbar {
    width: 6px;
}

.filters-groups::-webkit-scrollbar-track {
    background: transparent;
}

.filters-groups::-webkit-scrollbar-thumb {
    background: var(--color-stone-300);
    border-radius: 3px;
}

.filters-groups::-webkit-scrollbar-thumb:hover {
    background: var(--color-stone-400);
}

/* =====================================================
   ACTIVE FILTERS
   ===================================================== */
.active-filters {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-stone-100);
    background: var(--color-stone-50);
    flex-shrink: 0;
}

.active-filters[hidden] {
    display: none;
}

.active-filters__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.active-filters__title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-stone-600);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.active-filters__clear {
    font-size: 0.8125rem;
    color: var(--color-gold);
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 500;
}

.active-filters__clear:hover {
    text-decoration: underline;
}

.active-filters__list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.active-filter {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.625rem;
    background: var(--color-white);
    border: 1px solid var(--color-stone-200);
    border-radius: 9999px;
    font-size: 0.8125rem;
    color: var(--color-stone-700);
}

.active-filter button {
    display: flex;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-stone-400);
    transition: color 0.2s;
}

.active-filter button:hover {
    color: var(--color-stone-800);
}

.active-filter svg {
    width: 0.875rem;
    height: 0.875rem;
}

/* =====================================================
   FILTER GROUP
   ===================================================== */
.filter-group {
    border-bottom: 1px solid var(--color-stone-100);
}

.filter-group:last-child {
    border-bottom: none;
}

.filter-group__toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 1rem 1.25rem;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.filter-group__toggle:hover {
    background: var(--color-stone-50);
}

.filter-group__title {
    flex: 1;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-stone-800);
}

.filter-group__count {
    font-size: 0.75rem;
    color: var(--color-stone-400);
    background: var(--color-stone-100);
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
}

.filter-group__icon {
    width: 1.25rem;
    height: 1.25rem;
    color: var(--color-stone-400);
    transition: transform 0.2s;
    flex-shrink: 0;
}

.filter-group__toggle[aria-expanded="true"] .filter-group__icon {
    transform: rotate(180deg);
}

.filter-group__content {
    padding: 0 1.25rem 1rem;
}

.filter-group__content[hidden] {
    display: none;
}

/* =====================================================
   PRICE FILTER - COMPACT VERSION
   ===================================================== */
.price-filter__inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.price-filter__field {
    flex: 1;
    min-width: 0;
}

.price-filter__field label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--color-stone-500);
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.price-filter__field input {
    width: 100%;
    padding: 0.5rem 0.625rem;
    border: 1px solid var(--color-stone-200);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    background: var(--color-white);
    transition: border-color 0.2s;
}

.price-filter__field input:focus {
    outline: none;
    border-color: var(--color-gold);
}

.price-filter__field input::placeholder {
    color: var(--color-stone-400);
    font-weight: 400;
}

.price-filter__sep {
    color: var(--color-stone-300);
    font-size: 0.875rem;
    margin-top: 1rem;
}

.price-filter__presets {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.price-preset {
    padding: 0.5rem;
    background: var(--color-stone-100);
    border: 1px solid transparent;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-stone-600);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.price-preset:hover {
    background: var(--color-stone-200);
}

.price-preset.active {
    background: var(--color-gold);
    color: white;
    border-color: var(--color-gold);
}

/* =====================================================
   FILTER SEARCH
   ===================================================== */
.filter-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--color-stone-50);
    border-radius: 0.5rem;
    margin-bottom: 0.75rem;
}

.filter-search svg {
    width: 1rem;
    height: 1rem;
    color: var(--color-stone-400);
    flex-shrink: 0;
}

.filter-search__input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    font-size: 0.875rem;
    outline: none;
}

.filter-search__input::placeholder {
    color: var(--color-stone-400);
}

/* =====================================================
   FILTER OPTIONS
   ===================================================== */
.filter-options {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Scrollable options within filter group - NO separate scroll */
.filter-options--scrollable {
    max-height: 200px;
    overflow-y: auto;
    margin-right: -0.5rem;
    padding-right: 0.5rem;
}

.filter-options--tags {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Filter Option (Checkbox/Radio) */
.filter-option {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.25rem;
    cursor: pointer;
    border-radius: 0.375rem;
    transition: background 0.15s;
}

.filter-option:hover {
    background: var(--color-stone-50);
}

.filter-option input {
    display: none;
}

.filter-option__check {
    width: 1.125rem;
    height: 1.125rem;
    border: 2px solid var(--color-stone-300);
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
}

.filter-option__check--radio {
    border-radius: 50%;
}

.filter-option input:checked + .filter-option__check {
    background: var(--color-gold);
    border-color: var(--color-gold);
}

.filter-option input:checked + .filter-option__check::after {
    content: '';
    width: 0.375rem;
    height: 0.625rem;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
}

.filter-option input:checked + .filter-option__check--radio::after {
    width: 0.5rem;
    height: 0.5rem;
    background: white;
    border: none;
    border-radius: 50%;
    transform: none;
    margin: 0;
}

.filter-option__label {
    flex: 1;
    font-size: 0.875rem;
    color: var(--color-stone-700);
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.filter-option__count {
    font-size: 0.75rem;
    color: var(--color-stone-400);
    flex-shrink: 0;
}

/* Filter Tags */
.filter-tag {
    cursor: pointer;
}

.filter-tag input {
    display: none;
}

.filter-tag span {
    display: inline-block;
    padding: 0.4375rem 0.75rem;
    background: var(--color-stone-100);
    border-radius: 9999px;
    font-size: 0.8125rem;
    color: var(--color-stone-700);
    transition: all 0.2s;
    white-space: nowrap;
}

.filter-tag:hover span {
    background: var(--color-stone-200);
}

.filter-tag input:checked + span {
    background: var(--color-gold);
    color: white;
}

/* =====================================================
   CATALOG TOOLBAR
   ===================================================== */
.catalog-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--color-white);
    border-radius: 1rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--color-stone-100);
}

.catalog-toolbar__left,
.catalog-toolbar__right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.catalog-toolbar__count {
    font-size: 0.875rem;
    color: var(--color-stone-600);
}

.catalog-toolbar__count strong {
    color: var(--color-stone-800);
}

/* Filter Toggle (Mobile) */
.filter-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: var(--color-stone-100);
    border: none;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-stone-700);
    cursor: pointer;
    transition: all 0.2s;
}

.filter-toggle:hover {
    background: var(--color-stone-200);
}

.filter-toggle svg {
    width: 1.125rem;
    height: 1.125rem;
}

.filter-toggle__badge {
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.375rem;
    background: var(--color-gold);
    color: white;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.filter-toggle__badge[hidden] {
    display: none;
}

@media (min-width: 1024px) {
    .filter-toggle {
        display: none;
    }
}

/* Sort Dropdown */
.sort-dropdown {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sort-dropdown__label {
    font-size: 0.875rem;
    color: var(--color-stone-500);
    display: none;
}

@media (min-width: 640px) {
    .sort-dropdown__label {
        display: block;
    }
}

.sort-dropdown__select {
    padding: 0.625rem 2.25rem 0.625rem 0.875rem;
    background: var(--color-stone-100);
    border: none;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-stone-700);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2378716C' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.625rem center;
    background-size: 1rem;
}

/* View Toggle */
.view-toggle {
    display: none;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem;
    background: var(--color-stone-100);
    border-radius: 0.5rem;
}

@media (min-width: 768px) {
    .view-toggle {
        display: flex;
    }
}

.view-toggle__btn {
    padding: 0.5rem;
    border-radius: 0.375rem;
    color: var(--color-stone-400);
    background: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.view-toggle__btn:hover {
    color: var(--color-stone-600);
}

.view-toggle__btn--active {
    background: var(--color-white);
    color: var(--color-gold);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.view-toggle__btn svg {
    width: 1.25rem;
    height: 1.25rem;
    display: block;
}

/* =====================================================
   LOADING INDICATOR
   ===================================================== */
.loading-indicator {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 3rem;
    color: var(--color-stone-500);
}

.loading-indicator.htmx-request {
    display: flex;
}

.loading-spinner {
    width: 1.5rem;
    height: 1.5rem;
    border: 2px solid var(--color-stone-200);
    border-top-color: var(--color-gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Hide content during loading */
#products-container.htmx-request .products-grid,
#products-container.htmx-request .pagination,
#products-container.htmx-request .no-results {
    opacity: 0.5;
    pointer-events: none;
}

/* =====================================================
   PRODUCTS GRID
   ===================================================== */
.products-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

@media (min-width: 640px) {
    .products-grid {
        gap: 1.25rem;
    }
}

@media (min-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1280px) {
    .products-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* List View */
.products-grid--list {
    grid-template-columns: 1fr;
    gap: 1rem;
}

.products-grid--list .product-card {
    display: flex;
    flex-direction: row;
}

.products-grid--list .product-card__image {
    width: 160px;
    flex-shrink: 0;
}

@media (min-width: 640px) {
    .products-grid--list .product-card__image {
        width: 200px;
    }
}

.products-grid--list .product-card__content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1rem 1.25rem;
}

/* =====================================================
   NO RESULTS
   ===================================================== */
.no-results {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--color-white);
    border-radius: 1rem;
}

.no-results__icon {
    width: 4rem;
    height: 4rem;
    margin: 0 auto 1.5rem;
    color: var(--color-stone-300);
}

.no-results__icon svg {
    width: 100%;
    height: 100%;
}

.no-results__title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-stone-800);
    margin: 0 0 0.5rem;
}

.no-results__text {
    color: var(--color-stone-500);
    margin: 0 0 1.5rem;
}