/* ═══════════════════════════════════════════════════════════
   Shop Sidebar Filters
   ═══════════════════════════════════════════════════════════ */

/* ── Layout: sidebar + products ── */
.smfs-shop-wrapper {
    display: grid !important;
    grid-template-columns: 260px 1fr !important;
    gap: 30px !important;
    align-items: start;
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
}

.smfs-shop-wrapper *,
.smfs-shop-wrapper *::before,
.smfs-shop-wrapper *::after {
    box-sizing: border-box;
}

.smfs-products-area {
    min-width: 0;
    max-width: 100%;
}

/* ── Sidebar ── */
.smfs-shop-sidebar {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 14px;
    padding: 20px;
    position: sticky;
    top: 100px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #c8c8c8 transparent;
}

.smfs-shop-sidebar::-webkit-scrollbar {
    width: 6px;
}

.smfs-shop-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.smfs-shop-sidebar::-webkit-scrollbar-thumb {
    background: #c8c8c8;
    border-radius: 3px;
}

.smfs-shop-sidebar::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.smfs-sidebar-title {
    font-size: 16px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid #00c853;
}

/* ── Filter Section ── */
.smfs-filter-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f0f0f0;
}

.smfs-filter-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.smfs-filter-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

.smfs-filter-section h4::after {
    content: '';
    width: 8px;
    height: 8px;
    border-right: 2px solid #999;
    border-bottom: 2px solid #999;
    transform: rotate(45deg);
    transition: transform 0.2s;
    flex-shrink: 0;
}

.smfs-filter-section.smfs-collapsed h4::after {
    transform: rotate(-45deg);
}

.smfs-filter-body {
    overflow: hidden;
    transition: max-height 0.3s ease;
    max-height: 500px;
}

.smfs-filter-section.smfs-collapsed .smfs-filter-body {
    max-height: 0;
}

/* ── Size / Generic attribute filter (checkbox buttons) ── */
.smfs-filter-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.smfs-filter-list li {
    margin: 0;
}

.smfs-filter-list label {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.smfs-filter-list label:hover {
    border-color: #00c853;
    color: #00c853;
}

.smfs-filter-list input[type="checkbox"] {
    display: none;
}

.smfs-filter-list label.smfs-checked {
    background: #00c853;
    border-color: #00c853;
    color: #fff;
}

/* ── Category filter (checklist) ── */
.smfs-cat-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.smfs-cat-list li {
    margin: 0;
}

.smfs-cat-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.smfs-cat-list label:hover {
    background: #f5f5f5;
}

.smfs-cat-list input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #00c853;
    cursor: pointer;
    flex-shrink: 0;
}

.smfs-cat-list .smfs-cat-count {
    margin-left: auto;
    font-size: 11px;
    color: #999;
}

/* ── Color Filter (swatches) ── */
.smfs-color-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.smfs-color-list li {
    margin: 0;
}

.smfs-color-swatch {
    display: block;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #ddd;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.smfs-color-swatch:hover {
    border-color: #00c853;
    transform: scale(1.1);
}

.smfs-color-swatch.smfs-checked {
    border-color: #00c853;
    box-shadow: 0 0 0 2px #00c853;
}

.smfs-color-swatch.smfs-checked::after {
    content: '\2713';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

.smfs-color-swatch input[type="checkbox"] {
    display: none;
}

/* ── Price Filter ── */
.smfs-price-filter {
    padding: 4px 0;
}

.smfs-price-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.smfs-price-inputs input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 13px;
    color: #333;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
    -moz-appearance: textfield;
}

.smfs-price-inputs input::-webkit-outer-spin-button,
.smfs-price-inputs input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.smfs-price-inputs input:focus {
    border-color: #00c853;
}

.smfs-price-inputs span {
    color: #999;
    font-size: 13px;
    flex-shrink: 0;
}

.smfs-price-slider {
    position: relative;
    height: 6px;
    background: #e5e5e5;
    border-radius: 3px;
    margin: 16px 0 8px;
}

.smfs-price-slider .smfs-slider-track {
    position: absolute;
    height: 100%;
    background: #00c853;
    border-radius: 3px;
}

.smfs-price-slider input[type="range"] {
    position: absolute;
    width: 100%;
    height: 6px;
    top: 0;
    margin: 0;
    padding: 0;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    pointer-events: none;
}

.smfs-price-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #fff;
    border: 2px solid #00c853;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: all;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    margin-top: -7px;
}

.smfs-price-slider input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #fff;
    border: 2px solid #00c853;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: all;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

/* ── Apply / Clear Buttons ── */
.smfs-filter-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

.smfs-btn-filter {
    display: block;
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s, color 0.2s;
}

.smfs-btn-apply {
    background: #00c853;
    color: #fff;
}

.smfs-btn-apply:hover {
    background: #00b248;
}

.smfs-btn-clear {
    background: #f5f5f5;
    color: #666;
}

.smfs-btn-clear:hover {
    background: #e8e8e8;
    color: #333;
}

/* ── Active Filters Tags ── */
.smfs-active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.smfs-active-filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #e8faf0;
    border: 1px solid #c8f0d8;
    border-radius: 20px;
    font-size: 12px;
    color: #00c853;
    font-weight: 500;
}

.smfs-active-filter-tag .smfs-remove-filter {
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    margin-left: 2px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.smfs-active-filter-tag .smfs-remove-filter:hover {
    opacity: 1;
}

/* ── Mobile toggle button ── */
.smfs-filter-toggle {
    display: none;
    width: 100%;
    padding: 12px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    text-align: center;
    margin-bottom: 16px;
    box-sizing: border-box;
}

.smfs-filter-toggle svg {
    vertical-align: middle;
    margin-right: 6px;
}

/* ── Hide mobile close on desktop ── */
.smfs-sidebar-mobile-close {
    display: none;
}

/* ── Responsive ── */
@media (max-width: 992px) {
    .smfs-shop-wrapper {
        grid-template-columns: 220px 1fr !important;
        gap: 20px !important;
    }
}

@media (max-width: 768px) {
    /* Parent theme's <main id="main"> overflows viewport on category pages — constrain it */
    body.woocommerce-shop main#main.site-main,
    body.post-type-archive-product main#main.site-main,
    body.tax-product_cat main#main.site-main,
    body.tax-product_tag main#main.site-main {
        max-width: 100vw !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }

    .smfs-filter-toggle {
        display: block;
    }

    .smfs-shop-wrapper {
        display: block !important;
    }

    .smfs-shop-sidebar {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 9999;
        border-radius: 0;
        overflow-y: auto;
        padding: 20px;
        padding-top: 60px;
    }

    .smfs-shop-sidebar.smfs-sidebar-open {
        display: block;
    }

    .smfs-sidebar-mobile-close {
        display: block !important;
        position: absolute;
        top: 16px;
        right: 16px;
        background: none;
        border: none;
        font-size: 28px;
        color: #333;
        cursor: pointer;
        line-height: 1;
    }
}
