/* ═══════════════════════════════════════════════════════════════════════
   VoiceGuard Live Monitor - Dashboard Theme
   Enterprise-grade dark theme with alert animations
   ═══════════════════════════════════════════════════════════════════════ */

/* ─── Design Tokens ─────────────────────────────────────────────────── */
:root {
    --bg:           #0a0a12;
    --surface:      #12131f;
    --surface-2:    #1a1b2e;
    --surface-3:    #222338;
    --border:       #2a2b3d;
    --border-focus: #4a9eff40;
    --text:         #e1e2e8;
    --text-muted:   #8889a0;
    --text-dim:     #55566a;

    --accent:       #4a9eff;
    --green:        #22c55e;
    --red:          #ef4444;
    --amber:        #f59e0b;
    --orange:       #f97316;
    --darkred:      #991b1b;

    --green-bg:     rgba(34, 197, 94, 0.12);
    --red-bg:       rgba(239, 68, 68, 0.12);
    --amber-bg:     rgba(245, 158, 11, 0.12);
    --orange-bg:    rgba(249, 115, 22, 0.12);
    --darkred-bg:   rgba(153, 27, 27, 0.15);
    --accent-bg:    rgba(74, 158, 255, 0.08);

    --radius:       8px;
    --radius-sm:    4px;
    --radius-lg:    12px;

    --font:         'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --mono:         'SF Mono', 'JetBrains Mono', 'Fira Code', monospace;

    --shadow:       0 2px 8px rgba(0,0,0,0.3);
    --shadow-lg:    0 8px 32px rgba(0,0,0,0.5);
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
}

.hidden { display: none !important; }
.mono { font-family: var(--mono); }

/* ─── App Layout ────────────────────────────────────────────────────── */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.content {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 0;
}

/* ─── Header ────────────────────────────────────────────────────────── */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 52px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.header-left { display: flex; align-items: center; gap: 12px; }
.header-center { display: flex; align-items: center; }
.header-right { display: flex; align-items: center; gap: 12px; }

.logo { display: flex; align-items: center; gap: 8px; }
.logo-icon { font-size: 22px; color: var(--accent); }
.logo-text {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text);
}
.logo-badge {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    padding: 2px 6px;
    border-radius: 3px;
    background: var(--accent);
    color: #fff;
}

.header-status {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1.5px;
    padding: 4px 16px;
    border-radius: 20px;
    border: 1px solid;
}
.header-status.idle { color: var(--text-muted); border-color: var(--border); }
.header-status.active { color: var(--green); border-color: var(--green); background: var(--green-bg); }
.header-status.alarm { color: var(--red); border-color: var(--red); background: var(--red-bg); animation: pulse-border 1s infinite; }
.header-status.vishing { color: var(--orange); border-color: var(--orange); background: var(--orange-bg); animation: pulse-border-orange 1s infinite; }
.header-status.deepfake-vishing { color: var(--darkred); border-color: var(--darkred); background: var(--darkred-bg); animation: pulse-border-darkred 1s infinite; }

.recording-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--red);
    animation: blink 1s infinite;
}

.header-time {
    font-family: var(--mono);
    font-size: 14px;
    color: var(--text-muted);
}

/* ─── Sidebar ───────────────────────────────────────────────────────── */
.sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
}

/* ─── Panels ────────────────────────────────────────────────────────── */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.sidebar .panel {
    border: none;
    padding: 0;
    background: transparent;
}

.panel-title {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.panel-compact { padding: 10px 0 0 0; }

/* ─── Form Elements ─────────────────────────────────────────────────── */
.field {
    margin-bottom: 12px;
}
.field label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.field-hint {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 4px;
}

.input, .select {
    width: 100%;
    padding: 8px 10px;
    font-size: 13px;
    font-family: var(--font);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}
.input:focus, .select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--border-focus);
}
.select { cursor: pointer; }
.select option { background: var(--surface-2); }

.radio-group { display: flex; flex-direction: column; gap: 6px; }
.radio {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text);
}
.radio input { accent-color: var(--accent); }

.divider {
    height: 1px;
    background: var(--border);
    margin: 12px 0;
}

.status-badge {
    display: inline-block;
    font-size: 13px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
}
.status-badge.idle { color: var(--text-muted); background: var(--surface-2); }
.status-badge.calling { color: var(--amber); background: var(--amber-bg); }
.status-badge.active { color: var(--green); background: var(--green-bg); }
.status-badge.analyzing { color: var(--accent); background: var(--accent-bg); }
.status-badge.ended { color: var(--text-muted); background: var(--surface-2); }

/* ─── Buttons ───────────────────────────────────────────────────────── */
.button-group { display: flex; flex-direction: column; gap: 8px; }

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    letter-spacing: 0.5px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; filter: none; transform: none; }

.btn-icon { font-size: 16px; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-large { padding: 14px 20px; font-size: 15px; }

/* ─── System Status ─────────────────────────────────────────────────── */
.system-status {
    display: flex;
    justify-content: space-around;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}
.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
}
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-dim);
}
.status-dot.ok { background: var(--green); }
.status-dot.error { background: var(--red); }
.status-dot.loading { background: var(--amber); animation: blink 1.5s infinite; }

/* ─── Main Panel ────────────────────────────────────────────────────── */
.main-panel {
    flex: 1;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
}

/* ─── Verdict Banner ────────────────────────────────────────────────── */
.verdict-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    border-radius: var(--radius-lg);
    border: 2px solid;
    transition: all 0.3s;
}
.verdict-banner.idle {
    border-color: var(--border);
    background: var(--surface);
}
.verdict-banner.authentic {
    border-color: var(--green);
    background: var(--green-bg);
}
.verdict-banner.alarm {
    border-color: var(--red);
    background: var(--red-bg);
    animation: pulse-border 1.5s infinite;
}
.verdict-banner.suspicious {
    border-color: var(--amber);
    background: var(--amber-bg);
}
.verdict-banner.vishing {
    border-color: var(--orange);
    background: var(--orange-bg);
    animation: pulse-border-orange 1.5s infinite;
}
.verdict-banner.deepfake-vishing {
    border-color: var(--darkred);
    background: var(--darkred-bg);
    animation: pulse-border-darkred 1.2s infinite;
}

.verdict-icon { font-size: 36px; }
.verdict-title { font-size: 22px; font-weight: 700; }
.verdict-confidence { font-size: 14px; color: var(--text-muted); margin-top: 2px; }

/* ─── Deepfake Score Meter ──────────────────────────────────────────── */
.meter-container { padding: 8px 0; }
.meter-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-dim);
    margin-bottom: 6px;
}
.meter-track {
    position: relative;
    height: 20px;
    background: var(--surface-2);
    border-radius: 10px;
    overflow: visible;
}
.meter-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.5s ease, background 0.5s;
    background: linear-gradient(90deg, var(--green), var(--amber), var(--red));
    background-size: 300% 100%;
}
.meter-marker {
    position: absolute;
    top: -4px;
    width: 4px;
    height: 28px;
    background: #fff;
    border-radius: 2px;
    transform: translateX(-50%);
    transition: left 0.5s ease;
    box-shadow: 0 0 8px rgba(255,255,255,0.4);
}
.meter-value {
    font-family: var(--mono);
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    margin-top: 8px;
}

/* ─── Waveform ──────────────────────────────────────────────────────── */
.waveform-canvas {
    width: 100%;
    height: 80px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
}

/* ─── Transcript ────────────────────────────────────────────────────── */
.transcript-box {
    min-height: 60px;
    max-height: 100px;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    padding: 8px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
}
.transcript-placeholder {
    color: var(--text-dim);
    font-style: italic;
}

.keywords-section {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.keywords-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--red);
    letter-spacing: 1px;
}
.keywords-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.keyword-tag {
    font-size: 12px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid rgba(239,68,68,0.3);
}

/* ─── Detection Timeline ────────────────────────────────────────────── */
.timeline {
    display: flex;
    gap: 4px;
    align-items: flex-end;
    min-height: 60px;
    overflow-x: auto;
    padding: 4px 0;
}
.timeline-placeholder {
    color: var(--text-dim);
    font-size: 13px;
    font-style: italic;
    align-self: center;
    width: 100%;
    text-align: center;
}
.timeline-chunk {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 36px;
}
.timeline-bar {
    width: 28px;
    border-radius: 3px 3px 0 0;
    transition: height 0.3s, background 0.3s;
}
.timeline-label {
    font-size: 9px;
    font-family: var(--mono);
    color: var(--text-dim);
}

/* ─── 4-Stream Grid ─────────────────────────────────────────────────── */
.streams-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
}
.stream-item {
    display: flex;
    align-items: center;
    gap: 8px;
}
.stream-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    min-width: 80px;
}
.stream-bar-track {
    flex: 1;
    height: 8px;
    background: var(--surface-2);
    border-radius: 4px;
    overflow: hidden;
}
.stream-bar {
    height: 100%;
    border-radius: 4px;
    background: var(--accent);
    transition: width 0.5s ease;
}
.stream-value {
    font-size: 12px;
    font-family: var(--mono);
    color: var(--text-muted);
    min-width: 36px;
    text-align: right;
}
.ensemble-status {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-family: var(--mono);
}
.ensemble-status.active {
    color: #22c55e;
}
.ensemble-status.single {
    color: #f59e0b;
}
.weight-label {
    font-size: 10px;
    color: #ef4444;
    font-weight: 700;
}

/* ─── Footer ────────────────────────────────────────────────────────── */
.footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 32px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-dim);
}

/* ─── Alert Overlay ─────────────────────────────────────────────────── */
.alert-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: overlay-in 0.3s ease;
}
.alert-overlay.alarm-alert {
    background: rgba(239, 68, 68, 0.15);
    backdrop-filter: blur(8px);
}
.alert-overlay.auth-alert {
    background: rgba(34, 197, 94, 0.15);
    backdrop-filter: blur(8px);
}
.alert-overlay.vishing-alert {
    background: rgba(249, 115, 22, 0.18);
    backdrop-filter: blur(8px);
}
.alert-overlay.deepfake-vishing-alert {
    background: rgba(153, 27, 27, 0.22);
    backdrop-filter: blur(8px);
}

.alert-content {
    text-align: center;
    animation: alert-bounce 0.4s ease;
}
.alert-icon { font-size: 72px; margin-bottom: 16px; }
.alert-title { font-size: 42px; font-weight: 800; letter-spacing: 3px; }
.alert-confidence { font-size: 24px; margin-top: 8px; color: var(--text-muted); }
.alert-subtitle { font-size: 16px; margin-top: 4px; color: var(--text-dim); }

.alert-overlay.alarm-alert .alert-title { color: var(--red); }
.alert-overlay.auth-alert .alert-title { color: var(--green); }
.alert-overlay.vishing-alert .alert-title { color: var(--orange); }
.alert-overlay.deepfake-vishing-alert .alert-title { color: var(--darkred); }

/* ─── Animations ────────────────────────────────────────────────────── */
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@keyframes pulse-border {
    0%, 100% { border-color: var(--red); }
    50% { border-color: rgba(239, 68, 68, 0.4); }
}

@keyframes pulse-border-orange {
    0%, 100% { border-color: var(--orange); }
    50% { border-color: rgba(249, 115, 22, 0.4); }
}

@keyframes pulse-border-darkred {
    0%, 100% { border-color: var(--darkred); }
    50% { border-color: rgba(153, 27, 27, 0.4); }
}

@keyframes overlay-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes alert-bounce {
    0% { transform: scale(0.8); opacity: 0; }
    60% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

/* ─── Scrollbar ─────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
