/* Provider onboarding chat (/apply) — layered on associate.css's shared tokens, buttons and dialogs.
   Full-height flex layout: header (sticky, from associate.css) + #main filling the rest, with the
   #thread being the only scrollable region so PageUp/PageDown/Home/End/mouse-wheel all work on it
   natively — nothing here reimplements scrolling. */

html, body { height: 100%; }
body { display: flex; flex-direction: column; }
#main { flex: 1; min-height: 0; display: flex; flex-direction: column; max-width: 720px; width: 100%; margin: 0 auto; padding: 0 16px; }
#main > .card { margin: 16px 0; flex: none; }

/* ---- "use the plain form instead" choice bar ----
   Full-width bar at the top of #main, above the chat. Existing tokens only; min 44px tap target.
   On narrow phones (down to 320px) the text stacks above a full-width button so nothing overflows. */
.form-choice { flex: none; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; margin: 16px 0 0; padding: 12px 14px; background: var(--accent-soft);
  border: 1px solid var(--accent); border-radius: var(--radius); }
.form-choice-text { margin: 0; color: var(--text); font-weight: 600; font-size: .95rem; }
.form-choice-btn { min-height: 44px; padding: 10px 18px; font-size: 1rem; border-radius: 10px; flex: none; }
@media (max-width: 560px) {
  .form-choice { flex-direction: column; align-items: stretch; gap: 10px; }
  .form-choice-text { text-align: center; }
  .form-choice-btn { width: 100%; justify-content: center; }
}
/* Submitted already — the offer is moot. Pure CSS so apply.js behaviour is untouched. */
#main:has(#success:not([hidden])) .form-choice { display: none; }

.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---- thread ---- */
.thread { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 2px 8px; display: flex; flex-direction: column; gap: 10px; }
.thread:focus-visible { outline: 3px solid var(--focus); outline-offset: -2px; border-radius: 8px; }

.msg-row { display: flex; gap: 10px; align-items: flex-end; max-width: 100%; }
.msg-row.user { justify-content: flex-end; }
.msg-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.msg-row.user .msg-avatar { visibility: hidden; }
.msg-bubble { padding: 10px 13px; border-radius: 14px 14px 14px 4px; max-width: 78%; font-size: .95rem;
  line-height: 1.5; background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.msg-row.user .msg-bubble { background: var(--accent); color: var(--accent-ink); border-color: transparent; border-radius: 14px 14px 4px 14px; }
.msg-row.error .msg-bubble { background: var(--warn-soft); color: var(--text); border-color: var(--warn); }

.typing .msg-bubble { display: inline-flex; gap: 5px; padding: 12px 14px; align-items: center; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); opacity: .4; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@media (prefers-reduced-motion: no-preference) { @keyframes blink { 0%, 60%, 100% { opacity: .35; } 30% { opacity: 1; } } }

/* Suggested replies for the latest assistant message — real <button>s, native Tab/Enter/Space. */
.quickreplies { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 0 0 40px; }
.chip-btn { padding: 7px 14px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  border: 1.5px solid var(--accent); font: inherit; font-weight: 600; font-size: .85rem; cursor: pointer; }
.chip-btn:hover { background: var(--accent); color: var(--accent-ink); }
.chip-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---- review / submit card ---- */
.review h2 { margin-top: 0; }

/* ---- composer ---- */
.composer { flex: none; display: flex; gap: 8px; align-items: flex-end; padding: 10px 2px 16px;
  border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--bg); }
.composer textarea { flex: 1; resize: none; max-height: 40vh; overflow-y: auto; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: 20px; background: var(--panel); color: var(--text);
  font: inherit; font-size: .95rem; line-height: 1.4; }
.composer textarea:disabled { opacity: .6; }
.send-btn { width: 42px; height: 42px; border-radius: 50%; padding: 0; font-size: 1.1rem; flex: none; }

/* ---- answers summary dialog ---- */
.answers-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.answers-list dt { color: var(--muted); font-size: .85rem; }
.answers-list dd { margin: 0; font-weight: 600; }
.answers-list .empty-hint { grid-column: 1 / -1; color: var(--muted); font-style: italic; }

@media (max-width: 560px) {
  .msg-bubble { max-width: 88%; }
  .quickreplies { padding-left: 0; }
}

/* ---- "bubble" MCQ chips (entity-type gate) — real <input type=radio>, same pattern as
   apply-classic.css: Tab/arrow-keys/Space/Enter all work natively. */
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--panel); cursor: pointer; font-size: .92rem; user-select: none;
}
.chip input { width: 15px; height: 15px; accent-color: var(--accent); flex: none; margin: 0; }
.chip:hover { border-color: var(--accent); }
.chip.checked, .chip:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); font-weight: 600; }
.chip:has(input:focus-visible), .chip.chip-focus { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---- entity-type gate ---- */
.entity-chip-group { margin: 14px 0; }
.entity-chip { flex-direction: column; align-items: flex-start; padding: 14px 18px; gap: 4px; }
.entity-chip input { align-self: flex-start; }
.entity-chip .hint { margin: 0; padding-left: 21px; }
.entity-badge { display: flex; align-items: center; gap: 6px; margin: 0 2px 8px; }
.link-btn { background: none; border: none; padding: 0; margin: 0; cursor: pointer; font: inherit; color: var(--accent); text-decoration: underline; }
.link-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
