/* AU-IR "Ask AI" — native widget for the MkDocs Material guide.
   Floating button + right-docked Assistant panel. Themed from Material's
   own CSS variables, so it tracks the green primary and light/dark scheme. */

/* Defined on `body`, NOT `:root`: Material sets its per-scheme colour
   variables on <body data-md-color-scheme="…">, so resolving ours here lets
   them re-evaluate on every light/dark toggle. (At :root they'd freeze to the
   light-mode defaults — black text, invisible on the dark panel.) */
body {
  --ask-accent: var(--md-primary-fg-color, #2e7d32);
  --ask-accent-ink: var(--md-primary-bg-color, #fff);
  --ask-line: var(--md-default-fg-color--lightest, #e3e6e3);
  --ask-muted: var(--md-default-fg-color--light, #6b726b);
}

/* Floating action button (bottom-right, like agent-browser's "Ask AI") */
.ask-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 21;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border: 0; border-radius: 24px; cursor: pointer;
  background: var(--ask-accent); color: var(--ask-accent-ink);
  font: 600 14px/1 var(--md-text-font-family, system-ui), sans-serif;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .22);
}
.ask-fab:hover { filter: brightness(1.06); }
.ask-fab .ask-kbd {
  font-size: 11px; opacity: .8; border: 1px solid currentColor;
  border-radius: 5px; padding: 1px 4px;
}
.ask-panel.open ~ .ask-fab { display: none; }

/* Docked Assistant panel: it reserves a column on the right and the page
   content shrinks to make room (see body.ask-open below) — it does NOT overlay. */
.ask-panel {
  position: fixed; top: 0; right: 0; height: 100vh; width: 390px; max-width: 94vw;
  z-index: 30; display: flex; flex-direction: column;
  background: var(--md-default-bg-color, #fff); color: var(--md-default-fg-color, #1a1c1a);
  border-left: 1px solid var(--ask-line);
  box-shadow: -8px 0 30px rgba(0, 0, 0, .10);
  transform: translateX(100%); transition: transform .22s ease, width .22s ease;
  font: 14px/1.55 var(--md-text-font-family, system-ui), sans-serif;
}
.ask-panel.open { transform: translateX(0); }
.ask-panel.expanded { width: 660px; }

/* Reserve the column: shift the whole page left while the panel is open. */
body { transition: padding-right .22s ease; }
body.ask-open { padding-right: 390px; }
body.ask-open.ask-expanded { padding-right: 660px; }

.ask-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--ask-line);
}
.ask-head .ask-title { font-weight: 700; display: flex; align-items: center; gap: 7px; }
.ask-head .ask-sp { margin-left: auto; }
.ask-iconbtn {
  background: none; border: 0; cursor: pointer; color: var(--ask-muted);
  font-size: 16px; line-height: 1; padding: 5px; border-radius: 6px;
}
.ask-iconbtn:hover { background: var(--md-code-bg-color, rgba(127,127,127,.12)); color: inherit; }

.ask-disclaim { font-size: 11px; color: var(--ask-muted); padding: 8px 14px 0; text-align: center; }

.ask-body { flex: 1; overflow-y: auto; padding: 12px 14px; }
.ask-chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 6px 0 4px; }
.ask-chip {
  border: 1px solid var(--ask-line); background: var(--md-default-bg-color);
  color: inherit; padding: 6px 11px; border-radius: 16px; cursor: pointer; font-size: 12.5px;
}
.ask-chip:hover { border-color: var(--ask-accent); }

.ask-msg { display: flex; gap: 9px; margin: 13px 0; }
.ask-msg .ask-who {
  flex: 0 0 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #fff;
}
.ask-msg.user .ask-who { background: var(--md-accent-fg-color, #ffb300); color: #3a2c00; }
.ask-msg.ai .ask-who { background: var(--ask-accent); }
.ask-bubble {
  background: var(--md-code-bg-color, rgba(127,127,127,.08));
  border: 1px solid var(--ask-line); border-radius: 11px; padding: 9px 12px;
  max-width: 100%; overflow-x: auto;
}
.ask-msg.user .ask-bubble { background: transparent; border-color: transparent; padding: 4px 0 0; }
.ask-bubble p { margin: .4em 0; } .ask-bubble p:first-child { margin-top: 0; }
.ask-bubble ul, .ask-bubble ol { margin: .4em 0; padding-left: 1.25em; }
.ask-bubble a { color: var(--ask-accent); text-decoration: underline; }
.ask-bubble code { background: rgba(127,127,127,.18); padding: 1px 5px; border-radius: 5px; font-size: .92em; }
.ask-bubble pre { background: rgba(127,127,127,.14); padding: 10px; border-radius: 8px; overflow-x: auto; }
.ask-bubble pre code { background: none; padding: 0; }
.ask-model { font-size: 11px; color: var(--ask-muted); margin-top: 6px; }
.ask-err { color: #c62828; }

/* Inline step screenshots embedded in an answer */
.ask-img {
  display: block; max-width: 100%; height: auto; margin: 8px 0;
  border: 1px solid var(--ask-line); border-radius: 8px;
}

/* Streaming caret */
.ask-cursor { color: var(--ask-muted); animation: ask-blink 1s steps(2) infinite; }
@keyframes ask-blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
.ask-dots span { display: inline-block; width: 6px; height: 6px; margin: 0 1px; border-radius: 50%; background: var(--ask-muted); animation: ask-b 1s infinite; }
.ask-dots span:nth-child(2) { animation-delay: .2s; } .ask-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes ask-b { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

.ask-foot { border-top: 1px solid var(--ask-line); padding: 10px 12px; }
.ask-form { display: flex; gap: 7px; }
.ask-form input {
  flex: 1; padding: 10px 12px; border: 1px solid var(--ask-line); border-radius: 9px;
  background: var(--md-default-bg-color); color: inherit; font-size: 14px;
}
.ask-form button {
  background: var(--ask-accent); color: var(--ask-accent-ink); border: 0; border-radius: 9px;
  padding: 0 15px; font-weight: 700; cursor: pointer;
}
.ask-form button:disabled { opacity: .5; cursor: default; }

@media (max-width: 600px) {
  .ask-panel, .ask-panel.expanded { width: 100vw; max-width: 100vw; }
  .ask-fab { right: 14px; bottom: 14px; }
  /* phone: panel covers the screen, so don't also shrink the page */
  body.ask-open, body.ask-open.ask-expanded { padding-right: 0; }
}
