/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #e5e7eb;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    max-width: 100%;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    width: 40px;
    height: 40px;
    background: #6b9642;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-text h1 {
    font-size: 18px;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.header-text p {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.school-count {
    padding: 6px 12px;
    background: #f3f4f6;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fbbf24;
    transition: background-color 0.3s ease;
}

.status-indicator.connected {
    background: #10b981;
}

.status-indicator.error {
    background: #ef4444;
}

/* Map container */
#map {
    height: 100vh;
    width: 100vw;
    z-index: 1;
    touch-action: manipulation; /* Optimize touch interactions */
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-content {
    text-align: center;
    max-width: 400px;
    padding: 24px;
}

.spinner {
    width: 64px;
    height: 64px;
    border: 4px solid #e5e7eb;
    border-top: 4px solid #6b9642;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 24px;
}

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

.loading-content h2 {
    font-size: 24px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 8px;
}

.loading-content p {
    font-size: 16px;
    color: #6b7280;
    margin-bottom: 24px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #6b9642;
    width: 65%;
    border-radius: 4px;
    animation: progressPulse 2s ease-in-out infinite;
}

@keyframes progressPulse {
    0%, 100% { width: 65%; }
    50% { width: 85%; }
}

/* Error overlay */
.error-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.error-content {
    text-align: center;
    max-width: 400px;
    padding: 24px;
}

.error-icon {
    margin-bottom: 16px;
}

.error-content h2 {
    font-size: 24px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 8px;
}

.error-content p {
    font-size: 16px;
    color: #6b7280;
    margin-bottom: 24px;
}

.retry-button {
    padding: 12px 24px;
    background: #6b9642;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.retry-button:hover {
    background: #5d8037;
}

/* Map controls */
.map-controls {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-button {
    width: 44px;
    height: 44px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px; /* Minimum touch target size */
    min-width: 44px;
}

.control-button:hover {
    background: #f9fafb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.control-button:active {
    transform: translateY(0);
    background: #e5e7eb;
}

.control-button svg {
    color: #374151;
    width: 20px;
    height: 20px;
}

/* Legend */
.legend {
    position: fixed;
    bottom: 16px;
    left: 16px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    max-width: 280px;
}

.legend h3 {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 12px;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.legend-item span {
    font-size: 14px;
    color: #374151;
}

.cluster-example {
    width: 24px;
    height: 24px;
    background: #0059FF;
    border: 2px solid white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.legend-footer {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
}

.legend-footer p {
    font-size: 12px;
    color: #6b7280;
    margin: 0;
}

/* Custom marker cluster styles */
.marker-cluster {
    background: #0059FF !important;
    border: 2px solid white !important;
    border-radius: 50% !important;
    color: white !important;
    font-weight: 600 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
}

.marker-cluster div {
    background: #0059FF !important;
    border-radius: 50% !important;
}

/* Custom popup styles */
.leaflet-popup-content-wrapper {
    border-radius: 8px !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
    max-width: 280px !important;
    border: none !important;
}

.leaflet-popup-content {
    margin: 0 !important;
    padding: 0 !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    min-width: 220px !important;
}

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

.leaflet-popup-close-button {
    color: #6b7280 !important;
    font-size: 18px !important;
    width: 24px !important;
    height: 24px !important;
    padding: 0 !important;
    right: 8px !important;
    top: 8px !important;
    transition: color 0.2s ease !important;
}

.leaflet-popup-close-button:hover {
    color: #374151 !important;
}

@media (max-width: 480px) {
    .leaflet-popup-content-wrapper {
        max-width: calc(100vw - 24px) !important;
    }
    
    .leaflet-popup-content {
        min-width: calc(100vw - 80px) !important;
        max-width: calc(100vw - 80px) !important;
    }
    
    .leaflet-popup-close-button {
        width: 40px !important;
        height: 40px !important;
        font-size: 24px !important;
        right: 8px !important;
        top: 8px !important;
    }
}

/* Mobile and responsive design */
@media (max-width: 768px) {
    .map-controls {
        right: 12px;
        top: 12px;
        gap: 6px;
    }
    
    .control-button {
        width: 48px;
        height: 48px;
        min-height: 48px;
        min-width: 48px;
    }
    
    .control-button svg {
        width: 22px;
        height: 22px;
    }
    
    .loading-content {
        padding: 20px;
        margin: 0 16px;
    }
    
    .error-content {
        padding: 20px;
        margin: 0 16px;
    }
    
    .loading-content h2, .error-content h2 {
        font-size: 20px;
    }
    
    .loading-content p, .error-content p {
        font-size: 14px;
    }
    
    .retry-button {
        padding: 14px 28px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .map-controls {
        right: 8px;
        top: 8px;
        gap: 4px;
    }
    
    .control-button {
        width: 52px;
        height: 52px;
        min-height: 52px;
        min-width: 52px;
        border-radius: 12px;
    }
    
    .control-button svg {
        width: 24px;
        height: 24px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .control-button:hover {
        transform: none;
        background: white;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    .control-button:active {
        transform: scale(0.95);
        background: #e5e7eb;
    }
}

/* Hide default Leaflet attribution */
.leaflet-control-attribution {
    display: none !important;
}

/* Filter Toggle Button */
.filter-toggle-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 1001;
    height: 40px;
    padding: 0 12px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    color: #374151;
}

.filter-toggle-btn:hover {
    background: #f9fafb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.filter-toggle-btn.active {
    background: #6b9642;
    color: white;
    border-color: #5d8037;
}

/* Filter Controls */
.filter-controls {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    margin-left: 60px;
}

.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-btn {
    background: #f3f4f6;
    border: 2px solid transparent;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.filter-btn:hover {
    background: #e5e7eb;
    transform: translateY(-1px);
}

.filter-btn.active {
    background: #6b9642;
    color: white;
    border-color: #5d8037;
}

.filter-btn span {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 600;
}

.filter-btn.active span {
    background: rgba(255, 255, 255, 0.2);
}

/* Hidden state for filter controls */
.filter-controls.hidden {
    opacity: 0;
    transform: translateX(-20px);
    pointer-events: none;
}

/* Mobile adjustments for filter controls */
@media (max-width: 768px) {
    .filter-toggle-btn {
        top: 16px;
        left: 16px;
        height: 36px;
        padding: 0 10px;
    }
    
    .filter-controls {
        position: relative;
        top: 0;
        left: 0;
        margin: 16px;
        margin-bottom: 0;
        padding: 8px;
        margin-left: 0;
    }
    
    .filter-controls.hidden {
        display: none;
    }
    
    .filter-btn {
        font-size: 11px;
        padding: 5px 8px;
    }
}