/* Chat UI styles extracted from aicoursecreation.css */

.courseai-context-chat {
  display: none;
}

.ai-prompt-container {
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.ai-prompt-container:focus-within {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 0.25rem color-mix(in srgb, var(--primary) 25%, transparent) !important;
  outline: 0;
}

.ai-prompt-container textarea:focus {
  box-shadow: none !important;
  outline: none !important;
}

.ai-prompt-textarea::-webkit-scrollbar {
  width: 6px;
}

.ai-prompt-textarea::-webkit-scrollbar-thumb {
  background-color: var(--secondary);
  border-radius: 10px;
}

.ai-btn-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: transform 0.1s ease;
}

.ai-btn-send[disabled] {
  cursor: default !important;
}

.courseai-workspace.is-planning .courseai-context-editor {
  display: none;
}

.courseai-workspace.is-planning .courseai-context-chat {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  min-height: 0;
  min-width: 0;
}

/* Scrollable wrapper for history + checklist + adjustments */
.courseai-chat-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.courseai-workspace.is-planning .courseai-chat-history {
  flex: 0 0 auto;
}

/* Unify initial prompt message style with adjustment messages in the side panel */
.courseai-context-chat .courseai-chat-message--user {
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
}

.courseai-workspace.is-planning .planning-wrap {
  max-width: none;
  margin: 0;
  width: 100%;
  min-width: 0;
  min-height: 0;
  padding-left: 28px;
  overflow-y: auto;
}

@media (max-width: 1100px) {
  .courseai-workspace.is-planning {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }
  .courseai-workspace.is-planning .context-wrap {
    position: static;
    max-height: none;
    min-height: 0;
    border-right: none;
    padding-right: 0;
  }

  .courseai-workspace.is-planning .planning-wrap {
    padding-left: 0;
  }

  .courseai-workspace.is-planning .courseai-context-editor {
    display: none;
  }

  .courseai-workspace.is-planning .courseai-context-chat {
    display: flex;
  }
}

.courseai-chat-history {
  background: transparent;
  padding: 0;
}

.courseai-chat-history-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted-fg);
  margin-bottom: 8px;
}

.courseai-chat-message {
  display: inline-block;
  max-width: 100%;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.courseai-chat-message--user {
  background: var(--muted);
  border: 1px solid var(--border);
  color: var(--fg);
}

.courseai-chat-message--user p {
  margin: 0;
}

/* ─── SECTION CHECKLIST ───────────────────────────────────────────────── */
.courseai-checklist {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 4px 0;
  font-size: 13px;
}

/* Legacy uppercase label hidden in favour of .cg-group-head (§7.1 redesign). */
.courseai-checklist-label {
  display: none;
}

.courseai-checklist-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: relative;
}

/* Each section = an INDEPENDENT, full-width block (no connecting timeline line,
   no wrapping card). A clear separator divides consecutive sections. */
.courseai-checklist-item {
  display: block;
  width: 100%;
  color: var(--muted-fg);
  font-size: 14px;
  line-height: 1.4;
  opacity: .75;
  transition: opacity .2s;
}
.courseai-checklist-item + .courseai-checklist-item {
  border-top: 1px solid var(--border);
  padding-top: 24px;
}
.courseai-checklist-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
/* Activity-type icon in a regeneration item head: the SAME monologo.svg the
   center view uses, just smaller, sitting between the check circle and the
   activity title. */
.cg-activity-icon {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  object-fit: contain;
}

/* Manual "Retry" button — styled as a log entry action, not a standalone CTA.
   Matches the log's typography (15px, 1.6 line-height) and the user-turn card
   aesthetic (rounded, subtle fill, no heavy shadow). */
.cg-retry-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  align-self: flex-start;
  max-width: fit-content;
  margin: 6px 0 2px;
  padding: 6px 14px;
  border: 1px solid var(--danger, #dc3545);
  border-radius: 12px;
  background: transparent;
  color: var(--danger, #dc3545);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.6;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.cg-retry-btn:hover {
  background: var(--danger, #dc3545);
  color: #fff;
}
.cg-retry-btn::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 4v6h6'/%3E%3Cpath d='M3.51 15a9 9 0 1 0 2.13-9.36L1 10'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 4v6h6'/%3E%3Cpath d='M3.51 15a9 9 0 1 0 2.13-9.36L1 10'/%3E%3C/svg%3E") center/contain no-repeat;
}
/* The section name carries the weight — bigger and bolder than the detail. */
.courseai-checklist-name {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.35;
}

.courseai-checklist-item.is-done {
  opacity: 1;
}

.courseai-checklist-check {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}

.courseai-checklist-item.is-done .courseai-checklist-check {
  background: transparent;
  border-color: var(--muted-fg);
}

.courseai-checklist-check svg {
  width: 10px;
  height: 10px;
  fill: none;
  display: none;
}

.courseai-checklist-check .check-icon {
  stroke: var(--muted-fg);
  stroke-width: 3;
}

.courseai-checklist-check .spinner-icon {
  stroke: var(--muted-fg);
  stroke-width: 2.5;
  animation: courseai-spin .8s linear infinite;
}

.courseai-checklist-item.is-done .courseai-checklist-check svg.check-icon {
  display: block;
}

.courseai-checklist-item.is-loading .courseai-checklist-check svg.spinner-icon {
  display: block;
}

@keyframes courseai-spin {
  to { transform: rotate(360deg); }
}

/* Per-section Markdown detail: a full-width block BELOW the section name,
   indented to align under the name (past the check icon). Compact via .cg-log-md;
   long details clamp with a "Show more"/"Show less" toggle. */
.courseai-checklist-detail {
  display: block;
  width: auto;
  margin: 6px 0 0 26px;
  color: var(--fg);
  font-size: 13.5px;
  line-height: 1.55;
  position: relative;
}
.courseai-checklist-detail:empty {
  display: none;
}
.courseai-checklist-detail.cg-detail-clamped {
  max-height: 120px;
  overflow: hidden;
  cursor: pointer;
  -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 55%, transparent 100%);
}
.courseai-checklist-detail.cg-detail-clamped.is-expanded {
  max-height: none;
  cursor: auto;
  -webkit-mask-image: none;
  mask-image: none;
}
/* Centered "Show more"/"Show less" under the section detail. */
.cg-detail-toggle {
  display: flex;
  justify-content: center;
  width: 100%;
  margin: 6px 0 0 0;
}

/* Once the plan has been reviewed the whole structure is final, so every checklist
   row reads as done — regardless of the per-row streaming counter. This is purely
   declarative, so it also covers late buffered section/activity events that would
   otherwise leave a lingering spinner after the stream closed. */
body.cg-plan-reviewed .courseai-checklist-item {
  opacity: 1;
}
body.cg-plan-reviewed .courseai-checklist-check {
  background: transparent;
  border-color: var(--muted-fg);
}
body.cg-plan-reviewed .courseai-checklist-check svg.spinner-icon {
  display: none;
}
body.cg-plan-reviewed .courseai-checklist-check svg.check-icon {
  display: block;
}

/* EXCEPTION — a LIVE regen row. After the plan is reviewed the user can still
   regenerate/add a section: that streams a fresh row that is `is-loading` while
   body.cg-plan-reviewed is set. The reviewed rules above force the CHECK visible
   and the loading rule (.is-loading … .spinner-icon) forces the SPINNER visible,
   so BOTH render, overlapping into a broken glyph (a checkmark tangled with a
   spinning arc). While a row is still loading it must read as a clean spinner:
   hide the check and keep the light ring, exactly like the initial-planning
   spinner. Once it flips to is-done the reviewed/done rules show the check. */
body.cg-plan-reviewed .courseai-checklist-item.is-loading .courseai-checklist-check svg.check-icon {
  display: none;
}
body.cg-plan-reviewed .courseai-checklist-item.is-loading .courseai-checklist-check {
  border-color: var(--border);
}

.courseai-checklist-name {
  flex: 1;
  min-width: 0;
}

/* ─── ADJUSTMENT HISTORY ─────────────────────────────────────────────── */
.courseai-adjustment-history {
  display: flex;
  flex-direction: column;
}

.courseai-adjustment-history:empty {
  display: none;
}

.courseai-round {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.courseai-round + .courseai-round {
  margin-top: 12px;
  padding-top: 12px;
}

.courseai-round-response {
  display: flex;
  flex-direction: column;
}

/* ─── COMPACT CHAT CARD ───────────────────────────────────────────── */
.compact-chat-card {
  background: var(--card);
  /* Seamless Claude-style composer: one card, even padding, no inner divider. */
  padding: 10px 12px 8px;
  margin-top: auto;
  transition: border-color .15s, box-shadow .15s, opacity .2s, filter .2s;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.compact-chat-card:focus-within {
  border-color: var(--primary, #6b4eff);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary, #6b4eff) 15%, transparent);
}

/* Control-level disabled state for compact chat during active streams */
.compact-controls--disabled {
  opacity: 0.6;
  pointer-events: none;
  user-select: none;
  filter: grayscale(0.3);
}

/* Legacy container-level disabled state - keep for backward compatibility but don't use for new code */
.compact-chat-card--disabled {
  opacity: 0.6;
  pointer-events: none;
  user-select: none;
  filter: grayscale(0.3);
}

.compact-prompt-textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  max-height: 200px;
  /* Horizontal inset matches the toolbar controls below so text and icons share
     the same left edge (Claude). The card supplies the outer padding. */
  padding: 4px 2px 8px;
  font-size: 14px;
  line-height: 1.55;
  font-family: inherit;
  color: var(--fg);
  background: transparent;
  border: none;
  outline: none;
  resize: none;
}

.compact-prompt-textarea::placeholder {
  color: var(--muted-fg);
}

.compact-chat-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: nowrap;
  min-width: 0;
  /* No divider, no grey strip — the toolbar floats inside the single card (Claude). */
  border: none;
  background: transparent;
  padding: 2px 0 0;
}

.compact-toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  min-width: 0;
  flex: 1 1 auto;
  white-space: nowrap;
}

.compact-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.compact-chat-toolbar .tbar-btn,
.compact-chat-toolbar .tbar-select,
.compact-chat-toolbar .tbar-toggle-wrap,
.compact-chat-toolbar .tbar-sep {
  flex: 0 0 auto;
}

.compact-chat-toolbar .tbar-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  justify-content: center;
}

.compact-chat-toolbar .popover-wrap {
  flex-shrink: 0;
}

.compact-chat-toolbar .tbar-sep {
  display: none;
}

.compact-chat-toolbar .tbar-select {
  width: 54px;
  min-width: 54px;
  padding: 0 6px;
}

.compact-chat-toolbar .tbar-toggle-wrap {
  gap: 6px;
  padding-right: 0;
}

.btn-compact-regenerate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* Compact, square-ish send button like Claude/V0 — NOT a wide pill. The min/max
     guards stop any inherited padding/min-width from stretching it. */
  width: 32px;
  min-width: 32px;
  max-width: 32px;
  height: 32px;
  padding: 0;
  flex: 0 0 32px;
  /* Idle: a discreet white squircle with a hairline border and a grey arrow, so it
     reads clearly on the grey toolbar without shouting. */
  color: var(--muted-fg);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, color .15s, border-color .15s, opacity .12s, transform .1s;
}

/* Ready (has text): fill with the plugin accent + white arrow. */
.btn-compact-regenerate.is-ready {
  color: var(--primary-fg, #fff);
  background: var(--primary, #6b4eff);
  border-color: var(--primary, #6b4eff);
}

.btn-compact-regenerate:hover {
  opacity: 0.85;
}

.btn-compact-regenerate:active {
  transform: scale(0.95);
}

.btn-compact-regenerate:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* ─── COLLAPSIBLE CHECKLIST ───────────────────────────────────────────── */
.courseai-checklist.is-collapsed .courseai-checklist-list {
  display: none;
}

.cg-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
}

.cg-group-chevron {
  font-size: 14px;
  line-height: 1;
  color: var(--muted-fg);
  transition: transform 0.15s ease;
  display: inline-block;
}

.courseai-checklist.is-collapsed .cg-group-chevron {
  transform: rotate(-90deg);
}

.cg-group-count {
  font-size: 12px;
  color: var(--muted-fg);
  margin-left: 2px;
}

.cg-group-avatar {
  font-size: 14px;
  color: var(--muted-fg);
  flex-shrink: 0;
}

.cg-group-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted-fg);
  flex: 1;
  min-width: 0;
}
