/**
 * PopRace.org - Collection Filter Panel Styles
 * Professional filter UI with collapsible sections, sliders, and toggles
 * Version: 1.0.0
 * Date: November 18, 2025
 */

/* ===========================
   Filter Panel Container
   =========================== */

/* Fix sidebar container to constrain filter panel */
#filter-panel-container.sidebar-section {
    flex: 1 1 auto;
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Fix: prevent overflow in sidebar */
.filter-panel {
    background: var(--navy);
    border-radius: 8px;
    padding: 1rem;
    box-sizing: border-box;
}

/* ===========================
   Active Filters Display
   =========================== */

.active-filters-display {
    background: rgba(212, 165, 116, 0.1);
    border: 1px solid var(--gold);
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 1rem;
}

.active-filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.active-filters-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gold);
}

.clear-all-btn {
    background: transparent;
    border: 1px solid var(--gold);
    color: var(--gold);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-all-btn:hover {
    background: var(--gold);
    color: var(--navy);
}

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

.active-filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: var(--navy-light, #2d4a6f);
    border: 1px solid var(--gold);
    color: var(--cream);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    line-height: 1.4;
}

.remove-filter-btn {
    background: transparent;
    border: none;
    color: var(--gold);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    margin-left: 0.25rem;
    transition: color 0.2s ease;
}

.remove-filter-btn:hover {
    color: var(--cream);
}

/* ===========================
   Filter Sections
   =========================== */

.filter-section {
    border-bottom: 1px solid rgba(212, 165, 116, 0.2);
    margin-bottom: 0.5rem;
}

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

.filter-section-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: transparent;
    border: none;
    color: var(--cream);
    padding: 0.75rem 0;
    cursor: pointer;
    font-size: 0.9375rem;
    font-weight: 600;
    transition: color 0.2s ease;
}

.filter-section-header:hover {
    color: var(--gold);
}

.filter-section-title {
    text-align: left;
}

.filter-section-icon {
    color: var(--gold);
    font-size: 0.875rem;
    transition: transform 0.2s ease;
}

.filter-section-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.filter-section-content.open {
    max-height: 1000px;
    padding-bottom: 0.75rem;
}

/* ===========================
   Filter Actions (Select All / Clear)
   =========================== */

.filter-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.filter-select-all,
.filter-clear {
    background: transparent;
    border: 1px solid rgba(212, 165, 116, 0.3);
    color: var(--cream);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-select-all:hover,
.filter-clear:hover {
    border-color: var(--gold);
    color: var(--gold);
}

/* ===========================
   Checkbox Filters
   =========================== */

.filter-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.filter-checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.filter-checkbox-item:hover {
    background: rgba(212, 165, 116, 0.1);
}

.filter-checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--gold);
}

.filter-checkbox-label {
    flex: 1;
    color: var(--cream);
    font-size: 0.875rem;
}

.filter-count {
    color: rgba(245, 230, 211, 0.6);
    font-size: 0.75rem;
}

/* Condition-specific styling */
.condition-item {
    align-items: center;
}

.condition-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    font-size: 0.875rem;
    margin-right: 0.25rem;
}

/* ===========================
   Range Sliders
   =========================== */

.range-slider-container {
    padding: 0.5rem;
}

.range-values {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.range-label {
    color: var(--cream);
    font-size: 0.875rem;
}

.dual-range-slider {
    position: relative;
    height: 40px;
}

.range-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(212, 165, 116, 0.2);
    border-radius: 3px;
    outline: none;
    position: absolute;
    top: 0;
    pointer-events: none;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--gold);
    cursor: pointer;
    border-radius: 50%;
    pointer-events: all;
    border: 2px solid var(--navy);
    transition: transform 0.2s ease;
}

.range-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.range-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--gold);
    cursor: pointer;
    border-radius: 50%;
    pointer-events: all;
    border: 2px solid var(--navy);
    transition: transform 0.2s ease;
}

.range-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
}

/* Second slider overlay */
.dual-range-slider .range-slider:nth-child(2) {
    background: transparent;
}

/* ===========================
   Quick Toggle Filters
   =========================== */

.quick-filters-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.toggle-filter-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.toggle-filter-item:hover {
    background: rgba(212, 165, 116, 0.1);
    border-color: rgba(212, 165, 116, 0.3);
}

.toggle-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--gold);
}

.toggle-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.toggle-label {
    flex: 1;
    color: var(--cream);
    font-size: 0.875rem;
    font-weight: 500;
}

/* ===========================
   Mobile Filter Actions
   =========================== */

.filter-mobile-actions {
    display: none;
    padding: 1rem 0 0 0;
    border-top: 1px solid rgba(212, 165, 116, 0.2);
    margin-top: 1rem;
}

.btn-apply-filters {
    width: 100%;
    background: var(--gold);
    color: var(--navy);
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-apply-filters:hover {
    background: var(--cream);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(212, 165, 116, 0.3);
}

.btn-apply-filters:active {
    transform: translateY(0);
}

/* ===========================
   Empty State
   =========================== */

.filter-empty {
    color: rgba(245, 230, 211, 0.5);
    font-size: 0.875rem;
    text-align: center;
    padding: 1rem 0;
    font-style: italic;
}

/* ===========================
   Scrollbar Styling
   =========================== */

.filter-panel::-webkit-scrollbar {
    width: 8px;
}

.filter-panel::-webkit-scrollbar-track {
    background: rgba(212, 165, 116, 0.1);
    border-radius: 4px;
}

.filter-panel::-webkit-scrollbar-thumb {
    background: var(--gold);
    border-radius: 4px;
}

.filter-panel::-webkit-scrollbar-thumb:hover {
    background: var(--cream);
}

/* ===========================
   Mobile Responsive (< 768px)
   =========================== */

@media (max-width: 767px) {
    .filter-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 70vh;
        max-height: 70vh;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
        z-index: 1000;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        padding: 1.5rem;
    }

    .filter-panel.open {
        transform: translateY(0);
    }

    .filter-mobile-actions {
        display: block;
    }

    .active-filters-display {
        margin-bottom: 1.5rem;
    }

    .filter-section-content.open {
        max-height: 600px;
    }

    /* Mobile filter drawer overlay */
    .filter-drawer-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .filter-drawer-overlay.open {
        opacity: 1;
        pointer-events: all;
    }
}

/* ===========================
   Tablet Responsive (768px - 1024px)
   =========================== */

@media (min-width: 768px) and (max-width: 1024px) {
    .filter-panel {
        padding: 0.875rem;
    }

    .filter-section-header {
        font-size: 0.875rem;
    }

    .filter-checkbox-label,
    .toggle-label {
        font-size: 0.8125rem;
    }
}

/* ===========================
   Desktop (> 1024px)
   =========================== */

@media (min-width: 1025px) {
    .filter-panel {
        min-width: 280px;
        max-width: 320px;
    }

    /* Auto-open first 3 sections on desktop */
    .filter-section:nth-child(-n+4) .filter-section-content {
        max-height: 1000px;
        padding-bottom: 0.75rem;
    }

    .filter-section:nth-child(-n+4) .filter-section-icon {
        transform: rotate(180deg);
    }
}

/* ===========================
   Animations
   Use keyframes from utilities.css: fadeIn, fadeInSimple, slideUp, slideUpFull
   =========================== */

.filter-panel.opening {
    animation: slideUpFull 0.3s ease;
}

.active-filters-display {
    animation: fadeInSimple 0.2s ease;
}

/* ===========================
   Accessibility
   =========================== */

.filter-section-header:focus,
.filter-select-all:focus,
.filter-clear:focus,
.clear-all-btn:focus,
.btn-apply-filters:focus {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

.toggle-checkbox:focus,
input[type="checkbox"]:focus {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

.range-slider:focus::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.3);
}

.range-slider:focus::-moz-range-thumb {
    box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.3);
}

/* ===========================
   Print Styles
   =========================== */

@media print {
    .filter-panel {
        display: none;
    }
}
