/* Medvantage AI Auditor: case chat. Builds on the tokens in audit_dashboard.css. */

.app-nav {
  display: flex;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: var(--raised);
}
.app-nav a {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}
.app-nav a:hover { color: var(--navy); }
.app-nav a[aria-current="page"] {
  background: var(--surface);
  color: var(--navy);
  box-shadow: var(--shadow-sm);
}
.brand { text-decoration: none; }

/* ---------------- page layout ---------------- */
body.chat-page {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(1100px 520px at 88% -10%, rgba(242, 107, 33, 0.08), transparent 60%),
    radial-gradient(900px 600px at -5% 10%, rgba(31, 75, 153, 0.08), transparent 60%),
    var(--ground);
}
[data-theme="dark"] body.chat-page { background: var(--ground); }

.chat-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 32px 16px 24px;
}
.chat-column {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ---------------- intro ---------------- */
.chat-intro { padding-top: 24px; }
.chat-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 10px;
  letter-spacing: -0.02em;
}
.chat-lead {
  font-size: 0.98rem;
  line-height: 1.65;
  color: var(--text-secondary);
  margin: 0 0 20px;
  max-width: 64ch;
}
.sample-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sample-label { font-size: 0.85rem; color: var(--muted); margin-right: 2px; }
.sample-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.83rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}
.sample-btn:hover { border-color: var(--accent); color: var(--accent); }
.chat-privacy { margin: 18px 0 0; font-size: 0.8rem; color: var(--muted); }

/* ---------------- messages ---------------- */
.msg-user { display: flex; justify-content: flex-end; }
.msg-user .bubble {
  max-width: 85%;
  background: var(--navy);
  color: #fff;
  padding: 12px 16px;
  border-radius: 16px 16px 4px 16px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.92rem;
  line-height: 1.55;
  box-shadow: 0 6px 16px -10px rgba(31, 75, 153, 0.6);
}
[data-theme="dark"] .msg-user .bubble { background: #2b4f8f; }

.msg-ai { display: flex; gap: 12px; align-items: flex-start; }
.ai-avatar {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
}
.ai-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }

/* ---------------- thought process ---------------- */
.thought {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.thought summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  list-style: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--navy);
}
.thought summary::-webkit-details-marker { display: none; }
.thought-time { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.thought-chevron { margin-left: auto; color: var(--muted); transition: transform var(--transition); }
.thought[open] .thought-chevron { transform: rotate(180deg); }

.thought-spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--accent-light);
  border-top-color: var(--accent);
  animation: chat-spin 0.9s linear infinite;
}
.thought.finished .thought-spinner {
  animation: none;
  border-color: var(--match);
  background: var(--match);
  box-shadow: inset 0 0 0 3px var(--surface);
}
@keyframes chat-spin { to { transform: rotate(360deg); } }

.stages {
  list-style: none;
  margin: 0;
  padding: 2px 14px 10px 38px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted-light);
}
.stages li { display: flex; align-items: center; gap: 8px; }
.stage-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
}
.stages li.active { color: var(--accent); font-weight: 600; }
.stages li.active .stage-dot { background: var(--accent); animation: chat-pulse 1.2s ease-in-out infinite; }
.stages li.done { color: var(--text-secondary); }
.stages li.done .stage-dot { background: var(--match); border-color: var(--match); }
@keyframes chat-pulse { 50% { opacity: 0.35; } }

.thought-text {
  margin: 0 14px 14px;
  padding: 12px 14px;
  max-height: 280px;
  overflow-y: auto;
  border-left: 3px solid var(--accent-light);
  background: var(--raised);
  border-radius: 0 10px 10px 0;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------------- answer ---------------- */
.answer {
  font-size: 0.93rem;
  line-height: 1.65;
  color: var(--text);
}
.answer:empty { display: none; }
.answer h3 {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--navy);
  margin: 18px 0 6px;
}
.answer h3:first-child { margin-top: 0; }
.answer p { margin: 0 0 10px; }
.answer ul, .answer ol { margin: 0 0 12px; padding-left: 22px; }
.answer li { margin-bottom: 6px; }
.answer li::marker { color: var(--muted-light); }
.answer code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--raised);
  padding: 1px 5px;
  border-radius: 4px;
}
.answer-error {
  color: var(--conflict-ink);
  background: var(--conflict-bg);
  border: 1px solid var(--conflict-border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.86rem;
}

.sev {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 7px;
  border-radius: 999px;
  margin-right: 4px;
  vertical-align: 1px;
}
.sev-critical { background: var(--conflict-bg); color: var(--conflict-ink); border: 1px solid var(--conflict-border); }
.sev-high { background: var(--accent-light); color: var(--accent); border: 1px solid rgba(242, 107, 33, 0.35); }
.sev-moderate { background: var(--partial-bg); color: var(--partial-ink); border: 1px solid var(--partial-border); }
.sev-low { background: var(--raised); color: var(--muted); border: 1px solid var(--border); }

/* ---------------- composer ---------------- */
.composer {
  padding: 12px 16px 14px;
  background: linear-gradient(180deg, transparent, var(--ground) 30%);
}
.composer-box {
  max-width: 820px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 10px 30px -14px rgba(31, 75, 153, 0.3);
  padding: 12px 12px 10px 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.composer-box textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font: inherit;
  font-size: 0.93rem;
  line-height: 1.55;
  color: var(--text);
  max-height: 280px;
}
.composer-box textarea:disabled { opacity: 0.6; }
.composer-foot { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.composer-hint { font-size: 0.75rem; color: var(--muted); margin-right: auto; }
.composer-hint kbd {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
}
.send-btn, .stop-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 16px;
  border-radius: 999px;
  border: none;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}
.send-btn {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px -4px rgba(242, 107, 33, 0.55);
}
.send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.send-btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.stop-btn { background: var(--raised); color: var(--text); border: 1px solid var(--border); }
.send-btn[hidden], .stop-btn[hidden] { display: none; }
.composer-disclaimer { max-width: 820px; margin: 8px auto 0; text-align: center; font-size: 0.72rem; color: var(--muted); }

@media (max-width: 768px) {
  .chat-bar { grid-template-columns: auto 1fr; }
  .chat-bar .app-nav { display: none; }
  #new-case-btn span { display: none; }
  .chat-title { font-size: 1.5rem; }
  .msg-user .bubble { max-width: 92%; }
  .ai-avatar { display: none; }
}
