/* ============================================================
   AhadiCare AI — playground styles
   All colour, type and shape values come from brand.css.
   Do not hardcode a hex here: add or repoint a token instead.

   The one exception: every color-mix() declaration is preceded by a static
   twin, e.g.
       border-color: #81ad94;
       border-color: color-mix(in srgb, var(--ok) 45%, var(--border));
   Browsers that do not support color-mix() (Safari < 16.2) drop the second
   declaration and keep the first. Those static values are computed from the
   DEFAULT palette, so if you retheme LAYER 1 in brand.css they become slightly
   stale — on those old browsers only; every current browser uses the live
   color-mix() line and retints correctly.
   ============================================================ */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background:
    radial-gradient(900px 620px at 88% -12%, var(--bg-tint) 0%, transparent 62%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, .brand-name, .empty-title, .asm-total, .chat-title {
  font-family: var(--font-display);
}

a { color: var(--accent); text-decoration: none; font-weight: 600; }
a:hover { color: var(--text-strong); text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Top bar ─────────────────────────────────────────── */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 14px 28px; border-bottom: 1px solid var(--border);
  background: rgba(244, 240, 220, 0.82); background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  background: var(--panel-2);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.logo img { width: 26px; height: 26px; object-fit: contain; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -.2px; color: var(--text-strong); }
.brand-sub  { color: var(--muted); font-size: 12px; }
.topbar-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.pill {
  padding: 7px 14px; border: 1px solid var(--border); border-radius: var(--radius-pill);
  background: var(--panel-2); color: var(--text); font-size: 12px;
  text-decoration: none; font-family: var(--font-mono); font-weight: 600;
  transition: border-color .15s, color .15s;
}
.pill:hover { border-color: var(--border-strong); text-decoration: none; }
.pill-muted { color: var(--muted); }
.pill-ok  { color: var(--ok);     border-color: #81ad94; border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); }
.pill-bad { color: var(--danger); border-color: #d08f70; border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }

/* ── Layout ──────────────────────────────────────────── */
.grid {
  display: grid; gap: 20px; padding: 24px;
  grid-template-columns: 300px 1fr 380px;
  max-width: 1680px; margin: 0 auto;
}
@media (max-width: 1200px) { .grid { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-card); padding: 24px; box-shadow: var(--shadow);
}

/* Section labels use the site's eyebrow: uppercase, heavy, wide-tracked. */
.panel h2 {
  margin: 0 0 6px; font-size: 12px; letter-spacing: .18em;
  color: var(--accent); text-transform: uppercase; font-weight: 800;
  font-family: var(--font-body);
}
.hint { color: var(--muted); font-size: 12.5px; margin: 0 0 14px; line-height: 1.55; }

.panel-main { min-height: 720px; display: flex; flex-direction: column; }

/* ── Tenants + session ─────────────────────────────────── */
.tenant-list { display: grid; gap: 10px; }
.tenant {
  border: 1px solid var(--border); background: var(--panel-2);
  border-radius: var(--radius-md); padding: 13px 15px; cursor: pointer;
  transition: border-color .15s, transform .12s, box-shadow .15s;
}
.tenant:hover {
  border-color: var(--border-strong); transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.tenant.active {
  border-color: var(--accent);
  background: #e7f4f0; background: color-mix(in srgb, var(--accent-soft) 22%, var(--panel-2));
  box-shadow: inset 3px 0 0 var(--accent);
}
.tenant-name { font-weight: 700; color: var(--text-strong); }
.tenant-meta { font-size: 11px; color: var(--muted); font-family: var(--font-mono); margin-top: 3px; }

.session-card {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 14px; display: grid; gap: 9px;
}
.session-row { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }
.session-row code { color: var(--text); font-family: var(--font-mono); font-size: 11px; }

.mini-select, input, select, textarea {
  width: 100%; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 12px;
  font-size: 13px; font-family: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.mini-select { width: auto; padding: 5px 10px; border-radius: var(--radius-pill); }
textarea { font-family: var(--font-mono); font-size: 13px; resize: vertical; }
textarea:focus, input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(147, 210, 217, 0.45); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-soft) 45%, transparent);
}

label {
  display: block; font-size: 11px; color: var(--label); margin: 14px 0 6px;
  text-transform: uppercase; letter-spacing: .12em; font-weight: 700;
}

.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.stat {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 12px 13px;
}
.stat-label { font-size: 10px; text-transform: uppercase; color: var(--muted); letter-spacing: .12em; font-weight: 700; }
.stat-val { font-size: 19px; font-weight: 800; margin-top: 3px; font-family: var(--font-display); color: var(--text-strong); }

/* ── Buttons — pill shaped, per the site's Btn component ── */
.btn {
  padding: 10px 20px; border-radius: var(--radius-pill); border: 2px solid var(--border);
  background: var(--panel-2); color: var(--text-strong); cursor: pointer; font-size: 13px;
  font-family: inherit; font-weight: 700;
  transition: transform .15s, border-color .15s, background .15s, color .15s;
}
.btn:hover { transform: translateY(-1px); border-color: var(--text-strong); }
.btn-primary {
  background: var(--primary); border-color: var(--primary);
  color: var(--on-primary); font-weight: 800;
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text-strong); border-color: var(--border); }
.actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 12px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.col { min-width: 0; }

/* ── Mode tabs (center panel) ───────────────────────── */
.mode-tabs {
  display: flex; gap: 4px; margin-bottom: 16px;
  background: var(--well); border-radius: var(--radius-pill); padding: 4px;
  width: fit-content; max-width: 100%; flex-wrap: wrap;
}
.mode-tab {
  padding: 8px 18px; border-radius: var(--radius-pill); border: none;
  background: transparent; color: var(--muted); font-size: 12.5px; cursor: pointer;
  font-family: inherit; font-weight: 700;
  transition: background .15s, color .15s;
}
.mode-tab:hover { color: var(--text-strong); }
.mode-tab.active {
  color: var(--on-primary); background: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* ── Chat ───────────────────────────────────────────── */
.chat-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 14px; border-bottom: 1px solid var(--border); margin-bottom: 14px;
}
.chat-title { font-weight: 700; font-size: 17px; color: var(--text-strong); letter-spacing: -.2px; }
.chat-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.chat-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-pill);
  padding: 6px 14px; font-size: 12px; cursor: pointer; color: var(--muted);
  font-family: inherit; font-weight: 600;
  transition: color .15s, border-color .15s, background .15s;
}
.chip:hover {
  color: var(--accent); border-color: var(--accent);
  background: #ecf5f1; background: color-mix(in srgb, var(--accent-soft) 18%, var(--panel-2));
}
.chip-warn { color: var(--warn); border-color: #cea67d; border-color: color-mix(in srgb, var(--warn) 35%, var(--border)); }
.chip-warn:hover {
  color: var(--danger); border-color: var(--danger);
  background: #faede4; background: color-mix(in srgb, var(--danger) 8%, var(--panel-2));
}

.messages {
  flex: 1; overflow-y: auto; padding: 14px 6px; display: flex; flex-direction: column; gap: 12px;
  min-height: 320px; max-height: 520px;
}
.empty-hint { margin: auto; text-align: center; color: var(--muted); max-width: 420px; }
.empty-title { font-size: 23px; font-weight: 700; color: var(--text-strong); margin-bottom: 8px; letter-spacing: -.4px; }
.empty-sub { font-size: 13px; line-height: 1.6; }

.msg { display: flex; gap: 9px; max-width: 82%; animation: msg-in .25s ease-out; }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg-user { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 800; flex-shrink: 0;
  background: var(--well); color: var(--muted);
}
.msg-user .msg-avatar { background: var(--bubble-user); color: var(--bubble-user-text); }
.msg-bot .msg-avatar { background: var(--primary); color: var(--on-primary); }
.msg-body { display: flex; flex-direction: column; gap: 4px; }
.msg-user .msg-body { align-items: flex-end; }
.bubble {
  padding: 11px 16px; border-radius: var(--radius-md); line-height: 1.55;
  white-space: pre-wrap; word-wrap: break-word;
}
.msg-user .bubble {
  background: var(--bubble-user); color: var(--bubble-user-text);
  border-bottom-right-radius: 6px;
}
.msg-bot .bubble {
  background: var(--bubble-bot); color: var(--bubble-bot-text);
  border: 1px solid var(--border); border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-sm);
}
.msg-meta { font-size: 11px; color: var(--muted); }
.msg-meta.warn { color: var(--warn); font-weight: 600; }
.msg-meta.bad  { color: var(--danger); font-weight: 600; }

.typing { display: inline-flex; gap: 4px; padding: 13px 16px; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: typing 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .18s; }
.typing span:nth-child(3) { animation-delay: .36s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .35; } 30% { transform: translateY(-4px); opacity: 1; } }

.tool-hint {
  background: #e3f2ee; background: color-mix(in srgb, var(--accent-soft) 26%, var(--panel-2));
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  padding: 12px 16px; font-size: 13px; cursor: pointer;
  margin: 4px 0; line-height: 1.5;
  /* Rendered as a <button> so the offer is keyboard-reachable and announced as
     an action; these reset the UA button defaults back to the chat's type. */
  width: 100%; display: block; text-align: center;
  font-family: inherit; font-weight: 600; color: var(--text);
  transition: border-color .15s, background .15s;
}
.tool-hint:hover {
  border-color: var(--accent);
  background: #d4ecea; background: color-mix(in srgb, var(--accent-soft) 40%, var(--panel-2));
}
.tool-hint b { color: var(--accent-2); }

/* ── In-chat assessment (question bubble, progress, choice chips) ── */
.chat-q-meta {
  font-size: 11px; color: var(--muted); letter-spacing: .1em;
  font-family: var(--font-mono); text-transform: uppercase; font-weight: 600;
}
.chat-progress {
  height: 5px; background: var(--well);
  border-radius: var(--radius-pill); margin: 7px 0 11px; overflow: hidden;
}
.chat-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-soft));
  transition: width .3s ease;
}
.chat-q-text { font-weight: 700; margin: 6px 0 11px; line-height: 1.45; color: var(--text-strong); }
.chat-q-text.crisis { color: var(--danger); }
.chat-choices { display: flex; flex-direction: column; gap: 6px; }
.chat-choice {
  display: flex; align-items: center; gap: 10px; text-align: left;
  background: var(--panel-2);
  border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 9px 13px; font-size: 13px; cursor: pointer;
  font-family: inherit;
  transition: border-color .12s, background .12s, transform .08s;
}
.chat-choice:hover {
  border-color: var(--accent);
  background: #e7f4f0; background: color-mix(in srgb, var(--accent-soft) 22%, var(--panel-2));
  transform: translateX(2px);
}
.chat-choice-num {
  display: inline-grid; place-items: center;
  width: 24px; height: 24px; background: var(--well);
  border: 1px solid var(--border); border-radius: 6px;
  font-family: var(--font-mono);
  font-weight: 800; font-size: 11px; color: var(--accent);
  flex-shrink: 0;
}
.chat-q-hint { font-size: 11px; color: var(--faint); margin-top: 9px; }

/* ── Composer ───────────────────────────────────────── */
.composer { display: flex; gap: 9px; padding-top: 14px; border-top: 1px solid var(--border); }
.composer textarea { flex: 1; max-height: 120px; border-radius: var(--radius-md); }
.send-btn {
  padding: 0 24px; background: var(--primary);
  border: none; border-radius: var(--radius-pill); color: var(--on-primary);
  font-weight: 800; cursor: pointer; font-family: inherit; font-size: 14px;
  transition: transform .15s, background .15s;
}
.send-btn:hover { transform: translateY(-1px); background: var(--primary-hover); }
.composer-hint { text-align: center; font-size: 11px; color: var(--faint); padding: 8px 0 0; }

/* ── Assessment (paragraph-style choices) ───────────── */
.assessment-panel {
  margin-top: 14px; padding: 18px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: var(--radius-md);
}
.asm-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; gap: 10px; }
.asm-title { font-weight: 700; color: var(--text-strong); }
.asm-progress { font-size: 12px; color: var(--muted); font-family: var(--font-mono); }
.asm-bar {
  height: 6px; background: var(--well); border-radius: var(--radius-pill);
  overflow: hidden; margin: 11px 0 16px;
}
.asm-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-soft)); transition: width .3s ease; }
.asm-instruction { font-size: 12px; color: var(--muted); margin-bottom: 9px; }
.asm-question { font-size: 15px; font-weight: 700; margin-bottom: 11px; line-height: 1.45; color: var(--text-strong); }
.asm-question.crisis { color: var(--danger); }

.asm-choices { display: flex; flex-direction: column; gap: 6px; }
.asm-choice {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 15px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--text); text-align: left; cursor: pointer;
  font-size: 13px; font-family: inherit;
  transition: border-color .12s, background .12s, transform .08s;
}
.asm-choice:hover {
  border-color: var(--accent);
  background: #e5f0e6; background: color-mix(in srgb, var(--accent-soft) 20%, var(--panel));
  transform: translateX(2px);
}
.asm-choice-num {
  display: inline-grid; place-items: center; width: 26px; height: 26px;
  background: var(--well); border: 1px solid var(--border); border-radius: 7px;
  font-family: var(--font-mono); font-weight: 800; font-size: 12px; color: var(--accent);
  flex-shrink: 0;
}
.asm-choice-label { flex: 1; }

.asm-cancel {
  margin-top: 14px; background: transparent; border: none; color: var(--muted);
  font-size: 12px; cursor: pointer; font-family: inherit; font-weight: 600;
}
.asm-cancel:hover { color: var(--danger); }

.asm-result {
  padding: 18px; background: #e5f3ef; background: color-mix(in srgb, var(--accent-soft) 24%, var(--panel-2));
  border: 1px solid var(--border-strong); border-radius: var(--radius-md); margin-top: 14px;
}
.asm-result.crisis {
  background: #f9ebe2; background: color-mix(in srgb, var(--danger) 9%, var(--panel-2));
  border-color: #d08f70; border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
}
.asm-total { font-size: 32px; font-weight: 800; letter-spacing: -1px; color: var(--text-strong); }
.asm-result.crisis .asm-total { color: var(--danger); }
.asm-severity { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .14em; font-weight: 700; }
.asm-advice { margin-top: 11px; font-size: 13px; line-height: 1.6; }

/* ── Facility panel ─────────────────────────────────── */
.facility-panel { display: grid; gap: 9px; margin: 10px 0; }
.facility-card {
  background: var(--panel-2); border: 1px solid var(--border);
  border-left: 4px solid var(--danger); border-radius: var(--radius-sm); padding: 12px 15px;
}
.facility-name { font-weight: 700; color: var(--text-strong); }
.facility-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ── Analyzer response card ─────────────────────────── */
.response-card {
  min-height: 80px; border: 1px dashed var(--border); border-radius: var(--radius-md);
  padding: 16px; background: var(--panel-2); white-space: pre-wrap; line-height: 1.6;
  margin-top: 10px;
}
.response-card.empty { display: grid; place-items: center; color: var(--faint); font-style: italic; min-height: 60px; }

/* ── Right pane: snippets + events ───────────────────── */
.tabs { display: flex; gap: 4px; margin-bottom: 0; }
.tab {
  padding: 7px 14px; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border: 1px solid var(--border); border-bottom: none;
  background: var(--well); color: var(--muted); font-size: 12px; cursor: pointer;
  font-family: inherit; font-weight: 700;
  position: relative; top: 1px;
}
.tab.active { color: var(--code-accent); background: var(--code-bg); border-color: var(--code-border); }
.code {
  background: var(--code-bg); border: 1px solid var(--code-border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) var(--radius-sm);
  padding: 14px; font-size: 12px; font-family: var(--font-mono);
  color: var(--code-text); white-space: pre; overflow: auto; max-height: 260px;
  margin: 0;
}
.events { display: grid; gap: 9px; max-height: 340px; overflow: auto; }
.event {
  border: 1px solid var(--border); background: var(--panel-2); border-radius: var(--radius-sm);
  padding: 11px 13px; font-size: 12px;
}
.event-head {
  display: flex; justify-content: space-between; color: var(--muted);
  font-family: var(--font-mono); font-size: 11px; margin-bottom: 5px; gap: 8px;
}
.event-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event .u { color: var(--accent-2); font-weight: 600; }
.event .a { color: var(--accent); font-weight: 600; }
.event-flags { display: flex; gap: 4px; margin-top: 7px; flex-wrap: wrap; }
.badge {
  padding: 3px 10px; border-radius: var(--radius-pill); font-size: 10px;
  background: var(--well); border: 1px solid var(--border); color: var(--muted);
  font-family: var(--font-mono); font-weight: 600;
}
.badge.ok   { color: var(--ok);     border-color: #81ad94; border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); }
.badge.warn { color: var(--warn);   border-color: #c9986d; border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.badge.bad  { color: var(--danger); border-color: #d08f70; border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }

.foot {
  text-align: center; padding: 24px; color: var(--muted); font-size: 12px;
  border-top: 1px solid var(--border); margin-top: 12px;
}

/* ── Assessment debrief ──────────────────────────────
   The result is a piece of care, not a data readout: the score sits above as
   quiet context and the debrief itself is set as readable prose. */
.result-meta {
  font-size: 11px; color: var(--muted); font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: .1em; font-weight: 600;
  padding-bottom: 8px; margin-bottom: 10px; border-bottom: 1px solid var(--border);
}
.result-para { line-height: 1.65; }
.result-para + .result-para { margin-top: 10px; }

/* A crisis debrief leads with the safety directive; the rail marks it without
   turning the whole message red, which would read as alarm rather than care. */
.bubble.crisis {
  border-left: 4px solid var(--danger);
  background: #fcf3eb; background: color-mix(in srgb, var(--danger) 5%, var(--bubble-bot));
}
.bubble.crisis .result-meta + .result-para { color: var(--danger); font-weight: 600; }
