/* ============================================================
   Filter Demo — style.css
   Dark glassmorphic UI for ECE 215/315 Filter Demo
   ============================================================ */

/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --bg:           #0b0f1a;
  --surface-1:    #111827;
  --surface-2:    #1a2235;
  --surface-3:    #212d42;
  --border:       rgba(255,255,255,0.08);
  --border-hover: rgba(255,255,255,0.16);

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #4b6080;

  --accent:       #a78bfa;   /* purple — filter */
  --accent-orig:  #38bdf8;   /* sky    — original */
  --accent-filt:  #34d399;   /* emerald — filtered */
  --accent-lp:    #818cf8;
  --accent-hp:    #fb923c;
  --accent-bp:    #a78bfa;
  --accent-bs:    #f87171;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;

  --sidebar-w: 280px;
  --header-h:  54px;

  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --transition: 0.18s ease;
}

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

html, body {
  height: 100%;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  overflow: hidden;
}

/* ── Animated background ────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 20%, rgba(167,139,250,0.07) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(56,189,248,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 50% 60% at 60% 10%, rgba(52,211,153,0.04) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ── Header ─────────────────────────────────────────────── */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: linear-gradient(180deg, #142233, #0d1620);
  border-bottom: 1px solid #22303f;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px 0 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.back-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
  background: var(--surface-2);
}
.back-btn svg { flex-shrink: 0; opacity: 0.7; }

.header-badge {
  background: rgba(167,139,250,0.15);
  color: var(--accent);
  border: 1px solid rgba(167,139,250,0.3);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  letter-spacing: 0.5px;
}

.header-title h1 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.15;
  letter-spacing: 0;
}
.header-subtitle {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-secondary);
  letter-spacing: 0.2px;
  display: block;
}

/* Filter type strip in header */
.filter-type-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.ftype-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.5px;
}
.ftype-btn:hover { color: var(--text-primary); background: var(--surface-3); }
.ftype-btn.active {
  background: rgba(167,139,250,0.18);
  border-color: rgba(167,139,250,0.4);
  color: var(--accent);
}
#btn-lp.active { background:rgba(129,140,248,0.18); border-color:rgba(129,140,248,0.4); color:var(--accent-lp); }
#btn-hp.active { background:rgba(251,146,60,0.18); border-color:rgba(251,146,60,0.4); color:var(--accent-hp); }
#btn-bp.active { background:rgba(167,139,250,0.18); border-color:rgba(167,139,250,0.4); color:var(--accent-bp); }
#btn-bs.active { background:rgba(248,113,113,0.18); border-color:rgba(248,113,113,0.4); color:var(--accent-bs); }

.ftype-label {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 90px;
  padding-left: 4px;
}

/* ── Main layout ─────────────────────────────────────────── */
.app-main {
  display: flex;
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 12px;
  background: rgba(11,15,26,0.6);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}

/* ── Cards ───────────────────────────────────────────────── */
.audio-card, .freq-card, .info-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.audio-card-header, .freq-card-header, .info-card-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.info-card-header {
  font-size: 13px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  color: var(--accent);
}

/* ── Song selector ───────────────────────────────────────── */
.song-selector {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px;
}

.song-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  transition: all var(--transition);
}
.song-btn:hover {
  background: var(--surface-2);
  color: var(--text-primary);
  border-color: var(--border);
}
.song-btn.active {
  background: rgba(167,139,250,0.1);
  border-color: rgba(167,139,250,0.25);
  color: var(--text-primary);
}
.song-icon { font-size: 18px; }
.song-info { display: flex; flex-direction: column; }
.song-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.song-artist { font-size: 11px; color: var(--text-muted); }

/* ── Load status ─────────────────────────────────────────── */
.load-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--text-muted);
  min-height: 34px;
}
.load-status.hidden { display: none; }

.load-spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Playback controls ───────────────────────────────────── */
.playback-controls {
  display: flex;
  gap: 6px;
  padding: 10px 10px 6px;
}

.play-btn, .stop-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.play-btn:hover { background: var(--surface-3); color: var(--text-primary); }
.play-btn.accent {
  background: rgba(52,211,153,0.12);
  border-color: rgba(52,211,153,0.3);
  color: var(--accent-filt);
}
.play-btn.accent:hover { background: rgba(52,211,153,0.2); }
.play-btn.playing { 
  background: rgba(56,189,248,0.15); 
  border-color: rgba(56,189,248,0.4);
  color: var(--accent-orig);
}
.play-btn.accent.playing {
  background: rgba(52,211,153,0.2);
  border-color: rgba(52,211,153,0.5);
  color: var(--accent-filt);
}
.stop-btn {
  padding: 7px 10px;
  flex-shrink: 0;
}
.stop-btn:hover { background: rgba(248,113,113,0.12); border-color: rgba(248,113,113,0.3); color: var(--accent-bs); }

/* ── Progress bar ────────────────────────────────────────── */
.progress-wrap {
  padding: 4px 10px 12px;
}
.progress-bar {
  width: 100%;
  height: 3px;
  background: var(--surface-3);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 5px;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-orig), var(--accent-filt));
  border-radius: 2px;
  transition: width 0.25s linear;
}
.progress-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.playing-tag {
  background: rgba(167,139,250,0.15);
  border: 1px solid rgba(167,139,250,0.3);
  color: var(--accent);
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

/* ── Cutoff frequency controls ───────────────────────────── */
.freq-input-group {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.freq-input-group:last-child { border-bottom: none; }

.freq-input-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 7px;
}

.freq-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.fc1-dot { background: var(--accent-orig); }
.fc2-dot { background: var(--accent-filt); }

.freq-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.freq-input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 500;
  padding: 5px 10px;
  text-align: right;
  outline: none;
  transition: border-color var(--transition);
}
.freq-input::-webkit-inner-spin-button { opacity: 0.4; }
.freq-input:focus { border-color: var(--accent); }

.freq-unit { font-size: 12px; color: var(--text-muted); width: 22px; }

.freq-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-3);
  outline: none;
  cursor: pointer;
}
.freq-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent-orig);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 2px rgba(56,189,248,0.3);
  transition: box-shadow var(--transition);
}
.freq-slider::-webkit-slider-thumb:hover { box-shadow: 0 0 0 4px rgba(56,189,248,0.3); }
.fc2-slider::-webkit-slider-thumb {
  background: var(--accent-filt);
  box-shadow: 0 0 0 2px rgba(52,211,153,0.3);
}
.fc2-slider::-webkit-slider-thumb:hover { box-shadow: 0 0 0 4px rgba(52,211,153,0.3); }
#fc2-group.hidden { display: none; }

/* ── Info card ───────────────────────────────────────────── */
.info-card {
  flex-shrink: 0;
}
.filter-eq {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  line-height: 1.6;
}
.filter-desc {
  font-size: 12px;
  color: var(--text-muted);
  padding: 10px 14px;
  line-height: 1.6;
}

/* ── Plot panel ───────────────────────────────────────────── */
.plot-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Tab bar ─────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 2px;
  padding: 10px 14px 0;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: none;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.tab-btn:hover { color: var(--text-primary); background: var(--surface-2); }
.tab-btn.active {
  color: var(--text-primary);
  background: var(--bg);
  border-color: var(--border);
  border-bottom-color: var(--bg);
  margin-bottom: -1px;
}

/* ── Tab content ─────────────────────────────────────────── */
.tab-content { display: none; flex: 1; overflow: hidden; }
.tab-content.active { display: flex; flex-direction: column; flex: 1; }

/* ── Designer tab ────────────────────────────────────────── */
.designer-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 14px;
  gap: 10px;
}
.designer-hint {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}
.canvas-container {
  flex: 1;
  position: relative;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
#designer-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.designer-legend {
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-shrink: 0;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}
.legend-dot {
  width: 10px; height: 3px;
  border-radius: 2px;
  display: inline-block;
}

/* ── Chart grids ─────────────────────────────────────────── */
.chart-grid-2 {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 12px;
  padding: 14px;
  height: 100%;
}
.chart-grid-1 {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 12px;
  padding: 14px;
  height: 100%;
}

.chart-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.chart-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chart-sublabel {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: auto;
}
.chart-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.chart-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 6px 10px 4px;
}
.chart-wrap canvas {
  position: absolute;
  inset: 6px 10px 4px;
  width: calc(100% - 20px) !important;
  height: calc(100% - 10px) !important;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 800px) {
  :root { --sidebar-w: 220px; }
  .ftype-label { display: none; }
}
@media (max-width: 600px) {
  .app-main { flex-direction: column; }
  .sidebar { width: 100%; height: auto; overflow-y: visible; border-right: none; border-bottom: 1px solid var(--border); }
  html, body { overflow: auto; }
  .app-main { position: static; }
  .plot-panel { height: 80vh; }
}
