/* ==========================================================================
   VLOERPLUS FILTER FIXES
   - Desktop: alignment fix for selected filter value in combobox
   - Mobile: collapsible filter container with toggle button
   ========================================================================== */

/* -------------------------------------------------------------------------
   1. DESKTOP FIX: Align selected filter text vertically in pill container
   The combobox selection text + count doesn't center properly because
   the container uses flex-direction: column but the content needs row.
   ----------------------------------------------------------------------- */

/* Fix the inner combobox to align content properly */
.custom-filter-container .search-filter-component-combobox--mode-single .search-filter-component-combobox__actions {
    display: flex;
    align-items: center;
    min-height: 2.5rem;
}

/* Selection text: horizontal layout, vertically centered */
.custom-filter-container .search-filter-component-combobox--mode-single .search-filter-component-combobox__selection {
    display: flex;
    align-items: center;
    padding-top: 0;
    padding-bottom: 0;
    font-size: 1rem;
    line-height: 1.5rem;
    min-height: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Ensure the outer pill container doesn't force column layout on its children */
.custom-filter-container .search-filter-style--choice-select > div {
    height: 2.5rem;
    display: flex;
    align-items: flex-start;
    border-radius: 5rem;
    padding: 0 0.625rem 0 1.125rem;
    border-color: #fff;
    color: #001539;
    cursor: pointer;
    background-color: #fff;
    transition: border-color 0.2s ease;
}

/* Combobox header should also be flex-aligned */
.custom-filter-container .search-filter-component-combobox__header {
    display: flex;
    align-items: center;
    min-height: 2.5rem;
}

/* Selection count badge alignment */
.custom-filter-container .search-filter-component-combobox__selection-count {
    margin-left: 0.25rem;
    font-weight: 700;
}

/* Clear button alignment */
.custom-filter-container .search-filter-component-combobox__clear-selection {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Toggle arrow alignment */
.custom-filter-container .search-filter-component-combobox__listbox-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Price slider range field alignment in filter bar */
.custom-filter-container .search-filter-style--range-slider {
    display: flex;
    align-items: center;
}


/* -------------------------------------------------------------------------
   2. MOBILE: Filter toggle button + collapsible container
   ----------------------------------------------------------------------- */

/* The toggle button (hidden on desktop, shown on mobile) */
.vloerplus-filter-toggle {
    display: none; /* Hidden on desktop by default */
}

@media (max-width: 1023px) {

    /* Show the toggle button on mobile */
    .vloerplus-filter-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 0.875rem 1.25rem;
        background-color: #fff;
        border: 1px solid #E5E5EA;
        border-radius: 0.75rem;
        cursor: pointer;
        font-family: inherit;
        font-size: 1rem;
        font-weight: 600;
        color: #001539;
        transition: border-color 0.2s ease, background-color 0.2s ease;
        -webkit-tap-highlight-color: transparent;
        margin-bottom: 0;
    }

    .vloerplus-filter-toggle:hover,
    .vloerplus-filter-toggle:focus-visible {
        border-color: #016FD0;
        outline: none;
    }

    .vloerplus-filter-toggle[aria-expanded="true"] {
        border-color: #E5E5EA;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        border-bottom-color: #E5E5EA;
    }

    /* Toggle label area */
    .vloerplus-filter-toggle__label {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    /* Filter icon in button */
    .vloerplus-filter-toggle__icon {
        display: flex;
        align-items: center;
        flex-shrink: 0;
    }

    .vloerplus-filter-toggle__icon svg {
        width: 1.25rem;
        height: 1.25rem;
        fill: #001539;
    }

    /* Active filter count badge */
    .vloerplus-filter-toggle__count {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 1.375rem;
        height: 1.375rem;
        padding: 0 0.375rem;
        border-radius: 5rem;
        background-color: #016FD0;
        color: #fff;
        font-size: 0.75rem;
        font-weight: 700;
        line-height: 1;
    }

    .vloerplus-filter-toggle__count:empty,
    .vloerplus-filter-toggle__count[data-count="0"] {
        display: none;
    }

    /* Chevron arrow */
    .vloerplus-filter-toggle__arrow {
        display: flex;
        align-items: center;
        flex-shrink: 0;
        transition: transform 0.3s ease;
    }

    .vloerplus-filter-toggle__arrow svg {
        width: 1.25rem;
        height: 1.25rem;
        fill: none;
        stroke: #001539;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .vloerplus-filter-toggle[aria-expanded="true"] .vloerplus-filter-toggle__arrow {
        transform: rotate(180deg);
    }

    /* Hide the "Filters" title text on mobile when toggle is present */
    .custom-filter-container .custom-filter-title {
        display: none;
    }

    /* The filters wrapper: collapsed by default on mobile */
    .custom-filter-container .custom-filters {
        overflow: hidden;
        max-height: 0;
        opacity: 0;
        transition: max-height 0.35s ease, opacity 0.25s ease, padding 0.35s ease;
        margin-bottom: 0;
        padding-top: 0;
        padding-bottom: 0;
        background-color: #fff;
        border: 1px solid #E5E5EA;
        border-top: none;
        border-bottom-left-radius: 0.75rem;
        border-bottom-right-radius: 0.75rem;
        padding-left: 1.25rem;
        padding-right: 1.25rem;
        flex-wrap: wrap;
    }

    /* Open state */
    .custom-filter-container .custom-filters.is-open {
        max-height: 600px; /* generous max to accommodate all filters */
        opacity: 1;
        padding-top: 0.75rem;
        padding-bottom: 1rem;
        margin-bottom: 1.5rem;
    }

    /* Make each filter field full-width on mobile */
    .custom-filter-container .custom-filters .search-filter-field {
        width: 100%;
        flex: 0 0 100%;
    }

    /* Make the combobox pills full-width on mobile */
    .custom-filter-container .search-filter-style--choice-select > div {
        width: 100%;
        border-color: #E5E5EA;
        border-radius: 0.5rem;
        height: 2.75rem;
    }

    /* Reset button full-width */
    .custom-filter-container .search-filter-input-button.search-filter-field__input {
        width: 100%;
        border-radius: 0.5rem;
        height: 2.75rem;
        margin-top: 0.25rem;
    }

    /* Range slider full-width */
    .custom-filter-container .search-filter-style--range-slider {
        width: 100%;
    }

    /* When toggle is not present but there's no JS, 
       show filters normally as fallback */
    .custom-filter-container .custom-filters:not(.has-toggle) {
        max-height: none;
        opacity: 1;
        border: none;
        padding-left: 0;
        padding-right: 0;
    }
}

/* -------------------------------------------------------------------------
   3. DESKTOP (>=1024px): Override any mobile toggle artifacts
   ----------------------------------------------------------------------- */
@media (min-width: 1024px) {
    .vloerplus-filter-toggle {
        display: none !important;
    }

    .custom-filter-container .custom-filters {
        max-height: none !important;
        opacity: 1 !important;
        overflow: visible !important;
        border: none !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        border-radius: 0 !important;
    }
}
