/* ===== CSS Variables ===== */
:root {
    --bg-dark: #0a0a0f;
    --bg-card: rgba(20, 20, 30, 0.85);
    --bg-glass: rgba(30, 30, 45, 0.7);
    --accent-primary: #00d4ff;
    --accent-secondary: #7c3aed;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);
    --border-glass: rgba(255, 255, 255, 0.1);
    --shadow-glow: 0 0 30px rgba(0, 212, 255, 0.3);
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    font-family: var(--font-main);
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
}

/* ===== Header ===== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-glass);
    padding: 1rem 1.5rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1800px;
    margin: 0 auto;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.train-icon {
    font-size: 1.75rem;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stats {
    display: flex;
    gap: 2rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-primary);
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== Map ===== */
#map {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

/* Dark map tiles styling */
.leaflet-tile-pane {
    filter: brightness(0.85) contrast(1.1) saturate(0.9);
}

/* Custom map attribution */
.leaflet-control-attribution {
    background: var(--bg-glass) !important;
    backdrop-filter: blur(10px);
    color: var(--text-muted) !important;
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 4px 0 0 0;
}

.leaflet-control-attribution a {
    color: var(--accent-primary) !important;
}

/* ===== Legend ===== */
.legend {
    position: fixed;
    bottom: 2rem;
    left: 1rem;
    z-index: 1000;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 1rem;
    min-width: 180px;
}

.legend h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-glass);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.legend-marker {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    box-shadow: 0 0 8px currentColor;
}

.legend-marker.passenger {
    background: var(--accent-primary);
    color: var(--accent-primary);
}

.legend-marker.commuter {
    background: var(--accent-success);
    color: var(--accent-success);
}

.legend-marker.cargo {
    background: var(--accent-warning);
    color: var(--accent-warning);
}

/* ===== Loading Overlay ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border-glass);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-overlay p {
    font-size: 1rem;
    color: var(--text-secondary);
}

/* ===== Train Markers ===== */
.train-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.25rem;
    transition: transform 0.3s ease;
    cursor: pointer;
}

.train-marker:hover {
    transform: scale(1.3);
}

.train-marker.passenger {
    background: radial-gradient(circle, var(--accent-primary), #0099cc);
    box-shadow: 0 0 15px var(--accent-primary);
}

.train-marker.commuter {
    background: radial-gradient(circle, var(--accent-success), #059669);
    box-shadow: 0 0 15px var(--accent-success);
}

.train-marker.cargo {
    background: radial-gradient(circle, var(--accent-warning), #d97706);
    box-shadow: 0 0 15px var(--accent-warning);
}

/* ===== Popups ===== */
.leaflet-popup-content-wrapper {
    background: var(--bg-card) !important;
    backdrop-filter: blur(15px);
    border: 1px solid var(--border-glass);
    border-radius: 12px !important;
    box-shadow: var(--shadow-glow) !important;
}

.leaflet-popup-content {
    color: var(--text-primary) !important;
    font-family: var(--font-main) !important;
    margin: 0.75rem 1rem !important;
    font-size: 0.875rem;
}

.leaflet-popup-tip {
    background: var(--bg-card) !important;
}

.popup-content {
    min-width: 160px;
}

.popup-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-glass);
}

.popup-header .train-number {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.popup-row {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0;
}

.popup-row .label {
    color: var(--text-muted);
}

.popup-row .value {
    font-weight: 600;
    color: var(--text-primary);
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
    .header {
        padding: 0.75rem 1rem;
    }

    .logo h1 {
        font-size: 1.1rem;
    }

    .stats {
        gap: 1rem;
    }

    .stat-value {
        font-size: 1.1rem;
    }

    .legend {
        bottom: 1rem;
        left: 0.5rem;
        padding: 0.75rem;
        min-width: 150px;
    }
}