/* ==========================================================================
   3D Fruit Fly Autonomous Rover - Cyberpunk Glassmorphism Design Tokens & UI
   ========================================================================== */

:root {
    --bg-dark: #080b12;
    --card-bg: rgba(16, 23, 38, 0.75);
    --card-border: rgba(0, 242, 254, 0.25);
    --accent-cyan: #00f2fe;
    --accent-magenta: #f72585;
    --accent-gold: #ffb703;
    --accent-green: #4cc9f0;
    --danger-red: #ff0055;
    --text-primary: #f8f9fa;
    --text-muted: #94a3b8;
    --glow-cyan: 0 0 15px rgba(0, 242, 254, 0.4);
    --glow-magenta: 0 0 15px rgba(247, 37, 133, 0.4);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 15% 20%, rgba(0, 242, 254, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 85% 80%, rgba(247, 37, 133, 0.08) 0%, transparent 40%);
}

/* Header & Top Navigation */
.header {
    background: rgba(12, 17, 29, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--card-border);
    padding: 0.35rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-brand h1 {
    font-size: 1.1rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-magenta));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.header-brand p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.nav-links {
    display: flex;
    gap: 8px;
}

.nav-btn {
    padding: 0.35rem 0.8rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-btn:hover {
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
    box-shadow: var(--glow-cyan);
}

.nav-btn.active {
    background: linear-gradient(135deg, rgba(0, 242, 254, 0.15), rgba(247, 37, 133, 0.15));
    color: #ffffff;
    border-color: var(--accent-cyan);
}

/* Main Layout Grid - Maximized 3D Viewport */
.app-container {
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 8px;
    padding: 4px 8px;
    max-width: 100%;
    margin: 0 auto;
    height: calc(100vh - 46px);
    transition: grid-template-columns 0.3s ease;
}

.app-container.sidebar-collapsed {
    grid-template-columns: 1fr;
}

.app-container.sidebar-collapsed .dashboard-sidebar {
    display: none !important;
}

@media (max-width: 1100px) {
    .app-container {
        grid-template-columns: 1fr;
        height: auto;
    }
}

/* 3D Viewport Card */
.viewport-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    backdrop-filter: blur(12px);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    height: 100%;
    min-height: 500px;
}

#canvas3d {
    width: 100%;
    height: 100%;
    display: block;
}

/* HUD Overlay on top of 3D Scene */
.hud-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    pointer-events: none;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 10;
}

.hud-badge {
    background: rgba(8, 12, 22, 0.8);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(10px);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-cyan);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--glow-cyan);
}

.hud-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-cyan);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 242, 254, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(0, 242, 254, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 242, 254, 0); }
}

.camera-bar {
    pointer-events: auto;
    display: flex;
    gap: 8px;
    background: rgba(8, 12, 22, 0.85);
    backdrop-filter: blur(10px);
    padding: 6px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.cam-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 6px 12px;
    font-size: 0.78rem;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.cam-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.cam-btn.active {
    background: var(--accent-cyan);
    color: #000;
}

/* Bottom Controls Bar on 3D Viewport */
.viewport-controls-bar {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
    pointer-events: auto;
    background: rgba(8, 12, 22, 0.8);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(12px);
    padding: 6px 12px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 5px 11px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.78rem;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn:hover {
    transform: translateY(-2px);
    border-color: var(--accent-cyan);
    box-shadow: var(--glow-cyan);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-cyan), #0077b6);
    color: #000;
    border: none;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-red), #9d0208);
    color: #fff;
    border: none;
}

/* Toggle Switch */
.toggle-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #2a3447;
    transition: .3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--accent-cyan);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

/* Telemetry Dashboard Sidebar */
.dashboard-sidebar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    padding-right: 2px;
}

.panel-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    backdrop-filter: blur(16px);
    padding: 10px 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.panel-title {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 4px;
}

/* Stats Overview Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.stat-box {
    background: rgba(8, 12, 22, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 6px;
    text-align: center;
}

.stat-val {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--accent-cyan);
}

.stat-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-top: 1px;
}

/* Eye Sensors Array Bars */
.eye-sensors-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.eye-box {
    background: rgba(8, 12, 22, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 6px 8px;
}

.eye-label {
    font-size: 0.7rem;
    font-weight: 700;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
}

.eye-label.left { color: var(--accent-magenta); }
.eye-label.right { color: var(--accent-cyan); }

.sensor-bars {
    display: flex;
    gap: 2px;
    height: 26px;
    align-items: flex-end;
}

.s-bar {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    height: 10%;
    transition: height 0.1s ease, background-color 0.1s ease;
}

/* Wing Power Gauges */
.wing-gauges {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.gauge-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.gauge-name {
    font-size: 0.72rem;
    font-weight: 700;
    width: 65px;
}

.gauge-track {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.gauge-fill {
    height: 100%;
    width: 50%;
    border-radius: 4px;
    transition: width 0.1s ease;
}

.fill-left { background: linear-gradient(90deg, #f72585, #7209b7); }
.fill-right { background: linear-gradient(90deg, #00f2fe, #4cc9f0); }

.gauge-num {
    font-size: 0.75rem;
    font-weight: 800;
    width: 36px;
    text-align: right;
}

/* Connectome Stats List */
.connectome-info-list {
    font-size: 0.72rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
}

.info-val {
    font-weight: 700;
    color: var(--text-primary);
}

/* Oscilloscope Canvas in 3D Rover Sidebar */
.dashboard-sidebar #oscilloscopeCanvas {
    width: 100%;
    height: 52px;
    background: rgba(4, 8, 15, 0.9);
    border: 1px solid rgba(0, 242, 254, 0.2);
    border-radius: 6px;
    display: block;
}
