/* =========================================================================
   Drafting wizard - generation pipeline (7-step MVP)

   Loaded after styles.css and built entirely from its tokens, so both themes
   come for free. Kept in its own file because the drafting panel is a distinct
   surface from search, and because it lets the generation feature be styled
   without touching the stylesheet the search UI depends on.
   ========================================================================= */

/* Step rail: which of the 7 steps the session has reached */
.wizard-rail {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
}
.wizard-step {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: .78rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-faint);
}
.wizard-step.done {
  background: var(--high-soft);
  color: var(--high);
  border-color: transparent;
}
.wizard-step.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
  font-weight: 640;
}
.wizard-step.failed {
  background: var(--low-soft);
  color: var(--low);
  border-color: transparent;
}
.wizard-num {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: currentColor;
  color: var(--surface);
  font-size: .66rem;
  font-weight: 700;
  flex: none;
}
.wizard-label { white-space: nowrap; }

/* Behavioural hooks, not styling: .slot-confirm, .slot-field, .fact-key,
   .fact-value, .fact-kind, .fact-source and .flag-resolve exist so the wizard
   can collect a step's inputs with one querySelectorAll. Their appearance comes
   from the element rules on .slot-table and .fact-table below. */

/* Mode chooser: describe what you need, or upload a template */
.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.mode-btn {
  text-align: left;
  font: inherit;
  cursor: pointer;
  padding: 13px 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: grid;
  gap: 3px;
  transition: border-color .12s ease, background .12s ease;
}
.mode-btn:hover { border-color: var(--border-strong); }
.mode-btn.is-active { border-color: var(--accent); background: var(--accent-soft); }
.mode-title { font-weight: 620; font-size: .92rem; color: var(--text); }
.mode-btn.is-active .mode-title { color: var(--accent); }
.mode-sub { font-size: .78rem; color: var(--text-muted); }

.field { display: grid; gap: 6px; font-size: .8rem; color: var(--text-muted); }
.field input {
  padding: 11px 13px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.draft-fields { display: grid; margin-top: 14px; }
.dropzone.compact { padding: 22px 18px; }

.sub-head {
  font-size: .84rem;
  font-weight: 640;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin: 20px 0 10px;
}
.note-list {
  margin: 0 0 12px;
  padding-left: 20px;
  font-size: .82rem;
  color: var(--text-muted);
}
.note-list li { margin-bottom: 4px; }

/* Precedent candidates */
.precedent-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.precedent-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px;
  display: grid;
  gap: 7px;
  align-content: start;
  background: var(--surface);
}
.precedent-card.is-active { border-color: var(--accent); background: var(--accent-soft); }
.precedent-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.precedent-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.precedent-card p { margin: 0; }
.precedent-card .btn-ghost { justify-self: start; }

/* Slot and fact tables */
.slot-table,
.fact-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.slot-table th,
.fact-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: .72rem;
  font-weight: 640;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.slot-table td,
.fact-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.slot-table tr:last-child td,
.fact-table tr:last-child td { border-bottom: 0; }
.slot-table tr.is-dismissed { opacity: .45; }
.slot-table input[type="checkbox"] { accent-color: var(--accent); }
.slot-table input[type="text"],
.fact-table input[type="text"],
.fact-table select {
  width: 100%;
  min-width: 130px;
  padding: 6px 8px;
  font: inherit;
  font-size: .8rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.slot-original {
  font-family: var(--mono);
  font-size: .74rem;
  color: var(--text-muted);
  max-width: 260px;
  overflow-wrap: anywhere;
}
.slot-section { font-size: .74rem; color: var(--text-faint); max-width: 180px; }
.fact-label { font-weight: 600; color: var(--text); }
.fact-key-hint { font-family: var(--mono); font-size: .7rem; color: var(--text-faint); }
.fact-table .btn-link { font-size: .74rem; padding: 2px 0; margin-right: 8px; }

/* Consistency conflicts */
.conflict-row {
  border-left: 3px solid var(--border);
  padding: 10px 0 10px 12px;
  margin-bottom: 10px;
}
.conflict-row.error { border-left-color: var(--low); }
.conflict-row.warning { border-left-color: var(--medium); }
.conflict-row.info { border-left-color: var(--border-strong); }
.conflict-row.resolved { opacity: .6; }
.conflict-head { display: flex; gap: 9px; align-items: baseline; flex-wrap: wrap; }
.conflict-message { font-size: .85rem; }
.conflict-values { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 8px; }
.conflict-value {
  font-family: var(--mono);
  font-size: .76rem;
  background: var(--code-bg);
  padding: 3px 7px;
  border-radius: var(--radius-sm);
}

/* The draft itself */
.draft-body {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin: 14px 0;
  max-height: 620px;
  overflow-y: auto;
}
.draft-body p { margin: 0 0 12px; font-size: .88rem; line-height: 1.62; }
.draft-heading {
  font-size: .95rem;
  font-weight: 660;
  margin: 20px 0 8px;
  color: var(--text);
  letter-spacing: -.01em;
}
.draft-body > .draft-heading:first-child { margin-top: 0; }

/* An unresolved flag has to be impossible to miss - it is the one thing the
   reviewer must act on. */
mark.needs-input {
  background: var(--low-soft);
  color: var(--flag);
  font-weight: 700;
  font-family: var(--mono);
  font-size: .8em;
  padding: 1px 5px;
  border-radius: 4px;
}

/* Flags and findings */
.flag-list { display: grid; gap: 7px; margin-bottom: 12px; }
.flag-item {
  display: flex;
  gap: 9px;
  align-items: baseline;
  font-size: .83rem;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.flag-item.needs_input { background: var(--low-soft); }
.flag-check { padding: 6px 2px; font-size: .83rem; align-items: baseline; }

.finding-list { display: grid; gap: 8px; }
.finding { border-left: 3px solid var(--border-strong); padding: 8px 0 8px 12px; }
.finding.error { border-left-color: var(--low); }
.finding.warning { border-left-color: var(--medium); }
.finding.info { border-left-color: var(--border-strong); }
.finding-head {
  display: flex;
  gap: 9px;
  align-items: baseline;
  flex-wrap: wrap;
  font-size: .84rem;
}
.finding-excerpt {
  display: block;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: .74rem;
  color: var(--text-muted);
  background: var(--code-bg);
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  overflow-wrap: anywhere;
}
.finding p { margin: 4px 0 0; }

/* The style guide's own compliance test */
.qa-checks { display: grid; gap: 6px; margin-bottom: 8px; }
.qa-check {
  display: flex;
  gap: 11px;
  align-items: baseline;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.qa-check.ok { background: var(--high-soft); }
.qa-check.bad { background: var(--low-soft); }
.qa-mark { font-weight: 700; flex: none; }
.qa-check.ok .qa-mark { color: var(--high); }
.qa-check.bad .qa-mark { color: var(--low); }
.qa-name { font-size: .85rem; font-weight: 600; }
.qa-detail { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }

/* Required-clause checklist */
.clause-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.clause {
  font-size: .75rem;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.clause.present { background: var(--high-soft); color: var(--high); border-color: transparent; }
.clause.missing { background: var(--low-soft); color: var(--low); border-color: transparent; }
.clause.absent { color: var(--text-faint); }

/* Review editor - the hard gate */
.draft-editor {
  width: 100%;
  font-family: var(--mono);
  font-size: .8rem;
  line-height: 1.6;
  padding: 14px 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: vertical;
  margin-bottom: 14px;
}
.draft-editor:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.review-actions { margin-top: 12px; }
#review-name,
#review-note {
  padding: 9px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 200px;
}

/* The provider panel on the Settings tab */
.provider-site { margin-bottom: 22px; }
.provider-site:last-child { margin-bottom: 0; }
.provider-site-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.provider-site-head h3 { font-size: .92rem; font-weight: 640; margin: 0; }
.provider-setting {
  font-family: var(--mono);
  font-size: .74rem;
  color: var(--text-muted);
  background: var(--code-bg);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
}
.provider-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.provider-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 13px;
  background: var(--surface);
  display: grid;
  gap: 6px;
  align-content: start;
}
.provider-card.is-active { border-color: var(--accent); background: var(--accent-soft); }
.provider-card.is-unavailable { opacity: .72; }
.provider-card-head { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.provider-card p { margin: 0; }
.provider-model {
  font-family: var(--mono);
  font-size: .73rem;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

/* Which provider assembles the draft */
.provider-pick { gap: 8px; }
.provider-select {
  padding: 7px 10px;
  font: inherit;
  font-size: .82rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.provider-select option:disabled { color: var(--text-faint); }

/* Earlier drafts */
.session-row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  flex-wrap: wrap;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.session-row:last-child { border-bottom: 0; }

@media (max-width: 720px) {
  .mode-switch { grid-template-columns: 1fr; }
  .slot-original, .slot-section { max-width: none; }
}
