/* ================================================================
   AI-RICH-RENDER.CSS — styles for ChatGPT-style AI Call output
   (JSON cards, markdown prose, code blocks w/ copy button)
   Scoped under .ai-rich-content so it never leaks into other UI.
   ================================================================ */

.ai-rich-content { font-size: 14px; line-height: 1.55; }

/* ── Markdown prose ── */
.ai-rich-prose p { margin: 0 0 8px; }
.ai-rich-prose p:last-child { margin-bottom: 0; }
.ai-rich-prose h2, .ai-rich-prose h3, .ai-rich-prose h4 {
  margin: 10px 0 6px; line-height: 1.3; font-weight: 700;
}
.ai-rich-prose h2 { font-size: 16px; }
.ai-rich-prose h3 { font-size: 15px; }
.ai-rich-prose h4 { font-size: 14px; }
.ai-rich-prose ul, .ai-rich-prose ol { margin: 4px 0 8px; padding-left: 20px; }
.ai-rich-prose li { margin-bottom: 3px; }
.ai-rich-prose strong { font-weight: 700; }
.ai-rich-prose em { opacity: 0.9; }
.ai-rich-prose a { color: #6366f1; text-decoration: underline; }
.ai-rich-prose code:not(pre code) {
  background: rgba(148,163,184,0.18);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 12.5px;
}
.ai-rich-prose table {
  border-collapse: collapse;
  margin: 8px 0;
  width: 100%;
  font-size: 13px;
}
.ai-rich-prose th, .ai-rich-prose td {
  border: 1px solid rgba(148,163,184,0.35);
  padding: 5px 8px;
  text-align: left;
}
.ai-rich-prose th { background: rgba(148,163,184,0.15); font-weight: 600; }
.ai-rich-prose blockquote {
  border-left: 3px solid #6366f1;
  margin: 6px 0;
  padding: 2px 10px;
  opacity: 0.85;
}

/* ── Code blocks ── */
.ai-code-block {
  margin: 8px 0;
  border-radius: 10px;
  overflow: hidden;
  background: #1a1a24;
  border: 1px solid rgba(148,163,184,0.25);
}
.ai-code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(148,163,184,0.2);
}
.ai-code-lang {
  font-size: 11px;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.ai-code-copy {
  background: transparent;
  border: 1px solid rgba(148,163,184,0.3);
  color: #cbd5e1;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.15s, color 0.15s;
}
.ai-code-copy:hover { background: rgba(99,102,241,0.25); color: #fff; }
.ai-code-block pre {
  margin: 0;
  padding: 10px 12px;
  overflow-x: auto;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  color: #e2e8f0;
}
.ai-code-block code { background: none; padding: 0; }

/* ── JSON card ── */
.ai-json-card {
  border-radius: 10px;
  border: 1px solid rgba(148,163,184,0.25);
  background: #14141c;
  overflow: hidden;
  margin: 2px 0;
}
.ai-json-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(124,58,237,0.15);
  border-bottom: 1px solid rgba(148,163,184,0.2);
  font-size: 12px;
  font-weight: 600;
  color: #c4b5fd;
}
.ai-json-head i { color: #a78bfa; }
.ai-json-copy {
  margin-left: auto;
  background: transparent;
  border: 1px solid rgba(167,139,250,0.4);
  color: #c4b5fd;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.ai-json-copy:hover { background: rgba(124,58,237,0.25); color: #fff; }
.ai-json-body {
  padding: 10px 12px;
  overflow-x: auto;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  color: #e2e8f0;
}
.ai-json-node { display: inline; }
.ai-json-toggle {
  display: inline-block;
  width: 12px;
  cursor: pointer;
  color: #6b7280;
  user-select: none;
}
.ai-json-bracket { color: #9ca3af; }
.ai-json-key   { color: #7dd3fc; }
.ai-json-str   { color: #86efac; }
.ai-json-num   { color: #fca5a5; }
.ai-json-bool  { color: #fcd34d; }
.ai-json-null  { color: #9ca3af; font-style: italic; }
.ai-json-children {
  margin-left: 16px;
  border-left: 1px dashed rgba(148,163,184,0.2);
  padding-left: 10px;
}
.ai-json-children.collapsed { display: none; }
.ai-json-row { display: block; }

/* ── Light-theme override (builder preview panel has a light bg) ── */
.sim-bubble .ai-rich-content,
.cm-bubble  .ai-rich-content {
  color: inherit;
}
.sim-bubble .ai-code-block,
.sim-bubble .ai-json-card,
.cm-bubble .ai-code-block,
.cm-bubble .ai-json-card {
  background: #1a1a24; /* keep dark code/json cards even on a light bubble for contrast */
}
