/* NeuroLinked Dashboard - Dark Cyberpunk Theme */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: #0a0a0f;
    color: #c8d0e0;
    font-family: 'Segoe UI', 'SF Pro', -apple-system, sans-serif;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* 3D Brain Container - fullscreen background */
#brain-container {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
}
#brain-container canvas {
    display: block;
    width: 100%; height: 100%;
}

/* Top Bar */
#top-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 48px;
    background: rgba(10, 10, 20, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0, 255, 255, 0.15);
    display: flex;
    align-items: center;
    padding: 0 20px;
    z-index: 100;
    gap: 24px;
}

.logo {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 4px;
    color: #00ffff;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

.stats-row {
    display: flex;
    gap: 20px;
    align-items: center;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.2;
}

.stat-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #667;
}

.stat-value {
    font-size: 14px;
    font-weight: 600;
    color: #e0e8f0;
    font-variant-numeric: tabular-nums;
}

.stage-badge {
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: rgba(0, 255, 255, 0.15);
    color: #00ffff;
    border: 1px solid rgba(0, 255, 255, 0.3);
}
.stage-badge.stage-embryonic { background: rgba(0, 200, 255, 0.15); color: #00c8ff; border-color: rgba(0, 200, 255, 0.3); }
.stage-badge.stage-infant { background: rgba(0, 255, 136, 0.15); color: #00ff88; border-color: rgba(0, 255, 136, 0.3); }
.stage-badge.stage-juvenile { background: rgba(255, 204, 0, 0.15); color: #ffcc00; border-color: rgba(255, 204, 0, 0.3); }
.stage-badge.stage-adolescent { background: rgba(255, 102, 0, 0.15); color: #ff6600; border-color: rgba(255, 102, 0, 0.3); }
.stage-badge.stage-mature { background: rgba(170, 136, 255, 0.15); color: #aa88ff; border-color: rgba(170, 136, 255, 0.3); }

/* Side Panel */
#side-panel {
    position: fixed;
    top: 48px;
    right: 0;
    width: 280px;
    height: calc(100vh - 48px);
    background: rgba(10, 10, 20, 0.85);
    backdrop-filter: blur(12px);
    border-left: 1px solid rgba(0, 255, 255, 0.1);
    z-index: 100;
    overflow-y: auto;
    padding: 12px;
}

.panel-section {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.panel-section h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #556;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Neuromodulator Bars */
.neuro-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.neuro-label {
    font-size: 10px;
    font-weight: 600;
    width: 28px;
    color: #889;
    text-align: right;
}

.bar-track {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    width: 0%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.bar-da { background: linear-gradient(90deg, #ff6600, #ffcc00); }
.bar-ach { background: linear-gradient(90deg, #00ccff, #00ffff); }
.bar-ne { background: linear-gradient(90deg, #ff3366, #ff6699); }
.bar-5ht { background: linear-gradient(90deg, #aa88ff, #cc99ff); }

/* Region List */
.region-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    cursor: pointer;
    transition: background 0.15s;
    border-radius: 4px;
    padding: 4px 6px;
}
.region-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.region-name {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.5px;
    width: 90px;
    flex-shrink: 0;
    text-transform: uppercase;
}

.region-bar-track {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px;
    overflow: hidden;
}

.region-bar-fill {
    height: 100%;
    width: 0%;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.region-rate {
    font-size: 10px;
    font-variant-numeric: tabular-nums;
    width: 36px;
    text-align: right;
    color: #778;
}

/* Safety */
.safety-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

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

.safety-ok { color: #00ff88; }
.safety-warn { color: #ff4444; }

/* Claude Bridge */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff4444;
    display: inline-block;
}

.conn-text {
    font-size: 9px;
    margin-left: auto;
    color: #556;
}

.claude-stats {
    font-size: 12px;
    line-height: 1.8;
    color: #889;
}
.claude-stats span {
    color: #c8d0e0;
    font-weight: 600;
}

/* Text Input */
.input-row {
    display: flex;
    gap: 6px;
}

.input-row input {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(0, 255, 255, 0.2);
    border-radius: 6px;
    padding: 6px 10px;
    color: #e0e8f0;
    font-size: 12px;
    outline: none;
}
.input-row input:focus {
    border-color: rgba(0, 255, 255, 0.5);
    box-shadow: 0 0 8px rgba(0, 255, 255, 0.15);
}

.input-row button {
    background: rgba(0, 255, 255, 0.15);
    color: #00ffff;
    border: 1px solid rgba(0, 255, 255, 0.3);
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.input-row button:hover {
    background: rgba(0, 255, 255, 0.25);
}

/* Region Detail Overlay */
.overlay {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10, 10, 20, 0.95);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(0, 255, 255, 0.2);
    border-radius: 12px;
    padding: 16px 24px;
    z-index: 200;
    min-width: 300px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
.overlay.hidden { display: none; }

.overlay h2 {
    font-size: 14px;
    letter-spacing: 2px;
    color: #00ffff;
    margin-bottom: 6px;
}
.overlay p {
    font-size: 12px;
    color: #889;
    margin-bottom: 4px;
}
.overlay-close {
    position: absolute;
    top: 8px; right: 12px;
    background: none;
    border: none;
    color: #556;
    font-size: 18px;
    cursor: pointer;
}

/* Region labels (created by Brain3D) */
.region-label {
    position: fixed;
    pointer-events: none;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.7);
    text-shadow: 0 0 6px rgba(0, 255, 255, 0.5);
    white-space: nowrap;
    z-index: 50;
}

.region-label .rl-firing {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.4);
}

/* Scrollbar */
#side-panel::-webkit-scrollbar { width: 4px; }
#side-panel::-webkit-scrollbar-track { background: transparent; }
#side-panel::-webkit-scrollbar-thumb { background: rgba(0, 255, 255, 0.2); border-radius: 2px; }

/* ===================== MOBILE ===================== */
@media (max-width: 768px) {
    /* Top bar: compact, scrollable stats */
    #top-bar {
        height: 40px;
        padding: 0 12px;
        gap: 12px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .logo {
        font-size: 13px;
        letter-spacing: 3px;
        flex-shrink: 0;
    }
    .stats-row {
        gap: 12px;
        flex-shrink: 0;
    }
    .stat-label { font-size: 8px; }
    .stat-value { font-size: 11px; }
    .stage-badge { font-size: 9px; padding: 1px 7px; }

    /* Side panel: bottom drawer instead of right sidebar */
    #side-panel {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 45vh;
        max-height: 45vh;
        border-left: none;
        border-top: 1px solid rgba(0, 255, 255, 0.15);
        border-radius: 16px 16px 0 0;
        padding: 8px 16px 20px;
        transform: translateY(calc(100% - 44px));
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 150;
    }
    #side-panel.open {
        transform: translateY(0);
    }

    /* Drag handle */
    #side-panel::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 2px;
        margin: 4px auto 10px;
        flex-shrink: 0;
    }

    /* 3D brain gets full screen above drawer */
    #brain-container {
        height: calc(100vh - 44px);
        top: 40px;
    }

    /* Panel sections: tighter spacing */
    .panel-section {
        margin-bottom: 10px;
        padding-bottom: 8px;
    }
    .panel-section h3 {
        font-size: 10px;
        margin-bottom: 6px;
    }

    /* Regions: 2 columns on mobile */
    #region-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 2px 8px;
    }
    .region-name { width: auto; font-size: 8px; }
    .region-rate { font-size: 9px; width: 30px; }

    /* Input row: full width, larger touch targets */
    .input-row input {
        font-size: 14px;
        padding: 10px 12px;
        border-radius: 8px;
    }
    .input-row button {
        padding: 10px 16px;
        font-size: 13px;
        border-radius: 8px;
    }

    /* Region detail overlay */
    .overlay {
        bottom: 50vh;
        min-width: auto;
        width: calc(100% - 32px);
        padding: 12px 16px;
    }

    /* 3D region labels: smaller on mobile */
    .region-label-3d {
        font-size: 9px !important;
        padding: 2px 6px !important;
    }
    .region-label-3d .rl-stats {
        font-size: 8px;
    }

    /* Graph view button: above drawer */
    #graph-view-btn {
        bottom: 52px !important;
        right: 12px !important;
    }

    /* Neuro bars: slightly tighter */
    .neuro-bar { margin-bottom: 3px; }
    .neuro-label { font-size: 9px; width: 24px; }
    .bar-track { height: 5px; }

    /* Claude stats */
    .claude-stats { font-size: 11px; line-height: 1.6; }

    .viz-canvas { height: 110px; }
}

/* Learning visualizations */
.viz-canvas {
    width: 100%;
    height: 130px;
    display: block;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(0, 255, 255, 0.08);
    border-radius: 4px;
}

.chart-readout {
    margin-left: auto;
    font-size: 10px;
    letter-spacing: 1px;
    color: #aab;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.chart-caption {
    font-size: 10px;
    color: #778;
    margin-top: 4px;
    line-height: 1.4;
}

/* Login Modal */
.login-modal {
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 15, 0.85);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}
.login-modal.hidden { display: none; }
.login-box {
    background: #0f1420;
    border: 1px solid #2a3550;
    border-radius: 8px;
    padding: 28px;
    min-width: 320px;
    max-width: 90vw;
    box-shadow: 0 10px 40px rgba(0, 255, 200, 0.15);
}
.login-box h2 {
    margin: 0 0 8px;
    color: #00ffc8;
    font-size: 18px;
    letter-spacing: 1px;
}
.login-box p {
    color: #99a;
    font-size: 13px;
    margin: 0 0 16px;
}
.login-box input {
    width: 100%;
    padding: 10px 12px;
    background: #070a12;
    border: 1px solid #2a3550;
    border-radius: 4px;
    color: #cfd;
    font-family: monospace;
    font-size: 13px;
    box-sizing: border-box;
}
.login-box input:focus {
    outline: none;
    border-color: #00ffc8;
}
.login-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}
.login-box button {
    padding: 8px 18px;
    background: #00ffc8;
    border: none;
    border-radius: 4px;
    color: #000;
    font-weight: bold;
    cursor: pointer;
}
.login-box button:hover { background: #33ffd4; }
.login-hint {
    color: #c44;
    font-size: 12px;
    margin-top: 10px !important;
    min-height: 16px;
}

/* Auth button in top-bar */
.auth-btn {
    background: transparent;
    border: 1px solid #2a3550;
    color: #99a;
    border-radius: 4px;
    padding: 4px 8px;
    margin-left: 12px;
    cursor: pointer;
    font-size: 14px;
}
.auth-btn.authed { border-color: #00ffc8; color: #00ffc8; }
.auth-btn:hover { border-color: #00ffc8; color: #00ffc8; }
