/* Trợ lý AI Khoa CNTT – TDTU · chat features of KS-07 (W15a): formulas, server history,
   assistant picker, attachments, tutor status, hand-off, error notes.
   Every colour comes from /static/shared/fit-tokens.css (semantic tokens); no raw values. */
/* ─────────────── Formulas (KaTeX) ─────────────── */
.math-block {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 0.45em 0;
  padding: 3px 1px;
}
.math-block .katex-display { margin: 0.2em 0; }
.math-block:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; border-radius: 4px; }
/* An inline formula wider than the bubble scrolls on its own (marked by markScrollable). */
.math-inline.is-wide { display: block; max-width: 100%; overflow-x: auto; overflow-y: hidden; padding: 3px 1px; }
.math-pending { font-family: var(--font-mono-stack); font-size: 0.9em; overflow-wrap: anywhere; }
code.math-fallback {
  display: inline-block;
  max-width: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  vertical-align: bottom;
}

/* ─────────────── Assistant picker (top bar + list) ─────────────── */
.assistant-picker { flex: 0 1 auto; min-width: 0; margin-left: 4px; }
.assistant-caret { flex-shrink: 0; width: 14px; height: 14px; }

.assistant-backdrop { position: fixed; inset: 0; z-index: 94; background: var(--overlay); }
.assistant-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.assistant-opt {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
}
.assistant-opt:hover { background: var(--panel-2); }
.assistant-opt[aria-selected="true"] { background: var(--primary-soft); border-color: var(--primary); }
.assistant-opt:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* Welcome screen: who this assistant is for + a way to the picker. */
/* ─────────────── History (sidebar) ─────────────── */
.history-skeleton { padding: 8px 10px; }
.sk-line {
  display: block;
  height: 11px;
  margin-bottom: 6px;
  border-radius: 4px;
  background: var(--rule);
  animation: sk-pulse 1.3s ease-in-out infinite;
}
.sk-line.is-short { width: 55%; height: 9px; }
@keyframes sk-pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

/* Opening a conversation from the server. */
.conv-loading { display: flex; align-items: center; gap: 10px; padding: 28px 4px; color: var(--muted); font-size: 13px; }
.conv-spinner {
  width: 18px;
  height: 18px;
  flex: none;
  border: 2px solid var(--rule);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: conv-spin .8s linear infinite;
}
@keyframes conv-spin { to { transform: rotate(360deg); } }

/* ─────────────── Error notes with a next step ─────────────── */
/* ─────────────── Tutor status ─────────────── */
.composer-banner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 8px;
  padding: 7px 10px;
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.45;
}
.composer-banner svg { flex: none; width: 14px; height: 14px; margin-top: 2px; }

/* ─────────────── Hand-off to another assistant ─────────────── */
/* ─────────────── Attachments ─────────────── */
/* Files sent with a question, under the user's bubble. */
/* Waiting for the follow-up suggestions: readable, not faded. */
/* ─────────────── W15b: waiting for the first word ─────────────── */
/* After a long wait the bubble says it is still working and how to stop (files, Chuyên sâu). */
/* ─────────────── W15b: welcome states and first steps by role ─────────────── */
/* An exam is on for this tutor (walkthrough 06/11, C9): the same colours as the exam tag. */
/* Buttons of the welcome notes and the role dialog (same look as .note-action, own name). */
.persona-staff { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 14px 0 0; font-size: 13px; color: var(--text-2); }

/* The stream was cut: what was written stays, with a way to ask again. */
/* ─────────────── W15b: a guest's conversations while signed in; greeting not kept ─────────────── */
.history-guest {
  margin: 10px 8px 4px;
  padding: 10px;
  background: var(--panel-2);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-2);
}
.history-guest-text { margin: 0; }
.history-guest-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.history-guest-list { display: grid; gap: 2px; margin-top: 8px; }
.msg-unsaved { margin: 6px 0 0; font-size: 12px; line-height: 1.45; color: var(--text-2); }
.acct-guest { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 12px; font-size: 13px; line-height: 1.45; color: var(--text); cursor: pointer; }
.acct-guest input { flex: none; width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--primary); }

/* ─────────────── W15b: academic advising outcome (ADR-T024b) ─────────────── */
/* No record read (walkthrough C6): how to get a personal answer, not a verdict. */
/* ─────────────── W15b: evidence of web browsing (ADR-T023) ─────────────── */
.browse-evidence {
  max-width: 68ch;
  margin-top: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.45;
}
.browse-summary {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 12px;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  list-style: revert;
}
.browse-summary svg { flex: none; width: 15px; height: 15px; color: var(--primary); }
.browse-summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; border-radius: var(--radius-sm); }
.browse-list { display: grid; gap: 6px; margin: 0; padding: 0 12px 4px 34px; list-style: none; }
.browse-item { display: flex; flex-direction: column; gap: 1px; min-width: 0; padding-left: 8px; border-left: 3px solid var(--success); }
.browse-item.is-blocked { border-left-color: var(--warning); }
.browse-link {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  min-height: 24px;          /* WCAG 2.2 target size: the link stands alone on its line */
  color: var(--primary);
  font-weight: 600;
  overflow-wrap: anywhere;
  text-underline-offset: 2px;
}
.browse-link:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 2px; }
.browse-host { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.browse-meta { font-size: 12px; color: var(--text-2); overflow-wrap: anywhere; }
.browse-note { margin: 6px 12px 8px 34px; font-size: 12px; color: var(--text-2); }

@media (max-width: 720px) {
  .browse-list { padding-left: 14px; }
  .browse-note { margin-left: 14px; }
}
@media (max-width: 480px) {
  /* The assistant's name is what the top bar is for on a phone. Theme and transcript move to
     the drawer; the account chip keeps a short width. */
#themeBtn,
#exportBtn { display: none; }
  .assistant-picker { flex: 1 1 auto; margin-left: 0; }
}
