/* ============================================================
   components.css — shared UI components
   Available on every page via base.html
   ============================================================ */

/* ── Confidence colour tokens ────────────────────────── */
:root {
  --conf-high:   #22c55e;
  --conf-medium: #f59e0b;
  --conf-low:    #ef4444;
}

/* ── Confidence badge ─────────────────────────────────── */
.conf-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
}
.conf-high   { background: color-mix(in srgb, var(--conf-high)   15%, transparent); color: var(--conf-high); }
.conf-medium { background: color-mix(in srgb, var(--conf-medium) 15%, transparent); color: var(--conf-medium); }
.conf-low    { background: color-mix(in srgb, var(--conf-low)    15%, transparent); color: var(--conf-low); }
.conf-dot    { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.conf-high   .conf-dot { background: var(--conf-high); }
.conf-medium .conf-dot { background: var(--conf-medium); }
.conf-low    .conf-dot { background: var(--conf-low); }

/* ── Confidence bar ───────────────────────────────────── */
.conf-bar-wrap {
  height: 4px; background: var(--border);
  border-radius: 2px; overflow: hidden; flex: 1; min-width: 50px;
}
.conf-bar { height: 100%; border-radius: 2px; transition: width .4s ease; }

/* ── Spinner ──────────────────────────────────────────── */
.ac-spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%; animation: ac-spin .7s linear infinite; flex-shrink: 0;
}
@keyframes ac-spin { to { transform: rotate(360deg); } }

/* HTMX native indicator class */
.htmx-indicator { opacity: 0; transition: opacity 200ms; }
.htmx-request .htmx-indicator, .htmx-indicator.htmx-request { opacity: 1; }

/* ── History stepper ──────────────────────────────────── */
.hist-step { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.hist-step:last-child { border-bottom: none; }
.hist-dot {
  flex-shrink: 0; width: 8px; height: 8px;
  border-radius: 50%; margin-top: 4px;
}
.hist-dot-blue   { background: var(--accent); }
.hist-dot-green  { background: #22c55e; }
.hist-dot-amber  { background: #f59e0b; }
.hist-dot-grey   { background: var(--border); }
.hist-body { flex: 1; min-width: 0; }
.hist-header { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.hist-label { font-size: 12px; font-weight: 500; color: var(--text); }
.hist-pills { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.hist-reasoning summary { font-size: 11px; color: var(--text-muted); cursor: pointer; margin-top: 3px; }
.hist-reasoning-body { margin-top: 6px; font-size: 12px; color: var(--text); line-height: 1.6; }
.hist-reasoning-body p { margin: 0 0 8px; }
.hist-reasoning-body p:last-child { margin-bottom: 0; }
.hist-reasoning-body ol, .hist-reasoning-body ul { margin: 0 0 8px 1.4em; padding: 0; }
.hist-reasoning-body li { margin-bottom: 4px; }
.hist-reasoning-body li:last-child { margin-bottom: 0; }
.hist-reasoning-body strong { font-weight: 600; color: var(--text); }
.hist-reasoning-body em { font-style: italic; }
.hist-reasoning-body code { font-family: monospace; font-size: 11px; background: var(--surface-hover); border: 1px solid var(--border); border-radius: 3px; padding: 1px 4px; }
.hist-reasoning-body h1, .hist-reasoning-body h2, .hist-reasoning-body h3 { font-size: 12px; font-weight: 600; margin: 10px 0 4px; }
.hist-reasoning-body blockquote { border-left: 3px solid var(--border); margin: 0 0 8px 0; padding: 2px 10px; color: var(--text-muted); }

/* ── Mode toggle ──────────────────────────────────────── */
.mode-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.mode-btn {
  padding: 5px 14px; font-size: 12px; font-weight: 500; cursor: pointer; border: none;
  background: transparent; color: var(--text-muted); transition: background .15s, color .15s;
}
.mode-btn.active { background: var(--accent); color: #fff; }

/* ── Retrieved docs (shared: classify + agentic batch) ── */
.ret-doc { border: 1px solid var(--border); border-radius: 6px; overflow: hidden; margin-bottom: 8px; }
.ret-doc-header {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--surface-hover); border-bottom: 1px solid var(--border);
}
.ret-doc-tag { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px; }
.ret-tag-val { background: color-mix(in srgb, var(--conf-high) 15%, transparent); color: var(--conf-high); }
.ret-tag-ref { background: var(--accent-light); color: var(--accent); }
.ret-doc-desc { font-size: 12px; color: var(--text); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ret-doc-score { font-size: 11px; font-weight: 700; font-family: monospace; color: var(--text-muted); flex-shrink: 0; }
.ret-doc-fields {
  font-family: monospace; font-size: 11px; font-weight: 600;
  background: var(--surface-hover); padding: 6px 12px;
  border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 6px;
}
.ret-field { display: flex; gap: 3px; }
.ret-field-k { color: var(--text-muted); }
.ret-field-v { font-weight: 700; color: var(--text); }

/* ── Signal context markdown container (shared: classify + agentic batch) ── */
.ctx-interpretation { font-size: 13px; color: var(--text); line-height: 1.6; }
.ctx-interpretation p { margin: 0 0 8px; }
.ctx-interpretation p:last-child { margin-bottom: 0; }
.ctx-interpretation ul, .ctx-interpretation ol {
  margin: 2px 0 8px 0; padding-left: 18px;
  display: flex; flex-direction: column; gap: 2px;
}
.ctx-interpretation li { padding-left: 2px; }
.ctx-interpretation strong { font-weight: 600; }
.ctx-interpretation code {
  font-family: monospace; font-size: 11px; font-weight: 600;
  background: var(--surface); padding: 1px 4px; border-radius: 3px;
}
