/* ============================================
   Filters Sidebar v4.0 by danIT
   ============================================ */

/* --- Hide native products-selection bar --- */
#js-product-list-top.products-selection {
    display: none !important;
}

/* --- Page header (category title) --- */
#js-product-list-header {
    margin: 24px 0 8px;
}

#js-product-list-header .page-title {
    font-weight: 300;
    font-size: clamp(28px, 4vw, 40px);
    letter-spacing: -0.02em;
    color: #222222;
    margin: 0;
    text-transform: none;
    line-height: 1.15;
}

#js-product-list-header .page-title span {
    text-decoration: none;
}

#js-product-list-header .page-title::after {
    content: "";
    display: block;
    width: 32px;
    height: 2px;
    background: #4C3CFF;
    margin-top: 12px;
}

/* --- Toolbar --- */
.fsb-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0 16px;
    margin-bottom: 24px;
}

.fsb-toolbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.fsb-toolbar-right {
    display: flex;
    align-items: center;
}

.fsb-hidden { display: none !important; }

/* --- Sort / per-page selects --- */
.fsb-sort-select {
    padding: 8px 32px 8px 12px;
    font-size: 13px;
    font-weight: 500;
    color: #222222;
    background-color: #fff;
    border: 1px solid #E7E7E7;
    border-radius: 8px;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7'%3E%3Cpath fill='none' stroke='%23222222' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 11px;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
    line-height: 1.4;
}

.fsb-sort-select:hover { background-color: #E7E7E7; }
.fsb-sort-select:focus { border-color: #4C3CFF; outline: none; box-shadow: 0 0 0 2px rgba(76, 60, 255, 0.15); }

.fsb-item-count { font-size: 13px; color: #666; white-space: nowrap; }

/* --- Filter button --- */
.fsb-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border: 1px solid #E7E7E7;
    border-radius: 8px;
    background: #fff;
    color: #222222;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.18s, color 0.18s, background-color 0.18s;
    user-select: none;
    white-space: nowrap;
}

.fsb-filter-btn:hover { border-color: #4C3CFF; color: #4C3CFF; }
.fsb-filter-btn.active { background: #4C3CFF; border-color: #4C3CFF; color: #fff; }

.fsb-filter-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
    background: #4C3CFF; color: #fff; font-size: 11px; font-weight: 700; margin-left: 2px;
}

.fsb-filter-btn.active .fsb-filter-count { background: #fff; color: #4C3CFF; }

/* ============================================
   Sidebar overlay + panel
   ============================================ */
.fsb-sidebar-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.4);
    z-index: 99998; opacity: 0; visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}
.fsb-sidebar-overlay.open { opacity: 1; visibility: visible; }

.fsb-sidebar {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: 400px; max-width: 90vw; background: #fff;
    z-index: 99999; transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex; flex-direction: column;
    box-shadow: -4px 0 24px rgba(0,0,0,0.12);
}
.fsb-sidebar.open { transform: translateX(0); }

.fsb-sidebar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 20px; border-bottom: 1px solid #E7E7E7; flex-shrink: 0;
}

.fsb-sidebar-title { font-size: 16px; font-weight: 700; color: #4C3CFF; margin: 0; }

.fsb-sidebar-close {
    background: #E7E7E7; border: none; width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px; cursor: pointer; transition: all 0.15s;
    color: #666; font-size: 20px; line-height: 1;
}
.fsb-sidebar-close:hover { background: #4C3CFF; color: #fff; }

.fsb-sidebar-body {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    padding: 0; -webkit-overflow-scrolling: touch; position: relative;
}
.fsb-sidebar-body::-webkit-scrollbar { width: 5px; }
.fsb-sidebar-body::-webkit-scrollbar-thumb { background: #E7E7E7; border-radius: 3px; }

body.fsb-sidebar-open { overflow: hidden; }

/* ============================================
   Sidebar Footer — Apply / Reset buttons
   ============================================ */
.fsb-sidebar-footer {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid #E7E7E7;
    flex-shrink: 0;
    background: #fff;
}

.fsb-apply-btn {
    flex: 2;
    padding: 12px 20px;
    background: #4C3CFF;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s;
}

.fsb-apply-btn:hover {
    background: #87A1FF;
}

.fsb-reset-btn {
    flex: 1;
    padding: 12px 16px;
    background: #fff;
    color: #4C3CFF;
    border: 1.5px solid #E7E7E7;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.18s;
}

.fsb-reset-btn:hover {
    border-color: #4C3CFF;
    background: #E7E7E7;
}

/* ============================================
   Native PrestaShop filters inside sidebar
   ============================================ */

/* Hide mobile filter controls (we have our own Apply/Reset) */
.fsb-sidebar-body #search_filter_controls {
    display: none !important;
}

/* Make the filter wrapper fill the sidebar */
.fsb-sidebar-body #search_filters_wrapper,
.fsb-sidebar-body #facets_search_center,
.fsb-sidebar-body #facets_search_wrapper,
.fsb-sidebar-body .block-facets {
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    margin: 0 !important;
    padding: 0 !important;
}

.fsb-sidebar-body #search_filters {
    padding: 0 4px;
}

/* Facet sections (accordion) */
.fsb-sidebar-body .facet {
    border-bottom: 1px solid #E7E7E7;
    padding: 0;
}

.fsb-sidebar-body .facet:last-child {
    border-bottom: none;
}

.fsb-sidebar-body .facet-title,
.fsb-sidebar-body .block-title {
    font-size: 14px;
    font-weight: 600;
    color: #4C3CFF;
    margin: 0;
    padding: 16px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    transition: background 0.15s;
}

.fsb-sidebar-body .facet-title:hover,
.fsb-sidebar-body .block-title:hover {
    background: #F0EEFF;
}

.fsb-sidebar-body .facet-title::after,
.fsb-sidebar-body .block-title::after {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-right: 2px solid #4C3CFF;
    border-bottom: 2px solid #4C3CFF;
    transform: rotate(45deg);
    transition: transform 0.25s ease;
    flex-shrink: 0;
    margin-left: 12px;
}

.fsb-sidebar-body .facet-title.fsb-accordion-open::after,
.fsb-sidebar-body .block-title.fsb-accordion-open::after {
    transform: rotate(-135deg);
}

/* Accordion content wrapper */
.fsb-accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.fsb-accordion-content.fsb-accordion-open {
    max-height: 600px;
}

.fsb-accordion-content-inner {
    padding: 4px 20px 16px 20px;
}

/* Facet checkbox/radio lists */
.fsb-sidebar-body .facet ul {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 280px;
    overflow-y: auto;
}

.fsb-sidebar-body .facet ul::-webkit-scrollbar { width: 4px; }
.fsb-sidebar-body .facet ul::-webkit-scrollbar-thumb { background: #E7E7E7; border-radius: 2px; }

.fsb-sidebar-body .facet li {
    padding: 2px 0;
}

/* Brand-hierarchy: models indented under their parent brand */
.fsb-sidebar-body .facet li.fsb-facet-child .facet-label {
    padding-left: 26px;
    position: relative;
}

.fsb-sidebar-body .facet li.fsb-facet-child .facet-label::before {
    content: '';
    position: absolute;
    left: 12px;
    top: 50%;
    width: 7px;
    height: 1px;
    background: #C9C9C9;
}

.fsb-sidebar-body .facet-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 6px;
    transition: background 0.1s;
    font-size: 14px;
    color: #222222;
    margin: 0;
}

.fsb-sidebar-body .facet-label:hover {
    background: #E7E7E7;
}

/* Custom checkbox inside sidebar */
.fsb-sidebar-body .custom-checkbox {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.fsb-sidebar-body .custom-checkbox input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.fsb-sidebar-body .custom-checkbox .ps-shown-by-js {
    width: 18px;
    height: 18px;
    border: 1.5px solid #E7E7E7;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    transition: all 0.15s;
}

.fsb-sidebar-body .custom-checkbox input[type="checkbox"]:checked + .ps-shown-by-js {
    background: #4C3CFF;
    border-color: #4C3CFF;
}

.fsb-sidebar-body .custom-checkbox .ps-shown-by-js i {
    display: none;
    color: #fff;
    font-size: 10px;
}

.fsb-sidebar-body .custom-checkbox input[type="checkbox"]:checked + .ps-shown-by-js i {
    display: block;
}

/* Search link styling inside sidebar */
.fsb-sidebar-body a.search-link,
.fsb-sidebar-body a.js-search-link {
    color: #222222;
    text-decoration: none;
    flex: 1;
    font-size: 14px;
}

/* Magnitude counts */
.fsb-sidebar-body .magnitude {
    color: #999;
    font-size: 12px;
    margin-left: 2px;
}

/* Color swatches */
.fsb-sidebar-body .facet .color {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid #E7E7E7;
    display: inline-block;
    transition: border-color 0.15s;
}

.fsb-sidebar-body .facet input:checked ~ .color,
.fsb-sidebar-body .facet .facet-label.active .color {
    border-color: #4C3CFF;
    box-shadow: 0 0 0 2px #4C3CFF;
}

/* ============================================
   Active filters bar
   ============================================ */
#js-active-search-filters, .active_filters { margin-bottom: 14px; }

#active-search-filters {
    display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
}
#active-search-filters .active-filter-title {
    font-size: 12px; font-weight: 600; color: #999;
    text-transform: uppercase; letter-spacing: 0.5px; margin-right: 4px;
}
#active-search-filters .filter-blocks {
    display: flex; flex-wrap: wrap; gap: 6px;
    list-style: none; margin: 0; padding: 0;
}
#active-search-filters .filter-block a,
#active-search-filters .filter-block a.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; font-size: 12px; font-weight: 500;
    color: #222222; background: #E7E7E7; border: 1px solid #E7E7E7;
    border-radius: 6px; text-decoration: none; transition: all 0.15s;
}
#active-search-filters .filter-block a:hover { background: #4C3CFF; color: #fff; border-color: #4C3CFF; }
#active-search-filters .filter-block a i { font-size: 10px; opacity: 0.6; }
#active-search-filters .filter-block a:hover i { opacity: 1; }
#active-search-filters .filter-block-all a { color: #999; background: transparent; border: 1px dashed #E7E7E7; }
#active-search-filters .filter-block-all a:hover { color: #fff; background: #4C3CFF; border-color: #4C3CFF; border-style: solid; }

/* ============================================
   Overrides: black facet headings + clearer hierarchy
   ============================================ */

/* Facet headings in black instead of blue */
.fsb-sidebar-body .facet-title,
.fsb-sidebar-body .block-title {
    color: #222222;
}

/* Accordion arrow in black to match */
.fsb-sidebar-body .facet-title::after,
.fsb-sidebar-body .block-title::after {
    border-right-color: #222222;
    border-bottom-color: #222222;
}

/* Show the full models hierarchy: drop the inner scroll so indented
   children are never separated from their parent brand */
.fsb-sidebar-body .facet ul {
    max-height: none;
    overflow: visible;
}
.fsb-accordion-content.fsb-accordion-open {
    max-height: 1200px;
}

/* Parent brand rows: bolder so the grouping reads clearly */
.fsb-sidebar-body .facet li.fsb-facet-parent > .facet-label {
    font-weight: 700;
}

/* Indented model rows under their brand */
.fsb-sidebar-body .facet li.fsb-facet-child .facet-label {
    padding-left: 30px;
}
.fsb-sidebar-body .facet li.fsb-facet-child .facet-label::before {
    left: 14px;
    background: #B9B9B9;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 767px) {
    .fsb-toolbar { padding: 8px 0; gap: 8px; }
    .fsb-sort-select { font-size: 12px; padding: 8px 30px 8px 10px; }
    .fsb-filter-btn { padding: 8px 14px; font-size: 12px; }
    .fsb-item-count { display: none; }
    .fsb-sidebar { width: 100% !important; max-width: 100vw; }
    #active-search-filters { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 600px) {
    .fsb-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .fsb-toolbar-right { align-self: flex-end; }
}
