/*
  Chat-style UI (ChatGPT-like alignment)
  - Assistant bubbles align left
  - Patient input / responses align right
  - Conversation is rendered as a growing thread (no replacing previous questions)
  NOTE: Backend + overall flow remain the same; only presentation changes.
*/

:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: rgba(15, 23, 42, 0.12);
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);

  --assistant-bg: #f8fafc;
  --assistant-border: rgba(15, 23, 42, 0.10);

  --user-bg: #eaf2ff;
  --user-border: rgba(2, 132, 199, 0.18);

  --danger: #dc2626;
  --danger-bg: rgba(220, 38, 38, 0.08);

  --btn: #111827;
  --btn-hover: #0b1220;
  --btn-ghost: rgba(15, 23, 42, 0.06);
  --btn-ghost-hover: rgba(15, 23, 42, 0.10);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(1100px 540px at 50% 0%, #ffffff 0%, var(--bg) 62%);
  color: var(--text);
}

.wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 44px 16px 44px;
}

/* Bottom disclaimer */
.wrap::after {
  content: "This tool does not provide medical advice. Call 911 for emergencies.";
  display: block;
  margin: 18px auto 0;
  max-width: 640px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* App shell */
.shell {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.80);
  backdrop-filter: blur(8px);
}

.brandTitle {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brandSub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

/* Chat log */
.chat {
  padding: 18px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 74vh;
  overflow-y: auto;
}

/* Message rows */
.msg {
  width: 100%;
  display: flex;
}

.msg--assistant { justify-content: flex-start; }
.msg--user { justify-content: flex-end; }

/* Bubble */
.bubble {
  max-width: min(680px, 86%);
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid transparent;
  line-height: 1.45;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.06);
}

.bubble--assistant {
  background: var(--assistant-bg);
  border-color: var(--assistant-border);
}

.bubble--user {
  background: var(--user-bg);
  border-color: var(--user-border);
}

.bubble--error {
  background: var(--danger-bg);
  border-color: rgba(220, 38, 38, 0.35);
  color: var(--danger);
}

.bubble--muted {
  background: rgba(15, 23, 42, 0.03);
  border-color: rgba(15, 23, 42, 0.07);
  color: var(--muted);
  box-shadow: none;
}

.bubbleText { white-space: pre-wrap; }

.bubbleMeta {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.bubbleHint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

/* Composer (input + send/next) inside the user bubble */
.composer {
  display: flex;
  gap: 10px;
  align-items: center;
}

.input {
  flex: 1;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  background: #ffffff;
  color: var(--text);
  outline: none;
  font-size: 15px;
  line-height: 1.25;
}

.input::placeholder { color: rgba(100, 116, 139, 0.75); }

.input:focus {
  border-color: rgba(2, 132, 199, 0.40);
  box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.12);
}

.input--invalid {
  border-color: rgba(220, 38, 38, 0.55);
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.10);
}

.bubbleHint--error {
  color: #b91c1c;
  font-weight: 600;
}


/* Readonly inputs (used to display the submitted complaint as a visible textbox in the thread) */
.input[readonly] {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(15, 23, 42, 0.10);
  box-shadow: none;
  cursor: default;
}

.input[readonly]:focus {
  border-color: rgba(15, 23, 42, 0.12);
  box-shadow: none;
}

.btn {
  padding: 11px 14px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: var(--btn);
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease;
  white-space: nowrap;
}

.btn:hover { background: var(--btn-hover); }
.btn:active { transform: translateY(1px); }

.btn:disabled, .input:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btnGhost {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  background: var(--btn-ghost);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}

.btnGhost:hover { background: var(--btn-ghost-hover); }

/* Options (assistant) */
.options {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option {
  text-align: left;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  line-height: 1.35;
}

.option:hover {
  border-color: rgba(2, 132, 199, 0.25);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
}

.option.selected {
  border-color: rgba(2, 132, 199, 0.55);
  box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.10);
}

/* Divider inside bubbles */
.divider {
  height: 1px;
  width: 100%;
  background: rgba(15, 23, 42, 0.10);
  margin: 12px 0;
}

/* Fallback assistant body */
.answerBody {
  margin: 10px 0 0;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  background: rgba(15, 23, 42, 0.03);
  white-space: pre-wrap;
  overflow-x: auto;
  font-size: 13px;
}

/* Summary */
.summaryList {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.summaryItem {
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  background: rgba(255, 255, 255, 0.70);
}

.summaryQ { font-weight: 700; margin-bottom: 6px; }
.summaryA { white-space: pre-wrap; color: rgba(15, 23, 42, 0.86); }

.bottomSentinel { height: 1px; }

@media (max-width: 640px) {
  .chat { max-height: none; }
  .composer { flex-direction: column; align-items: stretch; }
  .btn { width: 100%; }
}


.input--textarea {
  min-height: 46px;
  resize: none;
  overflow-y: hidden;
  field-sizing: content;
  font: inherit;
}


.btnIcon {
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btnIcon--active {
  background: rgba(2, 132, 199, 0.14);
  border-color: rgba(2, 132, 199, 0.24);
}

.iconMic {
  display: block;
}
