/* Ask the docs - support chat widget.
   Self-contained. Reuses site variables from styles.css (--gold-bright, --gold-mid,
   --navy, --gray-*, --white). Everything is namespaced under .sw- to avoid clashes.
   To remove the widget entirely: delete this file, support-widget.js,
   support-widget.njk, and the guarded include in base.njk. */

.sw-root {
  /* widget-local tokens so the whole widget survives a rebrand, not most of it */
  --sw-user-bubble: #fef3c7;
  --sw-radius: 12px;
  --sw-shadow: 0 30px 80px -20px rgba(12, 26, 46, 0.25), 0 10px 30px -10px rgba(12, 26, 46, 0.15);
  --sw-z: 2147483000;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Launcher button ------------------------------------------------------- */
.sw-launcher {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: var(--sw-z);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border: none;
  border-radius: 999px;
  background: var(--gold-bright);
  color: var(--white);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 12px 30px -8px rgba(12, 26, 46, 0.3);
  transition: background 0.15s ease, transform 0.15s ease;
}

.sw-launcher:hover {
  background: var(--gold-mid);
}

.sw-launcher:active {
  transform: translateY(1px);
}

.sw-launcher:focus-visible {
  outline: 3px solid var(--gold-mid);
  outline-offset: 2px;
}

.sw-launcher svg {
  width: 18px;
  height: 18px;
  flex: none;
}

/* Hide the launcher while the panel is open */
.sw-root.sw-open .sw-launcher {
  display: none;
}

/* Panel ----------------------------------------------------------------- */
.sw-panel {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: var(--sw-z);
  width: 370px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 40px);
  display: none;
  flex-direction: column;
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--sw-radius);
  box-shadow: var(--sw-shadow);
  overflow: hidden;
}

.sw-root.sw-open .sw-panel {
  display: flex;
}

/* Header */
.sw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  background: var(--navy);
  color: var(--white);
  flex: none;
}

.sw-title {
  font-size: 0.98rem;
  font-weight: 600;
  margin: 0;
}

.sw-subtitle {
  display: block;
  font-size: 0.72rem;
  font-weight: 400;
  opacity: 0.7;
  margin-top: 2px;
}

.sw-close {
  border: none;
  background: transparent;
  color: var(--white);
  font-size: 1.4rem;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.85;
}

.sw-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.12);
}

.sw-close:focus-visible {
  outline: 2px solid var(--white);
  outline-offset: 1px;
}

/* Messages list */
.sw-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--gray-50, #f8f9fa);
}

.sw-msg {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.sw-msg-user {
  align-self: flex-end;
  background: var(--sw-user-bubble);
  color: var(--navy);
  border-bottom-right-radius: 4px;
}

.sw-msg-assistant {
  align-self: flex-start;
  background: var(--gray-100);
  color: var(--gray-700);
  border-bottom-left-radius: 4px;
}

/* Sources row */
.sw-sources {
  align-self: flex-start;
  max-width: 88%;
  margin-top: -4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sw-sources-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-600);
}

.sw-source-link {
  font-size: 0.82rem;
  color: var(--gold-mid);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  width: fit-content;
}

.sw-source-link:hover {
  border-bottom-color: var(--gold-mid);
}

/* Typing / loading indicator */
.sw-typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 4px;
  padding: 12px 14px;
  background: var(--gray-100);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
}

.sw-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gray-400);
  animation: sw-bounce 1.2s infinite ease-in-out;
}

.sw-typing span:nth-child(2) { animation-delay: 0.15s; }
.sw-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes sw-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .sw-typing span { animation: none; }
  .sw-launcher, .sw-launcher:active { transition: none; }
}

/* Composer */
.sw-composer {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--gray-100);
  background: var(--white);
}

.sw-input {
  flex: 1 1 auto;
  resize: none;
  max-height: 96px;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--navy);
}

.sw-input:focus {
  outline: none;
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 3px rgba(232, 150, 42, 0.15);
}

.sw-input:disabled {
  background: var(--gray-50, #f8f9fa);
  color: var(--gray-400);
}

.sw-send {
  flex: none;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: var(--gold-bright);
  color: var(--white);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.sw-send:hover:not(:disabled) {
  background: var(--gold-mid);
}

.sw-send:focus-visible {
  outline: 3px solid var(--gold-mid);
  outline-offset: 2px;
}

.sw-send:disabled {
  background: var(--gray-200);
  color: var(--gray-400);
  cursor: not-allowed;
}

.sw-send svg {
  width: 18px;
  height: 18px;
}

/* Small screens: full-width sheet */
@media (max-width: 420px) {
  .sw-panel {
    right: 8px;
    left: 8px;
    bottom: 8px;
    width: auto;
    max-width: none;
    height: min(80vh, 560px);
  }
  .sw-launcher {
    right: 12px;
    bottom: 12px;
  }
}
