/* ============================================
   Lights Screen — Dedicated lighting layout
   ============================================
   Row 1: Control strip (full width, 40% height)
   Row 2: Wide 3-bank pad view (60% height)
   ============================================ */

/* ---- Content wrapper ---- */
#lights-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  gap: 4px;
  padding: 4px;
}

/* ---- Row layout ---- */
.lights-row1 {
  flex: 0 0 40%;
  display: flex;
  gap: 4px;
  min-height: 0;
}

.lights-row2 {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* ---- Panel base ---- */
.lights-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  overflow: hidden;
}

.lights-panel-inner {
  position: absolute;
  inset: 4px;
  display: flex;
  flex-direction: column;
}

/* Panel label */
.lights-panel-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  text-align: center;
  padding: 3px 4px 4px;
  margin-bottom: 3px;
  border-bottom: 1px solid var(--border-dim);
  flex-shrink: 0;
}

/* ---- Control panels row — natural size, centered ---- */
.lights-controls {
  display: flex;
  flex-direction: row;
  gap: 6px;
  flex: 1;
  min-width: 0;
  justify-content: center;
}

/* Control panels need position:relative for .lights-panel-inner (absolute inset) */
.lp-laser,
.lp-fade,
.lp-master,
.lp-knobs {
  position: relative;
}

/* ---- Laser panel ---- */
.lp-laser {
  flex: 0 0 120px;
}

.lights-laser-layout {
  flex: 1;
  display: flex;
  gap: 8px;
  min-height: 0;
  padding: 4px;
}

.lights-laser-buttons {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  min-height: 0;
}

.lights-laser-buttons .laser-btn {
  flex: 1;
  min-height: 0;
  font-size: clamp(8px, 0.7vw, 11px);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.lights-laser-fx {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: stretch;
}

.lights-laser-fx .fader-wrapper {
  width: auto;
}

/* ---- Fade panel ---- */
.lp-fade {
  flex: 0 0 210px;
}

.lights-fade-layout {
  flex: 1;
  display: flex;
  gap: 8px;
  min-height: 0;
  padding: 4px;
}

.lights-fade-controls {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  align-items: center;
}

/* Center the ON button and displays within fade controls */
.lp-fade .console-fade-onoff {
  width: 90%;
  max-width: 130px;
}
.lp-fade .console-fade-display {
  width: 90%;
  max-width: 130px;
  text-align: center;
}
.lp-fade .console-fade-beat-label {
  text-align: center;
  width: 100%;
}

.lights-fade-fader {
  flex: 0 0 48px;
  display: flex;
  align-items: stretch;
  justify-content: center;
  min-width: 0;
}

/* Beat grid — reuse console-beat-btn styles */
.lights-fade-beat-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  gap: 4px;
  min-height: 0;
  min-width: 120px;
  width: 100%;
}

.lights-beat-btn {
  font-size: clamp(9px, 0.8vw, 12px);
  font-weight: 600;
  color: var(--text-dim);
  background: var(--bg-element);
  border: 1px solid var(--border-dim);
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 0;
}

.lights-beat-btn:hover {
  border-color: var(--border-bright);
  color: var(--text-secondary);
}

.lights-beat-btn.active {
  background: rgba(68, 204, 68, 0.15);
  border-color: rgba(68, 204, 68, 0.5);
  color: #44cc44;
}

/* ---- Master panel ---- */
.lp-master {
  flex: 0 0 auto;
}

.lp-master > .lights-panel-inner {
  position: relative;
  inset: auto;
  padding: 4px;
  height: 100%;
  box-sizing: border-box;
}

.lights-master-faders {
  flex: 1;
  display: flex;
  gap: 19px;
  padding: 0 19px 4px;
  align-items: stretch;
  justify-content: center;
  min-height: 0;
}

#screen-lighting .lights-master-faders .fader-wrapper {
  flex: 0 0 48px;
}

/* ---- Knobs panel ---- */
.lp-knobs {
  flex: 0 0 auto;
}

/* Knobs inner: in-flow horizontally (so parent shrink-wraps width)
   but stretches to full row height */
.lp-knobs > .lights-panel-inner {
  position: relative;
  inset: auto;
  padding: 4px;
  height: 100%;
  box-sizing: border-box;
}

.lights-knobs-layout {
  display: flex;
  gap: 19px;
  flex-direction: row;
  justify-content: center;
}

/* Banks shrink to fit content instead of stretching */
#screen-lighting .console-knob-bank {
  flex: 0 0 auto;
}

/* Breathing room between knobs within each bank */
#screen-lighting .console-knob-bank-faders {
  gap: 19px;
  padding: 0 19px 4px;
  justify-content: center;
}

#screen-lighting .console-knob-bank-faders .knob-wrapper {
  flex: 0 0 48px;
}

/* ---- Pads panel ---- */
.lp-pads-r2 {
  flex: 1;
  min-width: 0;
  display: flex;
}

/* Shared pads layout — reuses console classes for row labels and headers */
.lights-pads-layout {
  flex: 1;
  display: flex;
  align-items: stretch;
  padding: 4px;
  min-width: 0;
}

.lights-pads-col-labels {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width: 26px;
}

.lights-pads-labels-spacer {
  height: 20px;
  flex-shrink: 0;
}

.lights-pads-row-labels {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lights-pads-col-banks {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.lights-pads-header-row {
  display: flex;
  align-items: center;
  height: 20px;
  flex-shrink: 0;
}

.lights-pads-scroll-arrow {
  width: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--accent-text);
  cursor: pointer;
  user-select: none;
  opacity: 0.5;
  flex-shrink: 0;
}

.lights-pads-scroll-arrow:hover { opacity: 1; }
.lights-pads-scroll-arrow.disabled { opacity: 0.15; pointer-events: none; }

.lights-pads-bank-headers {
  flex: 1;
  display: flex;
  gap: 8px;
}

.lights-pads-grids-area {
  flex: 1;
  display: flex;
  min-height: 0;
}

.lights-pads-arrow-spacer {
  width: 22px;
  flex-shrink: 0;
}

.lights-pad-grids-wrapper {
  flex: 1;
  display: flex;
  gap: 6px;
  justify-content: center;
  align-items: center;
  min-height: 0;
}

/* Pad grid overrides inside lights screen */
#screen-lighting .pad-grid {
  flex: 0 0 auto;
  display: grid;
  grid-template-rows: repeat(4, 1fr);
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-dim);
  border-radius: 4px;
  padding: 4px;
  overflow: hidden;
  width: var(--grid-size);
  height: var(--grid-size);
}

#screen-lighting .pad-grid .grid-bank-label {
  display: none;
}

#screen-lighting .pad-row {
  display: contents;
}

#screen-lighting .pad {
  aspect-ratio: 1;
  width: 100%;
  height: auto;
  max-height: 100%;
  flex: none;
  min-width: 0;
  min-height: 0;
}

/* ---- Fader/knob overrides: uniform double-width + fill height ---- */
#screen-lighting .fader-wrapper {
  min-height: 0;
}

#screen-lighting .fader-track {
  width: 48px;
}

#screen-lighting .knob-wrapper {
  flex: 1;
  min-height: 0;
}

#screen-lighting .fader-track {
  height: auto;
  flex: 1;
  min-height: 30px;
}

#screen-lighting .knob-slider-track {
  width: 48px;
  height: auto;
  flex: 1;
  min-height: 30px;
}

/* Knob labels: same 2-line treatment as console */
#screen-lighting .console-knob-bank-faders .knob-label {
  white-space: normal;
  line-height: 1.1;
  max-width: none;
  font-size: 9px;
  text-align: center;
  word-break: break-word;
  hyphens: auto;
  min-height: calc(9px * 1.1 * 2);
  display: flex;
  align-items: center;
  justify-content: center;
}
