/* Main Styles for NYC Map Application */

body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Arial', sans-serif;
    color: #333;
}

/* Layout */
.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative; /* Position container relative for absolute positioning of children */
}

/* Header */
header {
    background-color: #1a2a6c;
    color: white;
    padding: 15px 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    position: relative; /* Ensure header stays above map */
    z-index: 1000; /* Higher z-index to stay above map */
}

header h1 {
    margin: 0;
    font-size: 24px;
}

/* Map container */
#map {
    flex: 1;
    width: 100%;
    z-index: 1;
    position: relative; /* Establish stacking context for map */
}

/* Filters panel */
.filters-panel {
    background-color: #f5f5f5;
    padding: 15px;
    box-shadow: 0 -2px 5px rgba(0,0,0,0.1);
    z-index: 1001; /* Higher than map and header */
    overflow-y: auto;
    max-height: 300px;
    transition: max-height 0.3s ease, transform 0.3s ease;
    position: relative; /* Ensure panel stays above map */
}

.filters-panel.collapsed {
    max-height: 40px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    margin-bottom: 10px;
}

.panel-title {
    font-weight: bold;
    font-size: 16px;
    margin: 0;
}

.toggle-button {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #1a2a6c;
}

/* Filter Grid */
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.filter-section {
    margin-bottom: 15px;
}

.filter-section h3 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #666;
}

/* Checkboxes */
.checkbox-group {
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px;
    background-color: white;
}

.checkbox-item {
    display: flex;
    align-items: center;
    margin: 5px 0;
}

.checkbox-item input[type="checkbox"] {
    margin-right: 8px;
}

/* Select/Unselect All buttons */
.select-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.select-btn {
    background-color: #1a2a6c;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    flex: 1;
}

.select-btn:hover {
    background-color: #0f1a4c;
}

/* Map Legend */
.map-legend {
    position: absolute;
    bottom: 20px;
    right: 10px;
    background-color: white;
    padding: 10px;
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(0,0,0,0.2);
    z-index: 1000;
    max-width: 200px;
    pointer-events: auto; /* Ensure clickability */
}

.legend-title {
    font-weight: bold;
    margin-bottom: 8px;
    text-align: center;
    font-size: 14px;
}

.legend-item {
    display: flex;
    align-items: center;
    margin: 5px 0;
    font-size: 12px;
}

.legend-color {
    display: block;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    border-radius: 50%;
}

/* Loading indicator */
.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    padding: 15px 20px;
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(0,0,0,0.2);
    z-index: 2000;
    text-align: center;
}

/* Walking Distance Controls */
.form-group {
    margin-bottom: 10px;
}

.btn {
    background-color: #1a2a6c;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    width: 100%;
}

.btn:hover {
    background-color: #0f1a4c;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
}

.form-group input[type="range"] {
    width: 100%;
}

.walking-legend {
    margin-top: 10px;
    font-size: 11px;
}

/* Popup styles */
.leaflet-popup-content {
    font-size: 14px;
    line-height: 1.4;
}

.leaflet-popup-content strong {
    display: block;
    margin-bottom: 5px;
    font-size: 16px;
}

.leaflet-popup-content em {
    display: block;
    color: #666;
    margin-bottom: 5px;
    font-style: italic;
}

.leaflet-popup-content a {
    color: #1a73e8;
    text-decoration: none;
    margin-top: 5px;
    display: inline-block;
}

.leaflet-popup-content a:hover {
    text-decoration: underline;
}

/* Zoom Controls */
.leaflet-control-zoom {
    z-index: 1002; /* Ensure zoom controls are accessible */
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
    margin: 10px !important; /* Override default margins */
}

/* Override for map UI controls */
.leaflet-control-container {
    position: absolute;
    z-index: 1002;
    pointer-events: auto;
}

/* Fix for filter panel on zoom */
.filters-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .filter-grid {
        grid-template-columns: 1fr;
    }
    
    header h1 {
        font-size: 18px;
        padding: 0;
    }
    
    .filters-panel {
        max-height: 250px;
    }
    
    /* Smaller margins on mobile */
    .map-legend {
        bottom: 10px;
        right: 5px;
        max-width: 150px;
        font-size: 11px;
    }
    
    /* Adjust positioning for filters panel on small screens */
    .filters-panel.collapsed {
        max-height: 35px;
    }
}

@media (max-width: 480px) {
    header {
        padding: 10px;
    }
    
    header h1 {
        font-size: 16px;
    }
    
    /* Make filter icons more tappable on mobile */
    .checkbox-item {
        margin: 8px 0;
    }
    
    .checkbox-item input[type="checkbox"] {
        transform: scale(1.2);
    }
}
