/* ── Themes ────────────────────────────────────────────────── */
:root {
  --accent: #0b6efd;
  --accent-dark: #0958d9;
  --bg: #f7f9fb;
  --border: #e6eef8;
  --muted: #6b7280;
}

html[data-biz="sparky"] {
  --accent: #f59e0b;
  --accent-dark: #d97706;
  --bg: #fffdf5;
  --border: #fde68a;
}

html[data-biz="roofing"] {
  --accent: #16a34a;
  --accent-dark: #15803d;
  --bg: #f0fdf4;
  --border: #bbf7d0;
}

/* ── Base ──────────────────────────────────────────────────── */
* { box-sizing: border-box }
body { font-family: Inter, Segoe UI, Arial, sans-serif; margin: 0; background: var(--bg); color: #111; transition: background .2s; }
.container { max-width: 980px; margin: 0 auto; padding: 24px }

/* ── Tab bar ───────────────────────────────────────────────── */
.tab-bar { background: #fff; border-bottom: 2px solid var(--border); display: flex; transition: border-color .2s; }
.tab {
  background: none;
  color: var(--muted);
  border: none;
  border-bottom: 3px solid transparent;
  padding: 14px 28px;
  font-size: .95rem;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: -2px;
  border-radius: 0;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--accent); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ── Header ────────────────────────────────────────────────── */
.site-header { background: #fff; border-bottom: 1px solid var(--border); padding: 18px 0; transition: border-color .2s; }
.site-header h1 { margin: 0; font-size: 1.4rem }
.lead { color: var(--muted); margin: 6px 0 12px }
.controls { display: flex; gap: 8px; align-items: center }
button { background: var(--accent); color: #fff; border: none; padding: 8px 12px; border-radius: 6px; cursor: pointer; transition: background .15s; }
button:hover { background: var(--accent-dark); }
main h2 { margin-top: 0 }

/* ── Chat widget ───────────────────────────────────────────── */
#chat-root { position: fixed; right: 20px; bottom: 20px; z-index: 9999 }
.chat-widget { width: 320px; height: 420px; background: #fff; border-radius: 10px; box-shadow: 0 8px 30px rgba(16,24,40,.12); overflow: hidden; display: flex; flex-direction: column }
.chat-header { background: var(--accent); color: #fff; padding: 12px; font-weight: 600; display: flex; flex-direction: column; gap: 2px; transition: background .2s; }
.token-count { font-size: .7rem; font-weight: 400; opacity: .8; display: flex; gap: 8px; align-items: center }
.reset-chat { color: #fff; opacity: .8; text-decoration: underline; cursor: pointer }
.reset-chat.hidden { display: none }
.reset-chat:hover { opacity: 1 }
.chat-body { flex: 1; padding: 12px; overflow: auto; background: #f6f8fb }
.msg { margin: 8px 0; padding: 8px 12px; border-radius: 12px; max-width: 80% }
.msg.user { background: var(--accent); color: #fff; margin-left: auto; transition: background .2s; }
.msg.bot { background: #fff; border: 1px solid var(--border) }
.chat-input { display: flex; padding: 10px; border-top: 1px solid #eee }
.chat-input input { flex: 1; padding: 8px; border: 1px solid #ddd; border-radius: 6px }
.chat-input button { margin-left: 8px }

/* ── Typing indicator ──────────────────────────────────────── */
.msg.bot.typing { background: #fff; border: 1px solid var(--border); padding: 12px 16px }
.typing-dots { display: flex; gap: 4px; align-items: center; height: 16px }
.typing-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: inline-block; animation: bounce 1.2s infinite ease-in-out }
.typing-dots span:nth-child(1) { animation-delay: 0s }
.typing-dots span:nth-child(2) { animation-delay: .2s }
.typing-dots span:nth-child(3) { animation-delay: .4s }
@keyframes bounce { 0%,60%,100% { transform: translateY(0) } 30% { transform: translateY(-6px) } }

@media (max-width: 600px) {
  .chat-widget { width: 90vw; height: 60vh }
}

/* ── Red Team button ─────────────────────────────────────── */
.btn-redteam { background: transparent; color: #dc2626; border: 1.5px solid #dc2626; }
.btn-redteam:hover { background: #dc2626; color: #fff; }

/* ── Red Team panel ──────────────────────────────────────── */
#rt-root { display: none; padding: 24px 0; }
#rt-root.rt-active { display: block; }

.rt-panel { max-width: 700px; }

.rt-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.rt-title { font-size: 1.25rem; font-weight: 700; color: #dc2626; margin-right: 10px; }
.rt-biz-name { color: var(--muted); font-size: .95rem; }
.rt-back-btn { background: transparent; color: var(--muted); border: 1px solid var(--border); font-size: .85rem; padding: 6px 12px; }
.rt-back-btn:hover { color: var(--accent); border-color: var(--accent); background: transparent; }

.rt-intro { color: var(--muted); font-size: .9rem; margin: 0 0 16px; }

.rt-run-btn { background: #dc2626; margin-bottom: 20px; }
.rt-run-btn:hover { background: #b91c1c; }
.rt-run-btn:disabled { background: var(--muted); cursor: default; }

/* ── Probe cards ─────────────────────────────────────────── */
.rt-cards { display: flex; flex-direction: column; gap: 12px; }

.rt-card { background: #fff; border: 2px solid var(--border); border-radius: 10px; padding: 14px 16px; transition: border-color .2s; }
.rt-card.rt-running   { border-color: #93c5fd; }
.rt-card.rt-pass      { border-color: #86efac; }
.rt-card.rt-fail      { border-color: #fca5a5; }
.rt-card.rt-ambiguous { border-color: #fcd34d; }
.rt-card.rt-error     { border-color: #e5e7eb; opacity: .7; }

.rt-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.rt-probe-name { font-weight: 600; font-size: .95rem; }
.rt-verdict-badge { font-size: .85rem; font-weight: 600; min-width: 72px; text-align: right; }
.rt-probe-desc { color: var(--muted); font-size: .82rem; }

.rt-transcript { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.rt-msg { padding: 8px 12px; border-radius: 8px; font-size: .82rem; max-width: 90%; line-height: 1.4; }
.rt-msg.rt-user      { background: var(--accent); color: #fff; align-self: flex-end; transition: background .2s; }
.rt-msg.rt-assistant { background: #f6f8fb; border: 1px solid var(--border); align-self: flex-start; }

/* ── Spinner ─────────────────────────────────────────────── */
.rt-spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid #e5e7eb; border-top-color: var(--accent); border-radius: 50%; animation: rt-spin .7s linear infinite; vertical-align: middle; }
@keyframes rt-spin { to { transform: rotate(360deg) } }

/* ── Summary ─────────────────────────────────────────────── */
.rt-summary { margin-top: 20px; padding: 14px 16px; border-radius: 10px; font-weight: 600; font-size: 1rem; text-align: center; }
.rt-summary.rt-all-pass    { background: #dcfce7; color: #15803d; }
.rt-summary.rt-partial     { background: #fef9c3; color: #854d0e; }
.rt-summary.rt-mostly-fail { background: #fee2e2; color: #991b1b; }
