/* OBS VJ Visualizer - Prescriptive Channel Strip Console Styling */

:root {
  --bg-dark: #000000;
  --panel-bg: #0d0d15;
  --panel-border: rgba(255, 255, 255, 0.08);
  --accent-blue: #e619c9;
  --accent-hover: #f425c2;
  --text-main: #ffffff;
  --text-muted: #a0a0b0;
  --input-bg: #050508;
  --radius: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html, body {
  width: 100%;
  min-height: 100vh;
  background-color: var(--bg-dark);
  color: var(--text-main);
  user-select: none;
  font-size: 13px;
  overflow-x: hidden;
  overflow-y: auto; /* ALLOW SMOOTH VERTICAL SCROLLING WHEN MULTIPLE ROWS ARE EXPANDED */
}

body {
  display: flex;
  flex-direction: column;
  padding: 12px 16px 60px 16px; /* GENEROUS BOTTOM PADDING TO PREVENT LAST ROW CLIPPING */
}

.console-container {
  width: 100%;
  max-width: 1850px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 40px;
}

/* Top Header Bar */
.top-bar {
  background-color: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 48px;
}

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

.brand-icon {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 6px #10b981;
}

h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.subtext {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Master Motion Echo Group */
.master-trail-group {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  padding: 4px 12px;
  border-radius: 5px;
  width: 320px;
}

.trail-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-hover);
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Add Layer Dropdown Menu */
.add-layer-dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 6px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 100;
  min-width: 150px;
  display: flex;
  flex-direction: column;
  padding: 4px;
}

.dropdown-menu.hidden {
  display: none;
}

.dropdown-item {
  background: none;
  border: none;
  color: var(--text-main);
  padding: 8px 12px;
  font-size: 0.82rem;
  text-align: left;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  white-space: nowrap;
}

.dropdown-item:hover {
  background: var(--input-bg);
  color: var(--accent-hover);
}

/* Embedded Interactive Canvas Preview Panel */
.preview-panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  margin-bottom: 12px;
  overflow: hidden;
  transition: all 0.3s ease;
}

.preview-panel.collapsed .preview-container {
  display: none !important;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: rgba(15, 23, 42, 0.6);
  border-bottom: 1px solid var(--panel-border);
}

.preview-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-hover);
  letter-spacing: 0.5px;
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.preview-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.preview-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px;
  background: #020617;
}

#controlPreviewCanvas {
  width: 100%;
  max-width: 640px;
  aspect-ratio: 16 / 9;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  object-fit: contain;
  pointer-events: auto !important;
  touch-action: none;
  cursor: pointer;
  position: relative;
  z-index: 10;
  transition: max-width 0.2s ease-in-out;
}

.preview-panel.expanded #controlPreviewCanvas {
  max-width: 100% !important;
  max-height: 65vh !important;
}

/* Layers Stack Container */
.layers-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 40px; /* ENSURES LAST ROW (BACKGROUND) EXPANDS CLEANLY WITHOUT CLIPPING */
}

/* Drag Handle Icon - Generous 32x32px Touch/Click Target with Hover Feedback */
.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  font-size: 1.1rem;
  color: var(--text-muted);
  cursor: grab;
  border-radius: 6px;
  border: 1px solid transparent;
  user-select: none;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
  flex-shrink: 0;
}

.drag-handle:hover {
  color: var(--accent-hover);
  background-color: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.3);
}

.drag-handle:active {
  cursor: grabbing;
  background-color: rgba(59, 130, 246, 0.25);
}

/* Dragging State Visual Feedback */
.layer-row.dragging {
  opacity: 0.35 !important;
  border: 2px dashed var(--accent-blue) !important;
  background-color: rgba(59, 130, 246, 0.08) !important;
}

/* Drop Target Indicators */
.layer-row.drag-over-above {
  border-top: 3px solid var(--accent-blue) !important;
  box-shadow: 0 -6px 16px rgba(59, 130, 246, 0.4) !important;
}

.layer-row.drag-over-below {
  border-bottom: 3px solid var(--accent-blue) !important;
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4) !important;
}

.layer-row.selected-card {
  border: 2px solid #e619c9 !important;
  box-shadow: 0 0 16px rgba(230, 25, 201, 0.45) !important;
  background-color: rgba(230, 25, 201, 0.04) !important;
}

/* CSS GRID LAYER ROW - COLLAPSED STATE (~110-140PX HEIGHT) */
.layer-row {
  display: grid;
  grid-template-columns: 225px 190px 175px 160px 1fr 44px;
  align-items: start;
  gap: 14px;
  background-color: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 12px 16px;
  min-height: 110px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: background-color 0.25s ease, border-color 0.25s ease, padding 0.25s ease, box-shadow 0.25s ease;
  overflow: visible; /* ENSURE NO CLIPPING OF THUMBS OR SWATCHES */
}

.layer-row.disabled {
  opacity: 0.45;
}

/* EXPANDED ROW STATE - PROPORTIONAL "ZOOM IN" WITH LARGER TARGETS & FONTS */
.layer-row.expanded {
  min-height: 200px;
  height: auto;
  padding: 20px 24px;
  gap: 18px;
  grid-template-columns: 265px 230px 180px 240px 1fr 50px;
  border-color: var(--accent-blue);
  box-shadow: 0 6px 24px rgba(59, 130, 246, 0.2);
  overflow: visible;
}

/* Expanded Column 1: Meta, Name, Badge, Switch, Drag Handle */
.layer-row.expanded .drag-handle {
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  font-size: 1.2rem;
}

.layer-row.expanded .layer-name {
  font-size: 1rem;
  max-width: 140px;
}

.layer-row.expanded .layer-badge {
  font-size: 0.85rem;
  padding: 3px 8px;
}

.layer-row.expanded .switch {
  transform: scale(1.25);
  transform-origin: right center;
}

/* Expanded Labels & Badges */
.layer-row.expanded .control-label {
  font-size: 0.95rem;
}

.layer-row.expanded .label-row {
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.layer-row.expanded .value-badge {
  font-size: 0.9rem;
  padding: 2px 7px;
}

/* Expanded Dropdowns & Selects */
.layer-row.expanded select {
  padding: 9px 12px;
  font-size: 0.95rem;
  border-radius: 6px;
}

/* Expanded File Upload Button */
.layer-row.expanded .file-upload-btn {
  padding: 8px 14px;
  font-size: 0.92rem;
}

/* Expanded Color Swatches & Picker in Column 4 */
.layer-row.expanded input[type="color"] {
  width: 34px;
  height: 34px;
}

.layer-row.expanded .swatch {
  width: 34px;
  height: 34px;
  border-radius: 5px;
}

/* Expanded Parameter Blocks & Range Sliders in Column 5 */
.layer-row.expanded .mini-param-block {
  width: 175px !important;
  max-width: 175px !important;
  padding: 6px 4px;
  gap: 6px;
}

.layer-row.expanded input[type="range"] {
  height: 26px !important;
  max-width: 175px !important;
}

.layer-row.expanded input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 4px;
}

.layer-row.expanded input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 4px;
}

.layer-row.expanded input[type="range"]::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
  margin-top: -7px; /* (8px track - 22px thumb)/2 = -7px offset -> PERFECT CENTER */
  border-width: 3px;
}

.layer-row.expanded input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-width: 3px;
}

/* Expanded Action Buttons in Column 6 */
.layer-row.expanded .action-btn {
  width: 34px;
  height: 34px;
  font-size: 0.95rem;
}

/* Column 1: Meta + Enable Switch */
.col-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  padding-right: 12px;
  height: 100%;
  gap: 8px;
}

.layer-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.layer-badge {
  font-size: 0.72rem;
  font-weight: 800;
  font-family: monospace;
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  color: var(--accent-hover);
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.layer-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 115px;
  transition: font-size 0.2s ease;
  flex-shrink: 1;
}

/* Toggle Switch UI */
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-toggle {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #242938;
  transition: .2s;
  border-radius: 20px;
}

.slider-toggle:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
}

input:checked + .slider-toggle {
  background-color: var(--accent-blue);
}

input:checked + .slider-toggle:before {
  transform: translateX(16px);
}

/* Column 2 & 3: Select Dropdowns / Buttons */
.col-select, .col-blend, .col-fit {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.control-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  transition: font-size 0.2s ease;
}

select {
  width: 100%;
  padding: 5px 8px;
  background-color: var(--input-bg);
  border: 1px solid var(--panel-border);
  border-radius: 5px;
  color: var(--text-main);
  font-size: 0.8rem;
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

select:focus {
  border-color: var(--accent-blue);
}

/* Column 4: Color Swatches & Picker */
.col-color {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.color-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

input[type="color"] {
  -webkit-appearance: none;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  cursor: pointer;
  background: none;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: 1px solid var(--panel-border);
  border-radius: 4px;
}

/* Color Swatches Grid & Long-Press Animation */
.swatches {
  display: flex;
  gap: 4px;
  align-items: center;
}

.swatch {
  position: relative;
  width: 20px;
  height: 20px;
  border-radius: 3px;
  border: 1px solid var(--panel-border);
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  overflow: hidden;
}

.swatch:hover {
  transform: scale(1.15);
  border-color: var(--accent-blue);
}

.swatch.long-pressing {
  transform: scale(1.35) !important;
  box-shadow: 0 0 10px var(--accent-blue), 0 0 16px var(--accent-hover) !important;
  border-color: #ffffff !important;
  z-index: 10;
  transition: transform 0.45s ease-out, box-shadow 0.45s ease-out;
}

.swatch.swatch-editing {
  transform: scale(1.4) !important;
  box-shadow: 0 0 14px #10b981 !important;
  border-color: #10b981 !important;
}

/* Hidden Swatch Picker positioned EXACTLY on top of the swatch box to give Chromium & WebKit exact coordinates */
.swatch-hidden-picker {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  opacity: 0 !important;
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
  cursor: pointer !important;
  pointer-events: none !important;
}

/* Column 5: Parameters Block */
.col-params {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 10px 16px;
  flex-wrap: wrap;
  overflow: visible; /* NO OVERFLOW CLIPPING OF SLIDER THUMBS */
}

.pattern-params-group {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 10px 16px;
  flex-wrap: wrap;
  overflow: visible;
}

/* MINI PARAMETER BLOCK - FIXED MAXIMUM WIDTH WITH PADDING FOR SLIDER THUMBS */
.mini-param-block {
  width: 135px !important;
  max-width: 135px !important;
  flex-shrink: 0 !important;
  flex-grow: 0 !important;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 3px 2px;
  overflow: visible;
  transition: all 0.2s ease;
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: font-size 0.2s ease;
}

.value-badge {
  font-size: 0.7rem;
  font-family: monospace;
  background-color: var(--input-bg);
  padding: 0 4px;
  border-radius: 3px;
  color: var(--accent-hover);
  border: 1px solid var(--panel-border);
  transition: font-size 0.2s ease;
}

/* RANGE SLIDER SPECIFICATION - 100% UNCLIPPED THUMB BOX SIZING */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100% !important;
  max-width: 135px !important;
  height: 18px !important; /* INPUT BOX HEIGHT GREATER THAN THUMB HEIGHT PREVENTS WEBKIT BOX CLIPPING */
  background: transparent !important;
  outline: none;
  margin: 0;
  cursor: pointer;
  transition: all 0.2s ease;
}

/* WebKit Track Styling */
input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 4px;
  background: #242938;
  border-radius: 2px;
  transition: all 0.2s ease;
}

/* Gecko (Firefox) Track Styling */
input[type="range"]::-moz-range-track {
  width: 100%;
  height: 4px;
  background: #242938;
  border-radius: 2px;
  transition: all 0.2s ease;
}

/* WebKit Thumb Styling */
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5px; /* (4px track - 14px thumb)/2 = -5px offset -> PERFECT VERTICAL CENTERING */
  border-radius: 50%;
  background: var(--text-main);
  border: 2px solid var(--accent-blue);
  cursor: pointer;
  transition: all 0.2s ease;
}

/* Gecko Thumb Styling */
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-main);
  border: 2px solid var(--accent-blue);
  cursor: pointer;
  transition: all 0.2s ease;
}

/* Column 6: Action Buttons (Expand + Remove) */
.col-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  justify-content: center;
}

.action-btn {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
}

.expand-btn {
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
}

.expand-btn:hover {
  border-color: var(--accent-blue);
  color: var(--accent-hover);
}

.remove-btn {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #f87171;
}

.remove-btn:hover {
  background: rgba(239, 68, 68, 0.3);
  border-color: #ef4444;
  color: #ffffff;
}

/* File Upload Button */
.file-upload-btn {
  display: inline-block;
  padding: 5px 10px;
  background-color: var(--input-bg);
  border: 1px dashed var(--accent-blue);
  border-radius: 5px;
  color: var(--accent-hover);
  cursor: pointer;
  font-size: 0.78rem;
  text-align: center;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.file-upload-btn:hover {
  background-color: rgba(59, 130, 246, 0.12);
}

/* Buttons */
.btn {
  padding: 5px 12px;
  border-radius: 5px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.btn-secondary {
  background-color: var(--input-bg);
  color: var(--text-main);
  border: 1px solid var(--panel-border);
}

.btn-secondary:hover {
  background-color: #1e2230;
  border-color: var(--accent-blue);
}

.btn-primary {
  background-color: var(--accent-blue);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
}

/* Video Layer Transport Controls */
.btn-transport-sm {
  padding: 4px 8px !important;
  font-size: 0.78rem !important;
  line-height: 1 !important;
  border-radius: 5px !important;
  background: var(--input-bg, #12121a) !important;
  border: 1px solid var(--panel-border, rgba(255, 255, 255, 0.12)) !important;
  color: var(--text-main, #ffffff) !important;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-transport-sm:hover {
  border-color: #e619c9 !important;
  background: #1a1a28 !important;
  box-shadow: 0 0 8px rgba(230, 25, 201, 0.3) !important;
}

.btn-transport-sm.active-pause {
  background: rgba(230, 25, 201, 0.25) !important;
  border-color: #e619c9 !important;
  color: #ffffff !important;
  box-shadow: 0 0 10px rgba(230, 25, 201, 0.4) !important;
}

.video-seek-slider {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: #12121a;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.video-seek-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #e619c9;
  box-shadow: 0 0 8px rgba(230, 25, 201, 0.6);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.video-seek-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #e619c9;
  box-shadow: 0 0 8px rgba(230, 25, 201, 0.6);
  cursor: pointer;
  border: none;
  transition: transform 0.15s ease;
}

.video-seek-slider::-webkit-slider-thumb:hover,
.video-seek-slider::-moz-range-thumb:hover {
  transform: scale(1.25);
}

/* Dedicated Transport Bar Container */
.video-transport-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 10px;
  background: rgba(10, 10, 16, 0.7);
  border: 1px solid rgba(230, 25, 201, 0.25);
  border-radius: 6px;
  margin-top: 8px;
  box-sizing: border-box;
  grid-column: 2 / span 3;
}

.vid-time-badge {
  font-family: monospace;
  font-size: 0.78rem;
  color: #38bdf8;
  white-space: nowrap;
}

.vid-loop-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #e2e8f0;
  cursor: pointer;
  white-space: nowrap;
}


