/* ═══════════════════════════════════════════════════════════════════
   FASP Faceted Filter — Styles
   Clean, minimal design matching the site's existing aesthetic.
   Accent: #b22727  |  Fonts: Space Grotesk / Source Sans 3
   ═══════════════════════════════════════════════════════════════════ */

/* ── Layout: sidebar + products ─────────────────────────────────── */
.woocommerce .fasp-ff-sidebar + .woocommerce-notices-wrapper,
.woocommerce .fasp-ff-sidebar ~ .woocommerce-notices-wrapper {
    grid-column: 2;
}

/* Force the shop content into a two-column grid on desktop */
body.post-type-archive-product .site-content .ast-container,
body.tax-product_cat .site-content .ast-container {
    display: grid !important;
    grid-template-columns: 260px 1fr;
    gap: 0 32px;
    align-items: start;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

body.post-type-archive-product .site-content .ast-container > *,
body.tax-product_cat .site-content .ast-container > * {
    grid-column: 2;
}

body.post-type-archive-product .site-content .ast-container > .fasp-ff-sidebar,
body.tax-product_cat .site-content .ast-container > .fasp-ff-sidebar,
body.post-type-archive-product .site-content .ast-container > .fasp-ff-mobile-toggle,
body.tax-product_cat .site-content .ast-container > .fasp-ff-mobile-toggle,
body.post-type-archive-product .site-content .ast-container > .fasp-ff-overlay,
body.tax-product_cat .site-content .ast-container > .fasp-ff-overlay {
    grid-column: 1;
}

/* Make sidebar sticky */
.fasp-ff-sidebar {
    grid-row: 1 / 20;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.15) transparent;
}

.fasp-ff-sidebar::-webkit-scrollbar {
    width: 4px;
}
.fasp-ff-sidebar::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
    border-radius: 4px;
}

/* ── Sidebar base ───────────────────────────────────────────────── */
.fasp-ff-sidebar {
    font-family: 'Source Sans 3', -apple-system, sans-serif;
    font-size: 0.9rem;
    color: #151922;
    background: #fff;
    border: 1px solid rgba(19,22,28,0.08);
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.fasp-ff-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(19,22,28,0.08);
}

.fasp-ff-sidebar-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
}

.fasp-ff-close-btn {
    display: none; /* shown on mobile */
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    line-height: 1;
    padding: 0 4px;
}

/* ── Active filters bar ─────────────────────────────────────────── */
.fasp-ff-active-bar {
    padding: 10px 16px;
    border-bottom: 1px solid rgba(19,22,28,0.08);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.fasp-ff-active-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    flex: 1;
}

.fasp-ff-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #f5f0f0;
    border: 1px solid rgba(178,39,39,0.15);
    color: #b22727;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.fasp-ff-tag:hover {
    background: #ece3e3;
}

.fasp-ff-tag .fasp-ff-tag-x {
    font-size: 0.85rem;
    line-height: 1;
    opacity: 0.7;
}

.fasp-ff-clear-all {
    background: none;
    border: none;
    color: #b22727;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
    white-space: nowrap;
}

/* ── Filter sections ────────────────────────────────────────────── */
.fasp-ff-section {
    border-bottom: 1px solid rgba(19,22,28,0.06);
}

.fasp-ff-section:last-of-type {
    border-bottom: none;
}

.fasp-ff-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 0.88rem;
    color: #151922;
    letter-spacing: 0.01em;
}

.fasp-ff-section-toggle:hover {
    background: rgba(19,22,28,0.02);
}

.fasp-ff-chevron {
    transition: transform 0.2s ease;
}

.fasp-ff-section-toggle[aria-expanded="false"] .fasp-ff-chevron {
    transform: rotate(-90deg);
}

.fasp-ff-section-body {
    padding: 0 16px 14px;
}

.fasp-ff-section-toggle[aria-expanded="false"] + .fasp-ff-section-body {
    display: none;
}

/* ── Filter lists ───────────────────────────────────────────────── */
.fasp-ff-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 220px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.12) transparent;
}

.fasp-ff-list::-webkit-scrollbar {
    width: 3px;
}
.fasp-ff-list::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.12);
    border-radius: 3px;
}

.fasp-ff-list li {
    margin: 0;
    padding: 0;
}

.fasp-ff-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    cursor: pointer;
    font-size: 0.86rem;
    line-height: 1.35;
    transition: color 0.15s;
}

.fasp-ff-list label:hover {
    color: #b22727;
}

.fasp-ff-list input[type="checkbox"],
.fasp-ff-list input[type="radio"] {
    accent-color: #b22727;
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    margin: 0;
}

.fasp-ff-label-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fasp-ff-count {
    font-size: 0.76rem;
    color: #999;
    font-weight: 500;
    flex-shrink: 0;
}

/* ── Brand search ───────────────────────────────────────────────── */
.fasp-ff-search-input-wrap {
    margin-bottom: 8px;
}

.fasp-ff-search-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid rgba(19,22,28,0.14);
    border-radius: 5px;
    font-size: 0.84rem;
    font-family: 'Source Sans 3', sans-serif;
    color: #151922;
    outline: none;
    transition: border-color 0.15s;
}

.fasp-ff-search-input:focus {
    border-color: #b22727;
    box-shadow: 0 0 0 2px rgba(178,39,39,0.1);
}

/* ── Price ranges ───────────────────────────────────────────────── */
.fasp-ff-price-ranges {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.fasp-ff-price-ranges label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    cursor: pointer;
    font-size: 0.86rem;
    transition: color 0.15s;
}

.fasp-ff-price-ranges label:hover {
    color: #b22727;
}

.fasp-ff-price-ranges input[type="radio"] {
    accent-color: #b22727;
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    margin: 0;
}

.fasp-ff-price-custom {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(19,22,28,0.06);
}

.fasp-ff-price-custom-label {
    font-size: 0.8rem;
    color: #777;
    display: block;
    margin-bottom: 6px;
}

.fasp-ff-price-inputs {
    display: flex;
    align-items: center;
    gap: 6px;
}

.fasp-ff-price-field {
    display: flex;
    align-items: center;
    border: 1px solid rgba(19,22,28,0.14);
    border-radius: 5px;
    overflow: hidden;
    flex: 1;
}

.fasp-ff-currency {
    padding: 0 6px;
    font-size: 0.84rem;
    color: #999;
    background: rgba(19,22,28,0.03);
    border-right: 1px solid rgba(19,22,28,0.08);
    line-height: 32px;
}

.fasp-ff-price-field input {
    border: none;
    outline: none;
    width: 100%;
    padding: 4px 6px;
    font-size: 0.84rem;
    font-family: 'Source Sans 3', sans-serif;
    color: #151922;
    -moz-appearance: textfield;
}

.fasp-ff-price-field input::-webkit-outer-spin-button,
.fasp-ff-price-field input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.fasp-ff-price-dash {
    color: #999;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.fasp-ff-price-go {
    background: #b22727;
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 5px 12px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}

.fasp-ff-price-go:hover {
    background: #961f1f;
}

/* ── Mobile toggle button ───────────────────────────────────────── */
.fasp-ff-mobile-toggle {
    display: none; /* shown via media query */
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 1px solid rgba(19,22,28,0.14);
    border-radius: 6px;
    padding: 10px 18px;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.92rem;
    font-weight: 600;
    color: #151922;
    cursor: pointer;
    margin-bottom: 16px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.fasp-ff-mobile-toggle:hover {
    border-color: #b22727;
    box-shadow: 0 0 0 2px rgba(178,39,39,0.1);
}

.fasp-ff-mobile-toggle svg {
    flex-shrink: 0;
}

/* ── Mobile apply button ────────────────────────────────────────── */
.fasp-ff-mobile-apply-wrap {
    display: none; /* shown on mobile */
    padding: 12px 16px;
    border-top: 1px solid rgba(19,22,28,0.08);
}

.fasp-ff-mobile-apply {
    width: 100%;
    padding: 12px;
    background: #b22727;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}

.fasp-ff-mobile-apply:hover {
    background: #961f1f;
}

/* ── Overlay ────────────────────────────────────────────────────── */
.fasp-ff-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99998;
}

.fasp-ff-overlay.active {
    display: block;
}

/* ── Result bar ─────────────────────────────────────────────────── */
.fasp-ff-result-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0 14px;
    margin-bottom: 4px;
    border-bottom: 1px solid rgba(19,22,28,0.08);
}

.fasp-ff-result-count {
    font-size: 0.88rem;
    color: #666;
}

.fasp-ff-sort-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fasp-ff-sort-wrap label {
    font-size: 0.84rem;
    color: #666;
    white-space: nowrap;
}

.fasp-ff-orderby {
    border: 1px solid rgba(19,22,28,0.14);
    border-radius: 5px;
    padding: 5px 10px;
    font-size: 0.84rem;
    font-family: 'Source Sans 3', sans-serif;
    color: #151922;
    background: #fff;
    cursor: pointer;
    outline: none;
}

.fasp-ff-orderby:focus {
    border-color: #b22727;
}

/* ── No results ─────────────────────────────────────────────────── */
.fasp-ff-no-results {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    font-size: 1rem;
}

/* ── Loading state ──────────────────────────────────────────────── */
#fasp-ff-products-wrap.fasp-ff-loading {
    opacity: 0.45;
    pointer-events: none;
    transition: opacity 0.2s;
}

/* Spinner */
.fasp-ff-spinner {
    display: none;
    text-align: center;
    padding: 40px 0;
}

.fasp-ff-spinner.active {
    display: block;
}

.fasp-ff-spinner::after {
    content: '';
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 3px solid rgba(178,39,39,0.2);
    border-top-color: #b22727;
    border-radius: 50%;
    animation: fasp-ff-spin 0.6s linear infinite;
}

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

/* ── Pagination ─────────────────────────────────────────────────── */
.fasp-ff-pagination {
    margin-top: 24px;
    text-align: center;
}

.fasp-ff-pagination ul {
    list-style: none;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0;
    padding: 0;
}

.fasp-ff-pagination li {
    margin: 0;
}

.fasp-ff-pagination a,
.fasp-ff-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid rgba(19,22,28,0.12);
    border-radius: 5px;
    font-size: 0.86rem;
    color: #151922;
    text-decoration: none;
    transition: all 0.15s;
}

.fasp-ff-pagination a:hover {
    border-color: #b22727;
    color: #b22727;
}

.fasp-ff-pagination .current {
    background: #b22727;
    border-color: #b22727;
    color: #fff;
}

/* ── Products grid tweaks ───────────────────────────────────────── */
#fasp-ff-products-wrap .products {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

#fasp-ff-products-wrap .products li.product {
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
    float: none !important;
}

/* ── Hide default WC sidebar on shop pages ──────────────────────── */
body.post-type-archive-product #secondary,
body.tax-product_cat #secondary,
body.post-type-archive-product .ast-woo-shop-sidebar,
body.tax-product_cat .ast-woo-shop-sidebar {
    display: none !important;
}

/* ── RESPONSIVE ─────────────────────────────────────────────────── */
@media (max-width: 920px) {
    #fasp-ff-products-wrap .products {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    body.post-type-archive-product .site-content .ast-container,
    body.tax-product_cat .site-content .ast-container {
        grid-template-columns: 1fr !important;
        padding: 16px 16px 40px;
    }

    body.post-type-archive-product .site-content .ast-container > *,
    body.tax-product_cat .site-content .ast-container > * {
        grid-column: 1;
    }

    /* Sidebar becomes a slide-in drawer */
    .fasp-ff-sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0;
        bottom: 0;
        width: 300px;
        max-width: 85vw;
        max-height: 100vh !important;
        z-index: 99999;
        border-radius: 0;
        border: none;
        box-shadow: 4px 0 24px rgba(0,0,0,0.15);
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        overflow-y: auto;
    }

    .fasp-ff-sidebar.open {
        transform: translateX(0);
    }

    .fasp-ff-close-btn {
        display: block;
    }

    .fasp-ff-mobile-toggle {
        display: inline-flex;
        grid-column: 1;
    }

    .fasp-ff-mobile-apply-wrap {
        display: block;
        position: sticky;
        bottom: 0;
        background: #fff;
    }

    .fasp-ff-result-bar {
        flex-wrap: wrap;
        gap: 8px;
    }
}

@media (max-width: 520px) {
    #fasp-ff-products-wrap .products {
        grid-template-columns: 1fr;
    }
}
