/* ── Design Tokens ── */
:root {
  --bg: #0a0a0f;
  --bg2: #0f0f1a;
  --bg3: #14141f;
  --surface: rgba(255,255,255,0.04);
  --surface-hover: rgba(255,255,255,0.07);
  --border: rgba(255,255,255,0.08);
  --purple: #a855f7;
  --purple-dim: rgba(168,85,247,0.15);
  --cyan: #06b6d4;
  --cyan-dim: rgba(6,182,212,0.15);
  --green: #22c55e;
  --green-dim: rgba(34,197,94,0.15);
  --red: #ef4444;
  --red-dim: rgba(239,68,68,0.15);
  --text: #f1f1f8;
  --text2: #a1a1b5;
  --text3: #6b6b82;
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-w: 240px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  padding: 24px 16px;
}

.sidebar-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 40px; padding: 0 8px; }
.logo-icon { width: 36px; height: 36px; }
.logo-text { font-family: 'Space Grotesk', sans-serif; font-size: 1.2rem; font-weight: 700; background: linear-gradient(135deg, var(--purple), var(--cyan)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  color: var(--text2); text-decoration: none;
  font-size: 0.9rem; font-weight: 500;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active { background: var(--purple-dim); color: var(--purple); border-color: rgba(168,85,247,0.25); }

.sidebar-footer { padding-top: 24px; border-top: 1px solid var(--border); }
.model-badge { display: flex; align-items: center; gap: 8px; padding: 8px 14px; font-size: 0.78rem; color: var(--text2); }
.badge-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse 2s infinite; }

@keyframes pulse { 0%,100%{ opacity:1; } 50%{ opacity:0.4; } }

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 40px;
  max-width: calc(100vw - var(--sidebar-w));
}

/* ── Tab Panels ── */
.tab-panel { display: none; animation: fadeUp 0.35s ease; }
.tab-panel.active { display: block; }
@keyframes fadeUp { from{ opacity:0; transform:translateY(16px); } to{ opacity:1; transform:translateY(0); } }

/* ── Hero ── */
.hero-section {
  display: grid; grid-template-columns: 1fr 1fr; gap: 40px;
  align-items: center; min-height: 340px;
  background: linear-gradient(135deg, rgba(168,85,247,0.08), rgba(6,182,212,0.05));
  border: 1px solid var(--border); border-radius: 24px;
  padding: 48px; margin-bottom: 32px; position: relative; overflow: hidden;
}
.hero-section::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 80% 20%, rgba(168,85,247,0.1) 0%, transparent 60%);
  pointer-events: none;
}
.hero-tag {
  display: inline-block; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--cyan);
  background: var(--cyan-dim); border: 1px solid rgba(6,182,212,0.3);
  padding: 4px 12px; border-radius: 20px; margin-bottom: 16px;
}
.hero-title { font-family: 'Space Grotesk', sans-serif; font-size: 2.6rem; font-weight: 700; line-height: 1.15; margin-bottom: 16px; }
.gradient-text { background: linear-gradient(135deg, var(--purple), var(--cyan)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.hero-subtitle { color: var(--text2); font-size: 1rem; line-height: 1.7; margin-bottom: 28px; max-width: 420px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.hero-visual { position: relative; display: flex; align-items: center; justify-content: center; }
.eeg-canvas { width: 100%; height: 140px; border-radius: var(--radius-sm); }
.hero-ring { position: absolute; right: -20px; top: 50%; transform: translateY(-50%); }
.ring { border-radius: 50%; border: 1px solid; position: absolute; transform: translate(-50%,-50%); animation: ringPulse 3s ease-in-out infinite; }
.ring-1 { width: 80px; height: 80px; border-color: rgba(168,85,247,0.3); animation-delay: 0s; }
.ring-2 { width: 130px; height: 130px; border-color: rgba(168,85,247,0.15); animation-delay: 0.5s; }
.ring-3 { width: 180px; height: 180px; border-color: rgba(168,85,247,0.07); animation-delay: 1s; }
@keyframes ringPulse { 0%,100%{ transform:translate(-50%,-50%) scale(1); opacity:1; } 50%{ transform:translate(-50%,-50%) scale(1.05); opacity:0.6; } }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 22px; border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 600; cursor: pointer;
  border: none; transition: all 0.2s ease; text-decoration: none;
  font-family: inherit;
}
.btn-primary { background: linear-gradient(135deg, var(--purple), #7c3aed); color: #fff; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(168,85,247,0.4); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface-hover); }
.btn-outline { background: transparent; color: var(--purple); border: 1px solid var(--purple); }
.btn-outline:hover { background: var(--purple-dim); }
.btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); background: var(--surface); }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 7px 16px; font-size: 0.82rem; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; box-shadow: none !important; }
.mt-16 { margin-top: 16px; }

/* ── Stats Grid ── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 32px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  display: flex; align-items: center; gap: 16px;
  transition: border-color 0.2s;
}
.stat-card:hover { border-color: rgba(168,85,247,0.3); }
.stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.purple { background: var(--purple-dim); color: var(--purple); }
.stat-icon.cyan { background: var(--cyan-dim); color: var(--cyan); }
.stat-icon.green { background: var(--green-dim); color: var(--green); }
.stat-icon.red { background: var(--red-dim); color: var(--red); }
.stat-value { font-size: 1.3rem; font-weight: 700; }
.stat-label { font-size: 0.78rem; color: var(--text2); margin-top: 2px; }

/* ── How It Works ── */
.how-it-works { }
.section-title { font-family: 'Space Grotesk', sans-serif; font-size: 1.5rem; font-weight: 700; margin-bottom: 20px; }
.steps-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.step-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  transition: all 0.2s;
}
.step-card:hover { background: var(--surface-hover); transform: translateY(-3px); }
.step-num { font-size: 2rem; font-weight: 800; background: linear-gradient(135deg,var(--purple),var(--cyan)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin-bottom: 12px; }
.step-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 8px; }
.step-card p { font-size: 0.85rem; color: var(--text2); line-height: 1.6; }

/* ── Page Header ── */
.page-header { margin-bottom: 28px; }
.page-title { font-family: 'Space Grotesk', sans-serif; font-size: 1.8rem; font-weight: 700; margin-bottom: 6px; }
.page-subtitle { color: var(--text2); font-size: 0.9rem; }

/* ── Two Column Layout ── */
.two-col { display: grid; grid-template-columns: 340px 1fr; gap: 20px; }

/* ── Panel Card ── */
.panel-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
}
.panel-title { font-size: 0.9rem; font-weight: 600; display: flex; align-items: center; gap: 8px; margin-bottom: 20px; color: var(--text); }

/* ── Input Panel ── */
.input-group { margin-bottom: 20px; }
.input-group label { display: block; font-size: 0.82rem; font-weight: 500; color: var(--text2); margin-bottom: 8px; }
.label-hint { color: var(--text3); font-weight: 400; }
.input-row { display: flex; gap: 8px; }
.input-field {
  flex: 1; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px;
  color: var(--text); font-size: 0.9rem; font-family: inherit;
  transition: border-color 0.2s; outline: none;
}
.input-field:focus { border-color: var(--purple); }
.input-field::placeholder { color: var(--text3); }

.divider-or { text-align: center; color: var(--text3); font-size: 0.8rem; margin: 16px 0; position: relative; }
.divider-or::before, .divider-or::after { content:''; position:absolute; top:50%; width:42%; height:1px; background:var(--border); }
.divider-or::before { left:0; } .divider-or::after { right:0; }
.divider-or span { background: var(--surface); padding: 0 10px; }

.sample-meta { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; margin-top: 16px; }
.meta-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; }
.meta-row:not(:last-child) { border-bottom: 1px solid var(--border); }
.meta-key { font-size: 0.78rem; color: var(--text2); }
.meta-val { font-size: 0.82rem; font-weight: 600; }

/* ── Chart ── */
.chart-card { margin-bottom: 16px; }
.chart-placeholder { text-align: center; padding: 40px; color: var(--text3); }
.placeholder-icon { margin-bottom: 12px; opacity: 0.3; }
.placeholder-icon svg { width: 48px; height: 48px; }
.chart-wrapper { height: 180px; }

/* ── Gauge ── */
.result-body { display: flex; align-items: center; gap: 24px; }
.result-gauge { flex-shrink: 0; }
.gauge-svg { width: 120px; height: 120px; transform: rotate(-90deg); }
.gauge-bg { fill: none; stroke: var(--border); stroke-width: 8; }
.gauge-fill { fill: none; stroke-width: 8; stroke-linecap: round; stroke-dasharray: 314; stroke-dashoffset: 314; transition: stroke-dashoffset 1s ease, stroke 0.4s; }
.gauge-label { font-size: 16px; font-weight: 700; fill: var(--text); transform: rotate(90deg); transform-origin: 60px 60px; }
.gauge-sub { font-size: 9px; fill: var(--text2); transform: rotate(90deg); transform-origin: 60px 60px; }

.result-badge { display: inline-block; padding: 8px 20px; border-radius: 20px; font-weight: 700; font-size: 1.1rem; margin-bottom: 16px; }
.result-badge.epilepsy { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.result-badge.normal { background: var(--green-dim); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }

.r-stat { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); }
.r-stat:last-child { border: none; }
.r-stat-key { font-size: 0.78rem; color: var(--text2); }
.r-stat-val { font-size: 0.82rem; font-weight: 600; }

/* ── Upload Zone ── */
.upload-zone {
  border: 2px dashed var(--border); border-radius: 20px;
  padding: 56px 40px; text-align: center; margin-bottom: 20px;
  position: relative; transition: all 0.2s; cursor: pointer;
}
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--purple); background: var(--purple-dim); }
.upload-icon { color: var(--text3); margin-bottom: 16px; }
.upload-icon svg { width: 56px; height: 56px; }
.upload-zone h3 { font-size: 1.2rem; font-weight: 600; margin-bottom: 8px; }
.upload-zone p { color: var(--text2); font-size: 0.9rem; }
.upload-actions { display: flex; gap: 12px; justify-content: center; margin: 20px 0 8px; }
.upload-hint { font-size: 0.78rem; color: var(--text3); }
.upload-overlay {
  position: absolute; inset: 0; border-radius: 18px;
  background: rgba(168,85,247,0.12); display: none;
  align-items: center; justify-content: center;
  font-size: 1.2rem; font-weight: 600; color: var(--purple);
}
.upload-zone.drag-over .upload-overlay { display: flex; }

/* ── File Info Bar ── */
.file-info-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 18px; margin-bottom: 20px;
}
.file-info-left { display: flex; align-items: center; gap: 10px; font-size: 0.88rem; }
.file-badge { background: var(--purple-dim); color: var(--purple); border-radius: 20px; padding: 2px 10px; font-size: 0.75rem; font-weight: 600; }
.file-info-right { display: flex; gap: 8px; }

/* ── Batch Summary ── */
.batch-summary { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 20px; }
.summary-card {
  border-radius: var(--radius); padding: 20px;
  display: flex; align-items: center; gap: 14px; border: 1px solid;
}
.epilepsy-card { background: var(--red-dim); border-color: rgba(239,68,68,0.2); }
.normal-card { background: var(--green-dim); border-color: rgba(34,197,94,0.2); }
.total-card { background: var(--cyan-dim); border-color: rgba(6,182,212,0.2); }
.rate-card { background: var(--purple-dim); border-color: rgba(168,85,247,0.2); }
.summary-icon { font-size: 1.6rem; }
.summary-val { font-size: 1.5rem; font-weight: 700; }
.summary-label { font-size: 0.75rem; color: var(--text2); }

/* ── Batch Charts ── */
.batch-charts { display: grid; grid-template-columns: 280px 1fr; gap: 16px; margin-bottom: 20px; }
.donut-card { display: flex; flex-direction: column; align-items: center; }
.donut-card canvas { max-width: 220px; max-height: 220px; }
.prob-card canvas { width: 100% !important; }

/* ── Results Table ── */
.table-card { }
.table-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.table-header .panel-title { margin-bottom: 0; }
.table-filters { display: flex; gap: 8px; }
.filter-btn {
  padding: 5px 14px; border-radius: 20px; border: 1px solid var(--border);
  background: transparent; color: var(--text2); font-size: 0.78rem;
  cursor: pointer; font-family: inherit; transition: all 0.2s;
}
.filter-btn.active { background: var(--purple-dim); color: var(--purple); border-color: rgba(168,85,247,0.4); }
.table-wrapper { overflow-x: auto; }
.results-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.results-table th {
  text-align: left; padding: 10px 14px;
  color: var(--text2); font-weight: 500; font-size: 0.78rem;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.results-table td { padding: 11px 14px; border-bottom: 1px solid rgba(255,255,255,0.04); }
.results-table tr:last-child td { border: none; }
.results-table tr:hover td { background: var(--surface-hover); }
.results-table tr.hidden { display: none; }

.tag { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.tag-epilepsy { background: var(--red-dim); color: var(--red); }
.tag-normal { background: var(--green-dim); color: var(--green); }
.tag-unknown { background: var(--surface); color: var(--text2); }

.prob-bar { display: flex; align-items: center; gap: 10px; }
.prob-bar-track { flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.prob-bar-fill { height: 100%; border-radius: 3px; transition: width 0.6s ease; }

/* ── Loading ── */
.loading-overlay {
  position: fixed; inset: 0; background: rgba(10,10,15,0.75);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; backdrop-filter: blur(4px);
}
.loading-overlay.active { display: flex; }
.loading-spinner { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.spinner-svg { width: 56px; height: 56px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 0.9rem; color: var(--text2); }

/* ── Responsive ── */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .steps-grid { grid-template-columns: 1fr 1fr; }
  .batch-summary { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 800px) {
  .sidebar { width: 64px; }
  .sidebar .logo-text, .sidebar .nav-item span, .sidebar-footer span { display: none; }
  .main-content { margin-left: 64px; padding: 24px; }
  .hero-section { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .batch-charts { grid-template-columns: 1fr; }
}
