/**
 * map-styles.css
 * Core styling for the Split-Screen Map Search Page.
 */

: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;
}

* { box-sizing: border-box; }
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; margin: 0; background-color: var(--bg); color: var(--primary); overflow: hidden; height: 100vh; display: flex; flex-direction: column; }

.split-view-container { display: flex; flex: 1; height: calc(100vh - 80px); width: 100%; overflow: hidden; }
.list-pane { width: 55%; height: 100%; overflow-y: auto; padding: 20px; background: var(--bg); }
.map-pane { width: 45%; height: 100%; position: relative; }
#propertyMap { width: 100%; height: 100%; }

.price-marker { background: #008040; color: white; padding: 4px 8px; border-radius: 6px; font-weight: bold; font-size: 0.85rem; border: 2px solid white; box-shadow: 0 3px 6px rgba(0,0,0,0.3); white-space: nowrap; text-align: center; transition: transform 0.2s; }
.price-marker:hover { background: var(--remax-blue); transform: scale(1.1); z-index: 1000 !important; }
.active-marker .price-marker { background: var(--remax-red); transform: scale(1.15); border-color: var(--primary); box-shadow: 0 4px 10px rgba(0,0,0,0.5); }

.property-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.5rem; }
.header-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }

.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; }
.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; }
.card-office { font-size: 0.75rem; color: #888888; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }

.sidebar { position: fixed; top: 0; left: -400px; width: 360px; height: 100vh !important; max-height: 100vh; z-index: 2000; background: var(--white); border-radius: 0; box-shadow: 4px 0 20px rgba(0,0,0,0.2); transition: left 0.3s ease-in-out; margin: 0; overflow-y: auto; padding: 20px; }
.sidebar.open { left: 0; }
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #ccc; border-radius: 10px; }
.sidebar-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 1999; }
.sidebar-overlay.open { display: block; }

.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: 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; }
.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; }

.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; }

.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; }

.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-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-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; }

.min-max-dropdown-container { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.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-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; }
.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; }

.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); font-size: 0.8rem; padding: 4px 10px; border-radius: 15px; display: flex; align-items: center; gap: 6px; border: 1px solid var(--remax-blue); 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); 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); color: var(--remax-blue); background: #f0f4ff; }

.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-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; }

.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; }    

/* =========================================
   MOBILE OVERRIDES (App-Like Experience)
   ========================================= */
.mobile-view-toggle { display: none; } /* Hidden on desktop */
.mobile-card-overlay { display: none; } /* Hidden on desktop */

/* =========================================
   MOBILE OVERRIDES (App-Like Experience)
   ========================================= */
.mobile-view-toggle { display: none; } /* Hidden on desktop */
.mobile-card-overlay { display: none; } /* Hidden on desktop */

@media (max-width: 992px) {
    /* 1. Base Layout */
    .split-view-container { flex-direction: column; position: relative; }
    .map-pane { width: 100%; height: 100%; z-index: 1; }
    
    /* 2. Map View State (Default on Mobile) */
    /* Instead of hiding the list-pane, make it a transparent overlay */
    .list-pane { 
        display: block; 
        width: 100%; 
        height: 100%; 
        background: transparent; 
        position: absolute; 
        top: 0; left: 0; 
        z-index: 2; 
        padding: 10px; 
        pointer-events: none; /* Let the map be clickable underneath */
        overflow: hidden; /* Prevent scrolling over the map */
    }
    
    /* Re-enable clicks on the buttons/dropdowns inside the transparent pane */
    .list-pane > * { pointer-events: auto; }
    
    /* Hide the grid and pagination while looking at the map */
    #propertyGrid, #paginationContainer { display: none !important; }
    
    /* Style the header-bar as a floating island over the map */
    .header-bar { 
        background: rgba(255, 255, 255, 0.95); 
        padding: 12px 15px; 
        border-radius: 8px; 
        box-shadow: 0 4px 15px rgba(0,0,0,0.15); 
        backdrop-filter: blur(5px);
        margin-bottom: 10px;
    }

    /* Style the active filter chips to float nicely too */
    #globalActiveFilters:not(:empty) {
        background: rgba(255, 255, 255, 0.95);
        padding: 10px;
        border-radius: 8px;
        box-shadow: 0 4px 15px rgba(0,0,0,0.15);
        margin-bottom: 10px;
    }

    /* Move zoom controls to the bottom right on mobile to avoid all top UI */
    .leaflet-top.leaflet-left { 
        top: auto !important; 
        bottom: 110px !important; /* Keeps it safely above your floating toggle button */
        left: auto !important; 
        right: 10px !important; 
    }
    
    /* 3. List View State (When user clicks 'List View') */
    body.show-list .list-pane { 
        background: var(--bg); 
        padding: 15px; 
        padding-bottom: 120px; /* Increased to ensure pagination clears the floating toggle */
        overflow-y: auto; 
        pointer-events: auto; 
    }
    body.show-list .map-pane { display: none; }
    body.show-list #propertyGrid { display: grid !important; }
    body.show-list #paginationContainer { display: flex !important; }
    

    /* 4. Toggles, Cards, and Sidebars */
    .mobile-view-toggle {
        display: flex; align-items: center; gap: 8px; position: fixed; bottom: 25px; left: 50%; transform: translateX(-50%); background: var(--primary); color: white; border: none; padding: 12px 24px; border-radius: 30px; font-weight: bold; font-size: 1rem; box-shadow: 0 4px 15px rgba(0,0,0,0.3); z-index: 3000; cursor: pointer;
    }
    .mobile-card-overlay {
        display: block; position: fixed; bottom: -150%; left: 0; width: 100%; padding: 15px; z-index: 2500; transition: bottom 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); pointer-events: none;
    }
    .mobile-card-overlay.active { bottom: 70px; pointer-events: auto; }
    .mobile-card-overlay .card { box-shadow: 0 10px 30px rgba(0,0,0,0.3); width: 100%; max-width: 400px; margin: 0 auto; pointer-events: auto; }
    .close-card-btn { position: absolute; top: 25px; right: 25px; background: rgba(255,255,255,0.9); border: none; border-radius: 50%; width: 32px; height: 32px; font-size: 1.2rem; display: flex; align-items: center; justify-content: center; z-index: 10; cursor: pointer; box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
    
    .sidebar { width: calc(100% - 30px); left: -100%; border-radius: 16px; top: 15px; height: calc(100dvh - 100px) !important; }
    .sidebar.open { left: 15px; }
    .filter-header { border-radius: 16px 16px 0 0; }
    .filter-footer { border-radius: 0 0 16px 16px; }
}

/* =========================================
   DESKTOP MAP POPUP OVERRIDES
   ========================================= */
/* 1. Remove all padding and enforce rounded corners on the main bubble */
.custom-desktop-popup .leaflet-popup-content-wrapper {
    padding: 0 !important;
    overflow: hidden !important;
    border-radius: 8px !important;
}

/* 2. Strip Leaflet's stubborn default margins */
.custom-desktop-popup .leaflet-popup-content {
    margin: 0 !important;
    width: 100% !important;
}

/* 3. Strip the card's border so we don't have double-borders */
.custom-desktop-popup .card {
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    border-radius: 0 !important; 
}

/* 4. Transform the close 'x' into a floating circular button over the image */
.custom-desktop-popup .leaflet-popup-close-button {
    top: 10px !important;
    right: 10px !important;
    background: rgba(255, 255, 255, 0.9) !important;
    color: var(--primary) !important;
    width: 30px !important;
    height: 30px !important;
    line-height: 30px !important;
    text-align: center !important;
    border-radius: 50% !important;
    font-size: 20px !important;
    font-weight: bold !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3) !important;
    padding: 0 !important;
    z-index: 100 !important;
}

/* 5. Add a nice hover effect to the close button */
.custom-desktop-popup .leaflet-popup-close-button:hover {
    background: #fff !important;
    color: var(--remax-red) !important;
}