/* ==========================================================================
   CDC Assistant – Inline Chat Panel (Phase 2.3)
   ========================================================================== */

/* ── FAB Button ────────────────────────────────────────────────────────── */

#askBtn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--color-accent, #2a9d8f);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 56px;
  height: 56px;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
  z-index: 1001;
}
#askBtn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}
#askBtn:focus-visible {
  outline: 3px solid var(--color-accent, #2a9d8f);
  outline-offset: 3px;
}

/* ── Panel Container ──────────────────────────────────────────────────── */

#askPanel {
  position: fixed;
  bottom: 5rem;
  right: 1.5rem;
  width: 380px;
  max-height: 520px;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #ddd);
  border-radius: 1rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--font-body, system-ui, -apple-system, sans-serif);
  z-index: 1000;
}
/* The `#askPanel` rule above has ID-level specificity, which beats
   the UA default `[hidden] { display: none }`. Without this restore,
   `<div id="askPanel" hidden>` still renders flex — the panel is
   visually positioned off the natural reading flow but stays in the
   pointer-event hit-test path and in the keyboard tab order. Real
   consequences: tab traversal lands on a "hidden" input; click
   targets near the FAB get intercepted. */
#askPanel[hidden] {
  display: none;
}

/* ── Header ───────────────────────────────────────────────────────────── */

.assistant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border, #e5e5e5);
  background: var(--color-surface-alt, #f8f9fa);
}

.assistant-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text, #1a1a2e);
}

.assistant-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--color-text-muted, #666);
  padding: 0.25rem;
  border-radius: 0.25rem;
}
.assistant-close:hover {
  color: var(--color-text, #1a1a2e);
  background: var(--color-surface-hover, rgba(0, 0, 0, 0.06));
}

/* ── Messages area ────────────────────────────────────────────────────── */

.assistant-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 180px;
  max-height: 360px;
}

/* ── Message bubbles ──────────────────────────────────────────────────── */

.assistant-msg {
  max-width: 90%;
  padding: 0.6rem 0.85rem;
  border-radius: 0.75rem;
  font-size: 0.9rem;
  line-height: 1.5;
  word-wrap: break-word;
}
.assistant-msg p {
  margin: 0;
}

.assistant-msg--user {
  align-self: flex-end;
  background: var(--color-accent, #2a9d8f);
  color: #fff;
  border-bottom-right-radius: 0.2rem;
}

.assistant-msg--bot {
  align-self: flex-start;
  background: var(--color-surface-alt, #f0f0f5);
  color: var(--color-text, #1a1a2e);
  border-bottom-left-radius: 0.2rem;
}

/* ── Citation links ───────────────────────────────────────────────────── */

.assistant-links {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.assistant-links li {
  padding: 0;
}
.assistant-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--color-accent, #2a9d8f);
  font-size: 0.85rem;
  text-decoration: none;
}
.assistant-links a::before {
  content: "→";
  font-size: 0.75rem;
}
.assistant-links a:hover {
  text-decoration: underline;
}

/* ── Next-topic suggestions ───────────────────────────────────────────── */

.assistant-suggestions {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.assistant-suggestions__label {
  font-size: 0.78rem;
  color: var(--color-text-muted, #666);
  margin-right: 0.25rem;
}
.assistant-suggestion-chip {
  display: inline-block;
  font-size: 0.78rem;
  padding: 0.2rem 0.6rem;
  /* Use the hover-shade accent so white text passes WCAG AA. The
     default --color-accent-primary (#3b82f6) on white is 3.7:1;
     --color-accent-hover (#2563eb) is 5.2:1. */
  background: var(--color-accent-hover, #2563eb);
  color: #fff;
  text-decoration: none;
  border-radius: 1rem;
  white-space: nowrap;
}
.assistant-suggestion-chip:hover {
  opacity: 0.85;
}

/* ── Feedback ─────────────────────────────────────────────────────────── */

.assistant-feedback {
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.assistant-fb-btn {
  background: none;
  border: 1px solid var(--color-border, #ddd);
  border-radius: 0.4rem;
  cursor: pointer;
  font-size: 1rem;
  padding: 0.2rem 0.5rem;
  transition: background 0.15s;
}
.assistant-fb-btn:hover {
  background: var(--color-surface-hover, rgba(0, 0, 0, 0.06));
}
.assistant-fb-thanks {
  font-size: 0.8rem;
  color: var(--color-text-muted, #888);
  font-style: italic;
}

/* ── Input row ────────────────────────────────────────────────────────── */

.assistant-input-row {
  display: flex;
  border-top: 1px solid var(--color-border, #e5e5e5);
  padding: 0.5rem;
  gap: 0.4rem;
  background: var(--color-surface, #fff);
}
.assistant-input {
  flex: 1;
  border: 1px solid var(--color-border, #ccc);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  outline: none;
  background: var(--color-surface, #fff);
  color: var(--color-text, #1a1a2e);
}
.assistant-input::placeholder {
  color: var(--color-text-muted, #999);
}
.assistant-input:focus {
  border-color: var(--color-accent, #2a9d8f);
  box-shadow: 0 0 0 2px rgba(42, 157, 143, 0.2);
}
.assistant-send {
  display: flex;
  align-items: center;
  justify-content: center;
  /* WCAG 2.2 target-size compliance — bumped from 36px to the 44px
     touch-friendly tier already used on .nav-chip and the mobile menu
     toggle (see 03-layout.css). Lighthouse `target-size` audit on
     /intro/ scored 0 against the styled build with the 36px size. */
  width: 44px;
  height: 44px;
  background: var(--color-accent, #2a9d8f);
  color: #fff;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  flex-shrink: 0;
}
.assistant-send:hover {
  opacity: 0.9;
}

/* ── Dark mode ────────────────────────────────────────────────────────── */

[data-theme="dark"] #askPanel {
  background: var(--color-surface, #1e1e2e);
  border-color: var(--color-border, #333);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
[data-theme="dark"] .assistant-header {
  background: var(--color-surface-alt, #252535);
  border-color: var(--color-border, #333);
}
[data-theme="dark"] .assistant-msg--bot {
  background: var(--color-surface-alt, #2a2a3e);
  color: var(--color-text, #e0e0e5);
}
[data-theme="dark"] .assistant-input-row {
  background: var(--color-surface, #1e1e2e);
  border-color: var(--color-border, #333);
}
[data-theme="dark"] .assistant-input {
  background: var(--color-surface-alt, #252535);
  border-color: var(--color-border, #444);
  color: var(--color-text, #e0e0e5);
}

/* ── Responsive ───────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  #askPanel {
    left: 0.5rem;
    right: 0.5rem;
    bottom: 0.5rem;
    width: auto;
    max-height: 75vh;
  }
}
