
:root {
    /* Light theme variables */
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --border-color: #e5e7eb;
    --border-radius: 8px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

    /* Status colors */
    --status-good: #ffffff;
    --status-delayed: #c084fc;
    --status-long-delayed: #8b5cf6;
    --status-very-delayed: #3b82f6;
    --status-hour-delayed: #10b981;
    --status-warning: #fbbf24;
    --status-critical: #f97316;
    --status-day-delayed: #ef4444;
    --status-multi-day: #f87171;
    --status-three-day: #d1d5db;
    --status-four-day: #9ca3af;
    --status-unavailable: #6b7280;
}

.dark-mode {
    /* Dark theme variables */
    --primary-color: #818cf8;
    --primary-hover: #a5b4fc;
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --bg-primary: #1f2937;
    --bg-secondary: #111827;
    --bg-tertiary: #374151;
    --border-color: #374151;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.3);

    /* Dark theme status colors - background stays dark */
    --status-good: #1f2937;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    padding: 0;
    margin: 0;
}

.container {
    max-width: 1400px;
    margin: 20px auto;
    padding: 30px;
    background-color: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
}

h1 {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 16px;
    margin-bottom: 20px;
}

/* Navigation Tabs */
.view-toggle {
    display: flex;
    gap: 10px;
}

.view-toggle a {
    padding: 8px 15px;
    border-radius: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 14px;
}

.view-toggle a:hover {
    background-color: var(--bg-tertiary);
    color: var(--primary-color);
}

.view-toggle a.active {
    background-color: var(--primary-color);
    color: white;
}

/* Controls */
.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0;
    flex-wrap: wrap;
    gap: 15px;
}

.actions {
    display: flex;
    gap: 10px;
}

.action-button {
    padding: 8px 15px;
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.action-button:hover {
    background-color: var(--bg-primary);
    color: var(--primary-color);
}

.action-button svg {
    width: 16px;
    height: 16px;
}

.refresh-control {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 15px;
    background-color: var(--bg-tertiary);
    border-radius: 6px;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.refresh-control input {
    width: 60px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    text-align: center;
}

.refresh-control button {
    padding: 6px 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.refresh-control button:hover {
    background-color: var(--primary-hover);
}

.status-counter {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

#refresh-status {
    font-size: 13px;
    color: var(--text-secondary);
}

.countdown {
    font-size: 13px;
    color: var(--text-secondary);
}

#next-refresh {
    color: var(--primary-color);
    font-weight: 500;
}

/* Filter and Search */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    padding: 15px;
    background-color: var(--bg-tertiary);
    border-radius: var(--border-radius);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.filter-group select {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
}

.search-box {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    min-width: 200px;
}

/* Table View */
.table-container {
    overflow-x: auto;
    margin-bottom: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    padding: 12px 15px;
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

table td {
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-color);
}

table tr:hover {
    background-color: var(--bg-tertiary);
}

/* Grid View */
.grid-container {
    display: table;
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.grid-row {
    display: table-row;
}

.network-label {
    display: table-cell;
    vertical-align: middle;
    text-align: center;
    font-weight: 600;
    width: 60px;
    min-width: 60px;
    height: 34px;
    background-color: var(--bg-tertiary);
    border-radius: 6px;
    color: var(--text-secondary);
    box-shadow: var(--shadow-sm);
    padding: 4px;
    margin: 2px;
    border: 1px solid var(--border-color);
}

.stations-container {
    display: table-cell;
    padding-left: 6px;
}

.stations-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 2px 0;
}

.grid-cell {
    width: 60px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.15s ease;
    position: relative;
    border: 1px solid var(--border-color);
    background-color: var(--status-good);
}

.grid-cell:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    z-index: 10;
}

/* Map View */
.map-container {
    width: 100%;
    height: 600px;
    background-color: var(--bg-tertiary);
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    position: relative;
}

/* Status Colors */
.station-unavailable {
    background-color: var(--status-unavailable);
    color: white;
    border-color: var(--status-unavailable);
}

.station-warning {
    background-color: var(--status-warning);
    color: #7c2d12;
    border-color: var(--status-warning);
}

.station-critical {
    background-color: var(--status-critical);
    color: white;
    border-color: var(--status-critical);
}

.station-delayed {
    background-color: var(--status-delayed);
    color: #4a044e;
    border-color: var(--status-delayed);
}

.station-long-delayed {
    background-color: var(--status-long-delayed);
    color: white;
    border-color: var(--status-long-delayed);
}

.station-very-delayed {
    background-color: var(--status-very-delayed);
    color: white;
    border-color: var(--status-very-delayed);
}

.station-hour-delayed {
    background-color: var(--status-hour-delayed);
    color: white;
    border-color: var(--status-hour-delayed);
}

.station-day-delayed {
    background-color: var(--status-day-delayed);
    color: white;
    border-color: var(--status-day-delayed);
}

.station-multi-day {
    background-color: var(--status-multi-day);
    color: #7f1d1d;
    border-color: var(--status-multi-day);
}

.station-three-day {
    background-color: var(--status-three-day);
    color: #1f2937;
    border-color: var(--status-three-day);
}

.station-four-day {
    background-color: var(--status-four-day);
    color: white;
    border-color: var(--status-four-day);
}

.station-good {
    background-color: var(--status-good);
    color: var(--text-primary);
    border-color: var(--border-color);
}

/* Tooltip */
.grid-cell::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #1f2937;
    color: white;
    text-align: center;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 20;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    pointer-events: none;
    box-shadow: var(--shadow-md);
}

.grid-cell::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px 6px 0;
    border-style: solid;
    border-color: #1f2937 transparent transparent;
    z-index: 20;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    pointer-events: none;
}

.grid-cell:hover::after,
.grid-cell:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Stats */
.stats-container {
    margin: 20px 0;
    padding: 20px;
    background-color: var(--bg-tertiary);
    border-radius: var(--border-radius);
    display: none;
}

.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.stats-title {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
}

.network-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 15px;
}

.network-stat {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.network-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
}

.progress-bar {
    height: 8px;
    background-color: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress {
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 4px;
}

/* Legend */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 25px 0;
    padding: 15px;
    background-color: var(--bg-tertiary);
    border-radius: var(--border-radius);
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    color: var(--text-secondary);
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Footer */
.footer {
    margin-top: 30px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: 14px;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
}

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

/* Loading */
#loading {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 30px 0;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--bg-tertiary);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    margin-right: 12px;
    animation: spin 1s linear infinite;
}

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

/* Error Message */
#error-message {
    padding: 15px;
    margin: 20px 0;
    border-radius: var(--border-radius);
    background-color: #fee2e2;
    color: #b91c1c;
    border-left: 4px solid #ef4444;
    display: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        margin: 10px;
        padding: 15px;
        border-radius: 6px;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .view-toggle {
        align-self: flex-end;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .actions {
        justify-content: space-between;
    }

    .refresh-control {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .filters {
        flex-direction: column;
        gap: 10px;
    }

    .filter-group {
        width: 100%;
    }

    .search-box {
        width: 100%;
    }

    .network-stats {
        grid-template-columns: 1fr;
    }

    .map-container {
            height: 400px;
        }
    }
    /* Marker Cluster Styles */
    .marker-cluster {
        background-clip: padding-box;
        border-radius: 20px;
    }

    .marker-cluster div {
        width: 36px;
        height: 36px;
        margin-left: 2px;
        margin-top: 2px;
        text-align: center;
        border-radius: 18px;
        font-size: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Map Controls */
    .leaflet-control-locate {
        border: 2px solid rgba(0,0,0,0.2);
        background-clip: padding-box;
    }

    .leaflet-control-locate a {
        background-color: var(--bg-primary);
        background-position: 50% 50%;
        background-repeat: no-repeat;
        display: block;
        width: 30px;
        height: 30px;
        line-height: 30px;
        color: var(--text-primary);
        text-align: center;
    }

    .leaflet-control-locate a:hover {
        background-color: var(--bg-tertiary);
        color: var(--primary-color);
    }

    .leaflet-control-locate.active a {
        color: var(--primary-color);
    }

    .leaflet-control-fullscreen {
        border: 2px solid rgba(0,0,0,0.2);
        background-clip: padding-box;
    }

    .leaflet-control-fullscreen a {
        background-color: var(--bg-primary);
        background-position: 50% 50%;
        background-repeat: no-repeat;
        display: block;
        width: 30px;
        height: 30px;
        line-height: 30px;
        color: var(--text-primary);
        text-align: center;
    }

    .leaflet-control-fullscreen a:hover {
        background-color: var(--bg-tertiary);
        color: var(--primary-color);
    }

    /* Map layers control */
    .leaflet-control-layers {
        border-radius: var(--border-radius);
        background-color: var(--bg-primary);
        color: var(--text-primary);
        border: 1px solid var(--border-color);
        box-shadow: var(--shadow-sm);
    }

    .dark-mode .leaflet-control-layers {
        background-color: var(--bg-tertiary);
    }

    .leaflet-control-layers-toggle {
        width: 36px;
        height: 36px;
        background-size: 20px 20px;
    }

    .leaflet-control-layers-expanded {
        padding: 10px;
        background-color: var(--bg-primary);
        color: var(--text-primary);
        border-radius: var(--border-radius);
    }

    .dark-mode .leaflet-control-layers-expanded {
        background-color: var(--bg-tertiary);
    }

    .leaflet-control-layers-list {
        margin-top: 8px;
    }

    .leaflet-control-layers label {
        margin-bottom: 5px;
        display: block;
    }

    /* Map layer selection buttons */
    .map-layers-control {
        position: absolute;
        top: 10px;
        right: 10px;
        z-index: 1000;
        background: white;
        padding: 5px;
        border-radius: 4px;
        box-shadow: 0 1px 5px rgba(0,0,0,0.65);
    }

    .map-layers-control button {
        display: block;
        margin: 5px 0;
        padding: 5px;
        width: 100%;
        border: none;
        background: #f8f8f8;
        cursor: pointer;
    }

    .map-layers-control button:hover {
        background: #f0f0f0;
    }

    .map-layers-control button.active {
        background: #ddd;
        font-weight: bold;
    }

    /* Map tools control */
    .map-tools-control {
        position: absolute;
        bottom: 30px;
        right: 10px;
        z-index: 1000;
        display: flex;
        flex-direction: column;
        gap: 5px;
    }

    .map-tools-control button {
        width: 34px;
        height: 34px;
        background: white;
        border: 2px solid rgba(0,0,0,0.2);
        border-radius: 4px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        color: #333;
    }

    .map-tools-control button:hover {
        background: #f4f4f4;
    }

    .dark-mode .map-tools-control button {
        background: #333;
        color: #fff;
        border-color: rgba(255,255,255,0.2);
    }

    .dark-mode .map-tools-control button:hover {
        background: #444;
    }

    /* Map measurement widget */
    .leaflet-measure-path-measurement {
        position: absolute;
        font-size: 12px;
        color: black;
        text-shadow: -1px 0 white, 0 1px white, 1px 0 white, 0 -1px white;
        white-space: nowrap;
        transform-origin: 0;
        pointer-events: none;
    }

    .dark-mode .leaflet-measure-path-measurement {
        color: white;
        text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
    }

    /* Popup styling */
    .leaflet-popup-content-wrapper {
        border-radius: var(--border-radius);
        background-color: var(--bg-primary);
        color: var(--text-primary);
        box-shadow: var(--shadow-md);
    }

    .dark-mode .leaflet-popup-content-wrapper {
        background-color: var(--bg-tertiary);
    }

    .leaflet-popup-content {
        margin: 12px;
        line-height: 1.5;
    }

    .leaflet-popup-tip {
        background-color: var(--bg-primary);
    }

    .dark-mode .leaflet-popup-tip {
        background-color: var(--bg-tertiary);
    }

    .leaflet-popup-content a {
        color: var(--primary-color);
        text-decoration: none;
    }

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

    /* Make the map more responsive on mobile */
    @media (max-width: 768px) {
        .map-container {
            height: 450px;
        }

        .leaflet-control-layers,
        .leaflet-control-zoom,
        .leaflet-control-fullscreen,
        .leaflet-control-locate {
            margin-right: 10px !important;
        }

        .leaflet-control-scale {
            margin-bottom: 40px !important;
        }
    }
    