/* EEG Dipole Demo - Main Stylesheet */

/* Dark Mode (default) */
:root {
    --bg: #0b1020;
    --bg-alt: #060812;
    --panel: #111a33;
    --panel2: #0f1730;
    --panel-solid: #111a33;
    --text: #e8ecff;
    --text-inverse: #1a2040;
    --muted: #b8c1ffcc;
    --border: #2a3a77;
    --accent: #7aa2ff;
    --accent-hover: #5d8aff;
    --danger: #ff6b6b;
    --ok: #5cffc9;
    --shadow: 0 10px 30px rgba(0,0,0,.35);
    --canvas-bg: radial-gradient(1100px 520px at 50% 30%, rgba(122,162,255,.08), rgba(0,0,0,0));
    --legend-bg: rgba(0,0,0,.18);
    --input-bg: rgba(0,0,0,.22);
    --overlay-bg: rgba(0,0,0,.16);
    --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
}

/* Light Mode */
[data-theme="light"] {
    --bg: #f0f4ff;
    --bg-alt: #e8ecf8;
    --panel: #ffffff;
    --panel2: #f8faff;
    --panel-solid: #ffffff;
    --text: #1a2040;
    --text-inverse: #e8ecff;
    --muted: #5a6080cc;
    --border: #c0c8e0;
    --accent: #4a7aff;
    --accent-hover: #3060ee;
    --danger: #e04040;
    --ok: #20a070;
    --shadow: 0 10px 30px rgba(0,0,50,.12);
    --canvas-bg: radial-gradient(1100px 520px at 50% 30%, rgba(70,120,200,.06), rgba(255,255,255,0));
    --legend-bg: rgba(0,0,50,.06);
    --input-bg: rgba(0,0,50,.04);
    --overlay-bg: rgba(0,0,50,.04);
}

/* Light mode specific overrides */
[data-theme="light"] .bar {
    background: linear-gradient(90deg, #2b6dff, #f0f4ff, #ff3b3b);
}

[data-theme="light"] .mode-toggle button.active {
    color: #fff;
}

[data-theme="light"] header {
    background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(240,244,255,.98));
}

[data-theme="light"] .panel {
    background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(248,250,255,.98));
}

[data-theme="light"] canvas {
    background: var(--canvas-bg);
}

html, body {
    height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
}

* { box-sizing: border-box; }

/* Header */
header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(16,26,58,.95), rgba(11,16,32,.95));
    position: sticky;
    top: 0;
    z-index: 10;
}

header h1 {
    font-size: 16px;
    margin: 0 0 4px 0;
    font-weight: 650;
    letter-spacing: .2px;
}

header .sub {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.35;
}

/* Layout */
.wrap {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 14px;
    padding: 14px;
    max-width: 1280px;
    margin: 0 auto;
}

.panel {
    background: linear-gradient(180deg, rgba(17,26,51,.95), rgba(12,18,40,.95));
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 12px;
}

.panel h2 {
    font-size: 13px;
    margin: 4px 0 10px 0;
    font-weight: 650;
    letter-spacing: .2px;
}

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

.row > * { flex: 1; }

.btnrow {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Buttons */
button {
    appearance: none;
    border: 1px solid var(--border);
    background: rgba(255,255,255,.04);
    color: var(--text);
    padding: 9px 10px;
    border-radius: 10px;
    font-size: 12px;
    cursor: pointer;
    transition: transform .02s ease, background .12s ease, border-color .12s ease;
}

button:hover {
    background: rgba(255,255,255,.07);
    border-color: rgba(122,162,255,.6);
}

button:active { transform: translateY(1px); }

button.danger { border-color: rgba(255,107,107,.6); }
button.danger:hover { background: rgba(255,107,107,.10); }

button.ok { border-color: rgba(92,255,201,.55); }
button.ok:hover { background: rgba(92,255,201,.10); }

/* Form elements */
label {
    font-size: 12px;
    color: var(--muted);
}

input[type="range"] { width: 100%; }

input[type="number"] {
    width: 100%;
    padding: 7px 8px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(0,0,0,.22);
    color: var(--text);
    font-family: var(--mono);
    font-size: 12px;
}

select {
    width: 100%;
    padding: 8px 8px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(0,0,0,.22);
    color: var(--text);
    font-size: 12px;
}

/* Typography helpers */
.small {
    font-size: 11px;
    color: var(--muted);
    line-height: 1.35;
}

.kbd {
    font-family: var(--mono);
    padding: 0 6px;
    border: 1px solid rgba(255,255,255,.16);
    border-bottom-color: rgba(255,255,255,.25);
    background: rgba(255,255,255,.06);
    border-radius: 7px;
    font-size: 11px;
    color: var(--text);
}

/* Visualization container */
.viz-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* 3D Panel */
.panel-3d {
    width: 100%;
}

.panel-3d .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}

.panel-3d .panel-header h2 {
    margin: 0;
}

.view-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.view-controls button {
    padding: 4px 8px;
    font-size: 11px;
}

/* Charts grid */
.charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

@media (max-width: 980px) {
    .wrap { grid-template-columns: 1fr; }
    .charts { grid-template-columns: 1fr; }
}

/* Canvas */
canvas {
    width: 100%;
    height: 520px;
    display: block;
    border-radius: 14px;
    background: radial-gradient(1100px 520px at 50% 30%, rgba(122,162,255,.08), rgba(0,0,0,0));
    border: 1px solid var(--border);
}

/* Legend */
.legend {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 10px;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,.10);
    background: rgba(0,0,0,.18);
}

.bar {
    height: 10px;
    flex: 1;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,.14);
    background: linear-gradient(90deg, #2b6dff, #e8ecff, #ff3b3b);
    position: relative;
    overflow: hidden;
}

.bar .tick {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(0,0,0,.25);
    left: 50%;
}

.legend .val {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text);
    white-space: nowrap;
}

/* Divider */
.hr {
    height: 1px;
    background: rgba(255,255,255,.09);
    margin: 12px 0;
}

/* Source List (dipoles/blobs) */
.sourceList {
    display: grid;
    gap: 8px;
    margin: 8px 0 10px 0;
}

.sourceItem {
    border: 1px solid rgba(255,255,255,.10);
    background: rgba(0,0,0,.16);
    border-radius: 12px;
    padding: 10px;
}

.sourceItem.active {
    border-color: rgba(122,162,255,.75);
    box-shadow: 0 0 0 2px rgba(122,162,255,.18) inset;
}

.sourceItem .top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

/* Legacy dipoleList/dipoleItem classes for compatibility */
.dipoleList {
    display: grid;
    gap: 8px;
    margin: 8px 0 10px 0;
}

.dipoleItem {
    border: 1px solid rgba(255,255,255,.10);
    background: rgba(0,0,0,.16);
    border-radius: 12px;
    padding: 10px;
}

.dipoleItem.active {
    border-color: rgba(122,162,255,.75);
    box-shadow: 0 0 0 2px rgba(122,162,255,.18) inset;
}

.dipoleItem .top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

/* Tags and pills */
.tag {
    font-family: var(--mono);
    font-size: 11px;
    padding: 3px 7px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,.16);
    background: rgba(255,255,255,.06);
}

.pill {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,.14);
    background: rgba(0,0,0,.18);
    color: var(--muted);
    white-space: nowrap;
}

/* Grids */
.grid2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.grid2 > div {
    display: grid;
    gap: 6px;
}

/* Hint boxes */
.hint {
    margin-top: 10px;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,.10);
    background: rgba(0,0,0,.14);
}

.hint ul {
    margin: 6px 0 0 18px;
    padding: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.hint li { margin: 4px 0; }

/* Footer */
.footer {
    margin-top: 8px;
    font-size: 11px;
    color: rgba(232,236,255,.55);
    line-height: 1.35;
}

/* Mode Toggle */
.mode-toggle {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: rgba(0,0,0,.25);
    border-radius: 12px;
    margin-bottom: 12px;
}

.mode-toggle button {
    flex: 1;
    padding: 14px 16px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
    transition: all 0.15s ease;
}

.mode-toggle button:hover:not(.active) {
    background: rgba(255,255,255,0.05);
}

.mode-toggle button.active {
    background: var(--accent);
    color: var(--bg);
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(122,162,255,0.3);
}

/* Timeline Controls */
.timeline-container {
    margin-top: 12px;
    padding: 12px;
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 12px;
    background: rgba(0,0,0,.14);
}

.timeline-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.timeline-controls button {
    padding: 6px 10px;
    font-size: 14px;
}

.timeline-slider {
    flex: 1;
}

.timeline-time {
    font-family: var(--mono);
    font-size: 12px;
    min-width: 80px;
    text-align: right;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--muted);
}

/* File Upload */
.file-upload {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.file-upload:hover {
    border-color: var(--accent);
    background: rgba(122,162,255,.05);
}

.file-upload.dragover {
    border-color: var(--ok);
    background: rgba(92,255,201,.08);
}

.file-upload input[type="file"] {
    display: none;
}

.file-upload .icon {
    font-size: 24px;
    margin-bottom: 8px;
}

.file-upload .text {
    font-size: 12px;
    color: var(--muted);
}

/* Channel Mapping */
.channel-mapping {
    margin-top: 10px;
}

.channel-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.channel-row:last-child {
    border-bottom: none;
}

.channel-name {
    font-family: var(--mono);
    font-size: 11px;
    min-width: 80px;
}

.channel-target {
    flex: 1;
}

/* Export Panel */
.export-panel {
    margin-top: 12px;
    padding: 12px;
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 12px;
    background: rgba(0,0,0,.14);
}

.export-info {
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 10px;
}

/* Blob-specific styles */
.blob-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent), transparent);
    border: 1px solid var(--accent);
}

/* Y-axis slider styling */
.y-axis-control {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 8px;
    background: rgba(0,0,0,.12);
    border-radius: 8px;
}

.y-axis-label {
    font-size: 11px;
    color: var(--muted);
    min-width: 60px;
}

.y-axis-value {
    font-family: var(--mono);
    font-size: 11px;
    min-width: 50px;
    text-align: right;
}

/* Orientation dial (circular control) */
.orientation-dial {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: rgba(0,0,0,.2);
    position: relative;
    cursor: pointer;
}

.orientation-dial .needle {
    position: absolute;
    width: 2px;
    height: 35px;
    background: var(--accent);
    left: 50%;
    bottom: 50%;
    transform-origin: bottom center;
    transform: translateX(-50%);
}

.orientation-dial .center {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--text);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
