body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    background-color: #0000a8;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: white;
    overflow: hidden;
}

#map {
    height: 100%;
    width: 100%;
    background-color: #00008a; /* Deep blue background for the map itself */
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    padding: 20px;
    z-index: 1000;
}

#header {
    background: rgba(46, 46, 46, 0.8);
    padding: 10px 20px;
    border-bottom: 3px solid #0055ff;
    width: fit-content;
    position: relative;
}

#live-indicator {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #ff0000;
    color: white;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 4px;
    animation: blink 1s infinite;
    display: none; /* Hidden by default */
}

/* Live Tracking Styles */
#btn-live-tracking.active {
    background: #ffffff !important;
    color: #000000 !important;
    border-color: #ffffff !important;
    box-shadow: 0 0 15px #ffffff;
}


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

#header h1 {
    margin: 0;
    font-size: 24px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #00ccff;
}

#timestamp {
    font-size: 14px;
    color: #cccccc;
    margin-top: 5px;
}

#radar-status-warning {
    background-color: rgba(255, 165, 0, 0.85);
    color: #000;
    font-weight: bold;
    padding: 5px 10px;
    border-radius: 4px;
    margin-top: 8px;
    display: none; /* Hidden by default */
    font-size: 12px;
    text-align: center;
    pointer-events: auto;
}

#radar-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
    pointer-events: auto;
}

#radar-controls button {
    background: rgba(100, 100, 150, 0.8);
    color: white;
    border: 2px solid #0055ff;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s ease;
    pointer-events: auto;
    text-transform: uppercase;
}

#radar-controls button:hover {
    background: rgba(120, 120, 180, 0.9);
    box-shadow: 0 0 10px #0055ff;
}

#radar-controls button.active {
    background: #0055ff;
    box-shadow: 0 0 15px #0055ff, inset 0 0 10px rgba(255, 255, 255, 0.3);
}

#radar-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    color: #cccccc;
    pointer-events: auto;
}

#radar-selector label {
    color: #cccccc;
}

#radar-selector select {
    background: rgba(100, 100, 150, 0.8);
    color: white;
    border: 2px solid #0055ff;
    padding: 6px 10px;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s ease;
}

#radar-selector select:hover {
    background: rgba(120, 120, 180, 0.9);
    box-shadow: 0 0 10px #0055ff;
}

#radar-selector select option {
    background: #000033;
    color: white;
}

#btn-loop {
    background: rgba(0, 128, 0, 0.8);
    border-color: #00ff00;
}

#btn-loop:hover {
    background: rgba(0, 160, 0, 0.9);
    box-shadow: 0 0 10px #00ff00;
}

#btn-loop.active {
    background: #00cc00;
    box-shadow: 0 0 15px #00cc00, inset 0 0 10px rgba(255, 255, 255, 0.3);
}

#legend {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    padding: 15px;
    border: 1px solid #555;
    pointer-events: auto;
    z-index: 1001;
    border-radius: 5px;
    transition: all 0.3s ease;
}

#legend-toggle-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(46, 46, 46, 0.9);
    color: white;
    padding: 8px;
    border-radius: 5px;
    cursor: pointer;
    z-index: 1002;
    pointer-events: auto;
    display: none; /* Only show on mobile if needed or as a generic toggle */
    border: 1px solid #0055ff;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    #ui-overlay {
        padding: 10px;
    }

    #header {
        padding: 8px 15px;
        width: calc(100% - 30px);
    }

    #header h1 {
        font-size: 18px;
    }

    #main-controls-toggle {
        width: 100% !important;
        box-sizing: border-box;
    }

    #main-controls-content {
        width: 100% !important;
        box-sizing: border-box;
    }

    #legend {
        top: auto;
        bottom: 20px;
        right: 10px;
        left: 10px;
        max-height: 30vh;
        overflow-y: auto;
        font-size: 10px;
    }

    .legend-item, .v-scale {
        font-size: 10px;
    }

    .box, .v-box {
        width: 15px;
        height: 15px;
    }

    #radar-controls button {
        padding: 10px 15px; /* Larger touch area */
        font-size: 13px;
    }

    #radar-selector select {
        padding: 8px 12px;
        font-size: 12px;
    }
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.legend-item:hover {
    opacity: 0.8;
}

.legend-item.disabled {
    opacity: 0.4;
    text-decoration: line-through;
}

#legend-no-alerts, #legend-no-watches { cursor: default; }

.legend-item:last-child {
    margin-bottom: 0;
}

.box {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    border: 2px solid white;
}

.tornado-warning { background-color: rgba(255, 0, 0, 0.5); border-color: #ff0000; }
.tornado-watch { background-color: rgba(255, 153, 0, 0.5); border-color: #ff9900; }
.thunderstorm-warning { background-color: rgba(255, 255, 0, 0.5); border-color: #ffff00; }
.thunderstorm-watch { background-color: rgba(255, 102, 178, 0.5); border-color: #ff66b2; }
.hurricane { background-color: rgba(128, 0, 128, 0.5); border-color: #800080; }
.flood { background-color: rgba(0, 255, 0, 0.5); border-color: #00ff00; }
.marine { background-color: rgba(255, 0, 255, 0.5); border-color: #ff00ff; }
.snow { background-color: rgba(0, 255, 255, 0.5); border-color: #00ffff; }
.winter-watch { background-color: rgba(51, 153, 255, 0.5); border-color: #3399ff; }
.other-warning { background-color: rgba(153, 153, 153, 0.5); border-color: #999999; }
.other-watch { background-color: rgba(170, 170, 170, 0.5); border-color: #aaaaaa; }

/* Velocity Legend Styles */
.legend-title {
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 8px;
    color: #00ccff;
}

.v-scale {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
}

.v-box {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    border: 2px solid white;
}

.inbound { background-color: rgba(0, 255, 0, 0.6); border-color: #00ff00; }
.outbound { background-color: rgba(255, 0, 0, 0.6); border-color: #ff0000; }

.v-note {
    font-size: 10px;
    font-style: italic;
    color: #aaaaaa;
    margin-top: 8px;
}

/* Custom Leaflet overrides */
.leaflet-container {
    background: #000063 !important;
}

.city-label {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    color: #d6d5d5 !important;
    font-weight: 900 !important;
    text-shadow: 1px 1px 3px black, -1px -1px 3px black, 1px -1px 3px black, -1px 1px 3px black !important;
    font-size: 14px !important;
    white-space: nowrap;
}

/* Alert Popup Styles */
.alert-popup {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #333;
}

.alert-popup h3 {
    margin-top: 0;
    margin-bottom: 8px;
    color: #cc0000;
    font-size: 16px;
    text-transform: uppercase;
    border-bottom: 1px solid #ccc;
    padding-bottom: 4px;
}

.alert-desc {
    font-size: 12px;
    line-height: 1.4;
    margin-bottom: 10px;
}

.alert-inst {
    font-size: 12px;
    line-height: 1.4;
    color: #cc0000;
    background: #ffeeee;
    padding: 5px;
    border-left: 3px solid #cc0000;
}

/* Spectrum Legends */
.spectrum-bar {
    height: 15px;
    width: 100%;
    margin: 5px 0;
    border-radius: 2px;
}

.reflectivity-spectrum {
    background: linear-gradient(to right, #00ecec, #01a0f6, #0000f6, #00ff00, #00c800, #009000, #ffff00, #e7c000, #ff9000, #ff0000, #d60000, #c00000, #ff00ff, #9955c9, #ffffff);
}

.velocity-spectrum {
    background: linear-gradient(to right, #00ff00, #00cc00, #008800, #004400, #777777, #440000, #880000, #cc0000, #ff0000);
}

.debris-spectrum {
    background: linear-gradient(to right, #ff00ff, #0000ff, #00ffff, #00ff00, #ffff00);
}
