/* ═══════════════════════════════════════
   ProctorAI – Premium Dark UI v2
   ═══════════════════════════════════════ */

:root {
    --bg-dark: #05080f;
    --bg-surface: #0a1020;
    --bg-card: rgba(10, 16, 32, 0.88);
    --bg-card-hover: rgba(15, 23, 45, 0.95);
    --text-primary: #e8ecf4;
    --text-secondary: #4a5578;
    --text-muted: #2e3654;
    --accent-blue: #3b82f6;
    --accent-cyan: #06d6dd;
    --accent-red: #f43f5e;
    --accent-green: #10b981;
    --accent-yellow: #f59e0b;
    --accent-purple: #8b5cf6;
    --accent-pink: #ec4899;
    --glass-border: rgba(255, 255, 255, 0.06);
    --glass-border-hover: rgba(255, 255, 255, 0.12);
    --glass-bg: rgba(10, 16, 32, 0.7);
    --glow-blue: 0 0 30px rgba(59, 130, 246, 0.15);
    --glow-cyan: 0 0 30px rgba(6, 214, 221, 0.15);
    --glow-red: 0 0 30px rgba(244, 63, 94, 0.2);
    --radius: 16px;
    --radius-sm: 10px;
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ── Subtle animated background grid ── */
.bg-grid {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(59, 130, 246, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(59, 130, 246, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
}

.bg-grid::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 15% 50%, rgba(59, 130, 246, 0.07) 0%, transparent 55%),
        radial-gradient(ellipse at 85% 20%, rgba(139, 92, 246, 0.06) 0%, transparent 55%),
        radial-gradient(ellipse at 50% 90%, rgba(6, 214, 221, 0.04) 0%, transparent 55%);
}

.app-container {
    position: relative;
    z-index: 1;
    padding: 0.75rem 1rem;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* ═══════════ Navbar ═══════════ */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.55rem 1.1rem;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(1.4);
    border-radius: var(--radius);
    border: 1px solid var(--glass-border);
    box-shadow: 0 1px 0 rgba(255,255,255,0.03) inset, 0 4px 20px rgba(0,0,0,0.3);
    position: relative;
}

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

.logo-icon-wrap {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    border-radius: 10px;
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
    position: relative;
}
.logo-icon-wrap::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    z-index: -1;
    filter: blur(8px);
    opacity: 0.4;
}
.logo-icon-wrap .material-icons-round { font-size: 20px; }

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo h1 {
    font-size: 1.1rem;
    font-weight: 900;
    background: linear-gradient(135deg, #60a5fa, #c084fc);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.logo-subtitle {
    font-size: 0.6rem;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* Recording indicator center */
.nav-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.recording-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.8rem;
    background: rgba(244, 63, 94, 0.08);
    border: 1px solid rgba(244, 63, 94, 0.2);
    border-radius: 999px;
    font-family: var(--font-mono);
}

.rec-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-red);
    box-shadow: 0 0 8px var(--accent-red);
    animation: rec-blink 1s ease-in-out infinite;
}

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

.rec-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--accent-red);
    letter-spacing: 0.1em;
}

.rec-timer {
    font-size: 0.72rem;
    color: var(--text-primary);
    font-weight: 500;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

/* Threat dots */
.threat-level { display: flex; align-items: center; gap: 0.5rem; }

.threat-label {
    font-size: 0.6rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
}

.threat-dots { display: flex; gap: 4px; }

.threat-dot {
    width: 8px;
    height: 18px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.06);
    transition: background 0.4s, box-shadow 0.4s;
}

.threat-dot.low { background: var(--accent-green); box-shadow: 0 0 8px rgba(16, 185, 129, 0.5); }
.threat-dot.medium { background: var(--accent-yellow); box-shadow: 0 0 8px rgba(245, 158, 11, 0.5); }
.threat-dot.high { background: var(--accent-red); box-shadow: 0 0 8px rgba(244, 63, 94, 0.5); }

/* Status pill */
.status-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.85rem;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 999px;
    border: 1px solid var(--glass-border);
    font-size: 0.75rem;
    font-weight: 600;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-yellow);
    box-shadow: 0 0 10px var(--accent-yellow);
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

.status-dot.active {
    background: var(--accent-green);
    box-shadow: 0 0 10px var(--accent-green);
}
.status-dot.error {
    background: var(--accent-red);
    box-shadow: 0 0 10px var(--accent-red);
}

/* ═══════════ Dashboard Layout ═══════════ */
.dashboard {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 0.75rem;
    min-height: 0;
}

/* ═══════════ Video Section ═══════════ */
.video-section {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-height: 0;
}

.video-container {
    position: relative;
    flex: 1;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid rgba(6, 214, 221, 0.15);
    box-shadow: 0 4px 40px rgba(0, 0, 0, 0.5), 0 0 60px rgba(6, 214, 221, 0.05);
}

/* Glow effect behind video */
.video-glow {
    position: absolute;
    inset: -2px;
    border-radius: var(--radius);
    background: conic-gradient(
        from 180deg,
        rgba(6, 214, 221, 0.15),
        rgba(59, 130, 246, 0.15),
        rgba(139, 92, 246, 0.15),
        rgba(6, 214, 221, 0.15)
    );
    filter: blur(4px);
    z-index: -1;
    animation: glow-rotate 8s linear infinite;
}

@keyframes glow-rotate {
    to { filter: blur(4px) hue-rotate(360deg); }
}

#webcam {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

#output-canvas {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Grid overlay on video */
.video-grid-overlay {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(6, 214, 221, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(6, 214, 221, 0.03) 1px, transparent 1px);
    background-size: 80px 80px;
    pointer-events: none;
    z-index: 3;
}

/* Corner brackets (enhanced) */
.corner-bracket {
    position: absolute;
    width: 40px;
    height: 40px;
    border-color: var(--accent-cyan);
    border-style: solid;
    border-width: 0;
    z-index: 5;
    opacity: 0.7;
    filter: drop-shadow(0 0 4px rgba(6, 214, 221, 0.4));
}
.corner-bracket.tl { top: 14px; left: 14px; border-top-width: 2.5px; border-left-width: 2.5px; border-radius: 6px 0 0 0; }
.corner-bracket.tr { top: 14px; right: 14px; border-top-width: 2.5px; border-right-width: 2.5px; border-radius: 0 6px 0 0; }
.corner-bracket.bl { bottom: 14px; left: 14px; border-bottom-width: 2.5px; border-left-width: 2.5px; border-radius: 0 0 0 6px; }
.corner-bracket.br { bottom: 14px; right: 14px; border-bottom-width: 2.5px; border-right-width: 2.5px; border-radius: 0 0 6px 0; }

/* Scan line */
.scan-line {
    position: absolute;
    width: 100%;
    height: 1.5px;
    background: linear-gradient(to right, transparent 5%, var(--accent-cyan) 30%, var(--accent-cyan) 70%, transparent 95%);
    top: 0;
    animation: scan 5s ease-in-out infinite;
    opacity: 0.35;
    pointer-events: none;
    z-index: 4;
    box-shadow: 0 0 15px rgba(6, 214, 221, 0.3);
}

@keyframes scan {
    0% { top: 0%; opacity: 0; }
    5% { opacity: 0.35; }
    95% { opacity: 0.35; }
    100% { top: 100%; opacity: 0; }
}

/* Live badge */
.live-badge {
    position: absolute;
    top: 14px;
    right: 60px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--accent-green);
    border: 1px solid rgba(16, 185, 129, 0.2);
    z-index: 10;
}

.live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-green);
    box-shadow: 0 0 6px var(--accent-green);
    animation: rec-blink 1.5s infinite;
}

/* Debug overlay */
#debug-overlay {
    position: absolute;
    bottom: 10px;
    left: 10px;
    color: rgba(6, 214, 221, 0.7);
    font: 500 9px var(--font-mono);
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    padding: 5px 9px;
    border-radius: 6px;
    border: 1px solid rgba(6, 214, 221, 0.1);
    z-index: 100;
    pointer-events: none;
    white-space: pre-line;
    max-width: 50%;
    line-height: 1.4;
}

/* ── Stats bar below video ── */
.stats-bar {
    display: flex;
    gap: 0.5rem;
}

.stat-item {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.7rem;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    transition: border-color 0.3s;
}
.stat-item:hover { border-color: var(--glass-border-hover); }

.stat-icon {
    font-size: 16px;
    color: var(--text-secondary);
}

.stat-text {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 0.85rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
    line-height: 1.1;
}

.stat-label {
    font-size: 0.55rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

/* ═══════════ Sidebar ═══════════ */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    min-height: 0;
}

.panel {
    background: var(--bg-card);
    backdrop-filter: blur(16px) saturate(1.3);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 0 rgba(255,255,255,0.02) inset;
}

.panel h2 {
    font-size: 0.62rem;
    font-weight: 700;
    margin-bottom: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.panel-icon {
    font-size: 15px;
    color: var(--accent-cyan);
}

.panel-badge {
    margin-left: auto;
    background: rgba(244, 63, 94, 0.1);
    color: var(--accent-red);
    font-size: 0.6rem;
    font-weight: 700;
    font-family: var(--font-mono);
    padding: 1px 7px;
    border-radius: 999px;
    border: 1px solid rgba(244, 63, 94, 0.2);
    min-width: 22px;
    text-align: center;
}

/* ══ Monitor Items ══ */
.monitor-panel { flex: 0 0 auto; }

.monitor-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.55rem;
    padding-left: 0.75rem;
    margin-bottom: 0.25rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid transparent;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.monitor-item:last-child { margin-bottom: 0; }

/* Left-edge color indicator */
.monitor-indicator {
    position: absolute;
    left: 0;
    top: 15%;
    bottom: 15%;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: transparent;
    transition: background 0.3s, box-shadow 0.3s;
}

.monitor-item.active-danger .monitor-indicator {
    background: var(--accent-red);
    box-shadow: 0 0 8px var(--accent-red);
}

.monitor-item.active-warning .monitor-indicator {
    background: var(--accent-yellow);
    box-shadow: 0 0 8px var(--accent-yellow);
}

.monitor-item.active-danger {
    background: rgba(244, 63, 94, 0.06);
    border-color: rgba(244, 63, 94, 0.12);
}

.monitor-item.active-warning {
    background: rgba(245, 158, 11, 0.06);
    border-color: rgba(245, 158, 11, 0.12);
}

.monitor-icon-wrap {
    width: 30px;
    height: 30px;
    min-width: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.monitor-icon-wrap .material-icons-round { font-size: 16px; }

.danger-icon {
    background: rgba(244, 63, 94, 0.1);
    color: var(--accent-red);
}

.warning-icon {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent-yellow);
}

.info-icon {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-blue);
}

.monitor-content {
    flex: 1;
    min-width: 0;
}

.monitor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.3rem;
}

.monitor-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ── Status badges ── */
.status-badge {
    padding: 0.12rem 0.5rem;
    border-radius: 5px;
    font-size: 0.58rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-family: var(--font-mono);
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-green);
    border: 1px solid rgba(16, 185, 129, 0.2);
    transition: all 0.3s;
}

.status-badge.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent-yellow);
    border-color: rgba(245, 158, 11, 0.25);
    animation: badge-pulse 1.5s infinite;
}

.status-badge.danger {
    background: rgba(244, 63, 94, 0.12);
    color: var(--accent-red);
    border-color: rgba(244, 63, 94, 0.25);
    animation: badge-pulse 1s infinite;
}

@keyframes badge-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.65; }
}

/* ── Progress bars ── */
.monitor-bar {
    height: 3px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 2px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: var(--accent-blue);
    border-radius: 2px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.4s ease;
    position: relative;
}

.bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 20px;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3));
    border-radius: 2px;
}

/* ═══════════ Activity Log ═══════════ */
.log-panel {
    flex: 1;
    overflow: hidden;
}

#activity-log {
    list-style: none;
    overflow-y: auto;
    height: 100%;
    padding-right: 0.35rem;
}

#activity-log::-webkit-scrollbar { width: 3px; }
#activity-log::-webkit-scrollbar-track { background: transparent; }
#activity-log::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 2px; }
#activity-log::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.12); }

.log-entry {
    display: flex;
    gap: 0.5rem;
    font-size: 0.72rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    animation: fadeSlideUp 0.3s ease-out;
}

@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(-3px); }
    to { opacity: 1; transform: translateY(0); }
}

.log-entry:last-child { border-bottom: none; }

.log-entry .time {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.62rem;
    min-width: 52px;
    font-weight: 500;
}

.log-entry.warning .msg { color: var(--accent-yellow); }
.log-entry.danger .msg { color: var(--accent-red); font-weight: 600; }
.log-entry.info .msg { color: var(--text-secondary); }

/* ═══════════ Alert Toasts ═══════════ */
.alert-container {
    position: absolute;
    top: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 85%;
    max-width: 380px;
    pointer-events: none;
    z-index: 50;
}

.alert-toast {
    background: linear-gradient(135deg, rgba(244, 63, 94, 0.92), rgba(185, 28, 28, 0.92));
    backdrop-filter: blur(12px);
    color: white;
    padding: 0.7rem 0.9rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 0.65rem;
    box-shadow: 0 8px 24px rgba(244, 63, 94, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.12);
    animation: slideDown 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transition: opacity 0.4s;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-16px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.alert-icon { font-size: 1.2rem; }

.alert-content p {
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: -0.01em;
}

.alert-content span {
    font-size: 0.7rem;
    opacity: 0.9;
}

/* ═══════════ Responsive ═══════════ */
@media (max-width: 1200px) {
    .dashboard { grid-template-columns: 1fr 300px; }
    .stats-bar { flex-wrap: wrap; }
    .stat-item { min-width: calc(50% - 0.25rem); }
}

@media (max-width: 900px) {
    .dashboard {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr auto;
    }
    .nav-center { display: none; }
}
