/* Completed Training — one card per practice chain, one block per section.
 *
 * Everything is namespaced .ct-* so nothing leaks into the rest of the CRM.
 * Visual language follows change-requests.css and social-channels.css: white
 * cards on a light page, 1px #e2e8f0 borders, 10-12px radii, 999px pills,
 * uppercase 11px column labels. Global custom props come from ui/css/styles.css
 * and are used with hard fallbacks. Dark theme is done the same way as
 * change-requests.css, with html[data-theme="dark"] overrides at the bottom
 * rather than hardcoded light-only colours.
 */

.ct-page {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  box-sizing: border-box;
  width: 100%;
  max-width: 1100px;
  overflow-x: hidden;
}

/* ── header ──────────────────────────────────────────────────────────── */
.ct-head { display: flex; flex-direction: column; gap: 4px; }
.ct-title { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; color: var(--text-primary, #0f172a); }
.ct-sub { margin: 0; font-size: 13px; line-height: 1.45; color: var(--text-muted, #64748b); max-width: 74ch; }

/* ── states ──────────────────────────────────────────────────────────── */
.ct-loading, .ct-empty { font-size: 13px; color: #94a3b8; padding: 24px 4px; }
.ct-error { font-size: 13px; color: #dc2626; padding: 24px 4px; }
.ct-error-banner {
  font-size: 13px; color: #991b1b; background: #fef2f2;
  border: 1px solid #fecaca; border-radius: 8px; padding: 10px 12px;
}
.ct-error-banner[hidden] { display: none; }
.ct-muted { font-size: 12px; color: #94a3b8; }

.ct-body { display: flex; flex-direction: column; gap: 20px; }

/* ── chain card ──────────────────────────────────────────────────────── */
.ct-chain {
  border: 1px solid var(--border-color, #e2e8f0); border-radius: 12px;
  background: var(--card-bg, #fff); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 14px;
}
.ct-chain.is-unlocked { border-color: #34d399; }

.ct-chain-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ct-chain-name { margin: 0; font-size: 16px; font-weight: 700; color: var(--text-primary, #0f172a); }

.ct-pill {
  font-size: 11px; font-weight: 700; border-radius: 999px; padding: 3px 10px;
  text-transform: uppercase; letter-spacing: .03em;
}
.ct-pill-green { background: #dcfce7; color: #166534; }
.ct-pill-amber { background: #fef3c7; color: #92400e; }

.ct-unlock-note {
  font-size: 12.5px; line-height: 1.45; color: #047857;
  background: #ecfdf5; border: 1px solid #a7f3d0; border-radius: 8px; padding: 8px 11px;
}

/* ── section block ───────────────────────────────────────────────────── */
.ct-sections { display: flex; flex-direction: column; gap: 12px; }
.ct-section {
  border: 1px solid var(--border-color, #e2e8f0); border-radius: 10px;
  padding: 12px 14px; background: #f8fafc;
}
.ct-section-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.ct-section-name { font-size: 14px; font-weight: 700; color: var(--text-primary, #0f172a); }

.ct-state {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  border-radius: 999px; padding: 2px 8px;
}
.ct-state-green { background: #dcfce7; color: #166534; }
.ct-state-amber { background: #fef3c7; color: #92400e; }
.ct-state-neutral { background: #f1f5f9; color: #64748b; }

/* Two columns on a desktop, stacked on a phone. `minmax(0, 1fr)` keeps a long
   name from forcing the grid wider than the card and starting a horizontal
   page scroll. */
.ct-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.ct-col { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.ct-col-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #94a3b8;
}

/* ── required chips ──────────────────────────────────────────────────── */
.ct-roster { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ct-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  background: var(--card-bg, #fff); border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 12px;
  color: var(--text-primary, #0f172a);
}
.ct-chip-name { overflow-wrap: anywhere; }
.ct-chip-x {
  appearance: none; border: none; background: #e2e8f0; color: #475569; border-radius: 999px;
  width: 16px; height: 16px; line-height: 16px; text-align: center; font-size: 12px;
  cursor: pointer; padding: 0; flex-shrink: 0;
}
.ct-chip-x:hover { background: #cbd5e1; }
.ct-chip-x:disabled { opacity: .5; cursor: default; }

.ct-add-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ct-add-select {
  font: inherit; font-size: 12px; border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 6px; padding: 5px 7px; background: var(--card-bg, #fff);
  color: var(--text-primary, #0f172a); max-width: 100%; min-width: 0; flex: 1 1 160px;
}
.ct-add-select:disabled { opacity: .6; }

.ct-btn {
  appearance: none; font: inherit; font-size: 12px; font-weight: 700;
  border-radius: 7px; padding: 6px 14px; cursor: pointer; border: 1px solid transparent;
  flex: 0 0 auto;
}
.ct-btn-add { background: #16a34a; color: #fff; }
.ct-btn-add:hover { background: #15803d; }
.ct-btn:disabled { opacity: .55; cursor: default; }
.ct-btn:focus-visible, .ct-add-select:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }

/* ── completed rows ──────────────────────────────────────────────────── */
.ct-done-list { display: flex; flex-direction: column; gap: 8px; }
.ct-done {
  border: 1px solid var(--border-color, #e2e8f0); border-radius: 8px;
  background: var(--card-bg, #fff); padding: 8px 10px;
  display: flex; flex-direction: column; gap: 4px;
}
.ct-done-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ct-done-name { font-size: 12.5px; font-weight: 700; color: var(--text-primary, #0f172a); overflow-wrap: anywhere; }
.ct-done-time { font-size: 11px; color: #94a3b8; }

.ct-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  border-radius: 999px; padding: 2px 7px;
}
.ct-badge-green { background: #dcfce7; color: #166534; }
.ct-badge-amber { background: #fef3c7; color: #92400e; }

.ct-cr-toggle {
  appearance: none; border: none; background: none; padding: 0; cursor: pointer;
  font: inherit; font-size: 11px; font-weight: 700; color: #2563eb; text-align: left;
  align-self: flex-start;
}
.ct-cr-toggle:hover { text-decoration: underline; }
.ct-cr-body {
  font-size: 12px; line-height: 1.45; color: #334155; overflow-wrap: anywhere;
  background: #f8fafc; border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 6px; padding: 7px 9px;
}
.ct-cr-body[hidden] { display: none; }

/* ── narrow screens ───────────────────────────────────────────────────
   At 390px two columns give each roster about 165px, which breaks names
   mid-word and pushes the add-select past the card edge. Below 760px the
   section becomes one column and the page keeps its normal vertical scroll. */
@media (max-width: 760px) {
  .ct-page { padding: 16px 12px; gap: 14px; }
  .ct-cols { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .ct-chain { padding: 14px; }
  .ct-add-select { flex: 1 1 100%; }
}

/* ── dark theme ───────────────────────────────────────────────────────── */
html[data-theme="dark"] .ct-title,
html[data-theme="dark"] .ct-chain-name,
html[data-theme="dark"] .ct-section-name,
html[data-theme="dark"] .ct-done-name,
html[data-theme="dark"] .ct-chip { color: #e2e8f0; }
html[data-theme="dark"] .ct-chain,
html[data-theme="dark"] .ct-done { background: #111827; border-color: #1e293b; }
html[data-theme="dark"] .ct-chain.is-unlocked { border-color: #10b981; }
html[data-theme="dark"] .ct-section { background: #0b1220; border-color: #1e293b; }
html[data-theme="dark"] .ct-chip { background: #0b1220; border-color: #1e293b; }
html[data-theme="dark"] .ct-chip-x { background: #1e293b; color: #cbd5e1; }
html[data-theme="dark"] .ct-chip-x:hover { background: #334155; }
html[data-theme="dark"] .ct-add-select { background: #0b1220; border-color: #1e293b; color: #e2e8f0; }
html[data-theme="dark"] .ct-unlock-note { background: #062e21; border-color: #10b981; color: #6ee7b7; }
html[data-theme="dark"] .ct-error-banner {
  background: rgba(239, 68, 68, 0.12); border-color: rgba(248, 113, 113, 0.34); color: #fca5a5;
}
html[data-theme="dark"] .ct-error { color: #fca5a5; }
html[data-theme="dark"] .ct-pill-green,
html[data-theme="dark"] .ct-state-green,
html[data-theme="dark"] .ct-badge-green { background: rgba(16, 185, 129, 0.18); color: #6ee7b7; }
html[data-theme="dark"] .ct-pill-amber,
html[data-theme="dark"] .ct-state-amber,
html[data-theme="dark"] .ct-badge-amber { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
html[data-theme="dark"] .ct-state-neutral { background: #1e293b; color: #94a3b8; }
html[data-theme="dark"] .ct-cr-body { background: #0b1220; border-color: #1e293b; color: #cbd5e1; }
html[data-theme="dark"] .ct-cr-toggle { color: #60a5fa; }
