/* ==========================================================================
   AI Assistant section
   ========================================================================== */
.section-assistant .section-title {
  max-width: 1140px;
}
/* Section subtitles stay white like the rest of the site; a soft shadow (the
   headings already have one) keeps them readable over the bright patches. */
.section-title h5:not(.title-bg) {
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
}
.section-assistant .ai-subtitle,
.section-ai .ai-subtitle {
  color: rgba(255, 255, 255, 0.88);
  font-weight: 400;
  font-size: 1.05rem;
  line-height: 1.5;
  margin-bottom: 1.1rem;
}

/* The section wrapper is a centered column flexbox, so its children shrink to
   fit their content. Pin the width here or the panel resizes with every
   message. */
.section-assistant .section-content {
  width: 100%;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}
.asst {
  width: 100%;
  margin: 0 auto;
  text-align: left;
}

/* status banner (offline / mock) */
.asst-status {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 auto 12px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.84rem;
  line-height: 1.4;
  color: #ffe66d;
  background: rgba(255, 230, 109, 0.1);
  border: 1px solid rgba(255, 230, 109, 0.35);
}
.asst-status[hidden] {
  display: none;
}
.asst-status i {
  font-size: 1rem;
  margin-top: 2px;
}
.asst-status small {
  display: block;
  margin-top: 2px;
  font-size: 0.72rem;
  color: rgba(255, 230, 109, 0.7);
}
.asst-status.is-pulse {
  animation: asst-pulse 0.6s ease;
}
@keyframes asst-pulse {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.02);
    box-shadow: 0 0 0 4px rgba(255, 230, 109, 0.25);
  }
  100% {
    transform: scale(1);
  }
}

/* tabs */
.asst-tabs {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.asst-tab {
  appearance: none;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.82);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.2s ease;
}
.asst-tab i {
  margin-right: 6px;
}
.asst-tab:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}
.asst-tab.is-active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  box-shadow: 0 6px 18px rgba(102, 126, 234, 0.35);
}

/* panel */
.asst-panel {
  display: none;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 15px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}
.asst-panel.is-active {
  display: flex;
}
/* `.scrollable` lets fullpage hand wheel events to this box; main.css also
   gives every .scrollable 80px of top padding, which we do not want here. */
.asst-output,
.section .section-wrapper .asst-output.scrollable {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  overflow-y: auto;
  padding: 16px;
  margin: 0;
  scroll-behavior: smooth;
  scrollbar-gutter: stable; /* a scrollbar appearing must not reflow the text */
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}
.asst-output::-webkit-scrollbar {
  width: 8px;
}
.asst-output::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 4px;
}
.asst-output::-webkit-scrollbar-track {
  background: transparent;
}
.asst-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.15);
}
.asst-form.is-column {
  flex-direction: column;
}
.asst-form input,
.asst-form textarea,
.asst-form select {
  flex: 1 1 auto;
  min-width: 0;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  color: #fff;
  font-size: 0.9rem;
  padding: 10px 12px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease, opacity 0.2s ease;
}
.asst-form select {
  flex: 0 1 auto;
  cursor: pointer;
}
.asst-form select option {
  color: #1d1d1d;
}
.asst-form textarea {
  resize: none; /* keep the panel layout fixed */
  height: 80px;
  line-height: 1.4;
}
.asst-form input::placeholder,
.asst-form textarea::placeholder {
  color: rgba(255, 255, 255, 0.45);
}
.asst-form input:focus,
.asst-form textarea:focus,
.asst-form select:focus {
  border-color: rgba(102, 126, 234, 0.9);
}
.asst-form .asst-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.7);
}
.asst-form .asst-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.asst-send {
  appearance: none;
  border: none;
  color: #fff;
  border-radius: 10px;
  padding: 0 16px;
  min-width: 44px;
  height: 40px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  box-shadow: 0 4px 14px rgba(102, 126, 234, 0.35);
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.asst-send i + span {
  margin-left: 6px;
}
.asst-send:hover {
  transform: translateY(-1px);
}
.asst-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.asst-link {
  appearance: none;
  background: none;
  border: none;
  color: #4ecdc4;
  font-size: 0.78rem;
  cursor: pointer;
  padding: 4px 0;
  font-family: inherit;
}
.asst-link:hover {
  text-decoration: underline;
}
.asst-note {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.45);
}

/* offline: everything stays visible but can't be used */
.asst.is-offline .asst-form input,
.asst.is-offline .asst-form textarea,
.asst.is-offline .asst-form select,
.asst.is-offline .asst-chips button,
.asst.is-offline .asst-link {
  opacity: 0.45;
  cursor: not-allowed;
}

/* "how it works" footnote: expands in place inside the panel (the output
   area above gives up the space, so the panel itself keeps its size) */
.asst-how {
  flex: 0 0 auto;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 6px 14px;
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.6);
}
.asst-how summary {
  cursor: pointer;
  color: rgba(255, 255, 255, 0.5);
  outline: none;
}
.asst-how summary i {
  margin-right: 5px;
}
.asst-how p {
  margin: 8px 0 4px;
  padding: 10px 12px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.8);
  background: rgba(0, 0, 0, 0.22);
  border-radius: 8px;
}
.asst-how code {
  font-size: 0.7rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  padding: 1px 4px;
}

/* empty state + example chips */
.asst-empty {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.88rem;
  line-height: 1.5;
}
.asst-empty p {
  margin: 0 0 10px;
}
.asst-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.asst-chips button {
  appearance: none;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.asst-chips button:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.4);
}

/* chat bubbles */
.msg {
  max-width: 92%;
  margin-bottom: 12px;
  font-size: 0.88rem;
  line-height: 1.5;
}
.msg.user {
  margin-left: auto;
  color: #fff;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.9) 0%, rgba(118, 75, 162, 0.9) 100%);
  border-radius: 14px 14px 4px 14px;
  padding: 9px 13px;
  width: fit-content;
  white-space: pre-wrap; /* keep line breaks from pasted descriptions */
  word-break: break-word;
}
.msg.user small {
  display: block;
  font-size: 0.68rem;
  opacity: 0.75;
  margin-bottom: 3px;
}
.msg.wide {
  max-width: 100%;
}
.msg.bot .answer.fit,
.msg.bot .answer.draft {
  padding: 14px 16px;
}
.msg.bot {
  color: rgba(255, 255, 255, 0.9);
}
.msg.bot .answer {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 4px 14px 14px 14px;
  padding: 10px 13px;
}
.msg.bot .answer:empty {
  display: none;
}
.msg.error .answer {
  border-color: rgba(248, 32, 75, 0.5);
  background: rgba(248, 32, 75, 0.12);
}
.msg p {
  margin: 0 0 6px;
}
.msg p:last-child {
  margin-bottom: 0;
}
.msg ul {
  margin: 4px 0 6px;
  padding-left: 18px;
  list-style: disc;
}
.msg li {
  list-style: disc;
  margin-bottom: 3px;
}
.msg code {
  font-size: 0.8em;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  padding: 1px 5px;
}
.msg a {
  color: #4ecdc4;
}
.msg em {
  color: rgba(255, 255, 255, 0.65);
}

/* typing indicator */
.asst-loading {
  display: inline-flex;
  gap: 4px;
  padding: 10px 13px;
}
.asst-loading i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  animation: asst-bounce 1.2s infinite ease-in-out;
}
.asst-loading i:nth-child(2) {
  animation-delay: 0.15s;
}
.asst-loading i:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes asst-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  40% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

/* sources + collapsed lookup trace under a chat answer */
.sources {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.5);
}
.sources a,
.sources span.src {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid rgba(78, 205, 196, 0.35);
  background: rgba(78, 205, 196, 0.08);
  color: #4ecdc4;
  text-decoration: none;
}
.sources a:hover {
  background: rgba(78, 205, 196, 0.18);
}
.trace {
  margin-top: 6px;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.5);
}
.trace summary {
  cursor: pointer;
  outline: none;
}
.trace summary i {
  margin-right: 4px;
}
.trace-call {
  margin-top: 6px;
  padding: 6px 9px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.2);
}
.trace-call b {
  color: #4ecdc4;
  font-weight: 600;
}
.trace-call code {
  display: block;
  margin-top: 3px;
  white-space: pre-wrap;
  word-break: break-word;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.7rem;
}
.trace-call pre {
  margin: 4px 0 0;
  padding: 6px;
  max-height: 140px;
  overflow: auto;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.68rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-meta {
  margin-top: 4px;
  font-size: 0.66rem;
  color: rgba(255, 255, 255, 0.4);
}

/* fit result */
.fit {
  font-size: 0.86rem;
  color: rgba(255, 255, 255, 0.88);
  line-height: 1.5;
}
.fit-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}
.fit-head h4 {
  margin: 0;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  text-shadow: none;
}
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #1d1d1d;
}
.badge.strong {
  background: #81c784;
}
.badge.good {
  background: #4ecdc4;
}
.badge.partial {
  background: #ffe66d;
}
.badge.weak {
  background: #ff8a80;
}
.fit p {
  margin: 0 0 10px;
}
.fit h5 {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.5);
  margin: 12px 0 6px;
}
.fit ul {
  margin: 0 0 4px;
  padding-left: 18px;
}
.fit li {
  list-style: disc;
  margin-bottom: 4px;
}
.fit li a {
  color: #4ecdc4;
}
.fit .muted {
  color: rgba(255, 255, 255, 0.6);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chips span {
  font-size: 0.72rem;
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.8);
}
.chips span.gap {
  color: #ff8a80;
  border-color: rgba(255, 138, 128, 0.5);
  background: rgba(255, 138, 128, 0.1);
}
.cta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.cta .asst-send,
.cta .asst-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  font-size: 0.8rem;
  border-radius: 10px;
  text-decoration: none;
}
.asst-ghost {
  appearance: none;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s ease;
}
.asst-ghost:hover {
  background: rgba(255, 255, 255, 0.14);
}

/* draft result */
.draft label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.5);
  margin: 0 0 4px;
}
.draft input,
.draft textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  color: #fff;
  font-size: 0.86rem;
  padding: 9px 12px;
  font-family: inherit;
  outline: none;
  margin-bottom: 10px;
  line-height: 1.5;
}
.draft textarea {
  min-height: 170px;
  resize: vertical;
}
.draft input:focus,
.draft textarea:focus {
  border-color: rgba(102, 126, 234, 0.9);
}
.draft .asst-note {
  display: block;
  margin-top: 8px;
}

/* "Try it" links on the capability cards */
.ai-try {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  font-size: 0.74rem;
  font-weight: 600;
  color: #4ecdc4 !important;
  text-decoration: none;
}
.ai-try i {
  font-size: 0.65rem;
  transition: transform 0.2s ease;
}
.ai-try:hover i {
  transform: translateX(3px);
}

/* ---- sizing -------------------------------------------------------------- */
@media (min-width: 992px) {
  .asst-panel.is-active {
    height: clamp(320px, calc(100vh - 330px), 520px);
  }
}
@media (min-width: 992px) and (max-height: 840px) {
  .section-assistant .section-wrapper {
    padding-top: 56px;
    padding-bottom: 40px;
  }
  .section-assistant .ai-heading {
    font-size: 2.4rem;
    margin-bottom: 0.25rem;
  }
  .section-assistant .ai-subtitle {
    font-size: 0.95rem;
    margin-bottom: 0.8rem;
  }
  .asst-tabs {
    margin-bottom: 10px;
  }
  .asst-tab {
    padding: 6px 14px;
    font-size: 0.8rem;
  }
  .asst-panel.is-active {
    height: clamp(280px, calc(100vh - 340px), 460px);
  }
}
@media (max-width: 991px) {
  /* fixed too, so sending a message never grows the page */
  .asst-panel.is-active {
    height: 520px;
  }
}
@media (max-width: 600px) {
  .asst-tab {
    padding: 6px 12px;
    font-size: 0.78rem;
  }
  .asst-tab i {
    margin-right: 4px;
  }
}

/* validation hints (4xx) look like guidance, not failures */
.msg.notice .answer {
  border-color: rgba(255, 230, 109, 0.45);
  background: rgba(255, 230, 109, 0.1);
  color: #ffe66d;
}

/* The site's global a:hover turns links red; keep the assistant's own colors */
a.asst-send,
a.asst-send:hover,
a.asst-send:focus {
  color: #fff;
  text-decoration: none;
}
a.asst-ghost:hover,
a.asst-ghost:focus {
  color: #fff;
  text-decoration: none;
}
.msg a:hover,
.fit li a:hover,
.sources a:hover {
  color: #4ecdc4;
  text-decoration: underline;
}
.asst-status a:hover {
  color: inherit;
}

/* No default focus ring after a mouse click; keep a subtle one for keyboard users */
.asst button:focus,
.asst a:focus,
.asst-tab:focus,
.ai-try:focus {
  outline: none;
  box-shadow: none;
}
.asst-tab.is-active:focus {
  box-shadow: 0 6px 18px rgba(102, 126, 234, 0.35); /* keep the active tab's glow */
}
.asst button:focus-visible,
.asst a:focus-visible,
.ai-try:focus-visible {
  outline: 2px solid rgba(78, 205, 196, 0.85);
  outline-offset: 2px;
}
