/* ========================================
   ELASTIC ARCHIVE FILTERS CSS
   Compact, legible filter system matching existing design
   ======================================== */

/* ========================================
   1. MAIN CONTAINER & LAYOUT
   ======================================== */

.elastic-archive-filters {
    background: white;
    border: 1px solid #bdbdbd;
    border-radius: 5px;
    padding: 12px;
    box-shadow: 0px 2px 1px 0px rgba(201, 201, 201, 1);
    margin-bottom: 16px;
    font-family: "Montserrat", sans-serif;
}

/* ========================================
   2. DRILL-DOWN FILTERS (HIERARCHICAL)
   ======================================== */

.ef-drill-down-container {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e0e0e0;
}

.ef-drill-down-container:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.ef-filter-title {
    font-size: 15px;
    font-weight: 600;
    color: #0c3049;
    margin: 0 0 8px 0;
    padding-bottom: 4px;
    border-bottom: 2px solid #DD183B;
}

.ef-drill-levels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
}

.ef-drill-level {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ef-level-label {
    font-size: 12px;
    font-weight: 600;
    color: #0c3049;
    margin: 0 0 2px 0;
}

/* Drill-down select styling */
.ef-drill-select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #bdbdbd;
    border-radius: 5px;
    font-size: 13px;
    font-family: "Montserrat", sans-serif;
    background-color: white;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    color: #333;
}

.ef-drill-select:hover:not(:disabled) {
    border-color: #DD183B;
}

.ef-drill-select:disabled {
    background-color: rgba(247, 243, 245, 1);
    cursor: not-allowed;
    opacity: 0.6;
}

.ef-drill-select:focus {
    outline: none;
    border-color: #0c3049;
    box-shadow: 0 0 4px rgba(12, 48, 73, 0.4);
}

/* ========================================
   3. ATTRIBUTE FILTERS GROUP
   ======================================== */

.elastic-attribute-filters-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

/* Mobile toggle functionality */
.ef-mobile-toggle-btn {
    display: none;
    width: 100%;
    padding: 8px 12px;
    background: #0c3049;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 600;
    font-family: "Montserrat", sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0px 2px 1px 0px rgba(201, 201, 201, 1);
    margin-top: 10px;
    text-align: center;
}

.ef-mobile-toggle-btn:hover {
    background: #DD183B;
    transform: translateY(-1px);
    box-shadow: 0px 3px 2px 0px rgba(201, 201, 201, 1);
}

.ef-mobile-toggle-btn:active {
    transform: translateY(0);
}

.ef-mobile-toggle-btn::after {
    content: " ▼";
    display: inline-block;
    transition: transform 0.3s ease;
}

.ef-mobile-toggle-btn.is-open::after {
    transform: rotate(180deg);
}

@media (max-width: 768px) {
    .ef-mobile-toggle-btn {
        display: block;
    }

    .elastic-attribute-filters-group {
        display: none;
        margin-top: 10px;
    }

    .elastic-attribute-filters-group.is-visible {
        display: grid;
    }
}

.ef-filter {
    background: rgba(247, 243, 245, 0.5);
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    padding: 10px;
    transition: all 0.2s ease;
}

.ef-filter:hover {
    border-color: #DD183B;
    box-shadow: 0 2px 8px rgba(221, 24, 59, 0.1);
}

.ef-filter .ef-filter-title {
    font-size: 14px;
    font-weight: 600;
    color: #0c3049;
    margin: 0 0 8px 0;
    padding-bottom: 0;
    border-bottom: none;
}

.ef-filter-content {
    display: flex;
    flex-direction: column;
}

/* ========================================
   4. RANGE FILTERS
   ======================================== */

.ef-filter-range .ef-filter-title {
    margin-bottom: 8px;
}

.ef-range-inputs {
    display: flex;
    gap: 6px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.ef-range-input-group {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 70px;
}

.ef-range-input-group label {
    font-size: 11px;
    font-weight: 500;
    color: #666;
    margin: 0 0 2px 0;
}

.ef-filter-range-min,
.ef-filter-range-max {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #bdbdbd;
    border-radius: 5px;
    font-size: 13px;
    font-family: "Montserrat", sans-serif;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: white;
    color: #333;
}

.ef-filter-range-min:hover,
.ef-filter-range-max:hover {
    border-color: #0c3049;
}

.ef-filter-range-min:focus,
.ef-filter-range-max:focus {
    outline: none;
    border-color: #0c3049;
    box-shadow: 0 0 4px rgba(12, 48, 73, 0.4);
}

.ef-filter-range-min::placeholder,
.ef-filter-range-max::placeholder {
    color: #999;
}

.ef-range-apply {
    padding: 6px 12px;
    background: #5cb85c;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 600;
    font-family: "Montserrat", sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0px 2px 1px 0px rgba(201, 201, 201, 1);
    white-space: nowrap;
}

.ef-range-apply:hover {
    background: #51a251;
    transform: translateY(-1px);
    box-shadow: 0px 3px 2px 0px rgba(201, 201, 201, 1);
}

.ef-range-apply:active {
    transform: translateY(0);
    box-shadow: 0px 2px 1px 0px rgba(201, 201, 201, 1);
}

.ef-range-hint {
    margin-top: 6px;
    font-size: 11px;
    color: #666;
    padding: 4px 8px;
    background: white;
    border-radius: 3px;
    border: 1px solid #e0e0e0;
}

.ef-range-min-val,
.ef-range-max-val {
    font-weight: 600;
    color: #0c3049;
}

/* ========================================
   5. DROPDOWN FILTERS & SELECT2 COMPATIBILITY
   ======================================== */

.ef-filter-dropdown .ef-filter-title {
    margin-bottom: 8px;
}

.ef-filter-dropdown .ef-filter-title label {
    color: #0c3049;
    font-weight: 600;
    font-size: 16px;
    margin: 0;
}

.ef-filter-select {
    width: 100% !important;
    padding: 8px 12px;
    border: 1px solid #bdbdbd;
    border-radius: 5px;
    font-size: 14px;
    font-family: "Montserrat", sans-serif;
    background: white;
    color: #333;
}

/* Select2 Container Overrides */
.ef-filter-content .select2-container {
    width: 100% !important;
    max-width: 100%;
}

/* Select2 Selection Box */
.ef-filter-content .select2-selection {
    border: 1px solid #bdbdbd !important;
    border-radius: 5px !important;
    padding: 6px 10px !important;
    min-height: 38px !important;
    background-color: white !important;
    transition: border-color 0.2s ease !important;
}

.ef-filter-content .select2-selection:hover {
    border-color: #DD183B !important;
}

.ef-filter-content .select2-container--focus .select2-selection,
.ef-filter-content .select2-container--open .select2-selection {
    border-color: #0c3049 !important;
    box-shadow: 0 0 4px rgba(12, 48, 73, 0.4) !important;
}

.ef-filter-content .select2-selection--single {
    height: auto !important;
}

.ef-filter-content .select2-selection__rendered {
    line-height: 24px !important;
    padding-left: 0 !important;
    padding-right: 20px !important;
    font-family: "Montserrat", sans-serif !important;
    font-size: 14px !important;
    color: #333 !important;
}

.ef-filter-content .select2-selection__placeholder {
    color: #999 !important;
}

.ef-filter-content .select2-selection__arrow {
    height: 36px !important;
    right: 8px !important;
}

.ef-filter-content .select2-selection__arrow b {
    border-color: #666 transparent transparent transparent !important;
    border-width: 5px 4px 0 4px !important;
}

.ef-filter-content .select2-container--open .select2-selection__arrow b {
    border-color: transparent transparent #666 transparent !important;
    border-width: 0 4px 5px 4px !important;
}

/* Select2 Dropdown */
.select2-container--default .select2-dropdown {
    border: 1px solid #bdbdbd !important;
    border-radius: 5px !important;
    box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.15) !important;
    margin-top: 4px;
}

.select2-container--default .select2-results__option {
    padding: 8px 12px !important;
    font-family: "Montserrat", sans-serif !important;
    font-size: 14px !important;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #DD183B !important;
    color: white !important;
}

.select2-container--default .select2-results__option[aria-selected=true] {
    background-color: rgba(247, 243, 245, 1) !important;
    color: #0c3049 !important;
    font-weight: 600 !important;
}

.select2-container--default .select2-results__option--highlighted[aria-selected=true] {
    background-color: #DD183B !important;
    color: white !important;
}

/* Select2 Search */
.select2-container--default .select2-search--dropdown .select2-search__field {
    border: 1px solid #bdbdbd !important;
    border-radius: 5px !important;
    padding: 6px 10px !important;
    font-family: "Montserrat", sans-serif !important;
    font-size: 14px !important;
}

.select2-container--default .select2-search--dropdown .select2-search__field:focus {
    border-color: #0c3049 !important;
    outline: none !important;
}

/* ========================================
   6. RESPONSIVE DESIGN
   ======================================== */

/* Tablet */
@media (max-width: 768px) {
    .elastic-archive-filters {
        padding: 15px;
    }

    .ef-drill-levels {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .elastic-attribute-filters-group {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .ef-range-inputs {
        flex-direction: column;
        align-items: stretch;
    }

    .ef-range-input-group {
        min-width: 100%;
    }

    .ef-range-apply {
        width: 100%;
        padding: 10px 16px;
    }

    .ef-filter-title {
        font-size: 16px;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .elastic-archive-filters {
        padding: 12px;
        margin-bottom: 16px;
        border-radius: 5px;
    }

    .ef-drill-down-container {
        padding-bottom: 16px;
        margin-bottom: 16px;
    }

    .ef-filter-title {
        font-size: 15px;
        margin-bottom: 12px;
        padding-bottom: 6px;
    }

    .ef-filter {
        padding: 10px;
    }

    .ef-filter .ef-filter-title {
        font-size: 14px;
        margin-bottom: 10px;
    }

    .ef-level-label,
    .ef-range-input-group label {
        font-size: 12px;
    }

    .ef-drill-select,
    .ef-filter-range-min,
    .ef-filter-range-max,
    .ef-filter-select {
        font-size: 13px;
        padding: 7px 10px;
    }

    .ef-range-apply {
        font-size: 12px;
        padding: 9px 14px;
    }

    .elastic-attribute-filters-group {
        gap: 10px;
        margin-top: 16px;
    }
}

/* ========================================
   7. ACCESSIBILITY & FOCUS STATES
   ======================================== */

.ef-drill-select:focus-visible,
.ef-filter-range-min:focus-visible,
.ef-filter-range-max:focus-visible,
.ef-range-apply:focus-visible,
.ef-filter-select:focus-visible {
    outline: 2px solid #0c3049;
    outline-offset: 2px;
}

/* Keyboard navigation support */
.ef-range-apply:focus {
    outline: 2px solid #0c3049;
    outline-offset: 2px;
}

/* Ensure disabled elements are clearly indicated */
.ef-drill-select:disabled,
.ef-filter-range-min:disabled,
.ef-filter-range-max:disabled,
.ef-filter-select:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* ========================================
   8. CLEAR FILTERS BUTTON
   ======================================== */

.ef-clear-filters-link {
    display: inline-block;
    margin-top: 10px;
    padding: 7px 14px;
    background: #d9534f;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 600;
    font-family: "Montserrat", sans-serif;
    transition: all 0.3s ease;
    box-shadow: 0px 2px 1px 0px rgba(201, 201, 201, 1);
    text-align: center;
}

.ef-clear-filters-link:hover {
    background: #0c3049;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0px 3px 2px 0px rgba(201, 201, 201, 1);
}

.ef-clear-filters-link:active {
    transform: translateY(0);
    box-shadow: 0px 2px 1px 0px rgba(201, 201, 201, 1);
}

.ef-clear-filters-link:focus-visible {
    outline: 2px solid #0c3049;
    outline-offset: 2px;
}

/* ========================================
   9. UTILITY CLASSES & STATES
   ======================================== */

/* Loading state for filters */
.ef-filter.is-loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.ef-filter.is-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #DD183B;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Active/selected filter state */
.ef-filter.has-active-filter {
    border-color: #DD183B;
    background: rgba(221, 24, 59, 0.05);
}

.ef-filter.has-active-filter .ef-filter-title {
    color: #DD183B;
}

/* ========================================
   10. PAGINATION
   ======================================== */

#ef-pagination-container {
    margin: 20px 0;
    display: flex;
    justify-content: center;
}

.ef-pagination {
    font-family: "Montserrat", sans-serif;
}

.ef-page-numbers {
    display: flex;
    align-items: center;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
    justify-content: center;
}

.ef-page-numbers li {
    margin: 0;
    padding: 0;
}

.ef-page-link,
.ef-page-current,
.ef-page-dots {
    display: inline-block;
    min-width: 36px;
    padding: 8px 12px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    border-radius: 5px;
    transition: all 0.3s ease;
    text-decoration: none;
    box-shadow: 0px 2px 1px 0px rgba(201, 201, 201, 1);
}

.ef-page-link {
    background: white;
    color: #0c3049;
    border: 1px solid #bdbdbd;
}

.ef-page-link:hover {
    background: #DD183B;
    color: white;
    border-color: #DD183B;
    transform: translateY(-1px);
    box-shadow: 0px 3px 2px 0px rgba(201, 201, 201, 1);
}

.ef-page-link:active {
    transform: translateY(0);
}

.ef-page-current {
    background: #0c3049;
    color: white;
    border: 1px solid #0c3049;
    cursor: default;
}

.ef-page-dots {
    background: transparent;
    color: #666;
    border: none;
    box-shadow: none;
    cursor: default;
    font-weight: 700;
}

/* Next/Prev arrows */
.ef-next,
.ef-prev {
    font-size: 16px;
    font-weight: 700;
}

/* Mobile pagination */
@media (max-width: 768px) {
    #ef-pagination-container {
        margin: 16px 0;
    }

    .ef-page-numbers {
        gap: 4px;
    }

    .ef-page-link,
    .ef-page-current,
    .ef-page-dots {
        min-width: 32px;
        padding: 6px 10px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .ef-page-numbers {
        gap: 3px;
    }

    .ef-page-link,
    .ef-page-current {
        min-width: 28px;
        padding: 5px 8px;
        font-size: 12px;
    }

    .ef-next,
    .ef-prev {
        font-size: 14px;
    }
}

/* ========================================
   11. LOADING OVERLAY & SPINNER
   ======================================== */

/* Filters container - loading state with overlay background */
.elastic-archive-filters {
    position: relative !important;
}

/* Simple loading state - just disable and add opacity */
.elastic-archive-filters.ef-loading {
    opacity: 0.6 !important;
    pointer-events: none !important;
    user-select: none !important;
}

/* Alternative: Use a real overlay div instead of pseudo-element */
.ef-filters-loading-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(255, 255, 255, 0.92) !important;
    backdrop-filter: blur(2px) !important;
    z-index: 99998 !important;
    border-radius: 5px !important;
    cursor: not-allowed !important;
}

/* Products container - needs relative positioning for overlay */
.products.ef-loading,
ul.products.ef-loading {
    position: relative;
}

/* Overlay that covers products only */
.ef-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    z-index: 10;
    backdrop-filter: blur(2px);
}

/* Spinner container (JS sets top/left dynamically) */
.ef-spinner-container {
    position: fixed;
    transform: translate(-50%, -50%);
    z-index: 99999;
    pointer-events: none;
}

/* Spinner visual */
.ef-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(12, 48, 73, 0.1);
    border-top: 4px solid #DD183B;
    border-right: 4px solid #DD183B;
    border-radius: 50%;
    animation: ef-spin 0.8s linear infinite;
    box-shadow: 0 0 20px rgba(221, 24, 59, 0.3);
}

@keyframes ef-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mobile spinner */
@media (max-width: 768px) {
    .ef-spinner {
        width: 40px;
        height: 40px;
        border-width: 3px;
    }
}

/* Print styles */
@media print {
    .elastic-archive-filters {
        box-shadow: none;
        border: 1px solid #000;
    }

    .ef-range-apply {
        display: none;
    }

    #ef-pagination-container {
        display: none;
    }

    .ef-loading-overlay,
    .ef-spinner-container {
        display: none;
    }
}