/* Coach dashboard (Phase 1: read-only). Reuses the .thread/.t-* classes from
   brainstorm.css for thread cards so a thread looks identical whether a
   student or their coach is looking at it. */

/* Container class is deliberately NOT `.coach`: chat messages use
   `class="msg coach"` (coach = the speaker), so a bare `.coach` selector here
   would also match every coach message and force it into this grid. Use a
   distinct `.coach-dashboard` name to avoid that collision. */
.coach-dashboard {
  display: none;
  gap: 2rem;
  max-width: 1100px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}
.coach-dashboard:not(.hidden) { display: grid; grid-template-columns: 260px 1fr; }

.coach-demo-back {
  grid-column: 1 / -1;
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 0.5rem;
}
.coach-demo-back:hover { color: var(--ink); }

.coach-roster-panel {
  border-right: 1px solid var(--line);
  padding-right: 1.5rem;
}
.coach-roster-title {
  font-family: var(--serif);
  font-size: 1.1rem;
  margin: 0 0 0.8rem;
  color: var(--ink);
}
.coach-roster-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.coach-roster-item {
  padding: 0.6rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.92rem;
  color: var(--body);
  word-break: break-word;
}
.coach-roster-item:hover { background: var(--bg-soft); }
.coach-roster-item.active {
  background: var(--accent-soft);
  color: var(--ink);
  font-weight: 600;
}

.coach-detail-title {
  font-family: var(--serif);
  font-size: 1.3rem;
  margin: 0 0 1rem;
  color: var(--ink);
}

.coach-review-bar {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin-bottom: 1.2rem;
}
.coach-review-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  color: #fff;
  background: var(--muted);
}
.coach-review-badge.status-pending_review { background: var(--brand-soft); }
.coach-review-badge.status-approved { background: #2f7d4f; }
.coach-review-badge.status-needs_revision { background: var(--accent); color: var(--ink); }
.coach-review-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem 0.7rem;
}
.coach-review-gate-into {
  font-size: 0.8rem;
  color: var(--muted);
}
.coach-review-prior-comment {
  font-family: var(--serif);
  font-size: 0.88rem;
  color: var(--body);
  margin: 0.6rem 0 0;
}
.coach-review-advance-note {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0.55rem 0 0;
  line-height: 1.4;
}
.coach-review-textarea {
  display: block;
  width: 100%;
  margin-top: 0.7rem;
  padding: 0.5rem 0.6rem;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--body);
  border: 1px solid var(--line);
  border-radius: 6px;
  resize: vertical;
  min-height: 2.4rem;
}
.coach-review-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
}
.coach-review-btn {
  font-family: inherit;
  font-size: 0.82rem;
  border: none;
  border-radius: 6px;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
}
.coach-review-btn:disabled { opacity: 0.6; cursor: default; }
.coach-review-btn.approve { background: #2f7d4f; color: #fff; }
.coach-review-btn.approve:hover:not(:disabled) { background: #26643f; }
.coach-review-btn.request { background: var(--bg); color: var(--ink); border: 1px solid var(--line); }
.coach-review-btn.request:hover:not(:disabled) { border-color: var(--accent); }
.coach-review-error {
  font-size: 0.8rem;
  color: #b3432b;
  margin: 0.5rem 0 0;
}
.coach-review-error.hidden { display: none; }

.coach-tabs {
  display: flex;
  gap: 0.3rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.4rem;
}
.coach-tab {
  font-family: inherit;
  font-size: 0.85rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.5rem 0.2rem;
  margin-right: 1.2rem;
  color: var(--muted);
  cursor: pointer;
}
.coach-tab:hover { color: var(--ink); }
.coach-tab.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.coach-detail-section { margin-bottom: 1.6rem; }
.coach-detail-section h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 0.6rem;
}
.coach-detail-empty {
  color: var(--muted);
  font-style: italic;
  font-size: 0.92rem;
}
.coach-gold-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--body);
}
.coach-gold-list li { margin-bottom: 0.4rem; }

.coach-transcript {
  max-height: 480px;
  overflow-y: auto;
  padding-right: 0.5rem;
}
/* .msg/.msg.user come from brainstorm.css (shared with the student's own chat
   view, see app/coach/index.js#renderMessage) — 88% max-width + a left
   margin/indent that reads fine in the student's two-column layout but wastes
   space in this narrower single-column panel. Widen just here. */
.coach-transcript .msg {
  max-width: 100%;
}
.coach-transcript .msg.user {
  margin-left: 0;
}

/* ---- Comments: aligned side rail (COACH_GATE_PLAN.md Phase 3) --------- */

.coach-tab-count {
  display: inline-block;
  min-width: 1.1rem;
  padding: 0 0.35rem;
  margin-left: 0.15rem;
  font-size: 0.72rem;
  line-height: 1.3rem;
  text-align: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--ink);
}

/* Two columns: the document (active tab's content) and the comment rail. */
.coach-doc-wrap { position: relative; display: flex; align-items: flex-start; gap: 1rem; }
.coach-doc { flex: 1 1 auto; min-width: 0; }
.coach-rail { position: relative; flex: 0 0 236px; width: 236px; align-self: stretch; }

/* Inline-highlight interaction states (base .cmt-mark lives in base.css). */
.cmt-mark.hl { background: var(--accent); }
.cmt-mark.active { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* A comment card, floated at its highlight's y by layoutRail(). */
.cmt-card {
  position: absolute;
  right: 0;
  width: 236px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  box-shadow: 0 1px 3px rgba(2, 37, 89, 0.06);
  cursor: pointer;
  transition: box-shadow 0.12s, border-color 0.12s, top 0.15s ease;
}
.cmt-card.hl, .cmt-card:hover { box-shadow: 0 4px 14px rgba(2, 37, 89, 0.14); }
.cmt-card.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cmt-card.orphaned { border-left-color: var(--muted); opacity: 0.85; }
.cmt-card-del {
  float: right;
  margin: -0.1rem -0.2rem 0 0.3rem;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.15rem;
}
.cmt-card-del:hover { color: var(--accent); }
.cmt-card-quote {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
}
.cmt-card-text { color: var(--ink); font-size: 0.88rem; line-height: 1.4; }

/* The "+" shown in the rail at the selection's line. */
.cmt-add {
  position: absolute;
  left: -13px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--brand);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(2, 37, 89, 0.14);
  transition: background 0.12s, color 0.12s;
}
.cmt-add:hover { background: var(--brand); color: #fff; }

/* Composer card: opens already as a textbox, pinned to the selection's line. */
.cmt-composer {
  position: absolute;
  right: 0;
  width: 236px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(2, 37, 89, 0.16);
  padding: 0.55rem;
  z-index: 5;
}
.cmt-compose-text {
  width: 100%;
  resize: vertical;
  font-family: var(--sans);
  font-size: 0.88rem;
  color: var(--body);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.45rem 0.55rem;
  box-sizing: border-box;
}
.cmt-compose-actions { display: flex; justify-content: flex-end; gap: 0.4rem; margin-top: 0.45rem; }
.cmt-compose-cancel {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.35rem 0.7rem;
  font-size: 0.82rem;
  color: var(--body);
  cursor: pointer;
}
.cmt-compose-save {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 0.35rem 0.8rem;
  font-size: 0.82rem;
  cursor: pointer;
}
.cmt-compose-error { color: #b3261e; font-size: 0.78rem; margin: 0.4rem 0 0; }
.cmt-compose-error.hidden { display: none; }

/* Narrow viewport: the rail drops below the document and cards stack normally
   (layoutRail's inline `top` is overridden). The aligned "+" is dropped. */
@media (max-width: 900px) {
  .coach-doc-wrap { flex-direction: column; }
  .coach-rail { position: static; width: 100%; flex: 1 1 auto; }
  .cmt-card, .cmt-composer { position: static; width: 100%; margin-bottom: 0.6rem; top: auto !important; }
  .cmt-add { display: none; }
}

/* Coach-suggested thread tag. */
.thread.coach-suggested { border-style: dashed; }
.t-coach-tag {
  display: inline-block;
  flex: 0 0 auto;
  align-self: flex-start;
  white-space: nowrap;
  margin-left: 0.5rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--ink);
  vertical-align: middle;
}
/* On the student's dark (filled) thread card the ink tag text needs a lighter
   treatment to stay legible. */
.thread.strong .t-coach-tag { background: rgba(255, 255, 255, 0.18); color: #fff; }

/* ---- Coach-suggested thread authoring -------------------------------- */

.thread-suggest-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.2rem;
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: 7px;
  padding: 0.4rem 0.75rem;
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}
.thread-suggest-btn:hover { border-color: var(--accent); color: var(--ink); }

/* Edit/Delete on a coach-suggested card. The card is usually .strong (dark), so
   default to a light treatment and flip for the rare light (.forming) card. */
.t-coach-controls { display: flex; gap: 0.9rem; margin-top: 0.7rem; }
.t-coach-controls button {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--sans);
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
}
.t-coach-controls button:hover { color: #fff; text-decoration: underline; }
.thread.forming .t-coach-controls button { color: var(--muted); }
.thread.forming .t-coach-controls button:hover { color: var(--accent); }

/* Modal for the suggest/edit-direction form. */
.tf-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 1rem;
  background: rgba(2, 37, 89, 0.28);
  overflow-y: auto;
}
.tf-modal.hidden { display: none; }
.tf-card {
  width: 480px;
  max-width: 100%;
  background: var(--bg);
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(2, 37, 89, 0.28);
  padding: 1.3rem 1.4rem;
}
.tf-title { font-family: var(--serif); font-size: 1.15rem; color: var(--ink); margin: 0 0 0.9rem; }
.tf-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
  margin: 0.9rem 0 0.3rem;
}
.tf-name, .tf-summary, .tf-evidence-text {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--body);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.5rem 0.6rem;
  resize: vertical;
}
.tf-name:focus, .tf-summary:focus, .tf-evidence-text:focus { outline: none; border-color: var(--accent); }
.tf-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.1rem; }
.tf-cancel {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  color: var(--body);
  cursor: pointer;
}
.tf-save {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
}
.tf-save:disabled { opacity: 0.6; cursor: default; }
.tf-error { color: #b3261e; font-size: 0.8rem; margin: 0.6rem 0 0; }
.tf-error.hidden { display: none; }
