/* ===== Category Header (inside desktop-sort-bar) ===== */

.category-header {
    display: none;
}

/* ===== Sort & Filter ===== */

/* Sort dropdown (shared between mobile panel and desktop bar) */
.sort-dropdown {
    width: 100%;
    padding: 10px 32px 10px 12px;
    font-size: 14px;
    font-weight: 500;
    color: #111827;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234b5563' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: background-color 0.15s;
}

.sort-dropdown:hover,
.sort-dropdown:focus {
    outline: none;
    background: #e5e7eb;
}

/* Filter icon button (in mobile top bar) */
.filter-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 0.5rem;
    background: transparent;
    color: #0284c7;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.filter-icon-btn:hover {
    background: #f3f4f6;
}

.filter-icon-btn.active {
    color: #0369a1;
}

.filter-icon-btn svg {
    width: 28px;
    height: 28px;
}

.filter-badge {
    display: none;
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: 9999px;
    font-size: 10px;
    font-weight: 700;
    background: #0284c7;
    color: #fff;
}

.filter-badge.visible {
    display: block;
}

/* Mobile sort dropdown inside filter panel */
.filter-panel-sort {
    border: 1px solid #e5e7eb;
}

/* ===== Filter Side Panel (mobile) ===== */

.filter-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1999;
}

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

.filter-panel {
    position: fixed;
    top: 0;
    right: -320px;
    width: 300px;
    height: 100%;
    background: #fff;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    z-index: 2000;
    transition: right 0.25s ease;
    display: flex;
    flex-direction: column;
}

.filter-panel.open {
    right: 0;
}

.filter-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
}

.filter-panel-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

.filter-panel-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #6b7280;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.filter-panel-close:hover {
    color: #111827;
}

.filter-panel-body {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.filter-section h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: #111827;
}

/* Price range */
.price-range-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
}

.price-range-field {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 14px;
    color: #111827;
    background: #fff;
    transition: border-color 0.2s;
    min-width: 0;
}

.price-range-field:focus {
    outline: none;
    border-color: #0ea5e9;
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.2);
}

.price-range-field::placeholder {
    color: #9ca3af;
}

.price-range-sep {
    color: #9ca3af;
    font-size: 16px;
    flex-shrink: 0;
}

/* Filter panel actions */
.filter-panel-actions {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid #e5e7eb;
}

.filter-clear-btn {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    background: #fff;
    color: #6b7280;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.filter-clear-btn:hover {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #dc2626;
}

/* ===== Sort Option Buttons ===== */
.sort-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.sort-option {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: 0.5rem;
    background: #f3f4f6;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.sort-option:hover {
    background: #e5e7eb;
    color: #111827;
}

.sort-option:active {
    background: #e5e7eb;
}

/* Selected states */
.sort-option[data-selected="1"] {
    background: #0284c7;
    color: #fff;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
}


/* ===== Brand multi-select dropdown ===== */
.brand-multi-select {
    position: relative;
    display: inline-block;
}

.brand-multi-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    background: #f3f4f6;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s, color 0.15s;
}

.brand-multi-btn:hover,
.brand-multi-btn:focus {
    outline: none;
    background: #e5e7eb;
}

.brand-multi-btn.active {
    background: #0284c7;
    color: #fff;
}

.brand-multi-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 170px;
    max-height: 240px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    z-index: 200;
    padding: 4px 0;
}

.brand-multi-dropdown.open {
    display: block;
}

.brand-multi-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
    transition: background 0.1s;
}

.brand-multi-option:hover {
    background: #f3f4f6;
}

.brand-multi-option input[type="checkbox"] {
    accent-color: #0284c7;
    width: 15px;
    height: 15px;
    cursor: pointer;
    flex-shrink: 0;
}

/* Mobile brand checkbox list */
.brand-checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.brand-checkbox-list .brand-multi-option {
    padding: 8px 4px;
    font-size: 14px;
}

/* ===== Desktop Sort/Filter Bar (≥48em) ===== */
.desktop-sort-bar {
    display: none;
}

@media (min-width: 48em) {
    .desktop-sort-bar {
        display: flex;
        flex-direction: column;
        background: #fff;
        position: sticky;
        top: 0;
        z-index: 100;
        width: 100%;
        box-sizing: border-box;
        border-bottom: 1px solid #e5e7eb;
        margin-bottom: 1.25rem;
    }

    .desktop-sort-bar .category-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1.5rem;
        padding: 0.75rem 1.25rem;
    }

    .category-header-title {
        font-size: 1.5rem;
        font-weight: 700;
        color: #111827;
        margin: 0;
        line-height: 1.2;
    }

    .category-header-desc {
        margin: 0.25rem 0 0;
        font-size: 0.875rem;
        color: #6b7280;
    }

    .category-header-btn {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.625rem 1.25rem;
        background: #0284c7;
        color: #fff;
        border: none;
        border-radius: 9999px;
        font-size: 0.875rem;
        font-weight: 600;
        text-decoration: none;
        white-space: nowrap;
        cursor: pointer;
        transition: all 0.2s;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    }

    .category-header-btn:hover {
        background: #0369a1;
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
        color: #fff;
    }

    .category-header-btn svg {
        width: 1.125rem;
        height: 1.125rem;
    }

    .desktop-sort-controls {
        display: flex;
        align-items: center;
        gap: 16px;
        padding: 10px 20px;
        border-top: 1px solid #e5e7eb;
        flex-wrap: wrap;
    }

    .desktop-sort-bar .filter-section {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .desktop-sort-bar .filter-section h4 {
        margin: 0;
        white-space: nowrap;
        font-size: 13px;
        color: #6b7280;
    }

    .desktop-sort-bar .sort-options {
        flex-wrap: nowrap;
    }

    .desktop-sort-bar .sort-option {
        padding: 6px 12px;
        font-size: 13px;
    }

    .desktop-filter-section {
        flex: 1;
        display: flex;
        justify-content: flex-end;
    }

    .desktop-price-range {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .desktop-filter-label {
        font-size: 13px;
        font-weight: 600;
        color: #6b7280;
        white-space: nowrap;
    }

    .desktop-price-range .price-range-field {
        width: 80px;
        padding: 6px 10px;
        font-size: 13px;
    }

    .desktop-price-range .price-range-sep {
        font-size: 14px;
    }

    .desktop-clear-btn {
        flex: none;
        padding: 6px 14px;
        font-size: 13px;
    }

    /* Hide filter icon button on desktop */
    .filter-icon-btn {
        display: none;
    }

}

/* ===== Mobile (<48em) ===== */
@media (max-width: 47.99em) {
    .desktop-sort-bar {
        display: none;
    }

    .filter-panel {
        width: 280px;
        right: -280px;
    }

    /* Shift with sidebar */
    #layout.active ~ .filter-overlay,
    #layout.active ~ .filter-panel {
        left: 250px;
    }
}

@media (max-width: 480px) {
    .filter-panel {
        width: 260px;
        right: -260px;
    }

    #layout.active ~ .filter-overlay,
    #layout.active ~ .filter-panel {
        left: 230px;
    }
}
