/* Vesa WooCommerce Filters
 * Custom styling for filter bar, swatches, pills, range slider.
 * Pairs with assets/js/woo-filters.js + noUiSlider.
 */

.vesa-woo-filters .vesa-filter-type,
.vesa-woo-filters .vesa-filter-type.recommended-filter {
    justify-content: center;
}

/* Each filter type is the anchor for its absolutely-positioned dropdown */
.vesa-woo-filters .vesa-filter-type {
    position: relative;
}

/* Desktop dropdown panels — hidden by default, shown via .active on parent */
.vesa-woo-filters .vesa-filter-type .filter-options {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    border: 1px solid #ececec;
    box-shadow: 0 12px 28px rgba(0, 0, 0, .08);
    z-index: 50;
    box-sizing: border-box;
}

/* Pills panels — flex wrap */
.vesa-woo-filters .vesa-filter-type.active > .filter-options.sizes,
.vesa-woo-filters .vesa-filter-type.active > .filter-options.categories,
.vesa-woo-filters .vesa-filter-type.active > .filter-options.material {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 14px;
    max-height: 320px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.vesa-woo-filters .vesa-filter-type .filter-options.sizes,
.vesa-woo-filters .vesa-filter-type .filter-options.material {
    min-width: 320px;
    max-width: 420px;
}

.vesa-woo-filters .vesa-filter-type .filter-options.categories {
    min-width: 380px;
    max-width: 480px;
}

/* Price panel */
.vesa-woo-filters .vesa-filter-type.active > .filter-options.prices {
    display: block;
    min-width: 280px;
    padding: 14px;
}

.vesa-woo-filters .vesa-filter-type .filter-options.prices {
    min-width: 280px;
}

/* Sort panel (right-aligned) */
.vesa-woo-filters .vesa-filter-type.active > .filter-options.recommended {
    display: block;
    min-width: 220px;
    max-height: 320px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 6px 0;
}

.vesa-woo-filters .vesa-filter-type.recommended-filter .filter-options.recommended {
    left: auto;
    right: 0;
    min-width: 220px;
}

.vesa-woo-filters .filter-options::-webkit-scrollbar {
    width: 6px;
}

.vesa-woo-filters .filter-options::-webkit-scrollbar-track {
    background: transparent;
}

.vesa-woo-filters .filter-options::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.vesa-woo-filters .filter-options::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Generic filter option */
.dropdown-filter-option {
    cursor: pointer;
    user-select: none;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.dropdown-filter-option.selected {
    border-color: #111;
}

/* Size pills */
.size-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 36px;
    padding: 0 14px;
    margin: 0;
    border: 1px solid #d0d0d0;
    border-radius: 2px;
    background: #fff;
    color: #6d6d6d;
    font-size: 13px;
    line-height: 1;
    text-transform: uppercase;
    transition: border-color .18s ease, color .18s ease, box-shadow .18s ease;
}

.size-pill:hover {
    border-color: #111;
    color: #111;
}

.size-pill.selected {
    border-color: #2563eb;
    color: #111;
    font-weight: 600;
    box-shadow: inset 0 0 0 1px #2563eb;
}

/* Color pills — text-only, identical to size pills */
.color-swatch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 36px;
    padding: 0 14px;
    margin: 0;
    border: 1px solid #d0d0d0;
    border-radius: 2px;
    background: #fff;
    font-size: 15px;
    line-height: 1;
    text-transform: uppercase;
    transition: border-color .18s ease, color .18s ease, box-shadow .18s ease;
}

.color-swatch .swatch-label {
    color: #6d6d6d;
    transition: color .18s ease;
}

.color-swatch:hover {
    border-color: #111;
}

.color-swatch:hover .swatch-label {
    color: #111;
}

.color-swatch.selected {
    border-color: #2563eb;
    box-shadow: inset 0 0 0 1px #2563eb;
}

.color-swatch.selected .swatch-label {
    color: #111;
    font-weight: 600;
}

/* Material pills — same box shape as size pills */
.material-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 36px;
    padding: 0 14px;
    margin: 0;
    border: 1px solid #d0d0d0;
    border-radius: 2px;
    background: #fff;
    font-size: 13px;
    line-height: 1;
    text-transform: uppercase;
    cursor: pointer;
    transition: border-color .18s ease, color .18s ease, box-shadow .18s ease;
}

.material-check .checkbox-label {
    color: #6d6d6d;
    transition: color .18s ease;
}

.material-check:hover {
    border-color: #111;
}

.material-check:hover .checkbox-label {
    color: #111;
}

.material-check.selected {
    border-color: #2563eb;
    box-shadow: inset 0 0 0 1px #2563eb;
}

.material-check.selected .checkbox-label {
    color: #111;
    font-weight: 600;
}

/* Sort options */
.filter-options.recommended .dropdown-filter-option {
    display: block;
    padding: 6px 0;
    font-size: 14px;
    color: #333;
}

.filter-options.recommended .dropdown-filter-option:hover,
.filter-options.recommended .dropdown-filter-option.selected {
    color: #111;
    font-weight: 600;
}

/* Price slider */
.slider-wrapper.vesa {
    padding: 16px 12px 8px;
    min-width: 240px;
}

.slider-wrapper.vesa .price-inputs {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 14px;
}

.slider-wrapper.vesa .min-price,
.slider-wrapper.vesa .max-price {
    width: 100%;
    max-width: 90px;
    height: 32px;
    padding: 4px 8px;
    border: 1px solid #d8d8d8;
    border-radius: 2px;
    font-size: 13px;
    text-align: center;
}

.slider-wrapper.vesa .sep {
    color: #999;
}

#price-range-select {
    display: inline-block;
    margin-top: 14px;
    padding: 8px 16px;
    background: #111;
    color: #fff;
    border-radius: 2px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .04em;
    cursor: pointer;
}

#price-range-select:hover {
    background: #333;
}

/* noUiSlider custom skin */
.vesa-range-slider.noUi-target {
    height: 4px;
    border: none;
    box-shadow: none;
    background: #e6e6e6;
    border-radius: 2px;
}

.vesa-range-slider .noUi-connect {
    background: #111;
}

.vesa-range-slider .noUi-handle {
    width: 16px;
    height: 16px;
    top: -7px;
    right: -8px !important;
    border-radius: 50%;
    border: 1px solid #111;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .15);
    cursor: grab;
}

.vesa-range-slider .noUi-handle:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(17, 17, 17, .2);
}

.vesa-range-slider .noUi-handle::before,
.vesa-range-slider .noUi-handle::after {
    display: none;
}

/* AJAX loader */
.vesa-ajax-progress {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, .6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.v-ajax-loader {
    width: 22px;
    height: 22px;
    border: 2px solid #ccc;
    border-top-color: #111;
    border-radius: 50%;
    animation: vesa-spin .8s linear infinite;
}

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

.dropdown-filter-option.disabled,
.apply-filters.disabled,
#price-range-select.disabled {
    opacity: .6;
    pointer-events: none;
}

/* Mobile trigger button — hidden on desktop, shown on mobile */
.vesa-filter-type.mobile {
    display: none;
}

/* ═════════════════════════════════════════════════════════
   MOBILE FILTER (≤990px)
   - Bar shows two buttons: Filters + Sort
   - "Filters" opens a fullscreen drawer (.filter-mobile-window)
   - Sort uses inline accordion expand
   ═════════════════════════════════════════════════════════ */
@media (max-width: 990px) {
    .vesa-woo-filters-wrapper {
        margin: 16px 0;
    }

    .vesa-woo-filters-holder {
        padding: 0 16px;
    }

    .vesa-woo-filters {
        display: flex;
        align-items: stretch;
        gap: 0;
        border-top: 1px solid #ececec;
        border-bottom: 1px solid #ececec;
        background: #fff;
    }

    /* Mobile "Filters" trigger — matches the desktop filter-header look */
    .vesa-filter-type.mobile {
        display: flex;
        flex: 1;
        align-items: center;
        justify-content: center;
        height: 48px;
        background: transparent;
        border-right: 1px solid #ececec;
        cursor: pointer;
        transition: background .15s ease;
    }

    .vesa-filter-type.mobile:hover {
        background: #fafafa;
    }

    .vesa-filter-type.mobile .filter-header {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
    }

    .vesa-filter-type.mobile .label {
        font-size: 13px;
        font-weight: 500;
        text-transform: uppercase;
        color: #1a1a1a;
    }

    .vesa-filter-type.mobile .mega-indicator {
        display: inline-flex;
        align-items: center;
        color: #555;
    }

    /* Hide the inline .vesa-filters-group from the bar — JS moves it to the drawer */
    .vesa-woo-filters > .vesa-filters-group {
        display: none;
    }

    /* Sort button on the mobile bar — same look as Filters */
    .vesa-woo-filters > .vesa-filter-type.recommended-filter {
        flex: 1;
        position: relative;
        height: 48px;
        background: transparent;
        cursor: pointer;
        transition: background .15s ease;
    }

    .vesa-woo-filters > .vesa-filter-type.recommended-filter:hover {
        background: #fafafa;
    }

    .vesa-woo-filters > .vesa-filter-type.recommended-filter > .filter-header {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        height: 100%;
        padding: 0 14px;
    }

    .vesa-woo-filters > .vesa-filter-type.recommended-filter .label {
        font-size: 13px;
        font-weight: 500;
        text-transform: uppercase;
        color: #1a1a1a;
    }

    .vesa-woo-filters > .vesa-filter-type.recommended-filter .mega-indicator {
        display: inline-flex;
        align-items: center;
        color: #555;
        transition: transform .2s ease;
    }

    .vesa-woo-filters > .vesa-filter-type.recommended-filter.active .mega-indicator {
        transform: rotate(180deg);
    }

    /* Sort options as a clean dropdown panel matching desktop look */
    .vesa-woo-filters > .vesa-filter-type.recommended-filter > .filter-options {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        max-height: 0;
        overflow: hidden;
        padding: 0;
        background: #fff;
        border: 1px solid #ececec;
        border-top: 0;
        box-shadow: 0 12px 28px rgba(0, 0, 0, .08);
        transition: max-height .22s ease, padding .22s ease;
        z-index: 50;
    }

    .vesa-woo-filters > .vesa-filter-type.recommended-filter.active > .filter-options {
        max-height: 320px;
        padding: 6px 0;
        overflow-y: auto;
    }

    .vesa-woo-filters > .vesa-filter-type.recommended-filter .filter-options.recommended .dropdown-filter-option {
        display: block;
        padding: 12px 20px;
        font-size: 14px;
        font-weight: 400;
        color: #444;
        text-transform: none;
        cursor: pointer;
        transition: background .12s ease, color .12s ease;
    }

    .vesa-woo-filters > .vesa-filter-type.recommended-filter .filter-options.recommended .dropdown-filter-option:hover {
        background: #fafafa;
        color: #1a1a1a;
    }

    .vesa-woo-filters > .vesa-filter-type.recommended-filter .filter-options.recommended .dropdown-filter-option.selected {
        background: #fafafa;
        color: #1a1a1a;
        font-weight: 600;
        position: relative;
    }

    .vesa-woo-filters > .vesa-filter-type.recommended-filter .filter-options.recommended .dropdown-filter-option.selected::before {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 3px;
        background: #2563eb;
    }

    /* ─── Drawer: parent acts as full-viewport backdrop,
              the .vesa-filters-group inside is the sliding panel ─── */
    .filter-mobile-window {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .45);
        opacity: 0;
        visibility: hidden;
        transition: opacity .25s ease, visibility 0s linear .25s;
        z-index: 9998;
        display: flex;
        justify-content: flex-end;
        overflow: hidden;
        pointer-events: none;
    }

    .filter-mobile-window.active {
        opacity: 1;
        visibility: visible;
        transition: opacity .25s ease;
        pointer-events: auto;
    }

    /* The actual sliding panel */
    .filter-mobile-window > .vesa-filters-group {
        position: relative;
        width: min(420px, 100%);
        height: 100%;
        background: #fff;
        box-shadow: -16px 0 40px rgba(0, 0, 0, .12);
        transform: translateX(100%);
        transition: transform .3s cubic-bezier(.2, .8, .2, 1);
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        overscroll-behavior: contain;
        padding-bottom: 88px;
    }

    .filter-mobile-window.active > .vesa-filters-group {
        transform: translateX(0);
    }

    /* Typography reset inside the drawer (won't inherit oversized site headings) */
    .filter-mobile-window,
    .filter-mobile-window * {
        box-sizing: border-box;
        font-family: inherit;
    }


    /* ─ Header (sticky title + close X) ─ */
    .filter-mobile-window .group-header {
        position: sticky;
        top: 0;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 16px;
        height: 56px;
        background: #fff;
        border-bottom: 1px solid #ececec;
        flex-shrink: 0;
        z-index: 3;
    }

    .filter-mobile-window .group-header > .label {
        font-size: 14px;
        font-weight: 600;
        text-transform: uppercase;
        color: #1a1a1a;
        line-height: 1;
    }

    .filter-mobile-window .filters-actions,
    .filter-mobile-window .filters-actions[data-active-filters="true"] {
        display: flex !important;
        align-items: center;
        gap: 4px;
    }

    /* Close X — always visible, regardless of data-active-filters state */
    .filter-mobile-window .close-indicator,
    .filter-mobile-window .filters-actions[data-active-filters="true"] .close-indicator,
    .filter-mobile-window .filters-actions[data-active-filters="false"] .close-indicator {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        position: relative;
        width: 40px;
        height: 40px;
        flex-shrink: 0;
        cursor: pointer;
        border-radius: 50%;
        background: transparent;
        color: #1a1a1a;
        transition: background .15s ease, transform .2s ease;
    }

    .filter-mobile-window .close-indicator:hover {
        background: #f0f0f0;
        transform: rotate(90deg);
    }

    .filter-mobile-window .close-indicator::before,
    .filter-mobile-window .close-indicator::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 20px;
        height: 2px;
        background: currentColor;
        border-radius: 1px;
    }

    .filter-mobile-window .close-indicator::before {
        transform: translate(-50%, -50%) rotate(45deg);
    }

    .filter-mobile-window .close-indicator::after {
        transform: translate(-50%, -50%) rotate(-45deg);
    }

    /* Apply button — moved by JS to be a direct child of .filter-mobile-window
       so position:absolute is anchored to the non-transformed drawer wrapper.
       Stays pinned at viewport bottom regardless of panel scroll. */
    .filter-mobile-window > #vesa-apply-filters {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        position: absolute;
        right: 0;
        bottom: 0;
        width: min(420px, 100%);
        height: 56px;
        background: #1a1a1a;
        color: #fff;
        border-radius: 0;
        font-size: 13px;
        font-weight: 600;
        text-transform: uppercase;
        cursor: pointer;
        z-index: 5;
        box-shadow: 0 -8px 24px rgba(0, 0, 0, .12);
        transform: translateX(100%);
        transition: transform .3s cubic-bezier(.2, .8, .2, 1);
    }

    .filter-mobile-window.active > #vesa-apply-filters {
        transform: translateX(0);
    }

    .filter-mobile-window > #vesa-apply-filters .mega-indicator {
        display: inline-flex;
    }

    /* When Apply still lives inside the header markup (transient state before JS
       moves it), keep it hidden visually so it doesn't appear in the header. */
    .filter-mobile-window .filters-actions > #vesa-apply-filters {
        display: none;
    }

    /* ─ Selected filters chips (above accordions, BELOW the sticky header) ─ */
    .filter-mobile-window .group-filters-mobile {
        flex-shrink: 0;
        padding: 12px 16px;
        border-bottom: 1px solid #ececec;
        background: #fafafa;
        position: relative;
        z-index: 1; /* must stay below the sticky group-header (z-index: 3) */
    }

    .filter-mobile-window .group-filters-mobile.empty,
    .filter-mobile-window .group-filters-mobile .box-select-wrapper.empty {
        display: none;
    }

    .filter-mobile-window .group-filters-mobile .box-select-wrapper {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 6px;
    }

    .filter-mobile-window .box-attr-term {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 4px 10px;
        margin: 0 6px 6px 0;
        background: #fff;
        border: 1px solid #d8d8d8;
        border-radius: 2px;
        font-size: 11px;
        color: #1a1a1a;
        cursor: pointer;
    }

    .filter-mobile-window .box-attr-term .label {
        font-size: 11px;
        line-height: 1;
    }

    .filter-mobile-window .box-attr-term .icon-remove {
        position: relative;
        width: 10px;
        height: 10px;
    }

    .filter-mobile-window .box-attr-term .icon-remove::before,
    .filter-mobile-window .box-attr-term .icon-remove::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 10px;
        height: 1px;
        background: #555;
    }

    .filter-mobile-window .box-attr-term .icon-remove::before {
        transform: translate(-50%, -50%) rotate(45deg);
    }

    .filter-mobile-window .box-attr-term .icon-remove::after {
        transform: translate(-50%, -50%) rotate(-45deg);
    }

    .filter-mobile-window .box-attr-term.all {
        background: transparent;
        border-color: transparent;
        color: #214af1;
        text-decoration: underline;
        padding: 4px 0;
        margin: 0;
        font-size: 11px;
    }

    /* ─ Filter accordions ─ */
    .filter-mobile-window .vesa-filter-type {
        flex-shrink: 0;
        border-bottom: 1px solid #ececec;
    }

    .filter-mobile-window .vesa-filter-type .filter-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 14px 16px;
        cursor: pointer;
        background: #fff;
        transition: background .15s ease;
    }

    .filter-mobile-window .vesa-filter-type .filter-header .label {
        font-size: 13px;
        font-weight: 500;
        text-transform: uppercase;
        line-height: 1;
        color: #1a1a1a;
    }

    .filter-mobile-window .vesa-filter-type .filter-header:hover {
        background: #fafafa;
    }

    .filter-mobile-window .vesa-filter-type .mega-indicator {
        display: inline-flex;
        align-items: center;
        transition: transform .25s ease;
        color: #555;
    }

    .filter-mobile-window .vesa-filter-type.active > .filter-header .mega-indicator {
        transform: rotate(180deg);
    }

    .filter-mobile-window .filter-options {
        display: none;
        padding: 12px 16px 16px;
        background: #fafafa;
        max-height: none;
        overflow: visible;
    }

    .filter-mobile-window .vesa-filter-type.active > .filter-options {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }

    .filter-mobile-window .vesa-filter-type.active > .filter-options.prices {
        display: block;
    }

    /* Compact pills inside drawer */
    .filter-mobile-window .size-pill,
    .filter-mobile-window .color-swatch,
    .filter-mobile-window .material-check {
        height: 32px;
        min-width: 38px;
        padding: 0 10px;
        margin: 0;
        font-size: 12px;
    }

    .filter-mobile-window .slider-wrapper.vesa {
        min-width: 0;
        padding: 4px 0 8px;
    }

    .filter-mobile-window #price-range-select {
        width: 100%;
        text-align: center;
    }

    /* Desktop max-heights are noise on mobile (drawer manages scroll) */
    .vesa-woo-filters .filter-options.sizes,
    .vesa-woo-filters .filter-options.categories,
    .vesa-woo-filters .filter-options.material {
        max-height: none;
        padding-right: 0;
    }
}
