/* ==========================================================================
   1. SEARCH PAGE MAIN LAYOUT
   ========================================================================== */
.search-container { max-width: 1400px; margin: 40px auto; padding: 0 20px; display: grid; grid-template-columns: 3fr 1fr; gap: 40px; }

.search-top-bar { grid-column: 1 / -1; margin-bottom: 10px; }
.search-breadcrumbs { font-size: 0.9rem; color: #888; margin-bottom: 15px; }
.search-breadcrumbs a { color: var(--rlp-red); text-decoration: none; }
.search-breadcrumbs a:hover { text-decoration: underline; }

.search-header { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 1px solid var(--border); padding-bottom: 15px; margin-bottom: 25px; }
.search-header h1 { font-size: 2rem; color: var(--rlp-red); margin: 0; font-weight: 400; }

.search-controls { display: flex; gap: 15px; align-items: center; color: #666; font-size: 1.2rem; }
.search-controls i { cursor: pointer; transition: color 0.2s; }
.search-controls i:hover, .search-controls i.active { color: var(--rlp-red); }

.search-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; color: #666; font-size: 0.95rem; }
.sort-dropdown { border: none; background: transparent; color: var(--text-dark); font-weight: 500; font-size: 0.95rem; cursor: pointer; outline: none; }

/* MAIN GRID OVERRIDES */
/* Since .property-card has slider widths in global.css, we override them here for the grid */
.property-grid .property-card { width: 100% !important; flex: auto; margin-bottom: 0; }

/* ==========================================================================
   2. NON-FILTER SIDEBAR WIDGETS
   ========================================================================== */
.sidebar-widget { background: #fff; padding: 30px 25px; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 30px; box-shadow: 0 4px 10px rgba(0,0,0,0.02); }
.sidebar-widget h3 { font-size: 1.2rem; font-weight: 400; color: var(--text-dark); margin-top: 0; margin-bottom: 20px; }

.sidebar-list { list-style: none; padding: 0; margin: 0; }
.sidebar-list li { margin-bottom: 15px; font-size: 0.95rem; }
.sidebar-list li:last-child { margin-bottom: 0; }
.sidebar-list a { color: var(--rlp-red); text-decoration: none; display: flex; align-items: center; gap: 10px; font-weight: 500; transition: color 0.2s; }
.sidebar-list a i { font-size: 0.8rem; }
.sidebar-list a:hover { color: #a30029; }


/* ==========================================================================
   3. STICKY TOP FILTER BAR
   ========================================================================== */
.sticky-filter-wrapper {
    position: sticky;
    top: 75px; /* <-- This is the magic number! It docks the bar right below the header */
    z-index: 900;
    background: #fff;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
}
.top-bar-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.top-bar-left { display: flex; align-items: center; gap: 12px; }

/* 1. Apply the 42px height to BOTH the left and right sides */
.top-bar-left, .top-bar-right { 
    display: flex; 
    align-items: center; 
    gap: 12px; 
    height: 42px; /* Forces uniform height across the whole bar */
}

/* 2. Fix the Search Input to match the height */
.filter-input-wrap { 
    display: flex; 
    align-items: center; 
    border: 1px solid #ccc; 
    border-radius: 4px; 
    overflow: hidden; 
    background: #fff; 
    height: 100%; /* Fill the 42px height */
    box-sizing: border-box;
}
.top-search-input { 
    border: none; 
    padding: 0 15px; 
    width: 280px; 
    outline: none; 
    font-size: 0.95rem; 
    height: 100%; /* Fill the container */
    background: transparent;
}
.search-icon { 
    padding: 0 15px; 
    color: #666; 
    cursor: pointer; 
    display: flex;
    align-items: center;
    height: 100%;
}

/* 3. CRITICAL: Make the popover wrapper fill the height so the buttons inside can stretch! */
.popover-wrapper { 
    position: relative; 
    height: 100%; 
}
/* Standard Top Bar Dropdown Buttons */
.top-filter-btn {
    background: #fff; border: 1px solid #ccc; padding: 0 15px; height: 100%; border-radius: 4px;
    font-size: 0.95rem; font-weight: 500; color: var(--text-dark); cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 8px; transition: 0.2s; box-sizing: border-box;
}
.top-filter-btn:hover, .top-filter-btn.active { background: #f0f0f0; border-color: #999; }

/* Save Search Button */
.btn-save-search { 
    background: #006aff; color: #fff; border: none; padding: 0 20px; height: 100%; border-radius: 4px; 
    font-weight: 600; font-size: 0.95rem; cursor: pointer; transition: 0.2s; display: flex; align-items: center; box-sizing: border-box;
}
.btn-save-search:hover { background: #005ce6; }

/* Inline Radio Toggles (For Sale / Lease) */
.top-inline-group.connected-group { display: flex; border: 1px solid #ccc; border-radius: 4px; overflow: hidden; margin: 0; height: 100%; box-sizing: border-box; }
.top-inline-group label { margin: 0; display: flex; height: 100%; }
.top-inline-group input[type="radio"] { display: none; }
.top-inline-group span { display: flex; align-items: center; justify-content: center; padding: 0 15px; font-size: 0.95rem; font-weight: 500; cursor: pointer; transition: 0.2s; height: 100%; box-sizing: border-box; }
.top-inline-group input[type="radio"]:checked + span { background: #004274; color: #fff; }


/* ==========================================================================
   4. DESKTOP POPOVER PANELS
   ========================================================================== */
.popover-wrapper { position: relative; }
.popover-panel {
    position: absolute; top: calc(100% + 10px); left: 0; background: #fff; border: 1px solid var(--border);
    border-radius: 8px; padding: 25px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); min-width: 350px; z-index: 1001; display: none; 
}
.popover-panel.show { display: block; } 

/* Price Popover Specifics */
.price-min-max-container { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.price-field { display: flex; flex-direction: column; flex: 1; }
.price-field label { font-size: 0.9rem; font-weight: 600; color: var(--text-dark); margin-bottom: 6px; }
.price-field input { width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 4px; font-size: 0.95rem; outline: none; transition: all 0.2s; }
.price-field input:focus { border-color: #006aff; box-shadow: 0 0 0 3px rgba(0, 106, 255, 0.15); }
.price-field input::placeholder { color: #888; }
.price-separator { color: #666; margin-top: 24px; }
.btn-apply-filter { width: 100%; background: #006aff; color: #fff; border: none; padding: 12px; border-radius: 4px; font-weight: 600; font-size: 1rem; cursor: pointer; transition: background 0.2s; }
.btn-apply-filter:hover { background: #005ce6; }


/* ==========================================================================
   5. OFF-CANVAS DRAWER
   ========================================================================== */
.sidebar {
    position: fixed; top: 0; right: 0; width: 100%; max-width: 400px; height: 100vh; background: #fff; z-index: 9999;
    overflow-y: auto; padding: 0; box-shadow: -5px 0 25px rgba(0,0,0,0.1); transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}
.sidebar.open { transform: translateX(0); }

.filter-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 9998; backdrop-filter: blur(2px); }
.filter-overlay.active { display: block; }

.filter-header { display: flex; justify-content: space-between; align-items: center; padding: 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: #fff; z-index: 10; }
.filter-header h3 { margin: 0; font-size: 1.2rem; }
.close-sidebar-btn { background: none; border: none; cursor: pointer; color: #333; font-size: 1.5rem; }
.reset-btn { background: none; border: none; color: var(--rlp-red); font-weight: 600; cursor: pointer; }

.drawer-body { padding: 25px 20px; }
.filter-footer { padding: 20px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: #fff; }
.btn-view-results { width: 100%; background: #006aff; color: white; border: none; padding: 12px; font-size: 1rem; font-weight: 600; border-radius: 4px; cursor: pointer; }

/* Filter Group Spacing & Typography */
.filter-group { margin-bottom: 30px; }
.filter-group .heading { display: block; font-size: 1.05rem; font-weight: 600; color: var(--text-dark, #333); margin-bottom: 12px; }

/* Unified Form Controls (Selects & Custom Dropdowns) */
.form-control, .dropdown-header {
    width: 100%; padding: 12px 15px; border: 1px solid #d1d1d5; border-radius: 6px; background-color: #fff;
    font-size: 0.95rem; color: var(--text-dark); outline: none; transition: all 0.2s ease; cursor: pointer;
    display: flex; justify-content: space-between; align-items: center;
}
select.form-control {
    -webkit-appearance: none; -moz-appearance: none; appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="%23666" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9l6 6 6-6"/></svg>');
    background-repeat: no-repeat; background-position: right 15px center; padding-right: 40px;
}
.form-control:focus, .form-control:hover, .dropdown-header:hover { border-color: #006aff; }
select.form-control:focus { box-shadow: 0 0 0 3px rgba(0, 106, 255, 0.1); }

/* Min/Max Select Rows */
.min-max-row { display: flex; align-items: center; gap: 12px; }
.min-max-row .form-control { flex: 1; }
.range-dash { color: #888; font-weight: 500; }


/* ==========================================================================
   6. CUSTOM UI INPUTS (Radios, Checkboxes & City Dropdown)
   ========================================================================== */
/* Square Radio Buttons (Beds/Baths) */
.square-radio-group { display: flex; gap: 6px; flex-wrap: nowrap; margin-bottom: 20px; width: 100%; }
.square-radio-group input[type="radio"] { display: none; }
.square-radio-group label.radio-btn { margin: 0; cursor: pointer; flex: 1; }
.square-radio-group span { display: flex; align-items: center; justify-content: center; width: 100%; height: 42px; border: 1px solid #d1d1d5; border-radius: 6px; background: #fff; color: var(--text-dark); font-weight: 500; font-size: 0.9rem; transition: all 0.2s ease; padding: 0; user-select: none; }
.square-radio-group label.radio-btn:hover span { border-color: #006aff; color: #006aff; }
.square-radio-group input[type="radio"]:checked + span { background: #006aff; color: #fff; border-color: #006aff; box-shadow: 0 2px 6px rgba(0, 106, 255, 0.2); }

.square-radio-group label.any-btn span { background: #f4f5f7; color: #555; }
.square-radio-group label.any-btn input[type="radio"]:checked + span { background: #444; border-color: #444; color: #fff; box-shadow: none; }

/* Custom Checkboxes (Property Types & Features) */
.checkbox-group { display: flex; flex-direction: column; gap: 12px; }
.custom-checkbox { display: flex; align-items: center; gap: 12px; cursor: pointer; margin: 0; user-select: none; }
.custom-checkbox input[type="checkbox"] { display: none; }
.custom-checkbox .checkmark { width: 22px; height: 22px; border: 2px solid #ccc; border-radius: 4px; background: #fff; display: flex; align-items: center; justify-content: center; transition: all 0.2s ease; }
.custom-checkbox:hover .checkmark { border-color: #006aff; }
.custom-checkbox input[type="checkbox"]:checked + .checkmark { background: #006aff; border-color: #006aff; }
.custom-checkbox input[type="checkbox"]:checked + .checkmark::after { content: ''; width: 6px; height: 11px; border: solid white; border-width: 0 2px 2px 0; transform: rotate(45deg); margin-bottom: 2px; }
.custom-checkbox .label-text { font-size: 0.95rem; color: var(--text-dark); font-weight: 500; }
.custom-checkbox .text-muted { color: #888; font-size: 0.85rem; font-weight: 400; }

/* City Dropdown UI */
.dropdown-panel { display: none; border: 1px solid var(--border); border-top: none; border-radius: 0 0 4px 4px; background: #fff; max-height: 300px; overflow-y: auto; padding: 10px; box-shadow: 0 4px 10px rgba(0,0,0,0.05); }
.dropdown-panel.show { display: block; }
.custom-checkbox input[type="checkbox"]:checked + .green-check { background: #28a745; border-color: #28a745; }
.city-item { padding: 8px 10px; border-radius: 4px; transition: background 0.2s; margin-bottom: 2px; }
.city-item:hover { background: #f8f9fa; }


/* ==========================================================================
   7. PAGINATION
   ========================================================================== */
.pagination-container { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--border); display: flex; justify-content: center; grid-column: 1 / -1; }
.pagination { display: flex; gap: 8px; align-items: center; }
.page-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 4px; background: #fff; color: var(--text-dark); font-weight: 500; font-size: 0.95rem; transition: all 0.2s; text-decoration: none; }
.page-btn:hover { background: #f0f0f0; border-color: #ccc; }
.page-btn.active { background: var(--rlp-red); color: #fff; border-color: var(--rlp-red); pointer-events: none; }
.page-dots { color: #888; font-weight: 600; padding: 0 5px; }


/* ==========================================================================
   8. RESPONSIVE MEDIA QUERIES
   ========================================================================== */

/* Mobile Master Filter Button */
.meta-controls { display: flex; align-items: center; gap: 15px; }
.btn-mobile-filter { display: none; background: #fff; border: 1px solid var(--border); padding: 8px 15px; border-radius: 4px; font-weight: 600; color: var(--text-dark); cursor: pointer; }
.btn-mobile-filter i { color: var(--rlp-red); margin-right: 5px; }

@media (max-width: 1024px) {
    .desktop-only { display: none !important; }
    .top-search-input { width: 100%; }
    .top-bar-left { width: 100%; justify-content: space-between; }
}

@media (max-width: 992px) {
    .search-container { grid-template-columns: 1fr; }
    .search-header { flex-direction: column; align-items: flex-start; gap: 15px; }
    
    /* Reveal mobile filter button and hide sidebars */
    .btn-mobile-filter { display: block; } 
    #sidebar-popular-searches, #sidebar-metro-cities { display: none; }
}

@media (max-width: 768px) {
    .page-btn { min-width: 35px; height: 35px; padding: 0 10px; font-size: 0.85rem; }
}
/* --- ACTIVE FILTER CHIPS --- */
.active-filters-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    grid-column: 1 / -1; /* Ensures it spans the full width of the grid area */
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 16px;
    background: #fff5f5; /* Very subtle light red background */
    border: 1px solid var(--rlp-red, #e3003a);
    border-radius: 20px; /* Pill shape */
    color: var(--rlp-red, #e3003a);
    font-size: 0.9rem;
    font-weight: 500;
}

.filter-chip .remove-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(227, 0, 58, 0.1); /* Soft red background for the X */
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-chip .remove-btn:hover {
    background: var(--rlp-red, #e3003a);
    color: #fff;
}

.filter-chip .remove-btn i {
    font-size: 0.75rem;
}
/* --- MOBILE DRAWER FILTERS --- */
/* Hide them on desktop */
.mobile-only-drawer-filters {
    display: none; 
}

/* Show them in the drawer once the top-bar versions disappear */
@media (max-width: 1024px) {
    .mobile-only-drawer-filters {
        display: block;
    }
}