/* =========================================
   1. VARIABLES & BASE STYLES
   ========================================= */
:root { 
    --primary: #0C0020; 
    --accent: #5550FF; 
    --accent-light: #F0F0FF; 
    --bg: #f9f9f9; 
    --white: #ffffff; 
    --border: #E1E0E4; 
    --text-muted: #666; 
    --danger: #e74c3c; 
    --text-main: #333333;
    --remax-blue: #003DA5;
    --remax-red: #E11B22;
    --remax-white: #ffffff;
    --remax-border: #E1E0E4;
}

* { box-sizing: border-box; }
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; margin: 0; background-color: var(--bg); color: var(--primary); }

/* =========================================
   2. MAIN LAYOUT & GRID
   ========================================= */
.container { display: flex; max-width: 1450px; margin: 0 auto; padding: 2rem; gap: 2rem; align-items: flex-start; }
.main-content { flex: 1; }
.header-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.property-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.5rem; }

/* =========================================
   3. MODERN PROPERTY CARDS
   ========================================= */
.card {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--white);
    transition: box-shadow 0.2s ease-in-out;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}
.card:hover { box-shadow: 0 4px 15px rgba(0,0,0,0.1); }
.card-img-wrapper { position: relative; height: 200px; }
.card-img { width: 100%; height: 100%; object-fit: cover; border-bottom: 1px solid var(--border); }
.tag-sale { position: absolute; top: 10px; right: 10px; background: var(--danger); color: white; padding: 4px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: bold; }

/* --- NEW GREEN BADGE (Top Left) - SMALLER --- */
.tag-new { 
    position: absolute; 
    top: 10px; 
    left: 10px; 
    background: #008040; 
    color: white; 
    padding: 3px 8px; 
    border-radius: 20px; 
    font-size: 0.7rem; 
    font-weight: 800; 
    text-transform: uppercase; 
    letter-spacing: 0.5px;
    z-index: 2;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.card-info { padding: 16px 18px; }
.card-price { font-size: 1.55rem; font-weight: 700; color: var(--primary); margin-bottom: 8px; font-family: 'Segoe UI', Tahoma, sans-serif; }
.card-stats { font-size: 0.95rem; color: var(--text-main); margin-bottom: 6px; }
.card-stats b { font-weight: 700; color: var(--primary); }
.card-address { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* =========================================
   4. SIDEBAR & FILTER STRUCTURE
   ========================================= */
.sidebar { width: 320px; background: var(--white); border-radius: 8px; border: 1px solid var(--border); padding: 20px; flex-shrink: 0; position: sticky; top: 90px; overflow-y: auto; }
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #ccc; border-radius: 10px; }

/* Sticky Header & Footer */
.filter-header { position: sticky; top: -20px; background: var(--white); z-index: 110; display: flex; justify-content: space-between; align-items: center; padding: 20px; border-bottom: 1px solid var(--border); margin: -20px -20px 20px -20px; }
.filter-header h3 { margin: 0; font-size: 1.2rem; font-weight: 700; position: absolute; left: 50%; transform: translateX(-50%); }
.close-sidebar-btn { background: none; border: none; cursor: pointer; padding: 0; display: flex; align-items: center; color: var(--primary); }
.reset-btn { color: #006666; background: none; border: none; cursor: pointer; font-weight: 700; font-size: 1rem; }

.filter-footer { display: none; }
.btn-view-results { width: 100%; background: var(--remax-red); color: white; border: none; padding: 14px; font-size: 1.1rem; font-weight: bold; border-radius: 8px; cursor: pointer; transition: background 0.2s; }
.btn-view-results:hover { background: #b3151b; }

/* Filter Groups & Standard Inputs */
.filter-group { margin-bottom: 1.5rem; }
.filter-group label.heading { display: block; font-weight: bold; margin-bottom: 10px; font-size: 0.95rem; }
.form-control { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 6px; outline: none; background: var(--white); font-size: 0.9rem;}
select.form-control:not([multiple]) { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23666%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E"); background-repeat: no-repeat; background-position: right 15px top 50%; background-size: 10px auto; }

/* =========================================
   5. CUSTOM UI COMPONENTS
   ========================================= */
/* Checkboxes & Pills */
.checkbox-group { display: flex; flex-direction: column; gap: 10px; }
.checkbox-item { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; cursor: pointer; }
.checkbox-item input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }
.scrollable-features { max-height: 200px; overflow-y: auto; padding-right: 10px; }
.scrollable-features::-webkit-scrollbar { width: 6px; }
.scrollable-features::-webkit-scrollbar-thumb { background: #ccc; border-radius: 10px; }

/* Segmented Controls (Beds/Baths/Sale Type) */
.connected-group { display: flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--white); width: 100%; }
.connected-group label { flex: 1; text-align: center; cursor: pointer; border-right: 1px solid var(--border); }
.connected-group label:last-child { border-right: none; }
.connected-group input { display: none; }
.connected-group span { display: block; padding: 8px 0; font-size: 0.85rem; font-weight: 500; transition: 0.2s; color: var(--primary); }
.connected-group input:checked + span { background: #f0f4ff; color: var(--remax-blue); border: 1px solid var(--remax-blue); margin: -1px; position: relative; z-index: 1; font-weight: bold; }

/* Dual Range Sliders */
.dual-range-wrapper { position: relative; width: 100%; height: 30px; margin-top: 10px; }
.dual-range-wrapper::before { content: ""; position: absolute; width: 100%; height: 4px; background: var(--border); top: 13px; border-radius: 2px; }
.slider-track { position: absolute; height: 4px; background: var(--remax-blue); top: 13px; border-radius: 2px; z-index: 1; }
.dual-range { -webkit-appearance: none; appearance: none; width: 100%; position: absolute; top: 5px; background: transparent; pointer-events: none; z-index: 2; }
.dual-range::-webkit-slider-thumb { -webkit-appearance: none; height: 20px; width: 20px; border-radius: 50%; background: var(--white); border: 2px solid var(--remax-blue); cursor: pointer; pointer-events: auto; box-shadow: 0 1px 3px rgba(0,0,0,0.15); position: relative; z-index: 3; }

/* Price Inputs */
.price-input-container { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.price-input-box { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; background: var(--white); flex: 1; }
.price-input-box span { color: var(--remax-blue); font-weight: bold; margin-right: 5px; }
.price-input-box input { border: none; outline: none; width: 100%; font-size: 0.95rem; color: var(--primary); }
.price-dash { color: #999; font-weight: bold; }
.price-labels { display: flex; justify-content: space-between; margin-top: 15px; font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }

/* Min/Max Dropdown Layout */
.min-max-dropdown-container { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.min-max-dropdown-container select { flex: 1; }

/* Custom Multi-Select Dropdowns */
.custom-dropdown { position: relative; width: 100%; font-size: 0.9rem; }
.dropdown-header { padding: 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--white); cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.dropdown-panel { position: absolute; top: 100%; left: 0; width: 100%; background: var(--white); border: 1px solid var(--border); border-top: none; border-radius: 0 0 6px 6px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); z-index: 50; display: none; }
.custom-dropdown.open .dropdown-panel { display: block; }
.dropdown-actions { display: flex; padding: 10px; border-bottom: 1px solid var(--border); gap: 0; }
.dropdown-actions button { flex: 1; padding: 8px; background: var(--white); border: 1px solid var(--border); cursor: pointer; font-size: 0.85rem; color: var(--primary); }
.dropdown-actions button:first-child { border-right: none; }
.dropdown-actions button:hover { background: var(--bg); }
.dropdown-search { padding: 10px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--white); z-index: 2; }
.dropdown-search input { width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 4px; outline: none; font-size: 0.9rem; }
.dropdown-divider { padding: 5px 15px; background: var(--bg); font-size: 0.75rem; font-weight: bold; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.dropdown-list { max-height: 200px; overflow-y: auto; }
.dropdown-list::-webkit-scrollbar { width: 6px; }
.dropdown-list::-webkit-scrollbar-thumb { background: #ccc; border-radius: 10px; }
.custom-option { padding: 10px 15px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid transparent; }
.custom-option:hover { background: var(--bg); }
.custom-option.selected { background: #f0f0f5; }
.custom-option .checkmark { display: none; color: var(--accent); font-weight: bold; font-size: 1.1rem; }
.custom-option.selected .checkmark { display: block; }

/* =========================================
   6. RESPONSIVE QUERIES
   ========================================= */
@media (min-width: 993px) {
    .sidebar { height: auto; max-height: calc(100vh - 120px); padding-bottom: 20px; }
    .close-sidebar-btn { display: none !important; }
    .filter-header h3 { position: static; transform: none; }
    .mobile-filter-btn { display: none !important; }
}

@media (max-width: 992px) {
    .container { flex-direction: column; padding: 1rem; align-items: stretch; }
    .main-content { width: 100%; }
    .property-grid { grid-template-columns: 1fr; }
    
    .sidebar { 
        position: fixed; 
        top: 15px; 
        right: -100%; 
        width: calc(100% - 30px); 
        height: calc(100vh - 110px); 
        height: calc(100dvh - 100px); 
        z-index: 1000; 
        border-radius: 16px; 
        transition: right 0.3s ease-in-out; 
        box-shadow: 0 10px 40px rgba(0,0,0,0.3); 
    }       
    .sidebar.open { right: 15px; }
    
    .sidebar-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 999; }
    .sidebar-overlay.open { display: block; }

    .filter-header { border-radius: 16px 16px 0 0; }

    .filter-footer { 
        display: block; 
        position: sticky; 
        bottom: -20px; 
        background: var(--white); 
        padding: 15px 20px; 
        margin: 20px -20px -20px -20px; 
        border-top: 1px solid var(--border); 
        z-index: 110; 
        border-radius: 0 0 16px 16px; 
    }
    
    .sidebar .filter-group label.heading { font-size: 1.15rem; margin-bottom: 12px; }
    .sidebar .form-control, .sidebar .custom-dropdown, .sidebar .dropdown-search input { font-size: 1.1rem; }
    .sidebar .custom-option { font-size: 1.1rem; padding: 14px 15px; }
    .sidebar .checkbox-item { font-size: 1.1rem; padding: 6px 0; }
    .sidebar .connected-group span { font-size: 1.05rem; padding: 12px 0; }
    .sidebar .price-input-box input, .sidebar .price-input-box span { font-size: 1.1rem; }
    .sidebar .price-labels, .sidebar #sizeLabel, .sidebar #yearLabel { font-size: 1rem !important; }
}

/* --- MULTI-SELECT CHIPS & QUICK PICKS --- */
.chip-container { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 15px; border-bottom: 1px solid var(--border); background: #fdfdfd; }
.chip-container:empty { display: none; }
.chip { background: #f0f4ff; color: var(--remax-blue, #003DA5); font-size: 0.8rem; padding: 4px 10px; border-radius: 15px; display: flex; align-items: center; gap: 6px; border: 1px solid var(--remax-blue, #003DA5); font-weight: 600; }
.chip-close { cursor: pointer; font-weight: bold; border-radius: 50%; width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; background: rgba(0, 61, 165, 0.1); transition: 0.2s; }
.chip-close:hover { background: var(--remax-blue, #003DA5); color: white; }

.quick-picks { padding: 10px 15px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; background: var(--white); }
.btn-quick { width: 100%; background: none; border: 1px dashed var(--text-muted); padding: 10px 12px; font-size: 0.8rem; border-radius: 4px; cursor: pointer; color: var(--text-main); transition: 0.2s; }
.btn-quick:hover { border-color: var(--remax-blue, #003DA5); color: var(--remax-blue, #003DA5); background: #f0f4ff; }

/* --- PAGINATION --- */
.pagination { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.page-btn { background: var(--white); border: 1px solid var(--border); color: var(--primary); padding: 8px 14px; border-radius: 6px; cursor: pointer; font-weight: 600; transition: 0.2s; font-size: 0.95rem; }
.page-btn:hover:not(:disabled) { border-color: var(--remax-blue); color: var(--remax-blue); }
.page-btn.active { background: var(--remax-blue); color: white; border-color: var(--remax-blue); }
.page-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.page-dots { color: var(--text-muted); font-weight: bold; }    

/* --- CARD ACTIONS (Price & Icons) --- */
.card-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.card-price { margin-bottom: 0 !important; }
.card-actions { display: flex; gap: 12px; }
.action-btn { background: none; border: none; cursor: pointer; padding: 0; color: var(--primary); display: flex; align-items: center; justify-content: center; transition: transform 0.2s, color 0.2s; }
.action-btn:hover { color: var(--remax-red); transform: scale(1.15); }
.action-btn svg { width: 22px; height: 22px; stroke-width: 2.2; }

/* --- MODALS --- */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 3000; align-items: center; justify-content: center; }
.modal-overlay.active { display: flex; }
.modal-content { background: white; padding: 24px; border-radius: 8px; width: 90%; max-width: 450px; position: relative; box-shadow: 0 10px 30px rgba(0,0,0,0.2); }
.modal-close { position: absolute; top: 15px; right: 15px; background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #999; line-height: 1; transition: 0.2s; }
.modal-close:hover { color: var(--danger); }
.modal-title { margin: 0 0 20px 0; font-size: 1.3rem; font-weight: bold; }

.share-input-row { display: flex; gap: 10px; margin-bottom: 15px; }
.share-input-row input { flex: 1; padding: 10px; border: 1px solid var(--border); border-radius: 6px; outline: none; font-size: 1rem; }
.share-add-btn { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #666; padding: 0 5px; font-weight: 300;}
.share-textarea { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 6px; height: 100px; outline: none; resize: none; font-family: inherit; font-size: 1rem; }
.char-count { font-size: 0.8rem; color: var(--text-muted); margin-top: 5px; margin-bottom: 15px; text-align: left; }
.modal-btn { width: 100%; background: var(--remax-red); color: white; border: none; padding: 12px; font-size: 1.1rem; font-weight: bold; border-radius: 6px; cursor: pointer; transition: 0.2s; }
.modal-btn:hover { background: #b3151b; }  

.card-office { font-size: 0.75rem; color: #888888; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }