/* =========================================
   1. MODAL OVERLAY & BUTTONS
   ========================================= */

/* LOCK THE BACKGROUND */
body.modal-open {
    overflow: hidden;
}

:root {
    --primary-teal: #448892; 
    --bg-light: #f4f7f6;
    --reset-gray: #777;
    --border-color: #ccc;
}

.filter-controls {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: max-content;
    margin: 0 auto;
}

.modal-trigger-btn {
    background-color: var(--primary-teal);
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    /* Removed margin: auto; as the container now handles centering */
}

.filter-icon:before { 
    content: "\f0b0";
    font: normal normal normal 14px / 1 'ShortcodesUltimateIcons'; 
}

#listing-counter-display {
    text-align: center;
    font-weight: bold;
    color: #777;
    font-size: .8rem;
    margin: 3px 0 -5px;
}

.badge {
    background: white;
    color: var(--primary-teal);
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    padding: 2px;
}

.modal-overlay {
    display: none; 
    position: fixed;
    z-index: 100000; 
    left: 0; top: 0;
    width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(3px);
    
    /* Updated for mobile scrolling */
    align-items: flex-start; 
    overflow-y: auto; 
    padding: 20px 0; 
}

.modal-content {
    background-color: #fff;
    width: 95%;
    max-width: 850px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    position: relative;
    animation: modalSlide 0.3s ease-out;
    
    /* Updated for mobile scrolling */
    max-height: none; 
    margin: auto; 
}

@keyframes modalSlide {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    padding: 20px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
}

.modal-header h3 { margin: 0; font-size: 1.25rem; }
.close-x { font-size: 32px; cursor: pointer; color: #aaa; line-height: 1; }

.modal-body {
    padding: 25px;
    overflow-y: visible; 
}

.modal-selector-row {
    margin-bottom: 25px;
    width: 100%;
}

.modal-footer {
    padding: 20px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #eee;
    background: #fafafa;
    border-radius: 0 0 16px 16px;
}

.clear-all-link { 
    background: none; 
    border: none; 
    color: var(--reset-gray); 
    text-decoration: none; 
    cursor: pointer; 
    font-weight: 600; 
    font-size: 1rem;
}
.apply-btn { 
    background: var(--primary-teal); 
    color: white; 
    border: none; 
    padding: 12px 30px; 
    border-radius: 8px; 
    cursor: pointer; 
    font-weight: bold; 
    font-size: 1rem;
}

@media (max-width: 780px) {
    .filter-controls {
    margin: 0 auto 0 0;
}
}



/* =========================================
   2. DROPDOWN STYLES
   ========================================= */
.filter-grid {
    display: grid;
    grid-template-columns: 1fr; 
    gap: 20px;
}

/* Dynamic Layouts for Larger Screens */
@media (min-width: 650px) {
    /* DEFAULT: 4 items or 2 items (2x2 or 1x2 balanced) */
    .filter-grid { 
        grid-template-columns: repeat(2, 1fr); 
    }
    
    /* OVERRIDE: Exactly 3 items (Places them 3-in-a-row to prevent empty space) */
    .filter-grid.grid-cols-3 { 
        grid-template-columns: repeat(3, 1fr); 
    }
    
    /* OVERRIDE: Exactly 1 item (Centers it perfectly) */
    .filter-grid.grid-cols-1 { 
        grid-template-columns: 1fr; 
    }
}

.filter-group {
    display: flex;
    flex-direction: column;
    min-width: 0; 
}

.filter-title {
    font-weight: 700;
    margin: 0 auto 8px;
    max-width: 360px;
    font-size: 1rem;
    letter-spacing: 0.5px;
    width: 100%;
}

.dropdown-wrapper {
    position: relative;
    width: 100%;
    max-width: 360px;
    margin: 0 auto;
}

.dropdown-button {
    width: 100%;
    padding: 0.5em 3.5em 0.5em 1em;
    background-color: #fff;
    border: 2px solid #ddd;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    box-sizing: border-box;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
}

.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-top: none;
    z-index: 100001; 
    max-height: 350px;
    overflow-y: auto;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    border-radius: 12px;
}

.dropdown-content label {
    display: block;
    padding: 10px 12px;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap; 
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-content label:hover { background-color: #f0f4f4; }
.dropdown-content input {
    margin-right: 10px;
    accent-color: var(--primary-teal);
    transform: scale(1.1);
}

.show-all-btn {
    display: block;
    width: 100%;
    padding: 12px;
    background-color: #fafafa;
    border: none;
    border-top: 1px solid #eee;
    color: var(--reset-gray);
    font-weight: bold;
    font-size: 11px;
    text-transform: uppercase;
    cursor: pointer;
    text-align: center;
}

.show-all-btn:hover {
    background-color: var(--primary-teal);
    color: white;
}

.is-open { display: block !important; }

/* =========================================
   3. BULLETPROOF SLIDER RESET & STYLING
   ========================================= */
.noUi-target, .noUi-target * { -webkit-touch-callout: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); -webkit-user-select: none; -ms-touch-action: none; touch-action: none; -moz-user-select: none; user-select: none; box-sizing: border-box; }
.noUi-target { position: relative; background: #e0e0e0; border-radius: 5px; border: none; height: 10px !important; box-shadow: none; }
.noUi-base, .noUi-connects { width: 100%; height: 100%; position: relative; z-index: 1; }
.noUi-connects { overflow: hidden; z-index: 0; border-radius: 5px; }
.noUi-connect { background: var(--primary-teal) !important; height: 100%; width: 100%; transform-origin: 0 0; will-change: transform; }
.noUi-origin { position: absolute; top: 0; left: 0; height: 0; width: 100%; will-change: transform; }

/* SUPER STRONG HANDLE STYLING */
.noUi-handle {
    width: 22px !important; 
    height: 22px !important; 
    background: #fff !important; /* Force White Background */
    border: 2px solid var(--primary-teal) !important; /* Force Teal Border */
    border-radius: 50% !important; /* Force Circle */
    box-shadow: 0 2px 4px rgba(0,0,0,0.2); 
    cursor: pointer; 
    position: absolute;
    top: -7px !important; 
    right: -11px !important; 
    outline: none;
}

/* Hides the default little lines inside the handle */
.noUi-handle:before, .noUi-handle:after { display: none !important; }

.slider-wrapper { margin: 15px 12px; position: relative; }
.slider-values { display: flex; justify-content: space-between; font-size: 14px; color: #555; font-weight: 600; margin-top: 15px; }

/* Flex container for the slider row to handle side-by-side layouts */
.modal-slider-row {
    margin-top: 25px;
    padding-top: 25px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: space-evenly;
    flex-wrap: wrap;
    gap: 20px;
    width: 100%;
}


/* =========================================
   TOOLTIP STYLES
   ========================================= */
.filter-tooltip {
    position: absolute;
    left: calc(100% + 15px); /* Position right of the button */
    top: 50%;
    transform: translateY(-50%);
    width: 260px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 12px 18px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    font-size: 14px;
    color: #444;
    z-index: 100;
    line-height: 1.4;
}

/* Tooltip Left Arrow */
.filter-tooltip::before, .filter-tooltip::after {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    border-style: solid;
}
.filter-tooltip::before {
    left: -9px;
    border-width: 8px 9px 8px 0;
    border-color: transparent #ddd transparent transparent;
}
.filter-tooltip::after {
    left: -8px;
    border-width: 8px 9px 8px 0;
    border-color: transparent #fff transparent transparent;
}

/* Tooltip Close Button */
.tooltip-close {
    position: absolute;
    top: -10px;
    right: -10px;
    background: var(--primary-teal);
    color: #fff;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-family: sans-serif;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Mobile Adjustment: Move tooltip below button on small screens */
@media (max-width: 780px) {
    .filter-tooltip {
        left: 50%;
        top: calc(100% + 15px);
        transform: translateX(-50%);
        text-align: center;
		width: 160px;
    }
    .filter-tooltip::before {
        top: -9px;
        left: 50%;
        transform: translateX(-50%);
        border-width: 0 9px 9px 9px;
        border-color: transparent transparent #ddd transparent;
    }
    .filter-tooltip::after {
        top: -8px;
        left: 50%;
        transform: translateX(-50%);
        border-width: 0 9px 9px 9px;
        border-color: transparent transparent #fff transparent;
    }
}