/* FlyBrain Experiment Studio — Professional DAW / NLE Bottom Layout */
:root {
  --bg-dark: #070a13;
  --bg-panel: #0d1322;
  --bg-card: #131b2e;
  --bg-input: #1a243b;
  --border-subtle: #23314d;
  --border-focus: #38bdf8;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --color-cyan: #38bdf8;
  --color-blue: #0284c7;
  --color-crimson: #ef4444;
  --color-green: #10b981;
  --color-amber: #f59e0b;
  --color-orange: #d97706;
  --color-purple: #a855f7;
  --color-pink: #ec4899;
  --color-slate: #64748b;
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Header */
.studio-header {
  height: 48px;
  background-color: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  z-index: 20;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: #000;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 1px;
  padding: 3px 8px;
  border-radius: 4px;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #fff;
}

.specimen-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: var(--bg-card);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
}

.specimen-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.specimen-select {
  background: var(--bg-input);
  color: #38bdf8;
  border: 1px solid var(--border-subtle);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.specimen-valence-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  font-family: monospace;
  letter-spacing: 0.2px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: all 0.2s ease;
  cursor: help;
}
.valence-neutral { background: rgba(148, 163, 184, 0.15); color: #94a3b8; border: 1px solid rgba(148, 163, 184, 0.3); }
.valence-approach { background: rgba(16, 185, 129, 0.18); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.45); }
.valence-avoidance { background: rgba(239, 68, 68, 0.18); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.45); }

.btn {
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover {
  background: #23314d;
  border-color: #38bdf8;
}
.btn-primary {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #fff;
  border: 1px solid #38bdf8;
}
.btn-primary:hover {
  background: linear-gradient(135deg, #0369a1, #0284c7);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}
.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.3);
  border-color: #ef4444;
}

/* Middle Workspace Split (3D Viewport on Left, Telemetry Sidebar on Right) */
.workspace-middle {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}

.viewport-panel {
  flex: 1;
  position: relative;
  background-color: #030611;
  overflow: hidden;
}

#three-canvas-container {
  width: 100%;
  height: 100%;
  position: relative;
}

.canvas-overlay-stats {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(13, 19, 34, 0.88);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 8px 12px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  line-height: 1.6;
  pointer-events: none;
  z-index: 10;
}

.camera-controls-bar {
  position: absolute;
  bottom: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(13, 19, 34, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--text-dim);
  z-index: 10;
}

/* Telemetry Sidebar */
.telemetry-sidebar {
  width: 380px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-tabs {
  display: flex;
  background-color: var(--bg-dark);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-tab {
  flex: 1;
  padding: 9px 0;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
}
.sidebar-tab:hover {
  color: var(--text-main);
}
.sidebar-tab.active {
  color: var(--color-cyan);
  border-bottom-color: var(--color-cyan);
  background: rgba(56, 189, 248, 0.05);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sidebar-content.hidden {
  display: none;
}

.telemetry-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 8px 10px;
}

.card-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}

/* Gait Stance/Swing Display */
.gait-diagram {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.leg-gait-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  font-family: monospace;
}
.leg-name { width: 22px; color: var(--text-dim); }
.gait-bar-container { flex: 1; height: 11px; background: var(--bg-input); border-radius: 2px; overflow: hidden; position: relative; }
.gait-bar-fill { height: 100%; transition: width 0.05s ease; }
.gait-stance { background: #10b981; }
.gait-swing { background: #475569; }

/* Bottom Timeline Sequencer (Full Width DAW / NLE) */
.timeline-bottom-panel {
  height: 340px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
  z-index: 15;
}

/* VCR Transport Bar */
.vcr-bar {
  height: 44px;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 14px;
  flex-shrink: 0;
}

.vcr-buttons {
  display: flex;
  align-items: center;
  gap: 5px;
}

.vcr-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s ease;
}
.vcr-btn:hover {
  background: var(--bg-input);
  border-color: var(--border-focus);
}
.vcr-btn.active {
  background: var(--color-cyan);
  color: #000;
  border-color: #fff;
}

.scrubber-container {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.scrubber-track {
  flex: 1;
  height: 5px;
  -webkit-appearance: none;
  background: var(--bg-input);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
.scrubber-track::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--color-cyan);
  box-shadow: 0 0 6px var(--color-cyan);
  cursor: pointer;
}

.scrubber-time-badge {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--text-muted);
  min-width: 140px;
}

/* Timeline Controls Toolbar */
.timeline-toolbar {
  height: 40px;
  padding: 0 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 10px;
}

.timeline-toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.preset-select {
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
}

.switch-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-main);
}

/* Selected Block Inspector Bar */
.block-inspector-bar {
  height: 32px;
  background: rgba(56, 189, 248, 0.08);
  border-bottom: 1px solid rgba(56, 189, 248, 0.25);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 11px;
  flex-shrink: 0;
}
.block-inspector-bar.hidden {
  display: none;
}

/* Scrollable Tracks Area */
.timeline-tracks-wrapper {
  flex: 1;
  position: relative;
  overflow-x: auto;
  overflow-y: auto;
  background: var(--bg-dark);
}

.time-ruler {
  height: 20px;
  position: sticky;
  top: 0;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
  margin-left: 170px;
  font-family: monospace;
  font-size: 9px;
  color: var(--text-dim);
  z-index: 10;
}

.time-tick {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  border-left: 1px solid var(--border-subtle);
  height: 100%;
  padding-left: 3px;
}

.tracks-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0 8px 0;
  position: relative;
  min-width: 100%;
}

.track-row {
  display: flex;
  height: 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  position: relative;
}

.track-header {
  width: 170px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: sticky;
  left: 0;
  z-index: 8;
}

.track-body {
  flex: 1;
  position: relative;
  background: repeating-linear-gradient(90deg, transparent, transparent 19px, rgba(255, 255, 255, 0.02) 20px);
  cursor: crosshair;
  min-width: 800px;
}

.stimulus-block {
  position: absolute;
  top: 3px;
  bottom: 3px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  cursor: grab;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  z-index: 5;
}
.stimulus-block:hover {
  border-color: #fff;
}
.stimulus-block.selected {
  border-color: #fff;
  box-shadow: 0 0 8px #38bdf8;
}

.stimulus-block .block-handle-left,
.stimulus-block .block-handle-right {
  width: 6px;
  height: 100%;
  cursor: ew-resize;
  position: absolute;
  top: 0;
}
.stimulus-block .block-handle-left { left: 0; }
.stimulus-block .block-handle-right { right: 0; }

.subtle-input {
  background: rgba(13, 19, 34, 0.7);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: #cbd5e1;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  width: 145px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}
.subtle-input:focus {
  border-color: #38bdf8;
  background: #0d1322;
  color: #fff;
}
.archive-del-btn {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #ef4444;
  border-radius: 3px;
  font-size: 10px;
  padding: 2px 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.archive-del-btn:hover {
  background: #ef4444;
  color: #fff;
}

/* The Red Needle is STRICTLY confined within the timeline-tracks-wrapper and reaches all tracks */
.timeline-needle {
  position: absolute;
  top: 0;
  min-height: 100%;
  width: 2px;
  background: #ef4444;
  box-shadow: 0 0 6px #ef4444;
  pointer-events: none;
  z-index: 12;
}

/* Progress Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-backdrop.hidden { display: none; }

.modal-dialog {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  width: 460px;
  padding: 22px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.8);
}

.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
  margin: 14px 0 10px 0;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #0284c7, #38bdf8);
  width: 0%;
  transition: width 0.1s ease;
}

/* Blender-style 3D Viewport Orientation Gizmo */
.viewport-gizmo-wrapper {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 25;
  pointer-events: auto;
  user-select: none;
}

#viewport-gizmo-canvas {
  width: 96px;
  height: 96px;
  cursor: pointer;
  border-radius: 50%;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}

#viewport-gizmo-canvas:hover {
  box-shadow: 0 6px 22px rgba(56, 189, 248, 0.35);
}

.gizmo-view-pills {
  display: flex;
  gap: 3px;
  background: rgba(15, 23, 42, 0.88);
  padding: 2px 4px;
  border-radius: 12px;
  border: 1px solid rgba(56, 189, 248, 0.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.gizmo-pill {
  background: transparent;
  color: #94a3b8;
  border: none;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.gizmo-pill:hover {
  color: #ffffff;
  background: rgba(56, 189, 248, 0.22);
}

.gizmo-pill.active {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.25);
  font-weight: 700;
  box-shadow: 0 0 6px rgba(56, 189, 248, 0.3);
}
