/* ============================================================
   Recordings — STUDIO content pipeline.
   Ported from the legacy single-file build, re-housed in the new
   Lenny OS shell. Outer container lightly restyled to the new
   design system; the toolbar/stats/grid/card/modal internals are
   the legacy components, recolored to the mint house accent and
   wired to the new tokens via legacy-var fallbacks.

   Scoped under #view-recordings where practical. The three modals
   are appended to <body>, so their .modal-backdrop / .modal / .modal-*
   class names live at the top level (they're unique to this feature)
   and also pull from the same legacy-var fallback block.
   ============================================================ */

/* ── Legacy-var fallback block. The legacy markup references --surface,
   --bg-deep, --text2, --gold-soft, etc. base.css only aliases a few of
   these, so define the rest here, mapped to the new tokens. Applied to
   the recordings view AND the body-level modal holder so both surfaces
   resolve identically. ─────────────────────────────────────────────── */
#view-recordings,
#rec-modals {
  --surface:    var(--card, #1E293B);
  --surface2:   var(--card-hover, #243044);
  --surface3:   var(--bg-elevated, #161B22);
  --bg-deep:    #0d1219;
  --text2:      var(--text-muted, #C9D1D9);
  --text3:      var(--text-faint, #8B949E);
  --border2:    var(--border-light, #3d4550);

  --gold-soft:  var(--gold-dim, rgba(245,184,66,0.15));
  --gold-deep:  rgba(245, 184, 66, 0.45);
  --gold-bright:#ffc95a;

  --mint-soft:  var(--teal-glow, rgba(95,176,137,0.12));
  --mint-deep:  rgba(95, 176, 137, 0.45);

  --coral:      #e87a5f;
}

/* ── Toolbar ─────────────────────────────────────────────────── */
#view-recordings .recordings-toolbar {
  display: flex; align-items: center; gap: 12px; margin-bottom: 24px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px;
}
#view-recordings .toolbar-search {
  flex: 1; min-width: 200px; background: var(--bg-deep); border: 1px solid var(--border);
  color: var(--text); padding: 9px 14px; border-radius: var(--radius);
  font-family: var(--font-body, 'Inter', sans-serif); font-size: 13px;
}
#view-recordings .toolbar-search::placeholder { color: var(--text3); }
#view-recordings .toolbar-search:focus { outline: none; border-color: var(--mint); box-shadow: 0 0 0 3px var(--mint-soft); }
#view-recordings .toolbar-btn {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 10px; font-weight: 500;
  letter-spacing: 0.15em; text-transform: uppercase; padding: 9px 14px; border-radius: var(--radius);
  cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
#view-recordings .toolbar-btn:hover { border-color: var(--mint); color: var(--mint); }
#view-recordings .toolbar-btn.primary { background: var(--gold-soft); border-color: var(--gold); color: var(--gold); }
#view-recordings .toolbar-btn.primary:hover { background: var(--gold); color: var(--bg-deep); }
#view-recordings .toolbar-btn.export { background: var(--mint-soft); border-color: var(--mint); color: var(--mint); }
#view-recordings .toolbar-btn.export:hover { background: var(--mint); color: #06231b; }

/* ── Stats strip ─────────────────────────────────────────────── */
#view-recordings .recordings-stats { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
#view-recordings .rstat {
  background: var(--surface); border: 1px solid var(--border); padding: 8px 14px; border-radius: var(--radius);
  display: flex; gap: 8px; align-items: center; font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 11px;
}
#view-recordings .rstat-label { color: var(--text3); letter-spacing: 0.15em; text-transform: uppercase; font-size: 9px; }
#view-recordings .rstat-value { color: var(--text); font-weight: 600; }
#view-recordings .rstat-value.gold { color: var(--gold); }
#view-recordings .rstat-value.mint { color: var(--mint); }
#view-recordings .rstat-value.coral { color: var(--coral); }

/* ── Selection bar ───────────────────────────────────────────── */
#view-recordings .selection-bar {
  display: none; align-items: center; justify-content: space-between; background: var(--gold-soft);
  border: 1px solid var(--gold); padding: 12px 18px; border-radius: var(--radius); margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
#view-recordings .selection-bar.active { display: flex; }
#view-recordings .selection-info { font-family: var(--font-display, 'Chakra Petch', sans-serif); font-size: 13px; color: var(--gold); font-weight: 600; letter-spacing: 0.1em; }
#view-recordings .selection-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Sync banner ─────────────────────────────────────────────── */
#view-recordings .sync-banner {
  background: var(--surface2); border: 1px solid var(--gold-deep); color: var(--gold);
  padding: 10px 18px; border-radius: var(--radius); margin-bottom: 18px;
  font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 11px; letter-spacing: 0.05em; display: none;
}
#view-recordings .sync-banner.show { display: block; }
#view-recordings .sync-banner.error { border-color: var(--coral); color: var(--coral); }
#view-recordings .sync-banner.success { border-color: var(--mint); color: var(--mint); }

/* ── Grid + cards ────────────────────────────────────────────── */
#view-recordings .recordings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
#view-recordings .recording-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; position: relative; transition: all 0.2s; display: flex; flex-direction: column; gap: 12px;
}
#view-recordings .recording-card.selected { border-color: var(--gold); background: var(--surface2); }
#view-recordings .recording-card::before,
#view-recordings .recording-card::after {
  content: ''; position: absolute; width: 12px; height: 12px; border-color: var(--gold-deep);
  transition: all 0.3s; pointer-events: none;
}
#view-recordings .recording-card::before { top: 5px; left: 5px; border-top: 1px solid; border-left: 1px solid; }
#view-recordings .recording-card::after { bottom: 5px; right: 5px; border-bottom: 1px solid; border-right: 1px solid; }
#view-recordings .recording-card:hover::before,
#view-recordings .recording-card:hover::after { width: 18px; height: 18px; border-color: var(--gold); }

#view-recordings .rec-row1 { display: flex; align-items: flex-start; gap: 12px; }
#view-recordings .rec-checkbox {
  width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px; border: 1.5px solid var(--border2);
  border-radius: 3px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; background: var(--bg-deep);
}
#view-recordings .rec-checkbox:hover { border-color: var(--gold); }
#view-recordings .rec-checkbox.checked { background: var(--gold); border-color: var(--gold); }
#view-recordings .rec-checkbox.checked::after { content: '✓'; color: var(--bg-deep); font-size: 12px; font-weight: 700; }
#view-recordings .rec-thumb {
  width: 60px; height: 38px; flex-shrink: 0; background: var(--bg-deep); border: 1px solid var(--border);
  border-radius: 3px; display: flex; align-items: center; justify-content: center; color: var(--text3); font-size: 18px;
}
#view-recordings .rec-meta { flex: 1; min-width: 0; }
#view-recordings .rec-title {
  font-family: var(--font-display, 'Chakra Petch', sans-serif); font-size: 14px; font-weight: 600; color: var(--text);
  letter-spacing: 0.02em; line-height: 1.3; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#view-recordings .rec-filename { font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 10px; color: var(--text3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#view-recordings .rec-info-row { display: flex; flex-wrap: wrap; gap: 10px; font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 10px; color: var(--text2); letter-spacing: 0.05em; }
#view-recordings .rec-info-row .sep { color: var(--text3); }
#view-recordings .rec-status-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#view-recordings .rec-status { font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 9px; letter-spacing: 0.2em; text-transform: uppercase; padding: 3px 9px; border-radius: 8px; font-weight: 600; }
#view-recordings .rec-status.unedited { background: rgba(232, 122, 95, 0.15); color: var(--coral); }
#view-recordings .rec-status.in-progress { background: var(--gold-soft); color: var(--gold); }
#view-recordings .rec-status.published { background: var(--mint-soft); color: var(--mint); }
#view-recordings .rec-status.archived { background: var(--surface3); color: var(--text2); }
#view-recordings .rec-project-tag { font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 9px; letter-spacing: 0.15em; text-transform: uppercase; padding: 3px 9px; border-radius: 8px; }
#view-recordings .rec-project-tag.unassigned { background: transparent; border: 1px dashed var(--border2); color: var(--text3); }
#view-recordings .rec-notes {
  font-family: var(--font-body, 'Inter', sans-serif); font-size: 12px; color: var(--text2); line-height: 1.5;
  padding: 8px 10px; background: var(--bg-deep); border-left: 2px solid var(--border); border-radius: 2px; min-height: 36px;
}
#view-recordings .rec-notes:empty::before { content: 'No notes yet — click Edit to add'; color: var(--text3); font-style: italic; }
#view-recordings .rec-checklist { display: flex; gap: 6px; flex-wrap: wrap; padding-top: 8px; border-top: 1px solid var(--border); }
#view-recordings .checklist-step {
  font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 4px 9px; border-radius: 8px; background: var(--bg-deep); color: var(--text3); border: 1px solid var(--border);
  cursor: pointer; transition: all 0.15s; display: flex; align-items: center; gap: 4px;
}
#view-recordings .checklist-step:hover { border-color: var(--gold-deep); color: var(--text2); }
#view-recordings .checklist-step.done { background: var(--mint-soft); color: var(--mint); border-color: var(--mint-deep); }
#view-recordings .checklist-step.done::before { content: '✓'; font-weight: 700; }
#view-recordings .rec-actions { display: flex; gap: 6px; flex-wrap: wrap; padding-top: 6px; }
#view-recordings .rec-btn {
  background: transparent; border: 1px solid var(--border2); color: var(--text2);
  font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 9px; letter-spacing: 0.15em; text-transform: uppercase;
  padding: 5px 10px; border-radius: var(--radius); cursor: pointer; transition: all 0.2s; flex: 1; min-width: 0;
}
#view-recordings .rec-btn:hover { border-color: var(--mint); color: var(--mint); }

/* readonly-mode dimming (kept for parity; READONLY=false by default) */
body.readonly #view-recordings .rec-checkbox,
body.readonly #view-recordings .checklist-step,
body.readonly #view-recordings .rec-btn[data-edit],
body.readonly #view-recordings .toolbar-btn[data-edit] { opacity: 0.5; pointer-events: none; }

/* ── Section headers (renamed from legacy .section-* to rec-section-*
   to avoid colliding with base.css .section-title). ──────────────── */
#view-recordings .recordings-section { margin-bottom: 28px; }
#view-recordings .rec-section-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
#view-recordings .rec-section-title { font-family: var(--font-display, 'Chakra Petch', sans-serif); font-size: 16px; font-weight: 600; color: var(--text); letter-spacing: 0.05em; text-transform: uppercase; }
#view-recordings .rec-section-title.gold { color: var(--gold); }
#view-recordings .rec-section-title.mint { color: var(--mint); }
#view-recordings .rec-section-title.coral { color: var(--coral); }
#view-recordings .rec-section-count { font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 11px; color: var(--text3); margin-left: auto; }

@media (max-width: 760px) {
  #view-recordings .recordings-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   MODALS — appended to <body> (#rec-modals). Class names kept from
   the legacy build (unique to this feature). Vars resolve via the
   fallback block at the top.
   ============================================================ */
#rec-modals .modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(5, 10, 20, 0.85); z-index: 2000; align-items: center; justify-content: center; padding: 20px; }
#rec-modals .modal-backdrop.active { display: flex; }
#rec-modals .modal {
  background: var(--surface); border: 1px solid var(--gold); border-radius: var(--radius); padding: 28px;
  max-width: 560px; width: 100%; max-height: 85vh; overflow-y: auto; position: relative;
}
#rec-modals .modal::before,
#rec-modals .modal::after { content: ''; position: absolute; width: 18px; height: 18px; border-color: var(--gold); }
#rec-modals .modal::before { top: 8px; left: 8px; border-top: 1.5px solid; border-left: 1.5px solid; }
#rec-modals .modal::after { bottom: 8px; right: 8px; border-bottom: 1.5px solid; border-right: 1.5px solid; }
#rec-modals .modal-title { font-family: var(--font-display, 'Chakra Petch', sans-serif); font-size: 18px; font-weight: 700; color: var(--gold); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 18px; }
#rec-modals .modal-label { display: block; font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 10px; color: var(--text3); letter-spacing: 0.2em; text-transform: uppercase; margin-bottom: 6px; margin-top: 14px; }
#rec-modals .modal-input,
#rec-modals .modal-select,
#rec-modals .modal-textarea {
  width: 100%; background: var(--bg-deep); border: 1px solid var(--border); color: var(--text);
  padding: 10px 14px; border-radius: var(--radius); font-family: var(--font-body, 'Inter', sans-serif); font-size: 13px;
}
#rec-modals .modal-textarea { min-height: 90px; resize: vertical; }
#rec-modals .modal-input:focus,
#rec-modals .modal-select:focus,
#rec-modals .modal-textarea:focus { outline: none; border-color: var(--gold); }
#rec-modals .modal-actions { display: flex; gap: 10px; margin-top: 22px; justify-content: flex-end; flex-wrap: wrap; }
#rec-modals .modal-btn {
  background: var(--gold); color: #1a1406; border: none; font-family: var(--font-display, 'Chakra Petch', sans-serif);
  font-size: 11px; font-weight: 600; letter-spacing: 0.15em; text-transform: uppercase; padding: 10px 20px;
  border-radius: var(--radius); cursor: pointer; transition: all 0.2s;
}
#rec-modals .modal-btn:hover { background: var(--gold-bright); }
#rec-modals .modal-btn.secondary { background: transparent; color: var(--text2); border: 1px solid var(--border2); }
#rec-modals .modal-btn.secondary:hover { border-color: var(--text); color: var(--text); }
