/* ============================================
   Deep Analysis Panel (Agentic Harness P1) — SKU page
   Persisted-run states rendered inside the shared .detail-ai-panel shell
   (spec/TODO_agentic_analysis_harness.md §13 P1). Shared/core glob file:
   the panel ships on the SKU page today and the FRQ/group surfaces reuse
   these classes in P2/P3.
   ============================================ */

/* Overlay visibility is class-driven (the legacy controller toggled an
   inline style — not a pattern to follow). */
.detail-ai-overlay.dap-visible { display: block; }

.dap-icon-white { color: #fff; }

/* --- Header verdict (fresh complete run, surfaced on the SKU view) -----
   One clickable chip in the SKU page header: the canonical qty-driven
   .ai-cell verdict pill (rendered as a span — the chip itself is the
   button) + truncated review headline + generated date. Opens the full
   deep-analysis panel. Only renders for a complete NON-stale run. */
.dap-header-verdict {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 400px;
  min-width: 0;
  font-family: inherit;
  font-size: 12px;
  background: #fff;
  border: 1px solid #e8e6e1;
  border-radius: 999px;
  padding: 4px 12px 4px 5px;
  cursor: pointer;
  text-align: left;
}
.dap-header-verdict:hover { border-color: #d6d3cd; background: #faf9f7; }
.dap-header-verdict .ai-cell { flex-shrink: 0; }
.dap-header-verdict-headline {
  font-weight: 600;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.dap-header-verdict-date { color: #8a8a8a; white-space: nowrap; flex-shrink: 0; }

/* --- Result region ---------------------------------------------------- */
.dap-result { min-height: 40px; }

.dap-empty { text-align: center; padding: 28px 8px; }
.dap-empty-title { font-size: 14px; font-weight: 700; color: #1a1a1a; margin: 0 0 6px; }
.dap-empty-sub { font-size: 12px; line-height: 1.6; color: #8a8a8a; margin: 0; }

.dap-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px 8px;
  text-align: center;
}
.dap-progress-title { font-size: 13px; font-weight: 600; color: #1a1a1a; }
.dap-progress-sub { font-size: 11px; color: #8a8a8a; line-height: 1.6; }

.dap-stale-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: 14px;
}

/* Cross-surface provenance (2026-08-14): the displayed run came through the
   other door (SKU page ↔ FRQ card) — quiet informational chip, visually
   distinct from the amber stale warning. */
.dap-provenance {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #3730a3;
  background: #eef2ff;
  border: 1px solid #e0e7ff;
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: 14px;
}

/* --- Verdict block ---------------------------------------------------- */
.dap-verdict-block {
  border: 1px solid #e8e6e1;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 16px;
}
.dap-verdict--accept { background: #f0fdf4; border-color: #bbf7d0; }
.dap-verdict--investigate { background: #fffbeb; border-color: #fde68a; }
.dap-verdict--hold { background: #fef2f2; border-color: #fecaca; }

.dap-verdict-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.dap-verdict-pill {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.06);
}
.dap-verdict--accept .dap-verdict-pill { color: #16a34a; }
.dap-verdict--investigate .dap-verdict-pill { color: #d97706; }
.dap-verdict--hold .dap-verdict-pill { color: #dc2626; }
.dap-confidence { font-size: 11px; color: #6b6b6b; }
.dap-verdict-date { font-size: 11px; color: #6b6b6b; margin-left: auto; }

/* D3 deep-vs-triage agreement chip (P2): renders in the verdict row when the
   SKU has both a deep and a triage verdict. Agree = quiet confirmation;
   overturn = amber attention (the deep investigation changed the answer). */
.dap-agreement {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.dap-agreement--agree { color: #15803d; background: #f0fdf4; border-color: #bbf7d0; }
.dap-agreement--overturn { color: #92400e; background: #fef3c7; border-color: #fde68a; }

.dap-order-line { font-size: 14px; color: #1a1a1a; margin-bottom: 6px; }
.dap-order-line strong { font-size: 16px; font-weight: 700; }
.dap-order-engine { font-size: 12px; color: #6b6b6b; margin-left: 4px; }
.dap-headline { font-size: 13px; font-weight: 700; color: #1a1a1a; margin-bottom: 4px; }
.dap-analysis { font-size: 12px; line-height: 1.6; color: #444; white-space: pre-line; }
/* The report toggle reveals/hides the full report (collapsed by default). */
.dap-report-toggle {
  background: none;
  border: none;
  padding: 2px 0 0;
  font-size: 11px;
  font-weight: 600;
  color: #6b6b6b;
  cursor: pointer;
}
.dap-report-toggle:hover { color: #1a1a1a; }

/* --- Sections (ruled-out, report) ------------------------------------- */
.dap-section { margin-bottom: 16px; }
.dap-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #8a8a8a;
  margin-bottom: 6px;
}
/* The report + investigation trail + ruled-out are the full audit detail —
   collapsed together by default so the verdict block stays the lede; the
   toggle reveals them. */
.dap-report-collapse--collapsed { display: none; }
.dap-ruled-out { margin: 0; padding-left: 18px; font-size: 12px; line-height: 1.7; color: #444; }
.dap-ruled-out li { margin-bottom: 2px; }

/* --- Investigation trail (D1) ------------------------------------------ */
.dap-trail-details { margin-bottom: 16px; border: 1px solid #e8e6e1; border-radius: 8px; }
.dap-trail-summary { cursor: pointer; padding: 8px 12px; font-size: 12px; font-weight: 600; color: #555; }
.dap-trail { margin: 0; padding: 4px 12px 10px 30px; font-size: 11px; line-height: 1.7; color: #555; }
.dap-trail-step { margin-bottom: 2px; }
.dap-trail-tool {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 600;
  color: #1a1a1a;
}
.dap-trail-args { color: #8a8a8a; margin-left: 6px; overflow-wrap: anywhere; }
.dap-trail-step--error .dap-trail-tool { color: #dc2626; }

/* --- Meta line (generated_at + cost, D2) -------------------------------- */
.dap-meta { font-size: 11px; color: #8a8a8a; display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; }
.dap-budget-note { color: #d97706; font-weight: 600; }

/* --- Failure / refusal -------------------------------------------------- */
.dap-error {
  border: 1px solid #fecaca;
  background: #fef2f2;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 16px;
}
.dap-error-title { font-size: 12px; font-weight: 700; color: #dc2626; margin-bottom: 4px; }
.dap-error-message { font-size: 12px; color: #7f1d1d; line-height: 1.5; overflow-wrap: anywhere; }

/* --- Actions ------------------------------------------------------------ */
.dap-actions { border-top: 1px solid #f0eeea; padding-top: 14px; }
.dap-run-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}
.dap-run-btn:hover { filter: brightness(1.05); }
.dap-run-btn:disabled { opacity: 0.55; cursor: default; }
.dap-no-permission { font-size: 11px; color: #8a8a8a; line-height: 1.6; margin: 0; }
/* Cost/time expectation next to the run button (FRQ dual-option cards). */
.frq-dap-hint { font-size: 11px; color: #8a8a8a; margin-left: 8px; white-space: nowrap; }
.dap-inline-error { margin-top: 10px; font-size: 12px; color: #dc2626; }

/* --- FRQ card context (Harness P2 §13d) ---------------------------------
   The panel renders INSIDE a review card (no overlay shell), replacing the
   legacy AI accordion slot — separated from the card's action row by a rule
   and tightened relative to the SKU-page overlay. */
.frq-deep-panel {
  margin-top: 12px;
  border-top: 1px solid #f0eeea;
  padding-top: 12px;
}
.frq-dap-result { min-height: 0; }
.frq-dap-result .dap-empty { padding: 14px 8px; }
.frq-dap-result .dap-progress { padding: 18px 8px; }
.frq-dap-actions {
  border-top: none;
  padding-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ============================================
   Investigate-group (Harness P3 step 6) — replenishment header cards
   Confirm modal + terminal toast for deep_group_analysis_controller.
   All dynamic content is filled via textContent; these classes style
   the static chrome only (spec §13 R6 — no innerHTML in the modal).
   ============================================ */

/* Differentiates the deep Investigate button from the adjacent triage
   AI Review button — the deep flow's purple gradient family. */
.dga-investigate-btn {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  color: #fff;
  border-color: transparent;
}
.dga-investigate-btn:hover { filter: brightness(1.05); }

.dga-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(30, 27, 24, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.dga-modal {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(30, 27, 24, 0.25);
  width: 100%;
  max-width: 440px;
  padding: 20px 22px;
}
.dga-modal-title {
  font-size: 15px;
  font-weight: 700;
  color: #1e1b18;
}
.dga-modal-target {
  font-size: 12px;
  font-weight: 600;
  color: #6d28d9;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dga-modal-body { margin-top: 12px; }
.dga-modal-summary {
  font-size: 13px;
  color: #3d3a36;
  line-height: 1.5;
  margin: 0 0 8px;
}
.dga-modal-tallies {
  list-style: disc;
  margin: 0 0 8px;
  padding-left: 18px;
  font-size: 12px;
  color: #6b675f;
  line-height: 1.6;
}
.dga-modal-tallies:empty { display: none; margin: 0; }
.dga-modal-coverage {
  font-size: 12px;
  color: #6b675f;
  line-height: 1.5;
  margin: 0 0 8px;
}
.dga-modal-coverage:empty { display: none; margin: 0; }
.dga-modal-duration {
  font-size: 12px;
  color: #8a857c;
  line-height: 1.5;
  margin: 0;
  border-top: 1px solid #f0eeea;
  padding-top: 8px;
}
/* Gate/budget refusals render VERBATIM here — loud, never swallowed. */
.dga-modal-refusal {
  margin-top: 10px;
  font-size: 12px;
  font-weight: 600;
  color: #b42318;
  background: #fef3f2;
  border: 1px solid #fecdca;
  border-radius: 8px;
  padding: 8px 10px;
  line-height: 1.5;
}
.dga-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}
.dga-modal-confirm:disabled { opacity: 0.55; cursor: default; }

/* Terminal toast — "Investigated N of M" + partial-failure detail. */
.dga-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 12px);
  z-index: 1300;
  max-width: 480px;
  background: #1e1b18;
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: 0 10px 30px rgba(30, 27, 24, 0.35);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.dga-toast--visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
