/* styles.css — Dark theme base styles */

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

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    background: #1a1a2e;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #e0e0e0;
}

#map {
    width: 100%;
    height: 100%;
}

/* Dark theme overrides for Leaflet controls */
.leaflet-control-zoom a {
    background-color: #16213e !important;
    color: #e0e0e0 !important;
    border-color: #0f3460 !important;
}

.leaflet-control-zoom a:hover {
    background-color: #0f3460 !important;
}

.leaflet-control-attribution {
    background-color: rgba(22, 33, 62, 0.8) !important;
    color: #8888aa !important;
}

.leaflet-control-attribution a {
    color: #5588cc !important;
}

/* Tile error message (AC1.5) */
.tile-error {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    background: rgba(22, 33, 62, 0.95);
    border: 1px solid #ff4444;
    border-radius: 8px;
    padding: 16px 24px;
    color: #ff6666;
    font-size: 14px;
}

/* Vehicle marker styles (AC2) */
.vehicle-marker {
    width: 48px;
    height: 32px;
    pointer-events: auto;
    transition: opacity 200ms ease;
}

/* Vehicle marker color is applied directly via SVG fill attribute in getVehicleIconHtml() */
/* No pulsing glow animation — color applied directly without filters */

/* Control panel styles (AC4) */
.control-panel {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    background: rgba(22, 33, 62, 0.95);
    border: 1px solid #0f3460;
    border-radius: 8px;
    padding: 12px;
    max-height: 60vh;
    overflow-y: auto;
    min-width: 180px;
}

.control-panel__title {
    font-size: 14px;
    color: #e0e0e0;
    margin-bottom: 8px;
    font-weight: 600;
}

.route-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Service type group container */
.service-group {
    margin-bottom: 4px;
}

/* Master toggle header row */
.service-group__header {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #7b8da1;
}

.service-group__header:hover {
    background: rgba(15, 52, 96, 0.5);
}

/* Children container — holds route items */
.service-group__children {
    padding-left: 8px;
}

/* Collapsed state — hide children */
.service-group__children--collapsed {
    display: none;
}

/* Sub-group heading (e.g., "Green Line" within Subway) */
.route-subgroup-heading {
    font-size: 10px;
    font-weight: 600;
    color: #6b7d91;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 4px;
    margin-bottom: 2px;
    padding: 0 6px;
}

.route-item {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.route-item:hover {
    background: rgba(15, 52, 96, 0.5);
}

.route-swatch {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
}

.route-name {
    color: #c0c0d0;
}

/* Mobile: drawer behavior */
@media (max-width: 767px) {
    .control-panel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 280px;
        max-height: 100vh;
        height: 100%;
        border-radius: 0;
        border-left: 1px solid #0f3460;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
    }

    .control-panel--open {
        transform: translateX(0);
    }

    .drawer-backdrop {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .drawer-backdrop--visible {
        display: block;
    }

    .route-item {
        padding: 10px 12px;
        min-height: 44px; /* Touch-friendly minimum */
    }

    .service-group__header {
        padding: 10px 12px;
        min-height: 44px;
    }

    .drawer-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 10px;
        right: 10px;
        z-index: 1001;
        width: 44px;
        height: 44px;
        background: rgba(22, 33, 62, 0.95);
        border: 1px solid #0f3460;
        border-radius: 8px;
        color: #e0e0e0;
        font-size: 20px;
        cursor: pointer;
    }
}

/* Desktop: static panel, no toggle */
@media (min-width: 768px) {
    .drawer-toggle {
        display: none;
    }

    .drawer-backdrop {
        display: none !important;
    }
}

/* Connection status indicator (AC7.2, AC7.3) */
.connection-status {
    position: fixed;
    bottom: 10px;
    left: 10px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(22, 33, 62, 0.9);
    border: 1px solid #0f3460;
    border-radius: 20px;
    font-size: 12px;
    color: #c0c0d0;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #888;
    flex-shrink: 0;
}

.connection-status--connected .status-dot {
    background: #00cc66;
}

.connection-status--reconnecting .status-dot {
    background: #ffaa00;
    animation: blink 1s ease-in-out infinite;
}

.connection-status--error .status-dot {
    background: #ff4444;
    animation: blink 0.5s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Vehicle popup styles (hover cards) */
.vehicle-popup-container .leaflet-popup-content-wrapper {
    background: rgba(22, 33, 62, 0.95);
    border: 1px solid #0f3460;
    border-radius: 8px;
    color: #e0e0e0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.vehicle-popup-container .leaflet-popup-tip {
    background: rgba(22, 33, 62, 0.95);
    border: 1px solid #0f3460;
    box-shadow: none;
}

.vehicle-popup-container .leaflet-popup-content {
    margin: 8px 10px;
    font-size: 13px;
    line-height: 1.4;
}

.vehicle-popup-container .leaflet-popup-close-btn {
    color: #8888aa;
}

.vehicle-popup-container .leaflet-popup-close-btn:hover {
    color: #e0e0e0;
}

.vehicle-popup__header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.vehicle-popup__swatch {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}

.vehicle-popup__route {
    font-weight: 600;
    color: #e0e0e0;
}

.vehicle-popup__label {
    color: #8888aa;
    font-size: 12px;
}

.vehicle-popup__status {
    color: #c0c0d0;
    margin-bottom: 4px;
}

.vehicle-popup__details {
    display: flex;
    gap: 8px;
    font-size: 12px;
    color: #8888aa;
}

/* Route name labels along polylines (highway marker style) */
.route-label {
    font-size: 10px;
    font-weight: 700;
    color: #e0e0e0;
    background: rgba(22, 33, 62, 0.9);
    border: 1.5px solid var(--route-color);
    border-radius: 3px;
    padding: 0 3px;
    white-space: nowrap;
    pointer-events: none;
    line-height: 1.4;
    display: inline-block;
}
