/**
 * TRREB MAP OVERLAY STYLES (STRING 2) - FIXED for SearchingInToronto_IDX Integration
 * File: trreb-map-overlay.css
 * Purpose: Styles for interactive map overlay with MLS district filtering
 * Integration: Extends searchingintoronto-idx-v11.css base styles
 * Dependencies: Requires base CSS classes from main plugin
 * RESO Compliance: Supports RESO Web API v4.0 data display
 * FIXED: Proper integration with base CSS, component architecture alignment
 */

/* ==========================================================================
   MAP OVERLAY CONTAINER - Extends filter-container-base
   ========================================================================== */

.trreb-map-overlay-container {
    margin: 20px 0;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.map-overlay-filters {
    /* Extends filter-container-base styling */
    border-bottom: 1px solid #eee;
    background: #fafafa;
}

.map-overlay-filters .filter-header-base {
    background: #fff;
    border-bottom: 1px solid #e5e5e5;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.map-overlay-filters .filter-header-base h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
}

.map-overlay-filters .filter-content-base {
    padding: 20px;
    background: #fff;
}

/* ==========================================================================
   MAP FILTER CONTROLS - Extends filter form styling
   ========================================================================== */

.map-filter-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.map-filter-col {
    display: flex;
    flex-direction: column;
}

.map-filter-col label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.map-filter-col .filter-select {
    /* Extends base filter-select styling */
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    color: #333;
    transition: border-color 0.2s ease;
}

.map-filter-col .filter-select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* ==========================================================================
   MLS DISTRICTS SELECTION - Custom styling for district checkboxes
   ========================================================================== */

.mls-districts-container {
    margin: 25px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.mls-districts-container h5 {
    margin: 0 0 15px 0;
    font-size: 15px;
    font-weight: 600;
    color: #2c3e50;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mls-districts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.mls-region-group {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.mls-region-title {
    margin: 0 0 12px 0;
    font-size: 13px;
    font-weight: 700;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 8px;
}

.mls-district-item {
    margin-bottom: 8px;
}

.mls-district-label {
    display: flex;
    align-items: center;
    font-size: 13px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.mls-district-label:hover {
    background-color: #f8f9fa;
}

.mls-district-checkbox {
    margin-right: 10px;
    width: 16px;
    height: 16px;
    accent-color: #3498db;
}

.mls-district-name {
    font-weight: 500;
    color: #495057;
}

.mls-district-checkbox:checked + .mls-district-name {
    color: #2980b9;
    font-weight: 600;
}

/* ==========================================================================
   MAP FILTER ACTIONS - Extends button styling
   ========================================================================== */

.map-filter-actions {
    display: flex;
    gap: 12px;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
    flex-wrap: wrap;
}

.map-filter-actions .btn-primary,
.map-filter-actions .btn-secondary {
    /* Extends base button styling */
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.map-filter-actions .btn-primary {
    background: #3498db;
    color: #fff;
}

.map-filter-actions .btn-primary:hover {
    background: #2980b9;
    transform: translateY(-1px);
}

.map-filter-actions .btn-secondary {
    background: #6c757d;
    color: #fff;
}

.map-filter-actions .btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

/* ==========================================================================
   MAP CONTAINER - Leaflet map styling
   ========================================================================== */

.map-container {
    position: relative;
    background: #f8f9fa;
}

#trreb-leaflet-map {
    border: none;
    outline: none;
}

/* Map loading overlay */
.map-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.map-loading-overlay.hidden {
    display: none;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f0f0f0;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: mapSpinner 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes mapSpinner {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 15px;
    color: #6c757d;
    font-weight: 500;
    text-align: center;
}

/* ==========================================================================
   MAP RESULTS PANEL - Property listing results
   ========================================================================== */

.map-results-panel {
    border-top: 1px solid #dee2e6;
    background: #f8f9fa;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #fff;
    border-bottom: 1px solid #e9ecef;
}

.results-count {
    font-weight: 600;
    color: #2c3e50;
    font-size: 15px;
}

.results-controls {
    display: flex;
    align-items: center;
}

.results-toggle {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #6c757d;
    padding: 5px 10px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.results-toggle:hover {
    background: #f8f9fa;
    color: #495057;
}

.results-content {
    max-height: 350px;
    overflow-y: auto;
    transition: max-height 0.3s ease;
}

.map-results-panel.collapsed .results-content {
    max-height: 0;
    overflow: hidden;
}

.map-results-panel.collapsed .results-toggle {
    transform: rotate(180deg);
}

/* ==========================================================================
   PROPERTY RESULTS LIST - Individual property cards
   ========================================================================== */

.map-results-list {
    padding: 15px;
}

.map-property-item {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.map-property-item:hover {
    border-color: #3498db;
    box-shadow: 0 3px 8px rgba(52, 152, 219, 0.15);
    transform: translateY(-1px);
}

.map-property-item.selected {
    border-color: #2980b9;
    background: #f0f8ff;
    box-shadow: 0 3px 8px rgba(41, 128, 185, 0.2);
}

.property-price {
    font-size: 18px;
    font-weight: 700;
    color: #27ae60;
    margin-bottom: 8px;
}

.property-address {
    font-size: 15px;
    color: #2c3e50;
    margin-bottom: 8px;
    font-weight: 500;
    line-height: 1.3;
}

.property-details {
    font-size: 13px;
    color: #6c757d;
    margin-bottom: 8px;
    line-height: 1.4;
}

.property-status {
    font-size: 11px;
    background: #27ae60;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.property-status.conditional {
    background: #f39c12;
}

.property-status.pending {
    background: #e74c3c;
}

/* ==========================================================================
   LEAFLET POPUP CUSTOMIZATION - Property and district popups
   ========================================================================== */

.trreb-property-popup {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    max-width: 280px;
}

.popup-header h5 {
    margin: 0 0 8px 0;
    color: #2c3e50;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
}

.popup-price {
    font-size: 18px;
    font-weight: 700;
    color: #27ae60;
    margin-bottom: 12px;
}

.property-details div {
    font-size: 13px;
    margin-bottom: 4px;
    color: #6c757d;
    line-height: 1.3;
}

.property-details div strong {
    color: #495057;
    font-weight: 600;
}

.popup-actions {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e9ecef;
}

.popup-actions .btn-secondary {
    font-size: 12px;
    padding: 6px 12px;
    background: #6c757d;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.popup-actions .btn-secondary:hover {
    background: #5a6268;
}

.trreb-district-popup {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    max-width: 260px;
}

.trreb-district-popup h5 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 15px;
    font-weight: 600;
}

.district-info div {
    font-size: 13px;
    margin-bottom: 4px;
    color: #6c757d;
    line-height: 1.3;
}

.district-info div strong {
    color: #495057;
    font-weight: 600;
}

/* ==========================================================================
   FILTER TOGGLE INTEGRATION - Consistent with main plugin
   ========================================================================== */

.filter-toggle {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: #6c757d;
    padding: 5px;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.filter-toggle:hover {
    background: #f8f9fa;
    color: #495057;
}

/* ==========================================================================
   RESPONSIVE DESIGN - Mobile and tablet support
   ========================================================================== */

@media (max-width: 768px) {
    .map-filter-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .mls-districts-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .map-filter-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .map-filter-actions .btn-primary,
    .map-filter-actions .btn-secondary {
        width: 100%;
        text-align: center;
    }
    
    .results-content {
        max-height: 250px;
    }
    
    .results-header {
        padding: 12px 15px;
    }
    
    .map-results-list {
        padding: 10px;
    }
    
    .map-property-item {
        padding: 12px;
    }
    
    .property-price {
        font-size: 16px;
    }
    
    .property-address {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .trreb-map-overlay-container {
        margin: 10px 0;
        border-radius: 6px;
    }
    
    .map-overlay-filters .filter-header-base {
        padding: 12px 15px;
    }
    
    .map-overlay-filters .filter-content-base {
        padding: 15px;
    }
    
    .mls-districts-container {
        margin: 20px 0;
        padding: 15px;
    }
    
    .mls-region-group {
        padding: 12px;
    }
    
    .map-filter-actions {
        margin-top: 20px;
        padding-top: 15px;
    }
    
    .property-price {
        font-size: 15px;
    }
    
    .property-address {
        font-size: 13px;
    }
    
    .property-details {
        font-size: 12px;
    }
}

/* ==========================================================================
   LEAFLET MAP CONTROL OVERRIDES - Customize map controls
   ========================================================================== */

.leaflet-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.leaflet-popup-tip {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Cluster markers customization */
.marker-cluster-small {
    background-color: rgba(52, 152, 219, 0.6);
}

.marker-cluster-small div {
    background-color: rgba(52, 152, 219, 0.8);
    color: #fff;
    font-weight: 600;
}

.marker-cluster-medium {
    background-color: rgba(241, 196, 15, 0.6);
}

.marker-cluster-medium div {
    background-color: rgba(241, 196, 15, 0.8);
    color: #fff;
    font-weight: 600;
}

.marker-cluster-large {
    background-color: rgba(231, 76, 60, 0.6);
}

.marker-cluster-large div {
    background-color: rgba(231, 76, 60, 0.8);
    color: #fff;
    font-weight: 600;
}

/* ==========================================================================
   INTEGRATION CLASSES - For seamless integration with main plugin
   ========================================================================== */

/* Ensure consistent styling with other filter components */
.trreb-map-overlay-container .filter-container-base {
    margin-bottom: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

/* Match main plugin's form styling */
.trreb-map-overlay-container .filter-select,
.trreb-map-overlay-container input[type="text"],
.trreb-map-overlay-container input[type="number"] {
    height: auto;
    min-height: 42px;
}

/* Consistent button heights with main plugin */
.trreb-map-overlay-container .btn-primary,
.trreb-map-overlay-container .btn-secondary {
    min-height: 42px;
    line-height: 1.2;
}

/* ==========================================================================
   ACCESSIBILITY IMPROVEMENTS
   ========================================================================== */

.mls-district-checkbox:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

.filter-toggle:focus,
.results-toggle:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

.map-property-item:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}