/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

#loading-overlay.hidden {
    display: none;
}

.loader-content {
    text-align: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid #333;
    border-top: 3px solid var(--neon-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
    box-shadow: 0 0 15px var(--neon-blue);
}

.loading-text {
    font-family: var(--font-mono);
    color: var(--neon-blue);
    letter-spacing: 2px;
    animation: blink 1s infinite alternate;
}

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

/* Cyberpunk Theme Variables */
:root {
    --bg-dark: #050505;
    --bg-panel: #111111;
    --neon-blue: #00f3ff;
    --neon-pink: #ff00ff;
    --neon-gold: #ffd700;
    --neon-green: #00ff41;
    --neon-red: #ff3333;
    --text-main: #e0e0e0;
    --text-dim: #666;
    --font-main: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'Courier New', Courier, monospace;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-main);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

#app {
    display: flex;
    height: 100%;
    width: 100%;
}

/* Sidebar HUD */
#hud-sidebar {
    width: 320px;
    background-color: var(--bg-panel);
    border-right: 1px solid #333;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    overflow-y: auto;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
    z-index: 10;
}

.hud-header {
    text-align: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #333;
    padding-bottom: 1rem;
}

.hud-header h2 {
    margin: 0;
    font-weight: 800;
    letter-spacing: 2px;
}

.neon-text {
    color: var(--neon-blue);
    text-shadow: 0 0 5px var(--neon-blue);
}

.status-indicator {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 0.5rem;
}

.hud-section {
    margin-bottom: 1.5rem;
    background: rgba(255, 255, 255, 0.02);
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #222;
}

.hud-section h3 {
    margin: 0 0 0.5rem 0;
    font-size: 0.8rem;
    color: var(--neon-blue);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* --- Consolidated Dashboard --- */
.dashboard-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dash-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.speed-group {
    display: flex;
    align-items: baseline;
    gap: 5px;
}

.speed-val {
    font-family: var(--font-mono);
    font-size: 3rem;
    line-height: 1;
    color: var(--text-main);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

.speed-unit {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.state-group {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}

.gear-display {
    display: flex;
    gap: 2px;
}

.gear {
    padding: 2px 6px;
    border: 1px solid #333;
    color: #444;
    font-weight: bold;
    font-size: 0.9rem;
}

.gear.active {
    color: var(--bg-dark);
    background: var(--text-main);
    box-shadow: 0 0 5px white;
}

.ap-badge {
    padding: 4px 8px;
    background: #222;
    border: 1px solid #444;
    border-radius: 3px;
    font-size: 0.8rem;
    font-weight: bold;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    width: 100%;
    text-align: center;
}

.ap-badge.active-tacc {
    color: var(--neon-blue);
    border-color: var(--neon-blue);
    background: rgba(0, 243, 255, 0.1);
    box-shadow: 0 0 5px rgba(0, 243, 255, 0.2);
}

.ap-badge.active-steer {
    color: var(--neon-blue);
    border-color: var(--neon-blue);
    background: rgba(0, 243, 255, 0.2);
    box-shadow: 0 0 8px rgba(0, 243, 255, 0.4);
}

.ap-badge.active-fsd {
    color: var(--neon-gold);
    border-color: var(--neon-gold);
    background: rgba(255, 215, 0, 0.2);
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

/* --- Control Deck --- */
.control-deck {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Deck Steering */
.deck-steering {
    display: flex;
    align-items: center;
    gap: 5px;
}

.steering-viz {
    flex: 1;
}

.center-bar-bg {
    height: 4px;
    background: #222;
    border: 1px solid #333;
    width: 100%;
    position: relative;
    display: flex;
    justify-content: center;
}

.center-bar-fill {
    height: 100%;
    background: var(--neon-green);
    width: 0px; 
    transition: width 0.1s;
}

.signal-arrow {
    font-size: 1rem;
    color: #333;
    width: 20px;
    text-align: center;
}

.signal-arrow.active {
    color: var(--neon-green);
    text-shadow: 0 0 5px var(--neon-green);
    animation: blink 0.5s infinite alternate;
}

/* Deck Cluster (Pedals + G-Force) */
.deck-cluster {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 120px;
}

/* Vertical Pedals */
.pedal-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    width: 20px;
}

.v-bar-container {
    flex: 1;
    width: 100%;
    background: #111;
    border: 1px solid #333;
    border-radius: 2px;
    position: relative;
    display: flex;
    flex-direction: column-reverse;
}

.v-bar-fill {
    width: 100%;
    height: 0%;
    transition: height 0.1s;
}

.v-bar-fill.throttle { background: var(--neon-blue); box-shadow: 0 0 5px var(--neon-blue); }
.v-bar-fill.brake { background: var(--neon-red); box-shadow: 0 0 5px var(--neon-red); }

.label-tiny {
    font-size: 0.6rem;
    color: #666;
    margin-top: 4px;
}

/* G-Force Bubble */
.g-force-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

#g-force-bubble {
    width: 100px;
    height: 100px;
    background: #050505;
    border: 2px solid #333;
    border-radius: 50%;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 20px rgba(0,0,0,1);
}

/* Bubble Grid */
.grid-ring {
    position: absolute;
    top: 50%; left: 50%;
    border: 1px solid #222;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}
.ring-1 { width: 33%; height: 33%; }
.ring-2 { width: 66%; height: 66%; }

.crosshair-h {
    position: absolute;
    top: 50%; left: 0; right: 0;
    height: 1px;
    background: #222;
}
.crosshair-v {
    position: absolute;
    left: 50%; top: 0; bottom: 0;
    width: 1px;
    background: #222;
}

/* The "Bubble" Dot */
#g-force-dot {
    width: 12px;
    height: 12px;
    background: rgba(255, 215, 0, 0.8);
    border: 2px solid #fff;
    border-radius: 50%;
    position: absolute;
    top: 50%; left: 50%;
    margin-top: -6px; margin-left: -6px;
    box-shadow: 0 0 10px var(--neon-gold);
    transition: transform 0.1s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 5;
}

/* Numeric G Readout */
.g-readout {
    position: absolute;
    bottom: 5px;
    left: 0; right: 0;
    text-align: center;
    font-size: 0.6rem;
    color: #666;
    font-family: var(--font-mono);
}

/* Sparkline */
.sparkline-wrapper {
    height: 40px;
    border-top: 1px solid #222;
    padding-top: 5px;
}

/* Map */
.map-container {
    height: 250px;
    min-height: 250px; /* Prevent squishing */
    flex-shrink: 0;    /* Prevent squishing in flex container */
    padding: 0;
    overflow: hidden;
}

#mini-map {
    width: 100%;
    height: 100%;
    background: #000;
}

/* Controls */
.control-row {
    display: flex;
    gap: 5px;
    margin-bottom: 5px;
}
.control-label {
    font-size: 0.7rem;
    color: #666;
    margin-top: 10px;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.cyber-btn {
    display: block;
    flex: 1;
    background: transparent;
    border: 1px solid var(--neon-blue);
    color: var(--neon-blue);
    padding: 0.5rem;
    cursor: pointer;
    font-family: var(--font-main);
    text-transform: uppercase;
    transition: all 0.2s;
    font-size: 0.8rem;
}

.cyber-btn:hover, .cyber-btn.active {
    background: var(--neon-blue);
    color: var(--bg-dark);
    box-shadow: 0 0 10px var(--neon-blue);
}

.cyber-btn.active:hover {
    background: transparent;
    color: var(--neon-blue);
    box-shadow: none;
}

/* Calendar & Heatmap */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 5px;
    background: #1a1a1a;
    border-radius: 4px;
}

#cal-month-year {
    font-weight: bold;
    color: var(--neon-blue);
}

.cal-btn {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 1rem;
}
.cal-btn:hover { color: white; }

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 15px;
}

.cal-day {
    aspect-ratio: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.75rem;
    color: #444;
    background: #111;
    cursor: default;
    border-radius: 2px;
    position: relative;
    transition: all 0.2s;
}

/* Heatmap Levels */
.cal-day.has-events {
    cursor: pointer;
    color: #eee;
    background: #222;
    box-shadow: inset 0 0 2px rgba(255,255,255,0.1);
}

.cal-day.heat-low { background: rgba(0, 243, 255, 0.1); border: 1px solid rgba(0, 243, 255, 0.2); }
.cal-day.heat-med { background: rgba(0, 243, 255, 0.3); border: 1px solid rgba(0, 243, 255, 0.4); box-shadow: 0 0 5px rgba(0,243,255,0.2); }
.cal-day.heat-high { background: rgba(0, 243, 255, 0.6); border: 1px solid rgba(0, 243, 255, 0.8); box-shadow: 0 0 10px rgba(0,243,255,0.4); color: #000; font-weight: bold; }

.cal-day.selected {
    border-color: var(--neon-gold);
    box-shadow: 0 0 10px var(--neon-gold);
    z-index: 2;
    transform: scale(1.1);
}

.day-events-list {
    border-top: 1px solid #333;
    padding-top: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.event-item {
    padding: 8px;
    border-bottom: 1px solid #222;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
}
.event-item:hover { background: #222; }
.event-item.active { 
    background: rgba(0, 243, 255, 0.1);
    color: var(--neon-blue);
    border-left: 2px solid var(--neon-blue);
}

.event-time { font-family: var(--font-mono); }
.event-dur { color: #666; font-size: 0.7rem; }

.empty-state {
    text-align: center;
    color: #444;
    font-size: 0.8rem;
    padding: 10px;
    font-style: italic;
}

/* Main Video Grid */
#video-grid-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #000;
}

.video-grid {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 2px;
    background: #111;
    padding: 2px;
    position: relative;
}

.video-cell {
    background: #000;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    cursor: pointer; 
    z-index: 1;
    border: 1px solid transparent;
}

.video-cell:hover {
    border-color: #333;
}

.video-cell video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.cam-label {
    position: absolute;
    top: 5px;
    left: 5px;
    background: rgba(0, 0, 0, 0.5);
    padding: 2px 5px;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.7);
    pointer-events: none;
    transition: all 0.3s;
}

/* Immersive Zoom States */
.video-cell.zoomed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    z-index: 50;
    border: 2px solid var(--neon-blue);
    box-shadow: 0 0 30px rgba(0, 243, 255, 0.2);
    background: #000;
}

.video-cell.zoomed .cam-label {
    font-size: 1.2rem;
    padding: 5px 15px;
    background: rgba(0, 0, 0, 0.8);
    color: var(--neon-blue);
    border-bottom-right-radius: 10px;
    border-right: 1px solid var(--neon-blue);
    border-bottom: 1px solid var(--neon-blue);
    top: 0;
    left: 0;
}

/* When grid has a zoomed item, hide others */
.video-grid.has-zoom .video-cell:not(.zoomed) {
    opacity: 0;
    pointer-events: none;
}


/* Privacy Mask */
.privacy-mask {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 25%; /* Bottom quarter */
    background: #000; /* Solid Black */
    pointer-events: none;
    display: block; /* Default enabled */
    z-index: 5;
}

.privacy-mask.hidden {
    display: none;
}

/* Night Sight Filter */
.night-sight-active video {
    filter: brightness(1.6) contrast(1.2) saturate(0.8);
}

/* Timeline */
#timeline-container {
    height: 50px;
    background: var(--bg-panel);
    border-top: 1px solid #333;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 1rem;
}

#btn-play-pause {
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.2rem;
    cursor: pointer;
    width: 30px;
}

.speed-select {
    background: #222;
    color: var(--text-main);
    border: 1px solid #444;
    border-radius: 4px;
    padding: 2px 5px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    cursor: pointer;
}

#scrubber {
    flex: 1;
    accent-color: var(--neon-blue);
    cursor: pointer;
}

#time-display {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    width: 100px;
    text-align: right;
}

/* Recording Pulse */
.recording {
    background: var(--neon-red) !important;
    color: white !important;
    border-color: red !important;
    box-shadow: 0 0 15px red !important;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}
@keyframes blink {
    from { opacity: 1; }
    to { opacity: 0.2; }
}
