/* ==========================================================================
   Behaviour Analysis Platform - Cybernetic Observational Design System
   ========================================================================== */

:root {
    --bg-base: #070B12;
    --bg-surface: #0C121E;
    --bg-panel: rgba(14, 21, 35, 0.85);
    --border-cyan: rgba(6, 182, 212, 0.25);
    --border-subtle: rgba(255, 255, 255, 0.08);
    
    --neon-cyan: #06B6D4;
    --neon-purple: #A855F7;
    --neon-emerald: #10B981;
    --neon-yellow: #F59E0B;
    --neon-red: #EF4444;
    
    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted: #475569;
    
    --font-heading: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --font-body: 'Inter', sans-serif;
    
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-pill: 9999px;
}

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

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-body);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Subtle Sci-Fi Grid Overlay */
.cyber-grid {
    position: fixed;
    inset: 0;
    background-image: 
        linear-gradient(to right, rgba(6, 182, 212, 0.03) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(6, 182, 212, 0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 0;
}

/* Header */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(12, 18, 30, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-cyan);
    padding: 0.85rem 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.app-logo {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #06B6D4, #3B82F6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 0 16px rgba(6, 182, 212, 0.4);
}

.pulse-ring {
    position: absolute;
    inset: -3px;
    border-radius: 9px;
    border: 1px solid var(--neon-cyan);
    animation: ringPulse 2s infinite ease-out;
}

@keyframes ringPulse {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.18); opacity: 0; }
}

.logo-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.logo-title .highlight {
    color: var(--neon-cyan);
}

.logo-subtitle {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
    letter-spacing: 0.15em;
}

.session-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.95rem;
    border-radius: var(--radius-pill);
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.3);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--neon-cyan);
}

.recording-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--neon-red);
    box-shadow: 0 0 8px var(--neon-red);
    animation: blink 1.5s infinite;
}

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

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.hardware-pill {
    display: flex;
    gap: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
}

.gpu-badge {
    background: rgba(168, 85, 247, 0.15);
    border: 1px solid rgba(168, 85, 247, 0.3);
    color: var(--neon-purple);
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
}

.port-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
}

.exit-link {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    transition: 0.2s;
}

.exit-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

/* Dashboard Container */
.dashboard-container {
    max-width: 1360px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
}

.kpi-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    backdrop-filter: blur(12px);
    transition: 0.2s;
}

.kpi-card:hover {
    border-color: var(--border-cyan);
    transform: translateY(-2px);
}

.kpi-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.kpi-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.1em;
}

.kpi-tag {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-pill);
}
.kpi-tag.green { background: rgba(16, 185, 129, 0.15); color: var(--neon-emerald); }
.kpi-tag.cyan { background: rgba(6, 182, 212, 0.15); color: var(--neon-cyan); }
.kpi-tag.yellow { background: rgba(245, 158, 11, 0.15); color: var(--neon-yellow); }
.kpi-tag.purple { background: rgba(168, 85, 247, 0.15); color: var(--neon-purple); }

.kpi-value-row {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    margin-bottom: 0.65rem;
}

.kpi-number {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
}

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

.kpi-spark {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-pill);
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.kpi-bar {
    height: 100%;
    background: var(--neon-emerald);
    border-radius: var(--radius-pill);
    transition: width 0.5s ease-out;
}
.kpi-bar.cyan { background: var(--neon-cyan); }
.kpi-bar.yellow { background: var(--neon-yellow); }
.kpi-bar.purple { background: var(--neon-purple); }

.kpi-footer {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* Panels */
.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    backdrop-filter: blur(16px);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.25rem;
}

.panel-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
}

.panel-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: block;
}

/* Observatory Grid */
.main-observatory-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

.canvas-wrapper {
    width: 100%;
    height: 280px;
    background: #080C14;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    margin-bottom: 1rem;
}

.waveform-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.channel-legend {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-line {
    width: 16px;
    height: 3px;
    border-radius: 2px;
}
.legend-line.cyan { background: var(--neon-cyan); box-shadow: 0 0 6px var(--neon-cyan); }
.legend-line.purple { background: var(--neon-purple); box-shadow: 0 0 6px var(--neon-purple); }
.legend-line.emerald { background: var(--neon-emerald); box-shadow: 0 0 6px var(--neon-emerald); }

.stream-controls {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.ctrl-btn {
    background: rgba(6, 182, 212, 0.15);
    border: 1px solid var(--border-cyan);
    color: var(--neon-cyan);
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    transition: 0.2s;
}

.ctrl-btn:hover {
    background: rgba(6, 182, 212, 0.25);
}

.ctrl-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--neon-cyan);
}

.ctrl-select, .cyber-select {
    background: #0D1422;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    outline: none;
}

/* Telemetry Injection Form */
.harness-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group label {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.val-badge {
    font-family: var(--font-mono);
    color: var(--neon-cyan);
    font-weight: 600;
}

.cyber-slider {
    width: 100%;
    accent-color: var(--neon-cyan);
    background: #0D1422;
    height: 6px;
    border-radius: 3px;
    cursor: pointer;
}

.cyber-select {
    width: 100%;
    font-size: 0.82rem;
    padding: 0.6rem;
}

.btn-inject {
    background: linear-gradient(135deg, #06B6D4, #2563EB);
    border: none;
    color: #fff;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(6, 182, 212, 0.3);
    transition: 0.2s;
}

.btn-inject:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(6, 182, 212, 0.45);
}

.inject-status {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: center;
}

/* Timeline Feed */
.timeline-feed {
    max-height: 220px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

.timeline-row {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.02);
    border-left: 2px solid var(--neon-cyan);
}

.timeline-row.anomaly {
    border-left-color: var(--neon-red);
    background: rgba(239, 68, 68, 0.06);
}

.row-time {
    color: var(--text-muted);
}

.row-badge {
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    background: rgba(6, 182, 212, 0.15);
    color: var(--neon-cyan);
    font-size: 0.65rem;
    font-weight: 700;
}

.row-badge.red {
    background: rgba(239, 68, 68, 0.2);
    color: var(--neon-red);
}

.row-msg {
    color: var(--text-secondary);
}

.clear-log-btn {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.72rem;
    cursor: pointer;
}

.clear-log-btn:hover {
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
}

.app-footer {
    text-align: center;
    padding: 1.5rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-subtle);
}

@media (max-width: 950px) {
    .main-observatory-grid { grid-template-columns: 1fr; }
    .header-right .hardware-pill { display: none; }
}
