/* RF TOOLS — page Analyse spectrale (façade d'instrument de mesure)
   Voir docs/superpowers/specs/2026-07-19-rf-tools-phase1-ui-notes.md */

.rft-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 10px;
}
.rft-page h2 { font-size: 16px; }

.rft-cols {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: 12px;
}

/* Rail devices — 220px fixe (§1) */
.rft-side {
  flex: 0 0 220px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-surface);
  border-radius: 6px;
  padding: 8px;
  overflow-y: auto;
}

.rft-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px; /* Task 2 : espace entre instruments empilés */
}

.rft-placeholder {
  flex: 1;
  min-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  color: var(--text-dim);
  font-size: 13px;
  background: var(--bg-surface);
  border-radius: 6px;
  border: 1px dashed var(--border);
}

.rft-empty {
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
  padding: 20px 10px;
}

/* Cartes device — structure §5 : fond --bg-group, radius 6px, LED + nom 13px + sous-ligne mono 10px */
.rft-dev {
  background: var(--bg-group);
  border-radius: 6px;
  padding: 10px;
  border-left: 3px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rft-dev-head {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rft-dev-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: break-word;
}

.rft-dev-sub {
  font-size: 10px;
  color: var(--text-dim);
  font-family: ui-monospace, 'SF Mono', 'Cascadia Mono', 'Consolas', monospace;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rft-led {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.rft-led-green { background: radial-gradient(circle, #66cc6a, #43a047); box-shadow: 0 0 6px rgba(67,160,71,0.6), inset 0 1px 1px rgba(255,255,255,0.2); }
.rft-led-grey  { background: radial-gradient(circle, #8a9096, #5a6066); }
.rft-led-amber { background: radial-gradient(circle, #ffdd8a, #ffd166); box-shadow: 0 0 4px rgba(255,209,102,0.5); }
.rft-led-off   { background: #4a4d50; }

.rft-badge {
  flex-shrink: 0;
  font-size: 9px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: .3px;
}
.rft-badge-active { color: var(--primary); background: rgba(229,0,109,0.15); text-transform: uppercase; }
.rft-badge-unsupported { color: #ffd166; background: rgba(255,209,102,0.12); }

/* État 1 : session en cours (Task 10) */
.rft-dev-active { border-left-color: var(--primary); }

/* État 2 : branché, supporté, inactif — cliquable */
.rft-dev-idle { cursor: pointer; }
.rft-dev-idle:hover { background: rgba(255,255,255,0.05); }

/* État 3 : branché, non supporté */
.rft-dev-unsupported { opacity: 0.55; cursor: default; }

/* État 4 : débranché (connu puis retiré) */
.rft-dev-gone { opacity: 0.4; cursor: default; }

.rft-btn {
  align-self: flex-start;
  margin-top: 2px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.rft-btn:hover { background: var(--primary-dark); }

/* --- Écran instrument (spectre + axe partagé + waterfall) — §1/§3 ---------------- */
.rft-instrument {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 300px; /* Task 2 : plancher par instrument quand plusieurs sont empilés */
  min-width: 0;
  gap: 10px;
}

.rft-screen {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 260px; /* Task 2 : réduit (420px mono-session) pour laisser tenir plusieurs instruments */
  background: #050608;
  border: 1px solid #000;
  border-radius: 6px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  cursor: grab; /* Task 4 : pan souris/tactile */
  touch-action: none; /* pan au doigt géré via pointer events, pas le scroll natif */
}
.rft-screen.rft-panning { cursor: grabbing; }

/* Piège vérifié au mockup : min-height:0 obligatoire sur les 3 canvas (sinon l'aspect-ratio
   intrinsèque d'un <canvas> en flex column gonfle l'axe et écrase le waterfall). */
.rft-spec { flex: 2 1 0; min-height: 0; width: 100%; display: block; }
.rft-axis { flex: 0 0 18px; height: 18px; min-height: 0; width: 100%; display: block; }
.rft-wf   { flex: 3 1 0; min-height: 0; width: 100%; display: block; }
.rft-screen canvas { will-change: transform; } /* translation GPU (pan) sans repaint des voisins */

/* Offset manuel −/+/Auto (§2) : posés sur l'écran mais SANS magenta (discipline écran) */
.rft-scale-tools {
  position: absolute;
  top: 6px;
  right: 8px;
  display: flex;
  gap: 4px;
  z-index: 2;
}
.rft-scale-btn {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  cursor: pointer;
  font-family: ui-monospace, 'SF Mono', 'Cascadia Mono', Consolas, monospace;
}
.rft-scale-btn:hover { background: rgba(255, 255, 255, 0.12); color: var(--text); }
.rft-scale-btn.rft-scale-auto-active {
  color: #7fd4ff;
  border-color: rgba(127, 212, 255, 0.5);
  background: rgba(127, 212, 255, 0.08);
}

/* --- Barre de commandes (§1) ------------------------------------------------------ */
.rft-bar {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  background: var(--bg-group);
  border-radius: 6px;
  padding: 10px 14px;
  flex-wrap: wrap;
}

.rft-field { display: flex; flex-direction: column; gap: 3px; }

.rft-field select,
.rft-field input[type="number"] {
  font-family: ui-monospace, 'SF Mono', 'Cascadia Mono', Consolas, monospace;
  font-variant-numeric: tabular-nums;
  background: #1c1e21;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 12px;
  width: 100px;
}
.rft-field select:focus,
.rft-field input[type="number"]:focus { border-color: var(--primary); outline: none; }

.rft-inline { display: flex; align-items: center; gap: 4px; }
.rft-inline input[type="number"] { width: 80px; }
.rft-unit { font-size: 9px; color: var(--text-dim); }

/* Readout — afficheur instrument, seul gros texte de la page (§4) */
.rft-readout {
  margin-left: auto;
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-family: ui-monospace, 'SF Mono', 'Cascadia Mono', Consolas, monospace;
  font-variant-numeric: tabular-nums;
}
.rft-readout-val { font-size: 26px; font-weight: 600; color: var(--text); }
.rft-readout-unit { font-size: 11px; color: var(--text-dim); }

.rft-btn-stop {
  background: var(--bg-surface);
  color: var(--text);
  border: 1px solid var(--primary);
}
.rft-btn-stop:hover { background: rgba(229, 0, 109, 0.15); }

/* Mobile ≤768px (§6) : rail en rangée horizontale de chips, jamais de débordement page */
@media (max-width: 768px) {
  .rft-cols { flex-direction: column; }
  .rft-side {
    flex: 0 0 auto;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .rft-dev {
    flex: 0 0 auto;
    min-width: 150px;
    max-width: 220px;
  }
  .rft-placeholder { min-height: 200px; }

  /* Écran : hauteurs fixes, le waterfall garde la priorité de surface (§6) */
  .rft-screen { min-height: 0; }
  .rft-spec { flex: 0 0 160px; }
  .rft-axis { flex: 0 0 18px; }
  .rft-wf { flex: 0 0 40vh; }

  /* 2 instruments empilés (Task 2) : waterfall réduit à 30vh (sinon page interminable) */
  .rft-main:has(.rft-instrument:nth-child(2)) .rft-wf { flex: 0 0 30vh; }

  /* Barre de commandes : rangée 1 = 4 colonnes égales (Centre/Gain/BP/FPS),
     rangée 2 = readout réduit + bouton pleine largeur, tactile 44px min */
  .rft-field { flex: 1 1 40%; min-width: 0; }
  .rft-field select,
  .rft-field input[type="number"] { width: 100%; }
  .rft-inline input[type="number"] { width: 100%; }
  .rft-readout { order: 5; flex: 1 1 auto; margin-left: 0; }
  .rft-readout-val { font-size: 18px; }
  .rft-btn-stop { order: 6; flex: 1 1 100%; min-height: 44px; }
}

/* --- Display modes (Task 3) ------------------------------------------------------- */
/* Default: both modes — spec 2/5, axis 18px, wf 3/5 (already set above) */

/* Spectrum only — waterfall hidden, spectrum fills */
.rft-mode-spec .rft-wf { display: none; }
.rft-mode-spec .rft-spec { flex: 1 1 auto; }

/* Waterfall only — spectrum hidden, waterfall fills */
.rft-mode-wf .rft-spec { display: none; }
.rft-mode-wf .rft-wf { flex: 1 1 auto; }

/* Display mode selector — overlay top-right (Task 3: moved from flex flow to absolute positioning) */
.rft-view-tools {
  position: absolute;
  top: 6px;
  right: 112px; /* Positioned left of .rft-scale-tools with 8px gap (measured: scale w=96 right=8, view w=78) */
  display: flex;
  gap: 4px;
  z-index: 2;
}

/* View buttons styling — same as scale buttons, active has cyan highlight */
.rft-view-btn { /* margin-left removed: flex gap handles spacing */ }
.rft-view-btn.rft-view-active {
  color: #7fd4ff;
  border-color: rgba(127, 212, 255, 0.5);
  background: rgba(127, 212, 255, 0.08);
}
