/* ==========================================================================
   Le Belle Arti — Filter System
   Toolbar · Drawer · Accordion · Active tags · View toggle
   ========================================================================== */

/* ── Toolbar ── */
.lba-filter-toolbar {
    border-bottom: 1px solid var(--lba-gray-200);
    margin-bottom: var(--lba-space-md);
    background: var(--lba-white);
    position: sticky;
    top: 67px; /* actual header height */
    z-index: 50;
    transition: top 0.35s ease; /* matches header slide animation */
}

.admin-bar .lba-filter-toolbar {
    top: 99px; /* header (67px) + WP admin bar (32px) */
}

/* When the smart header hides on scroll-down, pull the toolbar to the top */
.header-hidden .lba-filter-toolbar {
    top: 0;
}

.admin-bar.header-hidden .lba-filter-toolbar {
    top: 32px; /* just the WP admin bar remains */
}

.lba-filter-toolbar__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    min-height: 44px;
}

.lba-filter-toolbar__left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}

.lba-filter-toolbar__right {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-shrink: 0;
}

/* ── Filter trigger button (clean, minimal, with icon) ── */
.lba-filter-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0;
    font-family: var(--lba-font-secondary);
    font-size: 0.875rem;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    color: var(--lba-black);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: opacity 0.15s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.lba-filter-trigger__icon {
    flex-shrink: 0;
}

.lba-filter-trigger:hover {
    opacity: 0.7;
}

.lba-filter-trigger.is-disabled {
    opacity: 0.35;
    cursor: default;
}

.lba-filter-trigger__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.125rem;
    height: 1.125rem;
    padding: 0 0.25rem;
    background: var(--lba-black);
    color: var(--lba-white);
    font-size: 0.625rem;
    font-weight: 700;
    border-radius: 50%;
    line-height: 1;
}

/* ── Active filter tags ── */
.lba-active-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    align-items: center;
}

.lba-active-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.3125rem 0.625rem;
    font-family: var(--lba-font-secondary);
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    color: var(--lba-black);
    background: var(--lba-gray-100);
    border: 1px solid var(--lba-gray-300);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
}

.lba-active-tag:hover {
    background: var(--lba-gray-200);
    border-color: var(--lba-black);
}

.lba-active-tag__remove {
    display: flex;
    align-items: center;
    opacity: 0.5;
    transition: opacity 0.15s ease;
}

.lba-active-tag:hover .lba-active-tag__remove {
    opacity: 1;
}

/* ── Clear all ── */
.lba-clear-all {
    font-family: var(--lba-font-secondary);
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--lba-gray-500);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0;
    border-bottom: 1px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
}

.lba-clear-all:hover {
    color: var(--lba-black);
    border-bottom-color: var(--lba-black);
}

/* ── Result count ── */
.lba-filter-result-count {
    font-family: var(--lba-font-secondary);
    font-size: 0.875rem;
    color: var(--lba-gray-500);
    white-space: nowrap;
}

/* ── View toggle (Represent-style: label + 3 small square chips) ── */
.lba-view-toggle {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.lba-view-toggle__label {
    font-family: var(--lba-font-secondary);
    font-size: 0.875rem;
    color: var(--lba-black);
    letter-spacing: 0;
    margin-right: 6px;
}

.lba-view-toggle__btn {
    display: block;
    width: 0.75rem;
    height: 0.75rem;
    background: transparent;
    border: 1px solid var(--lba-black);
    cursor: pointer;
    padding: 0;
    transition: background 0.15s ease;
}

.lba-view-toggle__btn:hover {
    background: var(--lba-gray-300);
}

.lba-view-toggle__btn.is-active {
    background: var(--lba-black);
}

/* ── Sort ── */
.lba-sort-wrap {
    position: relative;
}

.lba-sort-select {
    font-family: var(--lba-font-secondary);
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    color: var(--lba-black);
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--lba-gray-300);
    padding: 0.25rem 1.5rem 0.25rem 0;
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23737373'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.25rem center;
    min-width: 140px;
}

.lba-sort-select:focus {
    outline: none;
    border-bottom-color: var(--lba-black);
}

/* ==========================================================================
   Filter backdrop
   ========================================================================== */

.lba-filter-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 149;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.lba-filter-backdrop.is-visible {
    opacity: 1;
    pointer-events: all;
}

/* ==========================================================================
   Filter drawer
   ========================================================================== */

.lba-filter-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 380px;
    max-width: 90vw;
    height: 100dvh;
    background: var(--lba-white);
    z-index: 150;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.08);
}

.lba-filter-drawer.is-open {
    transform: translateX(0);
}

.lba-filter-drawer__inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* Header */
.lba-filter-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--lba-gray-200);
    flex-shrink: 0;
}

.lba-filter-drawer__title {
    font-family: var(--lba-font-secondary);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--lba-black);
}

.lba-filter-drawer__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--lba-gray-500);
    transition: color 0.15s ease;
    margin-right: -0.375rem;
}

.lba-filter-drawer__close:hover {
    color: var(--lba-black);
}

/* Scrollable groups area */
.lba-filter-drawer__groups {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* Footer */
.lba-filter-drawer__footer {
    display: flex;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--lba-gray-200);
    flex-shrink: 0;
}

.lba-filter-drawer__clear {
    flex: 0 0 auto;
    padding: 0.75rem 1.25rem;
    font-family: var(--lba-font-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--lba-gray-500);
    background: none;
    border: 1px solid var(--lba-gray-300);
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.lba-filter-drawer__clear:hover {
    color: var(--lba-black);
    border-color: var(--lba-black);
}

.lba-filter-drawer__apply {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-family: var(--lba-font-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--lba-white);
    background: var(--lba-black);
    border: 1px solid var(--lba-black);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.lba-filter-drawer__apply:hover {
    background: var(--lba-gray-800, #1a1a1a);
}

.lba-filter-drawer__apply-count {
    font-weight: 400;
    opacity: 0.75;
}

/* ==========================================================================
   Filter accordion groups
   ========================================================================== */

.lba-filter-group {
    border-bottom: 1px solid var(--lba-gray-200);
}

.lba-filter-group__toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease;
}

.lba-filter-group__toggle:hover {
    background: var(--lba-gray-50);
}

.lba-filter-group__name {
    font-family: var(--lba-font-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--lba-black);
    flex: 1;
}

.lba-filter-group__active-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.125rem;
    height: 1.125rem;
    padding: 0 0.25rem;
    font-family: var(--lba-font-secondary);
    font-size: 0.625rem;
    font-weight: 700;
    background: var(--lba-black);
    color: var(--lba-white);
    border-radius: 50%;
}

.lba-filter-group__chevron {
    flex-shrink: 0;
    transition: transform 0.25s ease;
    color: var(--lba-gray-400);
}

.lba-filter-group__toggle.is-open .lba-filter-group__chevron {
    transform: rotate(180deg);
}

/* Options panel */
.lba-filter-group__options {
    display: none;
    padding: 0.25rem 1.5rem 1rem;
}

.lba-filter-group__options.is-open {
    display: block;
}

/* Checkbox options */
.lba-filter-option {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.4375rem 0;
    cursor: pointer;
    user-select: none;
}

.lba-filter-option input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.lba-filter-option__check {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    border: 1px solid var(--lba-gray-400);
    flex-shrink: 0;
    transition: background 0.15s ease, border-color 0.15s ease;
    background: var(--lba-white);
}

.lba-filter-option input:checked + .lba-filter-option__check {
    background: var(--lba-black);
    border-color: var(--lba-black);
}

.lba-filter-option input:checked + .lba-filter-option__check::after {
    content: '';
    display: block;
    width: 5px;
    height: 3px;
    border-left: 1.5px solid var(--lba-white);
    border-bottom: 1.5px solid var(--lba-white);
    transform: rotate(-45deg) translate(0.5px, -0.5px);
}

.lba-filter-option__name {
    font-family: var(--lba-font-secondary);
    font-size: 0.8125rem;
    color: var(--lba-black);
    line-height: 1.4;
    flex: 1;
}

.lba-filter-option__count {
    font-family: var(--lba-font-secondary);
    font-size: 0.75rem;
    color: var(--lba-gray-400);
    margin-left: auto;
    padding-left: 0.5rem;
    flex-shrink: 0;
}

.lba-filter-option:hover .lba-filter-option__name {
    color: var(--lba-gray-600, #4b4b4b);
}

/* ==========================================================================
   No results state
   ========================================================================== */

.lba-no-filter-results {
    grid-column: 1 / -1;
    padding: var(--lba-space-3xl) 0;
    text-align: center;
    font-family: var(--lba-font-secondary);
    font-size: 0.9375rem;
    color: var(--lba-gray-500);
}

/* ==========================================================================
   Loading overlay on grid during AJAX
   ========================================================================== */

.lba-product-grid-wrap {
    position: relative;
    min-height: 200px;
}

.lba-product-grid-wrap.is-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    z-index: 5;
}

.lba-product-grid-wrap.is-loading::before {
    content: '';
    position: absolute;
    top: 4rem;
    left: 50%;
    transform: translateX(-50%);
    width: 1.5rem;
    height: 1.5rem;
    border: 2px solid var(--lba-gray-300);
    border-top-color: var(--lba-black);
    border-radius: 50%;
    animation: lba-spin 0.7s linear infinite;
    z-index: 6;
}

@keyframes lba-spin {
    to { transform: translateX(-50%) rotate(360deg); }
}

/* ==========================================================================
   View column overrides (set by data-cols on .lba-archive)
   ========================================================================== */

.lba-archive[data-cols="2"] ul.products,
.lba-archive[data-cols="2"] ul.products.columns-1,
.lba-archive[data-cols="2"] ul.products.columns-2,
.lba-archive[data-cols="2"] ul.products.columns-3,
.lba-archive[data-cols="2"] ul.products.columns-4,
.lba-archive[data-cols="2"] ul.products.columns-5 {
    grid-template-columns: repeat(2, 1fr);
}

.lba-archive[data-cols="3"] ul.products,
.lba-archive[data-cols="3"] ul.products.columns-1,
.lba-archive[data-cols="3"] ul.products.columns-2,
.lba-archive[data-cols="3"] ul.products.columns-3,
.lba-archive[data-cols="3"] ul.products.columns-4,
.lba-archive[data-cols="3"] ul.products.columns-5 {
    grid-template-columns: repeat(3, 1fr);
}

.lba-archive[data-cols="4"] ul.products,
.lba-archive[data-cols="4"] ul.products.columns-1,
.lba-archive[data-cols="4"] ul.products.columns-2,
.lba-archive[data-cols="4"] ul.products.columns-3,
.lba-archive[data-cols="4"] ul.products.columns-4,
.lba-archive[data-cols="4"] ul.products.columns-5 {
    grid-template-columns: repeat(4, 1fr);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .lba-filter-toolbar {
        top: 60px;
    }

    .lba-filter-toolbar__inner {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .lba-filter-toolbar__right {
        gap: 0.75rem;
        width: 100%;
        justify-content: space-between;
    }

    .lba-filter-result-count {
        display: none;
    }

    .lba-filter-drawer {
        width: 100%;
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .lba-view-toggle__btn[data-cols="3"],
    .lba-view-toggle__btn[data-cols="4"] {
        display: none;
    }
    .lba-archive[data-cols="4"] ul.products,
    .lba-archive[data-cols="3"] ul.products {
        grid-template-columns: repeat(2, 1fr);
    }
}
