/* Tabler Icons */
@import url('https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@latest/tabler-icons.min.css');

/* ═══════════════════════════════════════════════════════════════════════════════
   CSA Facet Filter — clean horizontal bar matching the reference screenshot
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Wrapper */
.csa-facet-filter-wrapper {
    font-family: inherit;
    font-size: 14px;
    color: #1e293b;
    margin-left: 1%;
    margin-right: 1%;
}

.csa-facet-filter-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #111827;
    margin: 0 0 14px;
}

@media (min-width: 901px) {
    .csa-facet-filter-title {
        display: none;
    }
}

.csa-search-panel {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1.5fr) auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 18px;
}

.csa-search-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.csa-search-field label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
}

.csa-search-field input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #fff;
    color: #0f172a;
    font-size: 0.95rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.csa-search-field input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

.csa-search-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 18px;
    background: #2563eb;
    border: none;
    border-radius: 10px;
    color: #ffffff;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s ease;
}

.csa-search-button:hover,
.csa-search-button:focus-visible {
    background: #1d4ed8;
    outline: none;
}

.csa-loading-spinner {
    width: 100px;
    height: 100px;
    border: 5px solid #cbd5e1;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: csa-spin .8s linear infinite;
}

.csa-loading-text {
    font-size: 0.95rem;
    color: #334155;
}

@keyframes csa-spin {
    to { transform: rotate(360deg); }
}
/* Active chips row */
.csa-facet-active-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-height: 0;
    margin-bottom: 12px;
}

.csa-facet-active-row:empty {
    margin-bottom: 0;
}

.csa-active-label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
}

.csa-active-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

/* Individual chip — matches screenshot: rounded pill, border, × */
.csa-active-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px 5px 12px;
    border: 1.5px solid #2563eb;
    border-radius: 999px;
    background: #fff;
    color: #1e40af;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    line-height: 1;
    transition: background .12s, border-color .12s;
    white-space: nowrap;
}

.csa-active-chip:hover {
    background: #eff6ff;
    color: #727272;
}

.csa-active-chip-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    color: #2563eb;
    font-size: 23px;
    line-height: 10px;
    flex-shrink: 0;
}

/* Clear All pill */
.csa-clear-all-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border: 1.5px solid #cbd5e1;
    border-radius: 999px;
    background: #fff;
    color: #374151;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color .12s, background .12s;
}

.csa-clear-all-btn:hover {
    border-color: #2557a7;
    background: #eff6ff;
    color: #727272;
}

/* Filter bar (4-column grid) */
.csa-facet-filter-bar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

/* Individual filter card */
.csa-filter-card {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 11px 14px;
    background: #fff;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    min-width: 0;
    transition: border-color .15s, box-shadow .15s;
}

.csa-filter-card:hover {
    border-color: #93c5fd;
}

.csa-filter-card:focus-visible {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

.csa-filter-card.is-open {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

.csa-filter-card.has-value {
    border-color: #3b82f6;
    background: #fff;
}

/* Label text */
.csa-filter-card-label {
    flex: 1;
    font-size: 13.5px;
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.csa-filter-card.has-value .csa-filter-card-label {
    color: #1d4ed8;
    font-weight: 600;
}

/* Chevron */
.csa-filter-card-chevron {
    font-size: 16px;
    color: #6b7280;
    flex-shrink: 0;
    transition: transform .2s ease, color .15s;
}

.csa-filter-card.is-open .csa-filter-card-chevron {
    transform: rotate(180deg);
    color: #3b82f6;
}

.csa-filter-card.has-value .csa-filter-card-chevron {
    color: #3b82f6;
}

/* Dropdown panel */
.csa-filter-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    min-width: 240px;
    width: max-content;
    max-width: 320px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(15,23,42,.11);
    z-index: 9999;
    overflow: hidden;
}

.csa-filter-card.is-open .csa-filter-dropdown {
    display: block;
}

/* Search row inside dropdown */
.csa-filter-dropdown-search {
    position: relative;
    padding: 10px 10px 8px;
    border-bottom: 1px solid #f1f5f9;
}

.csa-dropdown-search-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 14px;
    pointer-events: none;
    margin-top: 2px;
}

.csa-filter-dropdown-input {
    width: 100%;
    box-sizing: border-box;
    padding: 7px 10px 7px 32px !important;
    padding: 12px 30px;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    font-size: 13px;
    font-family: inherit;
    color: #111827;
    background: #f8fafc;
    outline: none;
    transition: border-color .15s, background .15s;
}

.csa-filter-dropdown-input:focus {
    border-color: #93c5fd;
    background: #fff;
}

/* Options list */
.csa-filter-dropdown-list {
    list-style: none;
    margin: 0;
    padding: 4px 0;
    max-height: 260px;
    overflow-y: auto;
}

.csa-filter-dropdown-list::-webkit-scrollbar { width: 4px; }
.csa-filter-dropdown-list::-webkit-scrollbar-track { background: transparent; }
.csa-filter-dropdown-list::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 2px; }

/* Option row */
.csa-option-row {
    padding: 0;
}

.csa-option-label {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 14px;
    cursor: pointer;
    font-size: 13px;
    color: #374151;
    transition: background .1s;
    box-sizing: border-box;
}

.csa-option-label:hover {
    background: #f8fafc;
}

.csa-option-select-all .csa-option-label {
    font-weight: 500;
    border-bottom: 1px solid #f1f5f9;
    color: #111827;
}

/* Checkbox */
.csa-opt-checkbox {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    accent-color: #2563eb;
    cursor: pointer;
}

/* Option name */
.csa-opt-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Count badge */
.csa-opt-count {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    background: #f1f5f9;
    border-radius: 20px;
    padding: 2px 7px;
    line-height: 1.5;
    min-width: 24px;
    text-align: center;
}

/* Loading / empty / error states */
.csa-filter-dropdown-loading,
.csa-filter-dropdown-empty {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px;
    font-size: 13px;
    color: #9ca3af;
}

/* Retry button */
.csa-retry-btn {
    background: none;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    color: #3b82f6;
    font-size: 12px;
    cursor: pointer;
    padding: 2px 8px;
    margin-left: 6px;
}

.csa-retry-btn:hover { background: #eff6ff; }

/* Spinner */
@keyframes csa-spin { to { transform: rotate(360deg); } }

.csa-filter-spinner {
    display: inline-block;
    width: 13px;
    height: 13px;
    border: 2px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: csa-spin .65s linear infinite;
    flex-shrink: 0;
}

/* Mobile panel and button */
.csa-facet-filter-mobile-toggle-wrap {
    display: none;
    margin-bottom: 16px;
}

.csa-mobile-filter-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border: 1px solid #2563eb;
    border-radius: 10px;
    background: #2563eb;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
    width: -webkit-fill-available;
    border-radius: 2px;
}

.csa-mobile-filter-close {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border: 1px solid #2563eb;
    border-radius: 10px;
    background: #2563eb;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.csa-mobile-filter-toggle:hover,
.csa-mobile-filter-close:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

.csa-facet-filter-backdrop {
    display: none;
}

.csa-facet-filter-inner {
    position: static;
}

.csa-facet-filter-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

@media (max-width: 900px) {
    .csa-facet-filter-mobile-toggle-wrap {
        display: block;
    }

    .csa-mobile-filter-toggle {
        display: inline-flex;
        padding: 12px 18px;
        font-size: 0.95rem;
        border-radius: 2px;
    }

    .csa-mobile-filter-close {
        display: inline-flex;
        background: transparent;
        color: #dc2626;
        border: none;
        padding: 8px 10px;
        font-weight: 600;
    }

    /* Hide the "Filter By:" label on smaller viewports */
    .csa-active-label {
        display: none;
    }

    .csa-facet-filter-wrapper .csa-facet-filter-inner {
        position: fixed;
        inset: 0;
        width: 100%;
        max-height: 100vh;
        background: #fff;
        padding: 18px;
        overflow-y: auto;
        transform: translateY(100%);
        transition: transform .24s ease, visibility .24s ease;
        visibility: hidden;
        z-index: 9999;
    }

    .csa-facet-filter-wrapper.csa-mobile-open .csa-facet-filter-inner {
        transform: translateY(0);
        visibility: visible;
    }

    .csa-facet-filter-wrapper.csa-mobile-open .csa-facet-filter-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .35);
        z-index: 9990;
    }

    body.csa-facet-filter-open {
        overflow: hidden;
    }
}

/* Responsive */
@media (max-width: 1024px) {
    .csa-facet-filter-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .csa-facet-filter-bar {
        grid-template-columns: minmax(0, 1fr);
    }

    .csa-filter-dropdown {
        left: 0;
        right: 0;
        width: auto;
        max-width: none;
    }

    .csa-active-label {
        width: 100%;
    }
}
