/* Phase 5 — AI-assisted coding styles.
 * Respects CSS variables from variables.css so dark-mode is free.
 */

/* Sparkle icon next to AI buttons. */
.ai-sparkle {
  font-style: normal;
  font-size: 1.1em;
  margin-right: 2px;
  color: var(--color-accent);
}

.ai-suggest-btn {
  gap: var(--space-1);
}

/* Inline suggest panel — dropdown under the floating toolbar. */
.ai-suggest-wrap {
  position: relative;
}
.ai-suggest-panel {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 280px;
  max-width: 400px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-3);
  z-index: 200;
  max-height: 320px;
  overflow-y: auto;
}

/* Suggestion row (used in Mode 1 and Mode 3). */
.ai-sug-row,
.ai-new-code-row {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border);
}
.ai-sug-row:last-child,
.ai-new-code-row:last-child {
  border-bottom: none;
}
.ai-sug-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}
.ai-sug-rationale {
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-2);
}
.ai-sug-actions {
  display: flex;
  gap: var(--space-2);
}
.ai-new-code-row.is-accepted {
  opacity: 0.5;
  pointer-events: none;
}

/* AI badge on segment detail. */
.ai-badge {
  background: var(--color-accent-muted, #dce7f3);
  color: var(--color-accent);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
}

/* Document checkbox list in Mode 2 modal. */
.ai-doc-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: 240px;
  overflow-y: auto;
  padding: var(--space-2) 0;
}

/* Batch review panel (Mode 3) — sticky right-rail. */
.ai-batch-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
}
.ai-batch-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}
.ai-batch-header h3 {
  margin: 0;
  font-size: var(--font-size-lg);
}
.ai-batch-progress {
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-3);
}
.ai-batch-body {
  max-height: 400px;
  overflow-y: auto;
}
.ai-batch-row {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border);
}
.ai-batch-row:last-child { border-bottom: none; }
.ai-batch-bulk {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}

/* Dashed border for AI-accepted segments (supplement the inline style
   applied by renderAnnotatedText — this class can be toggled by the
   "Hide AI suggestions" filter). */
.seg.ai-source {
  border-bottom-style: dashed !important;
}

/* Dotted border for pending AI suggestions (rendered from the suggestion
   list, not yet coded_segments). */
.seg.ai-pending {
  border: 1px dotted var(--color-accent);
  background: rgba(74, 144, 217, 0.08);
  opacity: 0.7;
}

/* Phase 57 — on-brand "Approve AI run" cost modal. */
.ai-approve-modal {
  max-width: 440px;
  width: calc(100vw - 2 * var(--space-4));
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  /* Force an opaque panel — the modal sits over document text. */
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 41;
}
.ai-approve-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.ai-approve-head h2 {
  margin: 0;
  font-size: var(--font-size-lg);
}
.ai-approve-head .ai-sparkle {
  color: var(--color-accent);
  font-size: var(--font-size-xl);
  line-height: 1;
}
.ai-approve-sub { margin: 0; font-size: var(--font-size-sm); }
.ai-approve-stats {
  display: flex;
  gap: var(--space-5);
  background: var(--color-accent-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
}
.ai-approve-stats > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ai-approve-stats .muted { font-size: var(--font-size-sm); }
.ai-approve-stats strong { font-size: var(--font-size-lg); }
.ai-approve-cost { color: var(--color-accent); }
.ai-approve-hint { margin: 0; font-size: var(--font-size-sm); }
.ai-approve-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-1);
}

/* Phase 57 — compact per-project AI controls grid. */
.ai-controls-grid th,
.ai-controls-grid td {
  padding: var(--space-2);
  vertical-align: middle;
}

/* The 7-column grid is wider than the narrow 720px account column, so its card
   gets clipped + horizontally scrolled. Let this one card break out of the
   column to ~full width (viewport-centered, capped) so nothing is cut off; the
   rest of the account page stays narrow + readable. (Padding cancels in the
   margin math, so this centers on the viewport regardless of the parent.) */
.ai-controls-fullbleed {
  box-sizing: border-box;
  width: min(96vw, 1200px);
  margin-left: calc(50% - min(48vw, 600px));
}
/* The grid no longer needs to scroll at full width, but keep nowrap so cells
   don't wrap awkwardly if the viewport is genuinely narrow. */
.ai-controls-grid th,
.ai-controls-grid td { white-space: nowrap; }
.ai-controls-grid select,
.ai-controls-grid input[type="text"],
.ai-controls-grid input[type="number"] {
  padding: var(--space-1) var(--space-2);
  margin: 0;
}

/* Phase 57 — per-run model picker inside the approval modal. */
.ai-approve-model {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.ai-approve-model label { margin: 0; font-weight: 600; }
.ai-approve-model select { flex: 1; }
