* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: #333;
}

body {
    display: flex;
    flex-direction: column;
}

#header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

#header h1 {
    font-size: 2em;
    margin-bottom: 5px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 0.95em;
    opacity: 0.95;
    margin-bottom: 10px;
}

#stats {
    font-size: 0.9em;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 12px;
    border-radius: 4px;
    display: inline-block;
}

#map {
    flex: 1;
    position: relative;
}

.leaflet-control-attribution {
    background-color: rgba(255, 255, 255, 0.9);
    border: 1px solid #ddd;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#map.sidebar-open .leaflet-control-attribution {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

#legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: white;
    padding: 15px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 400;
    max-width: 200px;
}

#legend h3 {
    font-size: 0.95em;
    margin-bottom: 10px;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 0.9em;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #333;
}

.legend-icon {
    font-size: 1.2em;
}

#sidebar {
    position: absolute;
    right: 0;
    top: 0;
    width: 350px;
    height: 100%;
    background: white;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
    overflow-y: auto;
    z-index: 500;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    padding: 20px;
}

#sidebar.open {
    transform: translateX(0);
}

#sidebar-content {
    padding-bottom: 20px;
}

.station-detail {
    margin-bottom: 15px;
}

.station-detail h2 {
    font-size: 1.2em;
    margin-bottom: 10px;
    color: #667eea;
}

.station-detail p {
    margin-bottom: 8px;
    font-size: 0.95em;
    line-height: 1.5;
}

.station-detail .label {
    font-weight: 600;
    color: #555;
    display: inline-block;
    min-width: 80px;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #f0f0f0;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 4px;
    font-size: 1.3em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.close-btn:hover {
    background: #e0e0e0;
}

footer {
    background: #f5f5f5;
    padding: 15px;
    text-align: center;
    font-size: 0.85em;
    color: #666;
    border-top: 1px solid #ddd;
    z-index: 100;
}

footer a {
    color: #667eea;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Responsive design */
@media (max-width: 768px) {
    #header h1 {
        font-size: 1.5em;
    }

    #sidebar {
        top: auto;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        height: min(70%, 480px);
        max-height: 70vh;
        padding: 20px 16px 16px;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.2);
        transform: translateY(100%);
    }

    #sidebar.open {
        transform: translateY(0);
    }

    #sidebar-content {
        padding: 8px 4px 20px;
    }

    .close-btn {
        top: 10px;
        right: 12px;
        width: 36px;
        height: 36px;
        border-radius: 50%;
    }

    #legend {
        display: none;
    }

    footer {
        font-size: 0.8em;
    }
}

/* Custom marker styles */
.marker-cluster {
    background-clip: padding-box;
    border-radius: 20px;
    cursor: pointer;
}

.marker-cluster div {
    width: 30px;
    height: 30px;
    margin-left: 5px;
    margin-top: 5px;
    text-align: center;
    border-radius: 15px;
    font: 12px "Helvetica Neue", Arial, Helvetica, sans-serif;
    line-height: 30px;
    color: white;
}

.marker-cluster.marker-cluster-small {
    background-color: rgba(110, 204, 57, 0.6);
}

.marker-cluster.marker-cluster-small div {
    background-color: rgba(68, 163, 32, 0.6);
}

.marker-cluster.marker-cluster-medium {
    background-color: rgba(255, 188, 26, 0.6);
}

.marker-cluster.marker-cluster-medium div {
    background-color: rgba(255, 156, 0, 0.6);
}

.marker-cluster.marker-cluster-large {
    background-color: rgba(241, 128, 23, 0.6);
}

.marker-cluster.marker-cluster-large div {
    background-color: rgba(217, 101, 0, 0.6);
}

.marker-cluster.marker-cluster-xlarge {
    background-color: rgba(240, 59, 32, 0.6);
}

.marker-cluster.marker-cluster-xlarge div {
    background-color: rgba(216, 30, 5, 0.6);
}

.marker-cluster.marker-cluster-xxlarge {
    background-color: rgba(242, 32, 32, 0.6);
}

.marker-cluster.marker-cluster-xxlarge div {
    background-color: rgba(206, 17, 38, 0.6);
}

/* Loading state */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

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

/* Error state */
.error-message {
    background: #fee;
    color: #c33;
    padding: 15px;
    border-radius: 4px;
    margin: 10px;
}
