/* =================================================================
   Site assistant widget — "Workflow Canvas" styling.
   Reuses the site's design tokens (styles.css), so it follows both
   themes automatically. All classes prefixed .ai- to avoid clashes.
   ================================================================= */

.ai-fab {
  position: fixed;
  right: clamp(16px, 3vw, 28px);
  bottom: clamp(16px, 3vw, 28px);
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: box-shadow var(--t-fast), transform var(--t-fast), background var(--t-fast);
}
.ai-fab:hover { box-shadow: var(--glow); transform: translateY(-2px); }
.ai-fab__dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--flow);
  box-shadow: 0 0 10px var(--iris);
}

.ai-panel {
  position: fixed;
  right: clamp(12px, 3vw, 28px);
  bottom: clamp(12px, 3vw, 28px);
  z-index: 95;
  width: min(400px, calc(100vw - 24px));
  height: min(560px, calc(100dvh - 96px));
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
  opacity: 0;
  transform: translateY(14px) scale(0.98);
  pointer-events: none;
  transition: opacity var(--t), transform var(--t);
}
.ai-panel.is-open { opacity: 1; transform: none; pointer-events: auto; }

.ai-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.ai-head__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--flow); box-shadow: 0 0 8px var(--iris); }
.ai-head__title { font-family: var(--font-display); font-weight: 600; font-size: 1rem; }
.ai-head__sub { font-family: var(--font-mono); font-size: 0.72rem; color: var(--ink-3); }
.ai-close {
  margin-left: auto;
  border: 0; background: none; color: var(--ink-2);
  cursor: pointer; padding: 6px; border-radius: var(--radius-sm);
  transition: color var(--t-fast), background var(--t-fast);
}
.ai-close:hover { color: var(--ink); background: var(--line); }

.ai-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overscroll-behavior: contain;
}
.ai-msg { max-width: 88%; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 0.92rem; line-height: 1.55; }
.ai-msg--user { align-self: flex-end; background: var(--iris-strong); color: #fff; border-bottom-right-radius: 4px; }
.ai-msg--bot  { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
/* overflow-wrap: long unbreakable values (emails, profile URLs) wrap instead
   of overflowing the bubble on narrow screens. */
.ai-msg--bot a { color: var(--iris); text-decoration: underline; overflow-wrap: anywhere; }
/* Structured answers: the widget renders paragraphs, bullet lists, and bold. */
.ai-body p { margin: 0 0 9px; }
.ai-body ul { margin: 0 0 9px; padding-left: 18px; list-style: disc; }
.ai-body li { margin: 3px 0; }
.ai-body li::marker { color: var(--iris); }
.ai-body p:last-child, .ai-body ul:last-child { margin-bottom: 0; }
.ai-body strong { font-weight: 650; }
.ai-msg--error { border-color: rgba(244, 114, 114, 0.5); }

.ai-cursor { display: inline-block; width: 7px; height: 1em; vertical-align: text-bottom; background: var(--iris); animation: ai-blink 0.9s steps(2) infinite; }
@keyframes ai-blink { 50% { opacity: 0; } }

.ai-sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ai-src {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 0.7rem;
  padding: 3px 9px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill); color: var(--ink-2);
  text-decoration: none !important;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.ai-src:hover { color: var(--iris); border-color: var(--iris); }

.ai-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ai-chip {
  border: 1px solid var(--line-strong); background: none; color: var(--ink-2);
  font-family: var(--font-mono); font-size: 0.74rem;
  padding: 6px 11px; border-radius: var(--radius-pill); cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.ai-chip:hover { color: var(--iris); border-color: var(--iris); }

.ai-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: var(--surface-2); }
.ai-input {
  flex: 1; min-width: 0;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 0.92rem; padding: 10px 12px;
}
.ai-input:focus { outline: none; border-color: var(--iris); box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.18); }
.ai-send {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; border: 0; border-radius: var(--radius-sm);
  background: var(--iris-strong); color: #fff; cursor: pointer;
  transition: filter var(--t-fast);
}
.ai-send:hover { filter: brightness(1.1); }
.ai-send:disabled { opacity: 0.5; cursor: default; }

/* Mobile: sit above the quick-nav dock */
@media (max-width: 760px) {
  .ai-fab { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  .ai-panel { bottom: calc(72px + env(safe-area-inset-bottom, 0px)); height: min(520px, calc(100dvh - 160px)); }
}

@media (prefers-reduced-motion: reduce) {
  .ai-panel, .ai-fab { transition: none; }
  .ai-cursor { animation: none; }
}