/* === Base Reset === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body,
html {
    height: 100%;
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
        sans-serif;
}

/* === Map === */
#map {
    width: 100%;
    height: 100vh;
}

/* === Map Loading Overlay === */
.map-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
    background: rgb(15, 23, 42);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    transition: opacity 0.4s ease;
}

.map-loading-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255, 255, 255, 0.08);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.map-loading-text {
    font-family:
        "SF Mono", "Fira Code", "Cascadia Code", "JetBrains Mono", Consolas,
        monospace;
    font-size: 12px;
    letter-spacing: 0.05em;
    color: #64748b;
    text-transform: uppercase;
}

/* === Timeline === */
.timeline {
    position: fixed;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 640px;
    width: calc(100% - 40px);
    z-index: 100;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family:
        "SF Mono", "Fira Code", "Cascadia Code", "JetBrains Mono", Consolas,
        monospace;
    font-size: 11px;
    color: #94a3b8;
}

.timeline-label {
    flex-shrink: 0;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    user-select: none;
}

.timeline-time {
    flex-shrink: 0;
    min-width: 58px;
    text-align: center;
    color: #e2e8f0;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.timeline-range {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    transition: height 0.15s ease;
}

.timeline-range:hover {
    height: 6px;
}

/* Track – WebKit */
.timeline-range::-webkit-slider-runnable-track {
    height: inherit;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

/* Track – Firefox */
.timeline-range::-moz-range-track {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    border: none;
}

/* Progress fill – Firefox */
.timeline-range::-moz-range-progress {
    height: 4px;
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
    border-radius: 2px;
}

/* Thumb – WebKit */
.timeline-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: #e2e8f0;
    border: 2px solid #3b82f6;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(59, 130, 246, 0.5);
    transition:
        transform 0.1s ease,
        box-shadow 0.15s ease;
}

.timeline-range:hover::-webkit-slider-thumb {
    transform: scale(1.2);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.7);
}

/* Thumb – Firefox */
.timeline-range::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #e2e8f0;
    border: 2px solid #3b82f6;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(59, 130, 246, 0.5);
    transition:
        transform 0.1s ease,
        box-shadow 0.15s ease;
}

.timeline-range:hover::-moz-range-thumb {
    transform: scale(1.2);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.7);
}

.timeline-live-btn {
    flex-shrink: 0;
    padding: 4px 10px;
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 6px;
    font-family: inherit;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition:
        background 0.15s ease,
        color 0.15s ease;
    user-select: none;
}

.timeline-live-btn:hover {
    background: rgba(59, 130, 246, 0.35);
    color: #93bbfd;
}

.timeline-live-btn.active {
    background: rgba(52, 211, 153, 0.2);
    color: #34d399;
    border-color: rgba(52, 211, 153, 0.3);
}

.timeline-live-btn.active::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #34d399;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: middle;
    animation: live-pulse 1.5s ease-in-out infinite;
}

@keyframes live-pulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.4;
    }
}

/* === Signals Panel === */
.signals {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 100;
    display: inline-block;
    width: fit-content;
    max-width: calc(100vw - 24px);
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #e2e8f0;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.3),
        0 10px 20px -2px rgba(0, 0, 0, 0.25);
    padding: 10px 12px;
    font-size: 12px;
    line-height: 1.6;
    transition:
        opacity 0.2s ease,
        box-shadow 0.2s ease,
        background 0.2s ease,
        transform 0.2s ease;
}

.signals:hover {
    background: rgba(15, 23, 42, 0.94);
}

.signals-toggle {
    width: auto;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0;
    background: transparent;
    border: 0;
    cursor: pointer;
    user-select: none;
    color: #cbd5e1;
    font-family:
        "SF Mono", "Fira Code", "Cascadia Code", "JetBrains Mono", Consolas,
        monospace;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    text-align: left;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.signals-toggle:hover .signals-toggle-label,
.signals-toggle:hover .signals-toggle-icon {
    color: #e2e8f0;
}

.signals-toggle:focus-visible {
    outline: 2px solid rgba(96, 165, 250, 0.7);
    outline-offset: 4px;
    border-radius: 6px;
}

.signals-toggle-label {
    color: inherit;
}

.signals-toggle-icon {
    min-width: 16px;
    color: #60a5fa;
    font-size: 16px;
    line-height: 1;
    text-align: center;
    transition:
        color 0.2s ease,
        transform 0.2s ease;
}

.signals-body {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 260px;
    width: min(400px, calc(100vw - 24px));
    max-height: min(420px, calc(100vh - 80px));
    overflow-y: auto;
    padding: 14px 16px;
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.3),
        0 10px 20px -2px rgba(0, 0, 0, 0.25);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-6px) scale(0.98);
    transform-origin: top left;
    transition:
        opacity 0.2s ease,
        transform 0.2s ease,
        visibility 0.2s ease;
}

.signals.open .signals-body {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.signals.open .signals-toggle-icon {
    transform: rotate(90deg);
}

.signals pre {
    margin: 0;
    font-family:
        "SF Mono", "Fira Code", "Cascadia Code", "JetBrains Mono", Consolas,
        monospace;
    font-size: 11px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    color: #94a3b8;
}

/* Scrollbar styling */
.signals-body::-webkit-scrollbar {
    width: 6px;
}

.signals-body::-webkit-scrollbar-track {
    background: transparent;
}

.signals-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.signals-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* === Aircraft Popup === */
.entity-popup .maplibregl-popup-content {
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    padding: 10px 14px;
    color: #e2e8f0;
    font-family:
        "SF Mono", "Fira Code", "Cascadia Code", "JetBrains Mono", Consolas,
        monospace;
    font-size: 12px;
}

.entity-popup .maplibregl-popup-tip {
    border-top-color: rgba(15, 23, 42, 0.92);
}

.entity-popup .maplibregl-popup-close-button {
    color: #94a3b8;
    font-size: 16px;
    padding: 2px 6px;
}

.entity-popup .maplibregl-popup-close-button:hover {
    color: #e2e8f0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.entity-popup-title {
    font-weight: 600;
    font-size: 13px;
    color: #ffffff;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.entity-popup-field {
    color: #94a3b8;
    line-height: 1.8;
}
