/* Mobile Filter Toggle Styles - Only for mobile devices */

/* Default: Hide toggle button on desktop */
.filter-toggle-btn {
    display: none;
}

/* Reset button styling for all devices */
#link-reset.select-control {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.3s ease;
    width: 160px;
}

#link-reset.select-control:hover {
    background: #f2f2f2;
}

#link-reset.select-control i {
    font-size: 16px;
    color: #666;
}

#link-reset.select-control .select-control-label {
    padding: 8px 0;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

/* Filter control button (Lọc thêm) - match height with other controls */
.select-control.filter-control {
    height: 60px;
    min-height: 60px;
}

.select-control.filter-control .select-control-label {
    height: 60px;
    padding: 8px 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Search button inside filters wrapper - Desktop: float right */
.filters-collapsible-wrapper #btnSearch {
    display: inline-block;
    float: right;
    margin-left: 8px;
}

/* Mobile only styles */
@media only screen and (max-width: 576px) {
    /* Search input wrapper with toggle button */
    .search-bar-suggestion.search-input-wrapper {
        display: flex !important;
        align-items: center;
        gap: 8px;
        width: 100% !important;
        margin-right: 0 !important;
        padding: 12px 16px;
        float: none !important;
        position: relative;
    }

    .search-bar-suggestion.search-input-wrapper .re__input--sm {
        flex: 1;
        min-width: unset !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Toggle Button Styles */
    .filter-toggle-btn {
        display: flex !important;
        background: #fff;
        border: 1px solid #ccc;
        border-radius: 4px;
        width: 40px !important;
        height: 33px !important;
        min-width: 40px;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.3s ease;
        flex-shrink: 0;
        padding: 0;
        outline: none;
        z-index: 10;
    }

    .filter-toggle-btn:hover {
        background: #f2f2f2;
    }

    .filter-toggle-btn:active {
        background: #e0e0e0;
    }

    .filter-toggle-btn i {
        font-size: 20px;
        transition: transform 0.3s ease;
        color: #666;
        pointer-events: none;
    }

    .filter-toggle-btn.active i {
        transform: rotate(180deg);
    }

    /* Collapsible Wrapper */
    .filters-collapsible-wrapper {
        max-height: 0 !important;
        overflow: hidden !important;
        transition: max-height 0.5s ease-in-out;
        width: 100% !important;
        display: flex !important;
        flex-wrap: wrap !important;
        clear: both;
        float: none !important;
        order: 10;
    }

    .filters-collapsible-wrapper.filters-expanded {
        max-height: 3000px !important;
    }

    /* Search bar container */
    #boxSearchForm .search-bar {
        flex-wrap: wrap !important;
        display: flex !important;
        padding-bottom: 8px;
        position: relative;
    }

    /* Filter controls inside wrapper */
    .filters-collapsible-wrapper .select-control {
        width: calc(50% - 8px) !important;
        margin: 4px !important;
        border: 1px solid #e0e0e0 !important;
        border-radius: 4px;
        float: none !important;
        height: 48px;
        min-height: 48px;
        max-height: 48px;
        cursor: pointer;
        transition: all 0.3s ease;
        overflow: hidden;
    }

    .filters-collapsible-wrapper .select-control:hover {
        background: #f9f9f9;
        border-color: #ccc !important;
    }

    .filters-collapsible-wrapper .select-control:active {
        background: #f2f2f2;
    }

    /* Reduce height of select control labels */
    .filters-collapsible-wrapper .select-control .select-control-label {
        height: 48px !important;
        padding: 5px 8px !important;
        min-height: 48px !important;
        max-height: 48px !important;
        position: relative;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        overflow: hidden !important;
    }

    /* Reduce font size and spacing */
    .filters-collapsible-wrapper .select-control .dropbox-label {
        font-size: 10px !important;
        line-height: 12px !important;
        margin-bottom: 1px !important;
        display: block;
        color: #666 !important;
    }

    .filters-collapsible-wrapper .select-control .custom-value {
        font-size: 13px !important;
        line-height: 15px !important;
        margin-top: 0 !important;
        position: relative;
        display: block;
        color: #333 !important;
    }

    /* Show Select2 container properly */
    .filters-collapsible-wrapper .select2-container {
        display: block !important;
        width: 100% !important;
    }

    /* Ensure Select2 selection has proper height and shows arrow */
    .filters-collapsible-wrapper .select2-container .select2-selection--single {
        border: none !important;
        background: transparent !important;
        height: auto !important;
        min-height: auto !important;
        padding: 0 !important;
    }

    /* Text ellipsis for long values - keep padding for arrow */
    .filters-collapsible-wrapper .select2-selection__rendered {
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        display: block !important;
        padding-right: 24px !important;
        font-size: 13px !important;
        line-height: 16px !important;
    }

    /* Show Select2 arrow properly */
    .filters-collapsible-wrapper .select2-selection__arrow {
        height: 16px !important;
        right: 0 !important;
        top: 0 !important;
        width: 20px !important;
        display: block !important;
        position: absolute !important;
    }

    .filters-collapsible-wrapper .select2-selection__arrow b {
        border-color: #999 transparent transparent transparent !important;
        border-style: solid !important;
        border-width: 5px 4px 0 4px !important;
        height: 0 !important;
        left: 50% !important;
        margin-left: -4px !important;
        margin-top: -2px !important;
        position: absolute !important;
        top: 50% !important;
        width: 0 !important;
    }

    /* Arrow rotates when dropdown is open */
    .filters-collapsible-wrapper .select2-container--open .select2-selection__arrow b {
        border-color: transparent transparent #999 transparent !important;
        border-width: 0 4px 5px 4px !important;
    }

    /* Compact text-only filters (Price, Area) */
    .filters-collapsible-wrapper .btnFilterPrice,
    .filters-collapsible-wrapper .btnFilterAcreage {
        padding-right: 20px !important;
    }

    /* Remove fake icon - use Select2's native arrow instead */

    /* Show caret icon for price and area filters */
    .filters-collapsible-wrapper .custom-value.text-only i.fa-caret-down {
        display: inline-block !important;
        opacity: 1 !important;
        visibility: visible !important;
        font-size: 16px !important;
        margin-left: 4px !important;
        color: #999 !important;
    }

    /* Ensure the span and icon are on same line */
    .filters-collapsible-wrapper .custom-value.text-only {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 4px !important;
    }

    .filters-collapsible-wrapper .custom-value.text-only span {
        flex: 1;
    }

    .filters-collapsible-wrapper .custom-value.text-only i {
        flex-shrink: 0;
    }

    /* Compact select dropdown */
    .filters-collapsible-wrapper .select-control select {
        font-size: 13px !important;
    }

    /* Compact text in filter buttons */
    .filters-collapsible-wrapper .select-control .re__text {
        font-size: 13px !important;
        line-height: 20px !important;
        margin-top: 0 !important;
    }

    .filters-collapsible-wrapper .select-control .filter-info {
        line-height: 20px !important;
    }

    /* Reset button inside filter wrapper */
    .filters-collapsible-wrapper #link-reset {
        /* width: calc(50% - 8px) !important; */
        height: 48px !important;
        min-height: 48px !important;
        max-height: 48px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        margin: 4px !important;
        cursor: pointer;
        transition: all 0.3s ease;
        padding: 0 !important;
        border: 1px solid #e0e0e0 !important;
        border-radius: 4px !important;
        background: #fff !important;
    }

    .filters-collapsible-wrapper #link-reset:hover {
        background: #f9f9f9 !important;
        border-color: #ccc !important;
    }

    .filters-collapsible-wrapper #link-reset:active {
        background: #f2f2f2 !important;
    }

    .filters-collapsible-wrapper #link-reset i {
        font-size: 16px;
        display: inline-block !important;
        opacity: 1 !important;
        visibility: visible !important;
        color: #666;
    }

    /* Hide filter walls on mobile */
    .filters-collapsible-wrapper .re__filter-wall,
    #boxSearchForm .search-bar > .re__filter-wall {
        display: none !important;
    }

    /* Search button inside filters wrapper - full width row */
    .filters-collapsible-wrapper #btnSearch {
        width: calc(100% - 8px) !important;
        margin: 8px 4px 4px 4px !important;
        float: none !important;
        order: 999 !important;
        display: block !important;
        height: 44px !important;
        font-size: 15px !important;
        font-weight: 500 !important;
        border-radius: 4px !important;
        flex: 0 0 100% !important;
        max-width: calc(100% - 8px) !important;
    }

    /* Ensure button has proper spacing when filters expanded */
    .filters-collapsible-wrapper.filters-expanded #btnSearch {
        display: block !important;
    }

    #boxSearchForm .search-bar #link-reset {
        width: 42px !important;
        order: 998;
    }

    /* Ensure select controls are visible when expanded */
    .filters-collapsible-wrapper.filters-expanded .select-control {
        display: block !important;
    }

    /* Compact dropdown menus */
    .filters-collapsible-wrapper .custom-dropbox {
        margin-top: 48px !important;
    }

    /* Reduce spacing in price/area filters */
    .filters-collapsible-wrapper .select_option_custom {
        padding: 12px !important;
    }

    .filters-collapsible-wrapper .select_option_top {
        margin-bottom: 10px !important;
    }

    .filters-collapsible-wrapper .option_col label {
        font-size: 12px !important;
        margin-bottom: 4px !important;
    }

    .filters-collapsible-wrapper .option_col select {
        height: 36px !important;
        font-size: 13px !important;
        padding: 6px 8px !important;
    }

    /* Compact quick select options */
    .filters-collapsible-wrapper .select_option_quick li {
        padding: 8px 10px !important;
        font-size: 12px !important;
    }

    /* Compact advance filter button */
    .filters-collapsible-wrapper .select-control.filter-control {
        min-height: 48px !important;
        height: 48px !important;
        max-height: 48px !important;
        border: 1px solid #e0e0e0 !important;
        border-radius: 4px !important;
        background: #fff !important;
    }

    .filters-collapsible-wrapper .select-control.filter-control .select-control-label {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 4px !important;
        height: 48px !important;
        padding: 0 8px !important;
        min-height: 48px !important;
        max-height: 48px !important;
        flex-direction: row !important;
    }

    /* Reduce icon size */
    .filters-collapsible-wrapper .re__icon-filters {
        font-size: 15px !important;
        display: inline-block !important;
        opacity: 1 !important;
        visibility: visible !important;
        margin-right: 4px !important;
    }

    .filters-collapsible-wrapper .filter-info {
        display: inline-flex !important;
        align-items: center !important;
        line-height: 1 !important;
    }

    .filters-collapsible-wrapper .filter-info .icon-number {
        width: 16px !important;
        height: 16px !important;
        font-size: 10px !important;
        line-height: 16px !important;
    }

    /* Text in filter button */
    .filters-collapsible-wrapper .select-control.filter-control .re__text {
        font-size: 13px !important;
        line-height: 1 !important;
        margin: 0 !important;
    }

    /* Adjust advance filter dropdown position */
    .filters-collapsible-wrapper .select-filter-dropbox {
        top: 48px !important;
    }

    /* Compact advance filter content */
    .filters-collapsible-wrapper .select-context {
        margin-bottom: 12px !important;
    }

    .filters-collapsible-wrapper .select-context label {
        font-size: 12px !important;
        margin-bottom: 6px !important;
    }

    .filters-collapsible-wrapper .select-context select {
        height: 38px !important;
        font-size: 13px !important;
    }

    /* Compact bedroom options */
    .filters-collapsible-wrapper .select-bedroom ul li {
        padding: 8px 12px !important;
        font-size: 13px !important;
    }

    /* Compact submit button in advance filter */
    .filters-collapsible-wrapper .filter-reset {
        margin-top: 12px !important;
    }

    .filters-collapsible-wrapper .filter-reset button {
        height: 38px !important;
        font-size: 14px !important;
    }


    /* Compact select2 dropdown results */
    .select2-container--open .select2-dropdown--below {
        font-size: 13px !important;
    }

    .select2-results__option {
        padding: 8px 12px !important;
        font-size: 13px !important;
    }
}

/* Tablet: Keep normal layout */
@media only screen and (min-width: 577px) and (max-width: 768px) {
    .filter-toggle-btn {
        display: none !important;
    }

    .filters-collapsible-wrapper {
        max-height: none !important;
        overflow: visible !important;
    }
}
