/* ==========================================================================
   Documentation assistant widget.

   Every colour, radius and easing below comes from portal.css. The widget is part of
   the portal, not a thing bolted onto it, so it inherits the token set rather than
   carrying a palette of its own — including the deliberate light-only decision, for the
   same reason: it sits beside screenshots of a light application.
   ========================================================================== */

.nxa {
  --nxa-w: 24rem;
  --nxa-h: 34rem;
  --nxa-radius: 0.5rem;
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 60;
  font-family: "Montserrat", "Source Sans Pro", -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ------------------------------------------------------------------ launcher */

.nxa__open {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border: 1px solid var(--primary-deep, #002157);
  border-radius: 2rem;
  background: var(--primary, #1b599d);
  color: #fff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 10px rgb(0 33 87 / 0.22);
  transition: background 0.18s var(--ease, ease), transform 0.18s var(--ease, ease);
}
.nxa__open:hover { background: var(--primary-deep, #002157); }
.nxa__open:active { transform: translateY(1px); }
.nxa__open svg { flex: none; }

.nxa[data-open="true"] .nxa__open { display: none; }

/* --------------------------------------------------------------------- panel */

.nxa__panel {
  display: none;
  flex-direction: column;
  /* Anchored bottom-right, so it grows up and to the left. Native `resize: both` would
     drag the bottom-right corner further off-screen, which is why there is a custom grip
     on the opposite corner instead. */
  width: min(var(--nxa-w), calc(100vw - 2.5rem));
  height: min(var(--nxa-h), calc(100vh - 6rem));
  position: relative;
  background: var(--bg, #fff);
  border: 1px solid var(--border-strong, #d5dae1);
  border-radius: var(--nxa-radius);
  box-shadow: 0 10px 40px rgb(0 33 87 / 0.18);
  overflow: hidden;
}
.nxa[data-open="true"] .nxa__panel { display: flex; }

.nxa__head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 0.85rem 0.7rem 1.15rem;   /* room for the grip */
  background: var(--primary, #1b599d);
  color: #fff;
}
.nxa__title { font-size: 0.9rem; font-weight: 700; margin: 0; flex: 1; }
.nxa__sub {
  font-size: 0.72rem;
  opacity: 0.85;
  font-weight: 400;
  display: block;
  margin-top: 0.1rem;
}
.nxa__close {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 1.35rem;
  line-height: 1;
  padding: 0 0.25rem;
  cursor: pointer;
  border-radius: 3px;
}
.nxa__close:hover { background: rgb(255 255 255 / 0.16); }

/* ------------------------------------------------------------------- resize */

.nxa__grip {
  position: absolute;
  top: 0;
  left: 0;
  width: 1.1rem;
  height: 1.1rem;
  cursor: nwse-resize;
  z-index: 2;
  background: transparent;
  border: 0;
  padding: 0;
}
/* Two hairlines, the conventional grip marking, drawn in the header's own ink so it
   reads as part of the title bar rather than a stray artifact. */
.nxa__grip::after {
  content: "";
  position: absolute;
  inset: 0.28rem;
  border-top: 2px solid rgb(255 255 255 / 0.5);
  border-left: 2px solid rgb(255 255 255 / 0.5);
  border-radius: 2px 0 0 0;
}
.nxa__grip:hover::after { border-color: rgb(255 255 255 / 0.85); }

/* While dragging, stop the pointer selecting text across the whole page. */
.nxa--sizing, .nxa--sizing * { user-select: none !important; cursor: nwse-resize !important; }

.nxa__size {
  border: 0;
  background: transparent;
  color: #fff;
  padding: 0 0.3rem;
  cursor: pointer;
  border-radius: 3px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}
.nxa__size:hover { background: rgb(255 255 255 / 0.16); }
.nxa__size svg { display: block; }

/* --------------------------------------------------------------------- log */

.nxa__log {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--rail, #f7f8fa);
}

.nxa__msg {
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--body, #4a4a4a);
  padding: 0.6rem 0.75rem;
  border-radius: var(--nxa-radius);
  background: var(--bg, #fff);
  border: 1px solid var(--border, #e6e9ee);
  overflow-wrap: anywhere;
}
.nxa__msg--me {
  background: var(--primary, #1b599d);
  border-color: var(--primary-deep, #002157);
  color: #fff;
  align-self: flex-end;
  max-width: 85%;
}
.nxa__msg--hint {
  background: transparent;
  border: 0;
  padding: 0.25rem 0;
  color: var(--secondary, #5b5b5b);
  font-size: 0.8rem;
}
.nxa__msg p { margin: 0 0 0.5rem; }
.nxa__msg p:last-child { margin-bottom: 0; }
.nxa__msg a { color: var(--interactive, #4178be); }
.nxa__msg code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  background: var(--surface, #fafbfc);
  border: 1px solid var(--border, #e6e9ee);
  border-radius: 3px;
  padding: 0.05em 0.28em;
}
.nxa__msg--me code { background: rgb(255 255 255 / 0.16); border-color: transparent; color: #fff; }

/* Status line while the agent searches. Three to eight seconds of silence reads as a
   hang, so the surface being searched is named while it happens. */
.nxa__status {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  color: var(--secondary, #5b5b5b);
  font-style: italic;
}
.nxa__status::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--interactive, #4178be);
  animation: nxa-pulse 1.1s ease-in-out infinite;
  flex: none;
}
@keyframes nxa-pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .nxa__status::before { animation: none; opacity: 0.7; }
}

/* --------------------------------------------------------------- citations */

.nxa__cites {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.55rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border, #e6e9ee);
}
.nxa__cite {
  font-size: 0.72rem;
  text-decoration: none;
  padding: 0.16rem 0.45rem;
  border-radius: 2rem;
  border: 1px solid var(--border-strong, #d5dae1);
  color: var(--interactive, #4178be);
  background: var(--bg, #fff);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nxa__cite:hover { border-color: var(--interactive, #4178be); }

/* A source citation is a different kind of claim from a manual citation, and the reader
   has to be able to tell at a glance which one they are about to trust. */
.nxa__cite--source {
  color: var(--primary-deep, #002157);
  border-style: dashed;
}
.nxa__cite--source::before { content: "⌗ "; opacity: 0.6; }

/* ------------------------------------------------------------------- input */

.nxa__form {
  display: flex;
  gap: 0.4rem;
  padding: 0.6rem;
  border-top: 1px solid var(--border, #e6e9ee);
  background: var(--bg, #fff);
}
.nxa__input {
  flex: 1;
  font: inherit;
  font-size: 0.86rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border-strong, #d5dae1);
  border-radius: var(--nxa-radius);
  resize: none;
  max-height: 6rem;
  color: var(--body, #4a4a4a);
  background: var(--bg, #fff);
}
.nxa__input:focus-visible,
.nxa__send:focus-visible,
.nxa__open:focus-visible,
.nxa__close:focus-visible,
.nxa__cite:focus-visible {
  outline: 2px solid var(--focus, #3f7fd0);
  outline-offset: 1px;
}
.nxa__send {
  border: 1px solid var(--primary-deep, #002157);
  background: var(--primary, #1b599d);
  color: #fff;
  border-radius: var(--nxa-radius);
  padding: 0 0.8rem;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}
.nxa__send:disabled { opacity: 0.5; cursor: default; }

@media print { .nxa { display: none; } }
