/* ====================== Brain WebRTC — Stylesheet ====================== */

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;600;900&family=Share+Tech+Mono&display=swap');

/* ====================== CSS Variables ====================== */
:root {
    --bg-void: #03040d;
    --bg-deep: #06091a;
    --bg-surface: #0c1030;
    --bg-panel: #0f1535;

    --neural-blue: #2d8cf0;
    --neural-cyan: #00e5ff;
    --neural-violet: #7b5ea7;
    --neural-pulse: #a78bfa;

    --synapse-active: #4ade80;
    --synapse-dead: #f87171;
    --synapse-idle: #60a5fa;

    --text-primary: #e2eaff;
    --text-secondary: #7a90c4;
    --text-dim: #3a4a7a;

    --glow-blue: 0 0 18px rgba(45, 140, 240, 0.55);
    --glow-cyan: 0 0 24px rgba(0, 229, 255, 0.45);
    --glow-green: 0 0 18px rgba(74, 222, 128, 0.5);
    --glow-red: 0 0 18px rgba(248, 113, 113, 0.5);
}

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

html {
    height: 100%;
}

body {
    font-family: 'Share Tech Mono', monospace;
    background: var(--bg-void);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* ====================== Neural Background Grid ====================== */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(45, 140, 240, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(45, 140, 240, 0.04) 1px, transparent 1px);
    background-size: 48px 48px;
    pointer-events: none;
    z-index: 0;
}

/* Radial brain-glow beneath everything */
body::after {
    content: '';
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 900px;
    height: 900px;
    background: radial-gradient(ellipse at center,
            rgba(45, 140, 240, 0.08) 0%,
            rgba(123, 94, 167, 0.05) 40%,
            transparent 70%);
    pointer-events: none;
    z-index: 0;
    animation: breathe 6s ease-in-out infinite;
}

@keyframes breathe {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.7;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 1;
    }
}

/* ====================== Layout Shell ====================== */
.shell {
    position: relative;
    z-index: 1;
    max-width: 820px;
    margin: 0 auto;
    padding: 40px 24px 0px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 36px;
}

/* ====================== Header ====================== */
.header {
    text-align: center;
    width: 100%;
    animation: fadeSlideDown 0.8s ease both;
}

@keyframes fadeSlideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.header h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(2.4rem, 7vw, 4rem);
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    background: linear-gradient(135deg, var(--neural-cyan) 0%, var(--neural-blue) 50%, var(--neural-pulse) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 20px rgba(0, 229, 255, 0.35));
    line-height: 1;
}

.header-sub {
    font-size: 12px;
    color: var(--text-dim);
    letter-spacing: 0.2em;
    margin-top: 10px;
}

/* ====================== Status Bar ====================== */
.status-bar {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 1000;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: fadeSlideInRight 0.6s ease both;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--synapse-idle);
    box-shadow: var(--glow-blue);
    flex-shrink: 0;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.4);
        opacity: 0.6;
    }
}

@keyframes fadeSlideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

#status {
    font-size: 13px;
    color: var(--text-secondary);
    letter-spacing: 0.06em;
    flex: 1;
    font-family: 'Share Tech Mono', monospace;
}

/* ====================== Video Section ====================== */
.video-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    animation: fadeSlideDown 0.8s 0.3s ease both;
}

.video-frame {
    position: relative;
    display: inline-block;
}

/* Corner brackets */
.video-frame::before,
.video-frame::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    z-index: 2;
}

.video-frame::before {
    top: -2px;
    left: -2px;
    border-top: 2px solid var(--neural-cyan);
    border-left: 2px solid var(--neural-cyan);
    box-shadow: -2px -2px 10px rgba(0, 229, 255, 0.4);
}

.video-frame::after {
    bottom: -2px;
    right: -2px;
    border-bottom: 2px solid var(--neural-cyan);
    border-right: 2px solid var(--neural-cyan);
    box-shadow: 2px 2px 10px rgba(0, 229, 255, 0.4);
}

/* Extra corners via spans inside .video-wrapper */
.video-frame .corner-tr,
.video-frame .corner-bl {
    position: absolute;
    width: 22px;
    height: 22px;
    z-index: 2;
    pointer-events: none;
}

.video-frame .corner-tr {
    top: -2px;
    right: -2px;
    border-top: 2px solid var(--neural-cyan);
    border-right: 2px solid var(--neural-cyan);
    box-shadow: 2px -2px 10px rgba(0, 229, 255, 0.4);
}

.video-frame .corner-bl {
    bottom: -2px;
    left: -2px;
    border-bottom: 2px solid var(--neural-cyan);
    border-left: 2px solid var(--neural-cyan);
    box-shadow: -2px 2px 10px rgba(0, 229, 255, 0.4);
}

/* Scan-line sweep */
.video-frame .scanline {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--neural-cyan), transparent);
    opacity: 0.5;
    z-index: 3;
    animation: scanline 4s linear infinite;
    pointer-events: none;
}

@keyframes scanline {
    0% {
        top: 0%;
        opacity: 0.5;
    }

    50% {
        opacity: 0.8;
    }

    100% {
        top: 100%;
        opacity: 0;
    }
}

video#localVideo {
    display: block;
    width: 420px;
    height: 315px;
    background: #000;
    border-radius: 4px;
    object-fit: cover;
    filter: brightness(0.95) contrast(1.05);
}

/* ====================== Canvas Overlay (AI feed) ====================== */
#video-buffer-canvas {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 108px;
    height: 108px;
    border: 1px solid var(--neural-blue);
    border-radius: 4px;
    image-rendering: pixelated;
    background: #000;
    box-shadow: var(--glow-blue), inset 0 0 12px rgba(45, 140, 240, 0.1);
    z-index: 4;
}

/* Mini-label on the canvas */
#video-buffer-canvas::before {
    content: 'AI FEED';
    font-size: 8px;
}

.canvas-label {
    position: absolute;
    bottom: 10px;
    right: 124px;
    font-size: 9px;
    letter-spacing: 0.2em;
    color: var(--neural-blue);
    font-family: 'Orbitron', sans-serif;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    opacity: 0.7;
    z-index: 4;
}

/* ====================== Controls Panel ====================== */
.controls-panel {
    border: 1px solid rgba(45, 140, 240, 0.18);
    border-radius: 8px;
    padding: 28px 36px;
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
    position: relative;
    overflow: hidden;
    animation: fadeSlideDown 0.8s 0.45s ease both;
}

.controls-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20%;
    right: 20%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--neural-cyan), transparent);
}

.panel-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 10px;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.btn-group {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
}

/* ====================== Buttons ====================== */
button {
    font-family: 'Orbitron', sans-serif;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    padding: 14px 28px;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    min-width: 160px;
    position: relative;
    overflow: hidden;
    transition:
        background 0.25s,
        box-shadow 0.25s,
        border-color 0.25s,
        transform 0.15s;
}

/* Shimmer sweep on hover */
button::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.07) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.45s ease;
}

button:hover::after {
    transform: translateX(100%);
}

button:active {
    transform: scale(0.97);
}

/* IDLE (default) */
button {
    background: var(--bg-surface);
    color: var(--synapse-idle);
    border-color: rgba(96, 165, 250, 0.35);
    box-shadow: 0 0 12px rgba(96, 165, 250, 0.1);
}

button:hover {
    background: rgba(45, 140, 240, 0.12);
    box-shadow: var(--glow-blue);
    border-color: var(--neural-blue);
}

/* ACTIVE (ON) */
button.active {
    background: rgba(74, 222, 128, 0.08);
    color: var(--synapse-active);
    border-color: rgba(74, 222, 128, 0.45);
    box-shadow: var(--glow-green);
}

button.active:hover {
    background: rgba(74, 222, 128, 0.15);
}

/* INACTIVE (OFF) */
button.inactive {
    background: rgba(248, 113, 113, 0.07);
    color: var(--synapse-dead);
    border-color: rgba(248, 113, 113, 0.35);
    box-shadow: var(--glow-red);
}

button.inactive:hover {
    background: rgba(248, 113, 113, 0.14);
}

/* ====================== Agent ID Badge ====================== */
.agent-badge {
    font-size: 10px;
    letter-spacing: 0.18em;
    color: var(--text-dim);
    opacity: 0.65;
    text-align: center;
    animation: fadeSlideDown 0.8s 0.6s ease both;
}

.agent-badge span {
    color: var(--neural-violet);
    opacity: 1;
}

/* ====================== Responsive ====================== */
@media (max-width: 500px) {
    video#localVideo {
        width: 100%;
        height: auto;
        min-height: 240px;
    }

    .controls-panel {
        padding: 22px 18px;
    }

    .btn-group {
        flex-direction: column;
        align-items: stretch;
    }

    button {
        min-width: unset;
        width: 100%;
    }
    #status {
        display: none;
    }
}