/* DJ Pro — dark club aesthetic */

:root {
  --bg: #0b0d12;
  --panel: #131722;
  --panel-2: #1a2030;
  --line: #262f45;
  --text: #dfe6f3;
  --dim: #7d8aa5;
  --accent: #27e0b0;   /* deck A / primary */
  --accent-b: #4da3ff; /* deck B */
  --warn: #ff9d3c;
  --hot: #ff4d6b;
}

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

html, body { height: 100%; }

body {
  background: radial-gradient(1200px 500px at 50% -10%, #141b2e 0%, var(--bg) 60%);
  color: var(--text);
  font-family: "SF Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 10px 14px;
  gap: 10px;
}

/* ---------- visualizer layer ---------- */

.viz-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
}

/* App content sits above the visualizer. */
.topbar, .console-grid, .bottom, .footer { position: relative; z-index: 1; }

/* ---------- topbar ---------- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.brand { font-size: 20px; font-weight: 800; letter-spacing: 1px; }
.brand-dj { color: var(--accent); }
.brand-pro { color: var(--accent-b); }
.brand-sub { font-size: 10px; color: var(--dim); letter-spacing: 3px; margin-left: 8px; }

.topbar-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- buttons & inputs ---------- */

.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 12px;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-accent { background: var(--accent); color: #05261c; border-color: var(--accent); }
.btn-accent:hover { color: #05261c; filter: brightness(1.1); }
.btn-toggle.on { background: var(--accent); color: #05261c; border-color: var(--accent); box-shadow: 0 0 14px rgba(39, 224, 176, 0.5); }
.btn.recording { background: var(--hot); border-color: var(--hot); color: #fff; box-shadow: 0 0 14px rgba(255, 77, 107, 0.6); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: 0.7; } }

.select, .num, textarea, input[type="text"], input[type="password"] {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font: inherit;
  font-size: 11px;
}
.num { width: 64px; }
textarea { width: 100%; resize: vertical; }
:focus-visible { outline: 1px solid var(--accent); }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 22px;
  border-radius: 3px;
  background: linear-gradient(180deg, #eef3ff, #9fb2d8);
  border: 1px solid #55627e;
}

/* ---------- main grid ---------- */

.console-grid {
  display: grid;
  grid-template-columns: 1fr 230px 1fr;
  gap: 10px;
  align-items: stretch;
}

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

.panel, .deck, .mixer {
  background: rgba(19, 23, 34, 0.78); /* translucent so the visualizer glows through */
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}

/* ---------- deck ---------- */

.deck { display: flex; flex-direction: column; gap: 8px; }
.deck[data-deck="A"] { --deck-color: var(--accent); }
.deck[data-deck="B"] { --deck-color: var(--accent-b); }

.deck-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.deck-label {
  display: inline-block; /* transforms need a box; this span pulses with the beat */
  font-size: 16px; font-weight: 800; color: var(--deck-color);
  border: 1px solid var(--deck-color); border-radius: 6px; padding: 1px 9px;
  will-change: transform;
}
.deck-title { font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck-meta { color: var(--dim); font-size: 10px; white-space: nowrap; }

.waveform { width: 100%; height: 84px; background: #0d1119; border: 1px solid var(--line); border-radius: 6px; cursor: crosshair; }

.deck-time { display: flex; justify-content: space-between; color: var(--dim); font-size: 10px; }
.deck-bpm { color: var(--deck-color); font-weight: 700; }

.transport { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.transport .btn.playing { background: var(--deck-color); color: #041613; border-color: var(--deck-color); }
.transport .btn.active { background: var(--warn); border-color: var(--warn); color: #2b1600; }

.tempo-row { display: flex; align-items: center; gap: 8px; font-size: 10px; color: var(--dim); }
.tempo-row input[type="range"] { flex: 1; }

.deck-mixer {
  display: flex; align-items: flex-end; justify-content: space-around; gap: 6px;
  border-top: 1px dashed var(--line); padding-top: 8px;
}
.knob-group { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.knob-group label { font-size: 9px; color: var(--dim); letter-spacing: 1px; }

.knob {
  width: 40px; height: 40px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #2c3550, #1a2030 70%);
  border: 2px solid var(--line);
  position: relative;
  cursor: ns-resize;
  touch-action: none;
}
.knob:hover { border-color: var(--deck-color, var(--accent)); }
.knob-indicator {
  position: absolute; left: 50%; top: 3px;
  width: 3px; height: 12px; border-radius: 2px;
  background: var(--deck-color, var(--accent));
  transform-origin: 50% 17px;
  transform: translateX(-50%) rotate(var(--rot, 0deg));
}

.vol-group { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.vol-group input[type="range"] {
  writing-mode: vertical-lr; direction: rtl;
  width: 8px; height: 76px;
}

/* ---------- mixer (center) ---------- */

.mixer { display: flex; flex-direction: column; gap: 10px; }
.mixer-title { text-align: center; font-size: 10px; letter-spacing: 3px; color: var(--dim); }
.spectrum { width: 100%; height: 110px; background: #0d1119; border: 1px solid var(--line); border-radius: 6px; }

.master-vol-row { display: flex; align-items: center; gap: 8px; font-size: 9px; color: var(--dim); }
.master-vol-row input { flex: 1; }

.crossfader-wrap { margin-top: auto; }
.xf-labels { display: flex; justify-content: space-between; font-size: 9px; color: var(--dim); margin-bottom: 4px; }
.xf-labels span:first-child { color: var(--accent); font-weight: 800; }
.xf-labels span:last-child { color: var(--accent-b); font-weight: 800; }
#crossfader { width: 100%; }

.mixer-hint { text-align: center; font-size: 9px; color: var(--dim); min-height: 12px; }

/* ---------- bottom panels ---------- */

.bottom {
  display: grid;
  grid-template-columns: 1.1fr 1.2fr 0.9fr;
  gap: 10px;
  flex: 1;
  min-height: 210px;
}
@media (max-width: 980px) { .bottom { grid-template-columns: 1fr; } }

.panel-title { font-size: 10px; letter-spacing: 2px; color: var(--dim); margin-bottom: 8px; }

.generator { display: flex; flex-direction: column; gap: 8px; }
.gen-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.gen-controls label { display: flex; flex-direction: column; gap: 3px; font-size: 9px; color: var(--dim); }
.energy-label input { width: 90px; }
.gen-source { font-size: 9px; color: var(--dim); }

.library { display: flex; flex-direction: column; min-height: 0; }
.library-list { overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.lib-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 8px; font-size: 11px;
}
.lib-row.queued { border-color: var(--warn); }
.lib-info { flex: 1; min-width: 0; }
.lib-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-meta { color: var(--dim); font-size: 9px; }
.lib-actions { display: flex; gap: 4px; }
.lib-actions .btn { padding: 3px 7px; font-size: 9px; }
.lib-empty { color: var(--dim); font-size: 11px; padding: 12px; text-align: center; }

.ai-console { display: flex; flex-direction: column; min-height: 0; }
.console-log { overflow-y: auto; flex: 1; font-size: 10px; line-height: 1.7; }
.console-line { border-bottom: 1px solid rgba(38, 47, 69, 0.4); padding: 2px 0; }
.console-time { color: var(--dim); margin-right: 8px; font-size: 9px; }

.footer { text-align: center; color: var(--dim); font-size: 9px; padding: 2px; }
.footer b { color: var(--text); }

/* ---------- modal ---------- */

.modal {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0;
  max-width: 460px;
  width: 92vw;
}
.modal::backdrop { background: rgba(4, 6, 10, 0.7); backdrop-filter: blur(3px); }
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.modal h2 { font-size: 15px; }
.modal-note { font-size: 10px; color: var(--dim); line-height: 1.6; }
.modal-field { display: flex; flex-direction: column; gap: 4px; font-size: 10px; color: var(--dim); }
.modal-row { display: flex; align-items: center; gap: 10px; font-size: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
#test-result { font-size: 10px; }
#test-result.ok { color: var(--accent); }
#test-result.err { color: var(--hot); }

/* generating state */
.btn.busy { position: relative; color: transparent; }
.btn.busy::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(5, 38, 28, 0.4); border-top-color: #05261c;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
