/* Filter Button Wrapper */
.listing_filters_button_wrapper {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

/* Filter Trigger Button */
.filter-trigger {
    background: #FF385C;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(255, 56, 92, 0.2);
}

.filter-trigger:hover {
    background: #E31C5F;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 56, 92, 0.3);
}

.filter-trigger:active {
    transform: translateY(0);
}

.filter-trigger.has-active-filters {
    background: #E31C5F;
    position: relative;
}

.filter-trigger.has-active-filters::after {
    content: attr(data-filter-count);
    position: absolute;
    top: -8px;
    right: -8px;
    background: #fff;
    color: #FF385C;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #FF385C;
}

/* External Sort Button Styles */
.sort-button-external {
    position: relative;
    display: inline-block;
}

.sort-button-external .filter_menu_trigger {
    background: #ffffff;
    border: 2px solid #e0e6ed;
    border-radius: 8px;
    padding: 12px 16px;
    color: #484848;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 150px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.sort-button-external .filter_menu_trigger:hover {
    border-color: #FF385C;
    color: #FF385C;
}

.sort-button-external .filter_menu_trigger .caret_filter {
    margin-left: 8px;
    border-top: 4px solid;
    border-right: 4px solid transparent;
    border-left: 4px solid transparent;
    transition: transform 0.2s ease;
}

.caret:after {
    display: none;
    margin-top: 0px;
}

.sort-button-external .dropdown-menu.show,
.sort-button-external .dropdown-menu:not(.hide) {
    display: block;
}

.sort-button-external .dropdown-menu li {
    padding: 10px 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    color: #484848;
    font-weight: 400;
}

.sort-button-external .dropdown-menu li:hover {
    background-color: #f8f9fa;
    color: #FF385C;
}

.sort-button-external .dropdown-menu li:first-child {
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.sort-button-external .dropdown-menu li:last-child {
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

/* Results Count */
.filters-results-count {
    color: #666;
    font-size: 14px;
    margin-left: auto;
}

/* Filter Drawer Wrapper */
.filterwrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: all 0.3s ease;
}

.filterwrapper.open {
    opacity: 1;
    pointer-events: all;
}

/* Snap Drawers for Filter */
.filterwrapper .snap-drawers {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Filter Drawer */
.filter-drawer {
    position: absolute;
    top: 0;
    left: 0;
    width: 400px;
    height: 100%;
    background: #ffffff;
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.1);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    z-index: 1000000;
}

#filterwrapper_drawer.snap-drawer-open .filter-drawer {
    transform: translateX(0);
}

/* Filter Drawer Header */
.filter-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: #FF385C;
    color: white;
    border-bottom: none;
    position: sticky;
    top: 0;
    z-index: 10001;
}

.filter-drawer-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.filtermenu-close {
    cursor: pointer;
    font-size: 22px;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.filtermenu-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Filter Drawer Content */
.filter-drawer-content {
    padding: 24px;
}

/* Filter Groups */
.filter-group {
    margin-bottom: 15px;
    border-bottom: 1px solid #ddd;
    padding-bottom: 15px;
}

.filter-group.order_filter {
    margin-bottom: 0px;
    padding-bottom: 0px;
    border-bottom: none;
}

.filter-group:last-of-type {
    border-bottom: none;
}

/* Filter Label */
.filter-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
}

.filter-label i {
    color: #FF385C;
    font-size: 18px;
}

/* Price Range Styles */
.price-range-group {
    margin-bottom: 25px;
}

.price-range-wrapper {
    margin-top: 10px;
}

.price-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.price-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    text-align: center;
    font-weight: 500;
}

.price-input:focus {
    outline: none;
    border-color: #FF385C;
    box-shadow: 0 0 0 2px rgba(255, 56, 92, 0.1);
}

.price-separator {
    color: #666;
    font-weight: 500;
    font-size: 16px;
}

.price-range-slider {
    margin: 15px 0;
    position: relative;
}

.price-range {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #e0e0e0;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.price-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #FF385C;
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.price-range::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #FF385C;
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.price-range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #666;
    margin-top: 8px;
    font-weight: 500;
}

/* Filter Tags Container */
.filter-tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Filter Tag Buttons */
.filter-tag {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #e0e0e0;
    padding: 5px 10px;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.filter-tag:hover {
    border-color: #FF385C;
    color: #FF385C;
    background: rgba(255, 56, 92, 0.05);
}

.filter-tag.active {
    background: #FF385C;
    color: white;
    border-color: #FF385C;
    box-shadow: 0 2px 8px rgba(255, 56, 92, 0.3);
}

.filter-tag.active:hover {
    background: #e1315a;
    border-color: #e1315a;
}

/* Sort Dropdown (keeping dropdown for sort) */
.filter-drawer .listing_filter_select {
    width: 100%;
}

.listing_filter_select {
    border: none;
}

.filter-drawer .filter_menu_trigger {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    background: #f8f9fa;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    transition: all 0.2s ease;
}

.filter-drawer .filter_menu_trigger:hover {
    border-color: #FF385C;
    background: #fff;
    box-shadow: 0 2px 8px rgba(255, 56, 92, 0.1);
}

.filter-drawer .filter_menu_trigger:focus {
    outline: none;
    border-color: #FF385C;
    box-shadow: 0 0 0 3px rgba(255, 56, 92, 0.1);
}

.filter-drawer .caret_filter {
    border-top: 5px solid #666;
    border-right: 5px solid transparent;
    border-left: 5px solid transparent;
    transition: transform 0.2s ease;
}

.filter-drawer .filter_menu_trigger[aria-expanded="true"] .caret_filter {
    transform: rotate(180deg);
}

/* Dropdown Menu Styling */
.filter-drawer .dropdown-menu {
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    border: 2px solid #e0e0e0;
    border-top: none;
    border-radius: 0 0 12px 12px;
    margin-top: -2px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    background: #fff;
}

.filter-drawer .dropdown-menu li {
    padding: 12px 16px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s ease;
    border-bottom: 1px solid #f5f5f5;
}

.filter-drawer .dropdown-menu li:last-child {
    border-bottom: none;
}

.filter-drawer .dropdown-menu li:hover {
    background: rgba(255, 56, 92, 0.05);
    color: #FF385C;
}

/* Filter Actions */
.filter-actions {
    display: flex;
    gap: 12px;
    margin-top: 40px;
    padding-top: 24px;
    border-top: 2px solid #f0f0f0;
}

.filter-clear-btn,
.filter-apply-btn {
    flex: 1;
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
}

.filter-clear-btn {
    background: #f8f9fa;
    color: #666;
    border: 2px solid #e0e0e0;
}

.filter-clear-btn:hover {
    background: #e9ecef;
    color: #495057;
    border-color: #adb5bd;
}

.filter-apply-btn {
    background: #FF385C;
    color: white;
    box-shadow: 0 2px 8px rgba(255, 56, 92, 0.3);
}

.filter-apply-btn:hover {
    background: #e1315a;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(255, 56, 92, 0.4);
}

/* Overlay */
.filterwrapper::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.filterwrapper.open::before {
    opacity: 1;
    pointer-events: all;
}

/* Responsive Design */
@media (max-width: 768px) {
    .filter-drawer {
        width: 350px;
        left: -350px;
    }

    .listing_filters_button_wrapper {
        gap: 10px;
    }

    .sort-button-external .filter_menu_trigger {
        min-width: 120px;
        padding: 8px 12px;
        font-size: 13px;
    }

    .filters-results-count {
        font-size: 13px;
        margin-left: 0;
        order: -1;
        width: 100%;
    }

    .filter-drawer-content {
        padding: 20px;
    }

    .filter-group {
        margin-bottom: 24px;
        padding-bottom: 20px;
    }

    .filter-tag {
        padding: 6px 12px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .filter-drawer {
        width: 320px;
        left: -320px;
    }

    .listing_filters_button_wrapper {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .filter-trigger {
        width: 100%;
        justify-content: center;
    }

    .filter-actions {
        flex-direction: column;
    }

    .filter-clear-btn,
    .filter-apply-btn {
        width: 100%;
    }
}

/* Animation for smooth opening */
.filter-drawer {
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Accessibility improvements */
.filter-trigger:focus {}

.filtermenu-close:focus {}

.filter-tag:focus {}

/* Custom scrollbar for drawer */
.filter-drawer::-webkit-scrollbar {
    width: 6px;
}

.filter-drawer::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.filter-drawer::-webkit-scrollbar-thumb {
    background: #FF385C;
    border-radius: 3px;
}

.filter-drawer::-webkit-scrollbar-thumb:hover {
    background: #e1315a;
}

/* Active state for selected filters */
.filter-group.has-active-filters .filter-label {
    color: #FF385C;
}

.filter-group.has-active-filters .filter-label i {
    color: #FF385C;
}

/* Loading states */
.filter-clear-btn:disabled,
.filter-apply-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.filter-apply-btn.loading {
    position: relative;
}

.filter-apply-btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid transparent;
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* External sort dropdown */
.sort-button-external .dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-width: 215px;
    margin-top: 5px;
    padding: 8px 0;
    display: none;
}

.sort-button-external .dropdown-menu.show {
    display: block !important;
}

/* Ensure dropdown stays hidden on page load */
#filter_order_external {
    display: none;
}

/* Force hidden state overrides visibility */
#filter_order_external.force-hidden {
    display: none !important;
}

/* When shown via JavaScript and not force-hidden */
#filter_order_external:not(.force-hidden) {
    display: block;
}

/* Filter drawer open/close states */
body.snap-drawer-open {
    overflow: hidden;
}

#filterwrapper_drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    pointer-events: none;
    visibility: hidden;
    opacity: 0;
    transition: all 0.3s ease;
}

#filterwrapper_drawer.snap-drawer-open {
    pointer-events: auto;
    visibility: visible;
    opacity: 1;
}

#filterwrapper_drawer .snap-drawers {
    position: relative;
    width: 100%;
    height: 100%;
}

#filterwrapper_drawer .snap-drawers::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

#filterwrapper_drawer.snap-drawer-open .snap-drawers::before {
    opacity: 1;
    pointer-events: auto;
}

.filter-drawer {
    position: absolute;
    top: 0;
    left: 0;
    width: 400px;
    height: 100%;
    background: #ffffff;
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.1);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    z-index: 1000000;
}

#filterwrapper_drawer.snap-drawer-open .filter-drawer {
    transform: translateX(0);
}