/* ==========================================================================
   NDI Assistant — the concierge widget.

   Self-contained: it carries its own palette tokens so the same component
   looks right on the public site and inside the admin, which do not share a
   stylesheet. Colours are the six brand colours and blends between them.
   ========================================================================== */

.ndi-asst {
  --a-midnight: #040817;
  --a-surface: #0f1c3f;
  --a-cyan: #00f0ff;
  --a-sky: #00b4d8;
  --a-ice: #e0f7fa;
  --a-gold: #d4af37;
  --a-line: color-mix(in oklab, #00b4d8 22%, #0f1c3f);
  --a-soft: color-mix(in oklab, #e0f7fa 70%, #0f1c3f);
  --a-well: color-mix(in oklab, #0f1c3f 50%, #040817);
  --a-ease: cubic-bezier(0.22, 1, 0.36, 1);
  font-family: Inter, ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  color: var(--a-ice);
}
.ndi-asst *, .ndi-asst *::before, .ndi-asst *::after { box-sizing: border-box; }
.ndi-asst .sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.ndi-asst [hidden] { display: none !important; }
.ndi-asst-ico { width: 22px; height: 22px; }
.ndi-asst-ico-sm { width: 17px; height: 17px; }

/* --- Launcher ------------------------------------------------------------ */
.ndi-asst-launcher {
  position: fixed;
  right: 20px;
  bottom: 96px;
  z-index: 46;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 20px 0 8px;
  border: 1px solid rgb(212 175 55 / 0.45);
  border-radius: 999px;
  background: var(--a-surface);
  color: var(--a-ice);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 14px 34px -14px rgb(4 8 23 / 0.95), 0 0 0 4px rgb(0 180 216 / 0.08);
  transition: transform 260ms var(--a-ease), box-shadow 260ms ease, border-color 260ms ease;
}
.ndi-asst-launcher:hover {
  transform: translateY(-2px);
  border-color: var(--a-gold);
  box-shadow: 0 16px 36px -14px rgb(4 8 23 / 0.95), 0 0 22px -6px rgb(212 175 55 / 0.4);
}
.ndi-asst-launcher:focus-visible { outline: 2px solid var(--a-cyan); outline-offset: 3px; }
.ndi-asst-launcher-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--a-cyan);
  color: var(--a-midnight);
}
.ndi-asst-dot {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--a-gold);
  box-shadow: 0 0 0 2px var(--a-surface);
}
.ndi-asst.is-open .ndi-asst-launcher { opacity: 0; pointer-events: none; transform: scale(0.9); }

/* --- Panel --------------------------------------------------------------- */
.ndi-asst-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 95;
  display: flex;
  flex-direction: column;
  width: min(410px, calc(100vw - 40px));
  height: min(660px, calc(100vh - 120px));
  overflow: hidden;
  border: 1px solid var(--a-line);
  border-radius: 22px;
  background: var(--a-midnight);
  box-shadow:
    0 30px 70px -24px rgb(4 8 23 / 0.95),
    0 0 0 1px rgb(212 175 55 / 0.12);
  transform-origin: bottom right;
  animation: ndi-asst-in 320ms var(--a-ease) both;
}
@keyframes ndi-asst-in {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}
.ndi-asst-panel.is-minimized { height: auto; }
.ndi-asst-panel.is-minimized .ndi-asst-log,
.ndi-asst-panel.is-minimized .ndi-asst-form,
.ndi-asst-panel.is-minimized .ndi-asst-foot { display: none; }

.ndi-asst-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px 14px 16px;
  background: var(--a-surface);
  border-bottom: 1px solid var(--a-line);
}
.ndi-asst-head::after {
  content: "";
  position: absolute;
  inset: auto 16px -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgb(212 175 55 / 0.55), transparent);
}
.ndi-asst-avatar {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 50%;
  background: var(--a-ice);
  padding: 0;
  object-fit: contain;
}
.ndi-asst-titles { min-width: 0; flex: 1; }
.ndi-asst-titles h2 {
  margin: 0;
  font: 700 15px/1.2 Montserrat, Inter, sans-serif;
  letter-spacing: -0.01em;
  color: var(--a-ice);
}
.ndi-asst-titles p {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 3px 0 0;
  overflow: hidden;
  font-size: 11.5px;
  color: var(--a-soft);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.ndi-asst-live {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--a-cyan);
  box-shadow: 0 0 8px rgb(0 240 255 / 0.7);
}
.ndi-asst-tools { display: flex; gap: 2px; }
.ndi-asst-tools button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--a-soft);
  cursor: pointer;
  transition: background-color 180ms ease, color 180ms ease;
}
.ndi-asst-tools button:hover { background: rgb(224 247 250 / 0.07); color: var(--a-cyan); }
.ndi-asst-tools button:focus-visible { outline: 2px solid var(--a-cyan); outline-offset: -2px; }

/* --- Conversation -------------------------------------------------------- */
.ndi-asst-log {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 14px 8px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--a-line) transparent;
}
.ndi-asst-log:focus-visible { outline: 2px solid var(--a-cyan); outline-offset: -2px; }

.ndi-asst-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  margin-bottom: 14px;
  animation: ndi-asst-msg 260ms var(--a-ease) both;
}
@keyframes ndi-asst-msg {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.ndi-asst-msg.is-user { margin-left: auto; align-items: flex-end; }
.ndi-asst-bubble {
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.ndi-asst-msg.is-bot .ndi-asst-bubble {
  border: 1px solid var(--a-line);
  border-top-left-radius: 6px;
  background: var(--a-surface);
  color: var(--a-ice);
}
.ndi-asst-msg.is-user .ndi-asst-bubble {
  border-top-right-radius: 6px;
  background: color-mix(in oklab, var(--a-cyan) 16%, var(--a-surface));
  border: 1px solid rgb(0 240 255 / 0.3);
  color: var(--a-ice);
}
.ndi-asst-msg.is-error .ndi-asst-bubble { border-color: rgb(212 175 55 / 0.45); }
.ndi-asst-bubble p { margin: 0; }
.ndi-asst-bubble p + p, .ndi-asst-bubble p + ul, .ndi-asst-bubble ul + p { margin-top: 8px; }
.ndi-asst-bubble ul { margin: 6px 0 0; padding: 0; list-style: none; }
.ndi-asst-bubble li { position: relative; padding-left: 14px; }
.ndi-asst-bubble li + li { margin-top: 3px; }
.ndi-asst-bubble li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.62em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--a-sky);
}
.ndi-asst-bubble ol { margin: 6px 0 0; padding-left: 20px; }
.ndi-asst-bubble ol li { padding-left: 2px; }
.ndi-asst-bubble ol li::before { content: none; }
.ndi-asst-bubble ol li::marker { color: var(--a-sky); font-weight: 700; }
.ndi-asst-bubble p + ol, .ndi-asst-bubble ol + p { margin-top: 8px; }
/* Caveats such as "criteria follow the official notification". */
.ndi-asst-bubble .ndi-asst-note { font-size: 12.5px; font-style: italic; color: var(--a-soft); }
.ndi-asst-bubble strong { color: var(--a-ice); font-weight: 700; }
.ndi-asst-msg.is-bot .ndi-asst-bubble strong { color: var(--a-cyan); }
.ndi-asst-time {
  margin-top: 5px;
  padding: 0 4px;
  font-size: 10.5px;
  color: color-mix(in oklab, var(--a-ice) 50%, var(--a-midnight));
}

/* Cards */
.ndi-asst-cards { display: grid; gap: 8px; margin-top: 8px; width: 100%; }
.ndi-asst-card {
  position: relative;
  padding: 12px 14px;
  border: 1px solid var(--a-line);
  border-radius: 14px;
  background: var(--a-well);
  transition: border-color 200ms ease;
}
.ndi-asst-card:hover { border-color: rgb(0 180 216 / 0.5); }
.ndi-asst-card-top { display: flex; align-items: flex-start; gap: 10px; }
.ndi-asst-card-title {
  flex: 1;
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--a-ice);
}
.ndi-asst-card-badge {
  flex: none;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgb(212 175 55 / 0.14);
  color: var(--a-gold);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.ndi-asst-card-meta { margin: 3px 0 0; font-size: 11.5px; color: var(--a-sky); }
.ndi-asst-card-lines { margin: 8px 0 0; padding: 0; list-style: none; font-size: 12.5px; line-height: 1.5; color: var(--a-soft); }
.ndi-asst-card-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 9px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--a-cyan);
  text-decoration: none;
}
.ndi-asst-card-link:hover { text-decoration: underline; }

/* Quick actions and suggestions */
.ndi-asst-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ndi-asst-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 7px 13px;
  border: 1px solid rgb(0 180 216 / 0.55);
  border-radius: 999px;
  background: var(--a-surface);
  color: var(--a-ice);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.2;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 180ms ease, color 180ms ease, background-color 180ms ease, transform 180ms var(--a-ease);
}
.ndi-asst-chip:hover { border-color: var(--a-cyan); color: var(--a-cyan); transform: translateY(-1px); }
.ndi-asst-chip:focus-visible { outline: 2px solid var(--a-cyan); outline-offset: 2px; }
.ndi-asst-chip.is-primary { border-color: transparent; background: var(--a-cyan); color: var(--a-midnight); }
.ndi-asst-chip.is-primary:hover { color: var(--a-midnight); box-shadow: 0 0 18px -6px rgb(0 240 255 / 0.6); }
.ndi-asst-chip.is-gold { border-color: rgb(212 175 55 / 0.6); }
.ndi-asst-chip.is-gold:hover { border-color: var(--a-gold); color: var(--a-gold); }
.ndi-asst-chip[disabled] { opacity: 0.45; cursor: default; transform: none; }
.ndi-asst-chip-ico { width: 14px; height: 14px; flex: none; }
.ndi-asst-chip.is-retry { border-color: rgb(212 175 55 / 0.6); color: var(--a-gold); }

.ndi-asst-suggest { margin-top: 10px; }
.ndi-asst-suggest-label {
  margin: 0 0 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: color-mix(in oklab, var(--a-ice) 55%, var(--a-midnight));
}
.ndi-asst-suggest .ndi-asst-chip { border-style: dashed; border-color: var(--a-line); font-weight: 500; }

/* Typing indicator */
.ndi-asst-typing {
  display: inline-flex;
  gap: 5px;
  padding: 14px 16px;
  border: 1px solid var(--a-line);
  border-radius: 16px;
  border-top-left-radius: 6px;
  background: var(--a-surface);
}
.ndi-asst-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--a-sky);
  animation: ndi-asst-dot 1.1s ease-in-out infinite;
}
.ndi-asst-typing span:nth-child(2) { animation-delay: 0.15s; }
.ndi-asst-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ndi-asst-dot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* Empty / intro state */
.ndi-asst-intro { padding: 4px 4px 12px; text-align: center; }
.ndi-asst-intro-mark {
  display: inline-grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 10px;
  border: 1px solid rgb(212 175 55 / 0.45);
  border-radius: 18px;
  background: var(--a-surface);
  color: var(--a-cyan);
}
.ndi-asst-intro h3 { margin: 0; font: 700 17px/1.3 Montserrat, Inter, sans-serif; color: var(--a-ice); }
.ndi-asst-intro p { margin: 6px auto 0; max-width: 30ch; font-size: 13px; line-height: 1.5; color: var(--a-soft); }

/* --- Composer ------------------------------------------------------------ */
.ndi-asst-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 8px 12px 0;
  padding: 6px 6px 6px 16px;
  border: 1px solid var(--a-line);
  border-radius: 24px;
  background: var(--a-surface);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}
.ndi-asst-form:focus-within { border-color: var(--a-cyan); box-shadow: 0 0 0 4px rgb(0 240 255 / 0.1); }
/* One line by default; grows with Shift+Enter or long text, up to ~4 lines. */
.ndi-asst-form textarea {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  max-height: 104px;
  margin: 0;
  padding: 10px 0;
  border: 0;
  border-radius: 0;
  outline: 0;
  background: transparent;
  box-shadow: none;
  color: var(--a-ice);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 400;
  line-height: 20px;
  resize: none;
  overflow-y: auto;
  scrollbar-width: thin;
  -webkit-appearance: none;
  appearance: none;
}
/* The site's global field styles must not reach the composer: the
   rounded form around it already shows focus. */
.ndi-asst .ndi-asst-form textarea,
.ndi-asst .ndi-asst-form textarea:hover,
.ndi-asst .ndi-asst-form textarea:focus,
.ndi-asst .ndi-asst-form textarea:focus-visible {
  border: 0;
  outline: 0;
  background: transparent;
  box-shadow: none;
}
.ndi-asst-form textarea::placeholder { color: color-mix(in oklab, var(--a-ice) 45%, var(--a-surface)); }
.ndi-asst-count {
  align-self: center;
  flex: none;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  color: var(--a-gold);
}
.ndi-asst-send {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--a-cyan);
  color: var(--a-midnight);
  cursor: pointer;
  transition: transform 180ms var(--a-ease), box-shadow 180ms ease, opacity 180ms ease;
}
.ndi-asst-send:hover { transform: scale(1.05); box-shadow: 0 0 18px -4px rgb(0 240 255 / 0.6); }
.ndi-asst-send:focus-visible { outline: 2px solid var(--a-ice); outline-offset: 2px; }
.ndi-asst-send[disabled] { opacity: 0.4; cursor: default; transform: none; box-shadow: none; }
.ndi-asst-foot {
  margin: 0;
  padding: 8px 16px 12px;
  font-size: 10.5px;
  text-align: center;
  color: color-mix(in oklab, var(--a-ice) 45%, var(--a-midnight));
}

/* --- Phones: the panel becomes a full-screen sheet ----------------------- */
@media (max-width: 639.98px) {
  .ndi-asst-launcher {
    right: 14px;
    bottom: calc(var(--mobile-bar, 4.25rem) + env(safe-area-inset-bottom) + 142px);
    width: 52px;
    height: 52px;
    padding: 0;
    justify-content: center;
  }
  .ndi-asst-launcher-text { display: none; }
  .ndi-asst-launcher-icon { width: 42px; height: 42px; }
  .ndi-asst-panel {
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    border: 0;
    border-radius: 0;
    padding-bottom: env(safe-area-inset-bottom);
    transform-origin: bottom center;
  }
  .ndi-asst-head { padding-top: max(14px, env(safe-area-inset-top)); }
  .ndi-asst-msg { max-width: 92%; }
  .ndi-asst-form textarea { font-size: 16px; } /* no zoom-on-focus in iOS */
  .ndi-asst-chip { min-height: 38px; } /* comfortable touch targets */
}
/* The admin has no bottom bar, so the launcher sits in the corner. */
.ndi-asst[data-mode="admin"] .ndi-asst-launcher { bottom: 20px; }
@media (max-width: 639.98px) {
  .ndi-asst[data-mode="admin"] .ndi-asst-launcher { bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .ndi-asst-panel, .ndi-asst-msg { animation: none; }
  .ndi-asst-typing span { animation: none; opacity: 0.7; }
  .ndi-asst-launcher, .ndi-asst-chip, .ndi-asst-send { transition: none; }
  .ndi-asst-log { scroll-behavior: auto; }
}
