/* ===== WC Sidebar Filter - Main Styles ===== */

:root {
    --wsf-primary: #3498db;
    --wsf-text: #333333;
    --wsf-text-light: #666666;
    --wsf-border: #dddddd;
    --wsf-bg: #ffffff;
    --wsf-bg-hover: #f5f5f5;
    --wsf-radius: 4px;
    --wsf-transition: 0.2s ease;
}

.wsf-filter-container {
    font-size: 14px;
    line-height: 1.5;
    color: var(--wsf-text);
}

/* ===== Active Tags ===== */
.wsf-active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.wsf-active-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--wsf-bg-hover);
    border: 1px solid var(--wsf-border);
    border-radius: 20px;
    font-size: 12px;
    cursor: default;
    transition: background var(--wsf-transition);
}

.wsf-active-tag:hover {
    background: #e8e8e8;
}

.wsf-tag-remove {
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    opacity: 0.5;
    transition: opacity var(--wsf-transition);
}

.wsf-tag-remove:hover {
    opacity: 1;
    color: #e74c3c;
}

/* ===== Filter Group ===== */
.wsf-filter-group {
    margin-bottom: 20px;
    border-bottom: 1px solid var(--wsf-border);
    padding-bottom: 16px;
}

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

.wsf-filter-group.wsf--empty {
    display: none;
}

.wsf-filter-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: default;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== Accordion ===== */
.wsf--accordion .wsf-filter-title {
    cursor: pointer;
    user-select: none;
}

.wsf-filter-toggle-icon {
    display: none;
    width: 12px;
    height: 12px;
    position: relative;
    transition: transform var(--wsf-transition);
}

.wsf--accordion .wsf-filter-toggle-icon {
    display: block;
}

.wsf-filter-toggle-icon::before,
.wsf-filter-toggle-icon::after {
    content: '';
    position: absolute;
    background: var(--wsf-text-light);
    transition: transform var(--wsf-transition);
}

.wsf-filter-toggle-icon::before {
    width: 12px;
    height: 2px;
    top: 5px;
    left: 0;
}

.wsf-filter-toggle-icon::after {
    width: 2px;
    height: 12px;
    top: 0;
    left: 5px;
}

.wsf--closed .wsf-filter-toggle-icon::after {
    transform: rotate(90deg);
}

.wsf-filter-body {
    display: block;
}

.wsf--closed .wsf-filter-body {
    display: none;
}

/* ===== Checkbox List ===== */
.wsf-checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wsf-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 0;
    transition: color var(--wsf-transition);
}

.wsf-checkbox-label:hover {
    color: var(--wsf-primary);
}

.wsf-checkbox-label.wsf--disabled {
    display: none;
}

.wsf-checkbox-label.wsf--checked {
    color: var(--wsf-primary);
    font-weight: 500;
}

.wsf-checkbox-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.wsf-checkbox-box {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 2px solid var(--wsf-border);
    border-radius: var(--wsf-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--wsf-transition);
    position: relative;
}

.wsf-checkbox-box::after {
    content: '';
    position: absolute;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0);
    transition: transform 0.15s ease;
    margin-top: -1px;
}

.wsf-checkbox-input:checked + .wsf-checkbox-box {
    background-color: var(--wsf-primary);
    border-color: var(--wsf-primary);
}

.wsf-checkbox-input:checked + .wsf-checkbox-box::after {
    transform: rotate(45deg) scale(1);
}

.wsf-checkbox-text {
    flex: 1;
    font-size: 13px;
}

.wsf-checkbox-count {
    color: var(--wsf-text-light);
    font-size: 12px;
    min-width: 28px;
    text-align: right;
}

/* ===== Scrollable Lists ===== */
.wsf--scrollable {
    scrollbar-width: thin;
    scrollbar-color: var(--wsf-border) transparent;
}

.wsf--scrollable::-webkit-scrollbar {
    width: 4px;
}

.wsf--scrollable::-webkit-scrollbar-track {
    background: transparent;
}

.wsf--scrollable::-webkit-scrollbar-thumb {
    background: var(--wsf-border);
    border-radius: 4px;
}

/* ===== Color Swatches ===== */
.wsf-color-swatch-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.wsf-swatch-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    position: relative;
}

.wsf-swatch-label.wsf--disabled {
    display: none;
}

.wsf-swatch-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.wsf-swatch-color {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--wsf-border);
    transition: all var(--wsf-transition);
    background-color: #eee;
    position: relative;
}

.wsf-swatch-label:hover .wsf-swatch-color {
    transform: scale(1.1);
}

.wsf--checked .wsf-swatch-color {
    box-shadow: 0 0 0 2px var(--wsf-primary), 0 0 0 4px rgba(52, 152, 219, 0.2);
    border-color: var(--wsf-primary);
}

.wsf-swatch-color::after {
    content: '';
    position: absolute;
    width: 6px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0);
    transition: transform 0.15s ease;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.3));
}

.wsf--checked .wsf-swatch-color::after {
    transform: rotate(45deg) scale(1);
}

.wsf-swatch-text {
    font-size: 10px;
    font-weight: 600;
    color: var(--wsf-text-light);
}

.wsf-swatch-name {
    font-size: 11px;
    color: var(--wsf-text-light);
    text-align: center;
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Range Slider ===== */
.wsf-range-slider-group {
    padding: 4px 0;
}

.wsf-range-slider {
    height: 8px;
    margin: 14px 8px;
    position: relative;
    background: var(--wsf-border);
    border-radius: 4px;
}

.wsf-range-slider .noUi-target {
    border: none;
    box-shadow: none;
    background: var(--wsf-border);
    border-radius: 4px;
}

.wsf-range-slider .noUi-connect {
    background: var(--wsf-primary);
}

.wsf-range-slider .noUi-handle {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--wsf-primary);
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    cursor: pointer;
    top: -7px;
    right: -10px;
}

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

.wsf-range-slider .noUi-handle:focus {
    outline: none;
}

.wsf-range-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.wsf-range-input-wrap {
    display: flex;
    align-items: center;
    border: 1px solid var(--wsf-border);
    border-radius: var(--wsf-radius);
    overflow: hidden;
    flex: 1;
}

.wsf-range-prefix {
    padding: 6px 8px;
    background: var(--wsf-bg-hover);
    color: var(--wsf-text-light);
    font-size: 13px;
    border-right: 1px solid var(--wsf-border);
}

.wsf-range-input-min,
.wsf-range-input-max {
    width: 100%;
    border: none;
    padding: 6px 8px;
    font-size: 13px;
    outline: none;
    -moz-appearance: textfield;
}

.wsf-range-input-min::-webkit-outer-spin-button,
.wsf-range-input-min::-webkit-inner-spin-button,
.wsf-range-input-max::-webkit-outer-spin-button,
.wsf-range-input-max::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.wsf-range-separator {
    color: var(--wsf-text-light);
    font-size: 14px;
}

.wsf-range-apply {
    width: 100%;
    padding: 8px 16px;
    background: var(--wsf-primary);
    color: #fff;
    border: none;
    border-radius: var(--wsf-radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity var(--wsf-transition);
}

.wsf-range-apply:hover {
    opacity: 0.9;
}

/* ===== Star Rating ===== */
.wsf-star-rating-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.wsf-star-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 0;
    border-radius: var(--wsf-radius);
    transition: background var(--wsf-transition);
}

.wsf-star-label:hover {
    background: var(--wsf-bg-hover);
}

.wsf-star-label.wsf--active {
    font-weight: 500;
}

.wsf-star-label input {
    display: none;
}

.wsf-stars {
    display: flex;
    gap: 1px;
}

.wsf-star {
    font-size: 16px;
    color: var(--wsf-border);
    transition: color var(--wsf-transition);
}

.wsf-star--filled {
    color: #f1c40f;
}

.wsf-star-label-text {
    font-size: 13px;
    color: var(--wsf-text-light);
}

/* ===== Toggle Switch ===== */
.wsf-toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 4px 0;
}

.wsf-toggle-input {
    display: none;
}

.wsf-toggle-slider {
    width: 40px;
    height: 22px;
    background: var(--wsf-border);
    border-radius: 22px;
    position: relative;
    transition: background var(--wsf-transition);
    flex-shrink: 0;
}

.wsf-toggle-slider::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform var(--wsf-transition);
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.wsf-toggle-input:checked + .wsf-toggle-slider {
    background: var(--wsf-primary);
}

.wsf-toggle-input:checked + .wsf-toggle-slider::after {
    transform: translateX(18px);
}

.wsf-toggle-text {
    font-size: 13px;
}

/* ===== Clear All ===== */
.wsf-clear-all {
    display: block;
    margin-top: 16px;
    padding: 8px 0;
    text-align: center;
    font-size: 13px;
    color: var(--wsf-primary);
    text-decoration: none;
    border: 1px solid var(--wsf-primary);
    border-radius: var(--wsf-radius);
    transition: all var(--wsf-transition);
}

.wsf-clear-all:hover {
    background: var(--wsf-primary);
    color: #fff;
    text-decoration: none;
}

/* ===== Loading Overlay ===== */
.wsf-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.75);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    min-height: 200px;
    border-radius: var(--wsf-radius);
}

.wsf-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--wsf-border);
    border-top-color: var(--wsf-primary);
    border-radius: 50%;
    animation: wsf-spin 0.7s linear infinite;
}

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

.wsf-loading-overlay p {
    margin-top: 12px;
    font-size: 13px;
    color: var(--wsf-text-light);
}

/* ===== No Results ===== */
.wsf-no-results {
    width: 100%;
}

/* ===== Horizontal Layout ===== */
.wsf--horizontal {
    display: flex;
    flex-wrap: wrap;
    gap: 0 24px;
    align-items: flex-start;
}

.wsf--horizontal .wsf-filter-group {
    border-bottom: none;
    padding-bottom: 0;
    min-width: 180px;
}

.wsf--horizontal .wsf-active-filters {
    width: 100%;
    margin-bottom: 12px;
}

.wsf--horizontal .wsf-clear-all {
    width: 100%;
}

/* ===== Multi-Column Layout ===== */
.wsf--cols-2.wsf--vertical {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 20px;
}

.wsf--cols-3.wsf--vertical {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0 16px;
}

.wsf--cols-4.wsf--vertical {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 0 14px;
}

/* ===== Elementor Editor Placeholder ===== */
.wsf-editor-placeholder {
    background: #f7f7f7;
    border: 2px dashed #ccc;
    padding: 30px;
    text-align: center;
    border-radius: 4px;
    color: #666;
}

.wsf-editor-placeholder strong {
    display: block;
    font-size: 16px;
    margin-bottom: 8px;
}

.wsf-editor-placeholder p {
    margin: 4px 0;
    font-size: 13px;
}

/* ===== Mobile Responsive ===== */
@media (max-width: 768px) {
    .wsf--cols-2.wsf--vertical,
    .wsf--cols-3.wsf--vertical,
    .wsf--cols-4.wsf--vertical {
        grid-template-columns: 1fr 1fr;
    }

    .wsf--horizontal {
        flex-direction: column;
    }

    .wsf--horizontal .wsf-filter-group {
        width: 100%;
    }

    .wsf-color-swatch-list {
        gap: 10px;
    }

    .wsf-swatch-color {
        width: 36px;
        height: 36px;
    }
}

@media (max-width: 480px) {
    .wsf--cols-2.wsf--vertical,
    .wsf--cols-3.wsf--vertical,
    .wsf--cols-4.wsf--vertical {
        grid-template-columns: 1fr;
    }
}

/* ===== Mobile UX: Bottom Sheet Drawer ===== */
.wsf-mobile-bar,
.wsf-mobile-backdrop,
.wsf-drawer-header,
.wsf-drawer-footer {
    display: none;
}

@media (max-width: 768px) {
    body.wsf--has-mobile-bar {
        padding-bottom: 84px;
    }

    /* Floating action bar */
    .wsf-mobile-bar {
        display: flex;
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom));
        z-index: 999;
        align-items: center;
        gap: 10px;
        padding: 8px 10px 8px 8px;
        background: #ffffff;
        border: 1px solid var(--wsf-border);
        border-radius: 12px;
        box-shadow: 0 6px 22px rgba(26, 26, 26, 0.18);
    }

    .wsf-mobile-bar-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        min-height: 44px;
        padding: 0 16px;
        background: #80421D;
        color: #FCDC99;
        border: 0;
        border-radius: 8px;
        font-size: 15px;
        font-weight: 600;
        line-height: 1;
        cursor: pointer;
        white-space: nowrap;
    }

    .wsf-mobile-bar-btn:active {
        transform: scale(0.97);
    }

    .wsf-mobile-bar-info {
        flex: 1;
        min-width: 0;
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 13px;
        color: #1A1A1A;
        line-height: 1.3;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .wsf-mobile-bar-count {
        font-weight: 700;
    }

    .wsf-mobile-bar-badge {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 22px;
        height: 22px;
        padding: 0 6px;
        border-radius: 11px;
        background: #FCDC99;
        color: #80421D;
        font-size: 12px;
        font-weight: 700;
    }

    .wsf-mobile-bar-badge[hidden] {
        display: none;
    }

    /* Backdrop */
    .wsf-mobile-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 99998;
        background: rgba(26, 26, 26, 0.55);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.25s ease, visibility 0.25s ease;
    }

    .wsf-mobile-backdrop.wsf--visible {
        opacity: 1;
        visibility: visible;
    }

    body.wsf--locked {
        overflow: hidden;
    }

    /* Filter container becomes bottom sheet */
    .wsf-filter-container {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 99999;
        max-height: 85vh;
        max-height: 85dvh;
        overflow-y: auto;
        background: #ffffff;
        border-radius: 16px 16px 0 0;
        padding: 0 16px 16px;
        box-shadow: 0 -8px 30px rgba(26, 26, 26, 0.25);
        transform: translateY(105%);
        visibility: hidden;
        transition: transform 0.3s ease, visibility 0.3s ease;
        -webkit-overflow-scrolling: touch;
    }

    .wsf-filter-container.wsf--open {
        transform: translateY(0);
        visibility: visible;
    }

    /* Drawer header */
    .wsf-drawer-header {
        position: sticky;
        top: 0;
        z-index: 2;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin: 0 -16px 8px;
        padding: 14px 16px 10px;
        background: #ffffff;
        border-bottom: 1px solid var(--wsf-border);
        border-radius: 16px 16px 0 0;
    }

    .wsf-drawer-title {
        margin: 0;
        font-size: 17px;
        font-weight: 700;
        color: #1A1A1A;
    }

    .wsf-drawer-clear {
        min-height: 44px;
        padding: 0 10px;
        background: none;
        border: 0;
        color: #80421D;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
    }

    .wsf-drawer-clear:active {
        opacity: 0.6;
    }

    /* Drawer footer CTA */
    .wsf-drawer-footer {
        position: sticky;
        bottom: 0;
        z-index: 2;
        display: block;
        margin: 12px -16px -16px;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
        background: #ffffff;
        border-top: 1px solid var(--wsf-border);
    }

    .wsf-drawer-apply {
        width: 100%;
        min-height: 48px;
        background: #80421D;
        color: #FCDC99;
        border: 0;
        border-radius: 8px;
        font-size: 16px;
        font-weight: 700;
        cursor: pointer;
    }

    .wsf-drawer-apply:active {
        transform: scale(0.98);
    }

    /* All groups start collapsed on mobile */
    .wsf-filter-title {
        min-height: 44px;
        display: flex;
        align-items: center;
        cursor: pointer;
    }

    /* Touch-friendly rows */
    .wsf-checkbox-label {
        min-height: 40px;
    }

    .wsf-swatch-name {
        font-size: 13px;
    }

    /* Active tags scrollable strip inside drawer */
    .wsf-active-filters {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }

    .wsf-active-tag {
        flex-shrink: 0;
        min-height: 36px;
        align-items: center;
    }

    .wsf-tag-remove {
        min-width: 32px;
        min-height: 32px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}
