/* ════════════════════════════════════════════════════════════
   VoiceStudio — Creator Audio Suite
   Dark, industrial-precision aesthetic
   Font: Syne (display) + DM Mono (values)
════════════════════════════════════════════════════════════ */

/* ── Variables ───────────────────────────────────────────── */
:root {
  --bg-base:      #0b0c0f;
  --bg-panel:     #111318;
  --bg-card:      #181c24;
  --bg-card-alt:  #1e2330;
  --bg-input:     #0f1117;

  --border:       #252b38;
  --border-light: #2e3545;

  --text-primary:   #e8ecf4;
  --text-secondary: #8892a8;
  --text-muted:     #4a5268;

  --accent:       #00e5b4;
  --accent-dim:   #00c49a;
  --accent-glow:  rgba(0, 229, 180, 0.15);
  --accent-glow2: rgba(0, 229, 180, 0.06);

  --red:     #ff4757;
  --red-dim: #cc3344;
  --amber:   #ffb347;
  --blue:    #4a9eff;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;

  --font-ui:   'Syne', system-ui, sans-serif;
  --font-mono: 'DM Mono', 'Courier New', monospace;

  --transition: 150ms ease;
  --shadow:     0 4px 24px rgba(0,0,0,0.5);
  --shadow-sm:  0 2px 8px rgba(0,0,0,0.3);
}

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

html { font-size: 14px; height: 100%; }

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-ui);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Subtle grid texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* ── Header ──────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 56px;
  background: rgba(11,12,15,0.92);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  flex-shrink: 0;
}
.logo-icon svg { width: 18px; height: 18px; }

.logo-text {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.logo-badge {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-glow2);
  border: 1px solid rgba(0,229,180,0.25);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.08em;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  justify-content: center;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s;
  flex-shrink: 0;
}
.status-dot.idle     { background: var(--text-muted); }
.status-dot.ready    { background: var(--blue); }
.status-dot.recording {
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
  animation: pulse-dot 1s ease-in-out infinite;
}
.status-dot.paused   { background: var(--amber); }
.status-dot.stopped  { background: var(--accent); }

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

.status-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-secondary);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.rec-timer {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.1em;
  min-width: 7ch;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn-icon {
  width: 34px;
  height: 34px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.btn-icon svg { width: 16px; height: 16px; }
.btn-icon:hover { background: var(--bg-card-alt); color: var(--text-primary); border-color: var(--border-light); }

/* ── App Layout ──────────────────────────────────────────── */
.app-layout {
  position: relative;
  z-index: 1;
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 0;
  min-height: 0;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
  gap: 20px;
}

/* ── Panel Base ──────────────────────────────────────────── */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Main Panel ──────────────────────────────────────────── */
.panel-main {
  gap: 0;
}

/* Visualizer */
.visualizer-container {
  position: relative;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  height: 220px;
  overflow: hidden;
}

#vizCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.viz-overlay {
  position: absolute;
  bottom: 12px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.viz-level-bar {
  width: 6px;
  height: 60px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.level-fill {
  width: 100%;
  height: 0%;
  background: linear-gradient(to top, var(--accent), var(--amber), var(--red));
  border-radius: 3px;
  transition: height 50ms ease-out;
}

.db-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.no-input-warning {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(11,12,15,0.85);
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Transport */
.transport {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  flex-shrink: 0;
}

.transport-btn {
  flex: 1;
  height: 44px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.transport-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background 0.15s;
}
.transport-btn:hover:not(:disabled)::after { background: rgba(255,255,255,0.06); }
.transport-btn:active:not(:disabled) { transform: scale(0.98); }

.btn-rec {
  background: var(--red);
  color: #fff;
}
.btn-rec:hover:not(:disabled) { background: var(--red-dim); }
.btn-rec.recording {
  background: linear-gradient(135deg, #ff2244, #cc1133);
  box-shadow: 0 0 20px rgba(255,71,87,0.4);
  animation: rec-pulse 2s ease-in-out infinite;
}
@keyframes rec-pulse {
  0%, 100% { box-shadow: 0 0 20px rgba(255,71,87,0.4); }
  50%       { box-shadow: 0 0 32px rgba(255,71,87,0.7); }
}

.btn-pause {
  background: var(--bg-card-alt);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
}
.btn-pause:not(:disabled):hover { color: var(--amber); border-color: var(--amber); }
.btn-pause:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-stop {
  background: var(--bg-card-alt);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
}
.btn-stop:not(:disabled):hover { color: var(--text-primary); border-color: var(--border-light); }
.btn-stop:disabled { opacity: 0.4; cursor: not-allowed; }

/* Recordings */
.recordings-section {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 10px;
  border-bottom: 1px solid var(--border);
}
.section-header h3 {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.rec-count {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
}

.recordings-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.recordings-list::-webkit-scrollbar { width: 4px; }
.recordings-list::-webkit-scrollbar-track { background: transparent; }
.recordings-list::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 2px; }

.recordings-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
  padding: 40px 0;
}
.recordings-empty p { font-size: 0.85rem; color: var(--text-muted); }
.recordings-empty small { font-size: 0.7rem; color: var(--text-muted); opacity: 0.6; }

/* Recording Item */
.rec-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: var(--transition);
}
.rec-item:hover { border-color: var(--border-light); }

.rec-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.rec-item-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}
.rec-item-meta {
  display: flex;
  gap: 10px;
}
.rec-meta-pill {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text-muted);
  background: var(--bg-base);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
}

.rec-item-audio audio {
  width: 100%;
  height: 28px;
  filter: invert(0.88) hue-rotate(160deg) saturate(0.7);
}

.rec-item-actions {
  display: flex;
  gap: 6px;
}
.rec-action-btn {
  height: 26px;
  padding: 0 10px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 4px;
}
.rec-action-btn svg { width: 11px; height: 11px; }
.rec-action-btn:hover { color: var(--text-primary); border-color: var(--border-light); }
.rec-action-btn.danger:hover { color: var(--red); border-color: var(--red); }

/* ── FX Panel ────────────────────────────────────────────── */
.panel-fx {
  min-height: 0;
}

.fx-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 4px;
  gap: 0;
  flex-shrink: 0;
  overflow-x: auto;
}
.fx-tabs::-webkit-scrollbar { display: none; }

.fx-tab {
  flex: 1;
  min-width: 0;
  height: 44px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  padding: 0 6px;
}
.fx-tab:hover { color: var(--text-secondary); }
.fx-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-panel {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  flex-direction: column;
  gap: 14px;
}
.tab-panel::-webkit-scrollbar { width: 4px; }
.tab-panel::-webkit-scrollbar-track { background: transparent; }
.tab-panel::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 2px; }
.tab-panel.active { display: flex; }

/* FX Card */
.fx-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s;
}
.fx-card:hover { border-color: var(--border-light); }

.fx-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
}
.fx-card-header h4 {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.fx-card-header small {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.fx-card-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Controls */
.control-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.control-row label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  min-width: 100px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.val-display {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--accent);
  min-width: 5ch;
  text-align: right;
  flex-shrink: 0;
}

/* Slider */
.slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 3px;
  background: var(--bg-base);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  min-width: 0;
  position: relative;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 6px rgba(0,229,180,0.5);
  transition: transform 0.1s, box-shadow 0.1s;
}
.slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 10px rgba(0,229,180,0.7);
}
.slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

/* Select */
.select-input {
  flex: 1;
  height: 30px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  padding: 0 8px;
  outline: none;
  cursor: pointer;
  min-width: 0;
  transition: border-color 0.15s;
}
.select-input:focus { border-color: var(--accent); }
.select-input option { background: var(--bg-card); }

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-flex;
  cursor: pointer;
  flex-shrink: 0;
}
.toggle-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  width: 36px;
  height: 20px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  position: relative;
  transition: background 0.2s, border-color 0.2s;
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.toggle-switch input:checked + .toggle-track {
  background: rgba(0,229,180,0.15);
  border-color: var(--accent);
}
.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(16px);
  background: var(--accent);
  box-shadow: 0 0 6px rgba(0,229,180,0.6);
}
.toggle-switch.small .toggle-track { width: 28px; height: 16px; border-radius: 8px; }
.toggle-switch.small .toggle-track::after { width: 10px; height: 10px; }
.toggle-switch.small input:checked + .toggle-track::after { transform: translateX(12px); }

/* Info Box */
.info-box {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.65rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.info-box svg { flex-shrink: 0; margin-top: 1px; color: var(--text-muted); }

/* Gate Indicator */
.gate-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.68rem;
  color: var(--text-muted);
}
#gateStatus {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 4px;
}
.gate-open   { color: var(--accent); background: var(--accent-glow2); border: 1px solid rgba(0,229,180,0.2); }
.gate-closed { color: var(--red);   background: rgba(255,71,87,0.06);  border: 1px solid rgba(255,71,87,0.2); }

/* GR Meter */
.gr-meter-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}
.gr-label { font-size: 0.65rem; color: var(--text-muted); font-family: var(--font-mono); min-width: 2ch; }
.gr-meter {
  flex: 1;
  height: 6px;
  background: var(--bg-base);
  border-radius: 3px;
  overflow: hidden;
}
.gr-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(to right, var(--amber), var(--red));
  border-radius: 3px;
  transition: width 80ms;
}
.gr-val { font-family: var(--font-mono); font-size: 0.65rem; color: var(--amber); min-width: 5ch; text-align: right; }

/* EQ Canvas */
.eq-canvas {
  width: 100%;
  height: 100px;
  border-radius: var(--radius-sm);
  background: var(--bg-base);
  margin-bottom: 6px;
  display: block;
}

/* EQ Band */
.eq-band {
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.band-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.band-name {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
}

/* Pitch Presets */
.pitch-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.preset-btn {
  height: 26px;
  padding: 0 12px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: var(--transition);
}
.preset-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-glow2); }

/* Session Buttons */
.session-actions { display: flex; flex-direction: column; gap: 8px; }
.btn-session {
  height: 38px;
  background: var(--bg-card-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-session:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-glow2); }

.btn-export {
  height: 44px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #000;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  text-transform: uppercase;
}
.btn-export:hover:not(:disabled) { background: var(--accent-dim); box-shadow: 0 4px 16px rgba(0,229,180,0.3); }
.btn-export:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Toast ───────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.75rem;
  color: var(--text-primary);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 300px;
  animation: toast-in 0.25s ease;
  pointer-events: auto;
}
.toast.success { border-left: 3px solid var(--accent); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--blue); }

@keyframes toast-in {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes toast-out {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(120%); opacity: 0; }
}

/* ── Scrollbars Global ───────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .app-layout {
    grid-template-columns: 1fr;
    padding: 12px;
    gap: 12px;
  }
  .panel-fx { max-height: 65vh; }
  .visualizer-container { height: 160px; }
  .logo-text { display: none; }
}

@media (max-width: 600px) {
  .fx-tab { font-size: 0.55rem; letter-spacing: 0.06em; }
  .control-row label { min-width: 80px; }
  .rec-timer { font-size: 0.85rem; }
  .header-status { gap: 6px; }
}

/* ── Accent hover glow on sliders that are active ────────── */
.slider:focus::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px var(--accent-glow);
}
