/* ==========================================
   DRIVERWATCH ENTERPRISE - TECHNICAL UI
   ========================================== */

:root {
    /* Enterprise Monochrome Palette */
    --sys-bg: #09090b;
    --sys-panel: #121214;
    --sys-border: #27272a;
    --sys-border-high: #3f3f46;

    /* Technical Accents */
    --acc-primary: #f8fafc;
    --acc-muted: #94a3b8;
    --acc-dark: #334155;

    /* Status Colors (Muted, professional) */
    --stat-standby: #eab308;
    --stat-active: #22c55e;
    --stat-warn: #fb923c;
    --stat-danger: #ef4444;
    --stat-info: #3b82f6;

    /* Typographic Grid */
    --font-mono: 'JetBrains Mono', monospace;
    --font-sans: 'Inter', sans-serif;

    --radius: 4px;
    --transition: all 0.2s ease;
}

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

body {
    background-color: var(--sys-bg);
    color: var(--acc-primary);
    font-family: var(--font-sans);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================
   NAVIGATION
   ========================================== */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--sys-border);
    margin-bottom: 1.5rem;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-svg {
    color: var(--acc-primary);
}

.logo h1 {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.1em;
}

.version {
    font-size: 0.7rem;
    color: var(--acc-muted);
    font-weight: 400;
    margin-left: 0.5rem;
    padding: 0.1rem 0.4rem;
    background: var(--sys-border);
    border-radius: 2px;
}

.system-tag {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--acc-muted);
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--sys-border-high);
    border-radius: var(--radius);
}

.status-indicator {
    color: var(--stat-standby);
    font-weight: 700;
}

.status-indicator.ACTIVE {
    color: var(--stat-active);
}

.status-indicator.WARNING {
    color: var(--stat-warn);
}

.status-indicator.CRITICAL {
    color: var(--stat-danger);
}

.nav-right .clock {
    font-family: var(--font-mono);
    font-size: 1rem;
    color: var(--acc-muted);
    letter-spacing: 0.05em;
}

/* ==========================================
   DASHBOARD GRID
   ========================================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 1.5rem;
    flex-grow: 1;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================
   MODULE COMMONS
   ========================================== */
.panel-primary,
.data-module {
    background: var(--sys-panel);
    border: 1px solid var(--sys-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.panel-header,
.module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--sys-border);
}

h2,
h3 {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--acc-muted);
}

/* ==========================================
   PRIMARY: OPTICAL TELEMETRY
   ========================================== */
.panel-badge {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    background: var(--sys-border);
    border-radius: 2px;
    color: var(--acc-muted);
}

.panel-badge.ONLINE {
    background: rgba(34, 197, 94, 0.1);
    color: var(--stat-active);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.camera-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    border: 1px solid var(--sys-border-high);
    border-radius: 2px;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

/* Technical Camera Overlay */
.crosshair {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    z-index: 10;
}

.top-left {
    top: 10px;
    left: 10px;
    border-right: none;
    border-bottom: none;
}

.top-right {
    top: 10px;
    right: 10px;
    border-left: none;
    border-bottom: none;
}

.bottom-left {
    bottom: 10px;
    left: 10px;
    border-right: none;
    border-top: none;
}

.bottom-right {
    bottom: 10px;
    right: 10px;
    border-left: none;
    border-top: none;
}

#webcam-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#webcam-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    filter: contrast(1.1) saturate(0.9);
    /* More technical look */
}

/* States */
.camera-wrapper.awake {
    border-color: var(--stat-active);
}

.camera-wrapper.sleepy {
    border-color: var(--stat-danger);
    box-shadow: inset 0 0 0 1px var(--stat-danger);
}

.camera-wrapper.neutral {
    border-color: var(--stat-warn);
}

.standby-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--acc-dark);
}

.standby-text {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    letter-spacing: 0.1em;
}

.camera-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 10;
}

.recording-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--stat-danger);
    letter-spacing: 0.05em;
}

.rec-pulse {
    width: 8px;
    height: 8px;
    background: var(--stat-danger);
    border-radius: 50%;
    opacity: 0;
}

.rec-pulse.active {
    animation: pulse-red 1s infinite alternate;
}

@keyframes pulse-red {
    from {
        opacity: 0.3;
        transform: scale(1);
    }

    to {
        opacity: 1;
        transform: scale(1.2);
        box-shadow: 0 0 8px var(--stat-danger);
    }
}

.data-stream {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--acc-muted);
}

.live-pulse {
    width: 6px;
    height: 6px;
    background: var(--acc-dark);
    border-radius: 50%;
}

.live-pulse.active {
    background: var(--stat-danger);
    animation: quick-pulse 1s infinite alternate;
}

@keyframes quick-pulse {
    0% {
        opacity: 0.4;
    }

    100% {
        opacity: 1;
    }
}

/* ==========================================
   BUTTONS
   ========================================== */
.control-group {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
}

button {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    padding: 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    text-transform: uppercase;
}

.btn-primary {
    background: var(--acc-primary);
    color: var(--sys-bg);
    border: none;
}

.btn-primary:hover:not(:disabled) {
    background: #e2e8f0;
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--sys-panel);
    color: var(--acc-muted);
    border: 1px solid var(--sys-border-high);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--sys-border);
    color: var(--acc-primary);
}

button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ==========================================
   DATA MODULES (Right Column)
   ========================================== */
.panel-secondary {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--sys-border-high);
}

.status-dot.awake {
    background: var(--stat-active);
    box-shadow: 0 0 10px var(--stat-active);
}

.status-dot.sleepy {
    background: var(--stat-danger);
    box-shadow: 0 0 10px var(--stat-danger);
}

.status-dot.neutral {
    background: var(--stat-warn);
}

.muted-tag {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--stat-info);
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 0.1rem 0.4rem;
    border-radius: 2px;
}

/* ASSESSMENT CONTAINER */
.assessment-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1rem 0;
    border-left: 3px solid var(--sys-border-high);
    padding-left: 1.5rem;
    transition: var(--transition);
}

.assessment-container.awake {
    border-color: var(--stat-active);
}

.assessment-container.sleepy {
    border-color: var(--stat-danger);
}

.assessment-container.neutral {
    border-color: var(--stat-warn);
}

.assessment-value {
    font-family: var(--font-mono);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--acc-primary);
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}

.assessment-value.awake {
    color: var(--stat-active);
}

.assessment-value.sleepy {
    color: var(--stat-danger);
}

.assessment-value.neutral {
    color: var(--stat-warn);
}

.assessment-sub {
    font-size: 0.85rem;
    color: var(--acc-muted);
}

/* NEURAL NET BARS */
.nn-bars {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.empty-data {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--acc-dark);
    text-align: center;
    padding: 1rem 0;
}

.nn-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nn-label {
    width: 60px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--acc-muted);
}

.nn-track {
    flex-grow: 1;
    height: 4px;
    background: var(--sys-border);
    border-radius: 2px;
    overflow: hidden;
}

.nn-fill {
    height: 100%;
    width: 0%;
    background: var(--acc-muted);
    transition: width 0.1s linear;
}

.nn-fill.awake {
    background: var(--stat-active);
}

.nn-fill.sleepy {
    background: var(--stat-danger);
}

.nn-fill.neutral {
    background: var(--stat-warn);
}

.nn-val {
    width: 45px;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--acc-primary);
}

/* METRICS GRID */
.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.metric-box {
    background: var(--sys-bg);
    border: 1px solid var(--sys-border);
    padding: 1rem;
    border-radius: 2px;
}

.metric-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--acc-muted);
    margin-bottom: 0.5rem;
}

.metric-val {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--acc-primary);
}

/* EVENT TERMINAL */
.log-module {
    flex-grow: 1;
}

.export-btn {
    padding: 0.2rem 0.6rem;
    font-size: 0.65rem;
    background: transparent;
    border: 1px solid var(--sys-border-high);
    color: var(--acc-muted);
}

.export-btn:hover {
    color: var(--acc-primary);
    border-color: var(--acc-primary);
}

.terminal-container {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--acc-muted);
    background: #000;
    border: 1px solid var(--sys-border);
    padding: 1rem;
    border-radius: 2px;
    flex-grow: 1;
    overflow-y: auto;
    max-height: 180px;
}

/* ==========================================
   MEDIA VAULT
   ========================================== */
.vault-module {
    flex-grow: 1;
}

.vault-container {
    background: #000;
    border: 1px solid var(--sys-border);
    padding: 0.5rem;
    border-radius: 2px;
    flex-grow: 1;
    overflow-y: auto;
    max-height: 250px;
}

.vault-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid var(--sys-border);
    font-family: var(--font-mono);
}

.vault-item:last-child {
    border-bottom: none;
}

.vault-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.vault-type {
    font-size: 0.7rem;
    font-weight: 800;
}

.vault-time {
    font-size: 0.65rem;
    color: var(--acc-muted);
}

.vault-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-play,
.btn-del {
    padding: 0.3rem 0.6rem;
    font-size: 0.6rem;
    border-radius: 2px;
    border: 1px solid var(--sys-border-high);
}

.btn-play {
    background: var(--sys-border);
    color: var(--acc-primary);
}

.btn-play:hover {
    background: var(--stat-active);
    color: #000;
    border-color: var(--stat-active);
}

.btn-del {
    background: transparent;
    color: var(--acc-muted);
}

.btn-del:hover {
    color: var(--stat-danger);
    border-color: var(--stat-danger);
}

/* VAULT PLAYER */
.vault-player-panel {
    border-color: var(--acc-muted);
    max-width: 800px;
}

.close-vault {
    margin-left: auto;
    background: transparent;
    color: var(--acc-muted);
    border: 1px solid var(--sys-border);
    padding: 0.2rem 0.6rem;
    border-radius: 2px;
}

.close-vault:hover {
    color: var(--acc-primary);
    border-color: var(--acc-primary);
}

.terminal-line {
    margin-bottom: 0.4rem;
    line-height: 1.3;
}

.terminal-line .time {
    color: var(--sys-border-high);
    margin-right: 0.75rem;
}

.t-info {
    color: var(--stat-info);
}

.t-warn {
    color: var(--stat-warn);
}

.t-crit {
    color: var(--stat-danger);
}

.t-succ {
    color: var(--stat-active);
}

/* Custom Scrollbar for Terminal */
.terminal-container::-webkit-scrollbar {
    width: 4px;
}

.terminal-container::-webkit-scrollbar-track {
    background: #000;
}

.terminal-container::-webkit-scrollbar-thumb {
    background: var(--sys-border-high);
}

/* ==========================================
   ALARM & DISPATCH MODALS
   ========================================== */
.overlay-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.overlay-modal.hidden {
    display: none;
}

.modal-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
}

.modal-bg.danger-bg {
    background: rgba(20, 0, 0, 0.95);
}

.modal-bg.dispatch-bg {
    background: rgba(0, 5, 20, 0.95);
}

.modal-content {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 600px;
    background: var(--sys-panel);
    border: 1px solid var(--sys-border-high);
    padding: 2.5rem;
}

.danger-panel {
    border-color: var(--stat-danger);
    box-shadow: 0 0 50px rgba(239, 68, 68, 0.1);
}

.dispatch-panel {
    border-color: var(--stat-info);
    box-shadow: 0 0 50px rgba(59, 130, 246, 0.1);
}

.warning-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--stat-danger);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    margin-bottom: 2rem;
    border-bottom: 1px solid rgba(239, 68, 68, 0.2);
    padding-bottom: 1rem;
}

.warning-header.dispatch-header {
    color: var(--stat-info);
    border-bottom-color: rgba(59, 130, 246, 0.2);
}

.alert-massive {
    font-size: 2.5rem;
    color: var(--acc-primary);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 2rem;
}

.readout-box {
    background: #000;
    border: 1px solid var(--sys-border);
    padding: 1.5rem;
    margin-bottom: 2.5rem;
}

.readout-row {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.readout-row:last-child {
    margin-bottom: 0;
}

.readout-lbl {
    color: var(--acc-muted);
}

.readout-val {
    color: var(--acc-primary);
    font-weight: 600;
}

.countdown-text {
    color: var(--stat-warn);
}

.btn-override {
    width: 100%;
    background: var(--stat-danger);
    color: #fff;
    border: none;
    font-size: 0.9rem;
    padding: 1.25rem;
}

.btn-override:hover {
    background: #b91c1c;
}

/* Dispatch Box */
.call-interface {
    background: #000;
    border: 1px solid var(--sys-border);
    padding: 2rem;
    margin-bottom: 2.5rem;
    font-family: var(--font-mono);
}

.target-node {
    color: var(--acc-primary);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.call-status {
    color: var(--stat-info);
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

.data-transfer {
    margin-bottom: 1rem;
}

.transfer-bar {
    width: 100%;
    height: 2px;
    background: var(--sys-border);
    position: relative;
}

.transfer-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: var(--stat-info);
    transition: width 0.5s ease;
}

.call-metrics {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--sys-border-high);
}

.btn-abort {
    width: 100%;
    background: transparent;
    color: var(--acc-primary);
    border: 1px solid var(--sys-border-high);
}

.btn-abort:hover {
    background: var(--sys-border);
}