/* EN-2897: styles for the help centre's support chat (assistant.js): a round launcher bottom
   right that opens a chat window above it, full screen on narrow screens. First-party and static:
   the CSP allows no inline styles, so everything it needs is here. */

.sa-launcher {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--brand-dark, #047857);
  color: #fff;
  box-shadow: 0 6px 20px rgb(0 0 0 / 25%);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.sa-launcher:hover {
  background: var(--brand-darker, #065f46);
  transform: scale(1.06);
}

.sa-launcher .sa-icon {
  width: 28px;
  height: 28px;
}

.sa-launcher:focus-visible,
.sa-header-button:focus-visible,
.sa-suggestion:focus-visible,
.sa-rate-button:focus-visible,
.sa-send:focus-visible,
.sa-link:focus-visible {
  outline: 3px solid var(--brand, #10b981);
  outline-offset: 2px;
}

.sa-window[hidden] {
  display: none;
}

.sa-window {
  position: fixed;
  right: 20px;
  bottom: calc(20px + 56px + 12px + env(safe-area-inset-bottom, 0px));
  z-index: 1000;
  display: flex;
  flex-direction: column;
  width: 380px;
  height: min(600px, calc(100dvh - 20px - 56px - 12px - 20px - env(safe-area-inset-bottom, 0px)));
  overflow: hidden;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 16px;
  background: var(--card, #fff);
  color: var(--text, #1f2937);
  box-shadow: 0 12px 40px rgb(0 0 0 / 25%);
  font-size: 15px;
  line-height: 1.4;
}

.sa-icon {
  display: block;
  width: 20px;
  height: 20px;
  flex: none;
}

.sa-icon--down {
  transform: rotate(180deg);
}

.sa-header {
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
  padding: 12px 8px 12px 16px;
  background: var(--brand-dark, #047857);
  color: #fff;
}

.sa-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgb(255 255 255 / 20%);
}

.sa-titles {
  flex: 1 1 auto;
  min-width: 0;
}

.sa-title {
  margin: 0;
  color: inherit;
  font-size: 16px;
  font-weight: 600;
}

.sa-subtitle {
  margin: 0;
  font-size: 12.5px;
  opacity: 0.9;
}

.sa-header-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: inherit;
  cursor: pointer;
}

.sa-header-button:hover {
  background: rgb(255 255 255 / 18%);
}

.sa-header-button:focus-visible {
  outline-color: #fff;
  outline-offset: -2px;
}

.sa-log {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sa-turn {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-self: flex-start;
  max-width: 88%;
}

.sa-msg {
  max-width: 88%;
  padding: 9px 13px;
  border-radius: 16px;
  overflow-wrap: anywhere;
}

.sa-turn .sa-msg {
  max-width: 100%;
}

.sa-user {
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  background: var(--brand-dark, #047857);
  color: #fff;
  white-space: pre-wrap;
}

.sa-bot {
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  background: var(--bg, #f3f4f6);
}

.sa-bot p,
.sa-answer p,
.sa-answer ul,
.sa-answer ol,
.sa-answer pre {
  margin: 0 0 0.5rem;
}

.sa-bot > :last-child,
.sa-answer > :last-child {
  margin-bottom: 0;
}

.sa-answer ul,
.sa-answer ol {
  padding-left: 1.25rem;
}

.sa-answer pre {
  overflow-x: auto;
}

.sa-answer a {
  color: var(--brand-dark, #047857);
  text-decoration: underline;
}

.sa-suggestions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sa-suggestions[hidden] {
  display: none;
}

.sa-suggestion {
  padding: 7px 13px;
  border: 1px solid var(--brand-dark, #047857);
  border-radius: 999px;
  background: transparent;
  color: var(--brand-dark, #047857);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.sa-suggestion:hover {
  background: var(--brand-dark, #047857);
  color: #fff;
}

.sa-rate {
  display: flex;
  gap: 2px;
}

/* Thumbs show on the latest answer; earlier ones on hover or focus. Touch screens keep them all. */
@media (hover: hover) {
  .sa-turn:has(~ .sa-turn) .sa-rate {
    opacity: 0;
    transition: opacity 0.15s;
  }

  .sa-turn:hover .sa-rate,
  .sa-turn .sa-rate:focus-within {
    opacity: 1;
  }
}

.sa-rate-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted, #4b5563);
  cursor: pointer;
}

.sa-rate-button:hover:not(:disabled),
.sa-rate-button[aria-pressed='true'] {
  color: var(--brand-dark, #047857);
}

.sa-rate-button:disabled:not([aria-pressed='true']) {
  opacity: 0.4;
  cursor: default;
}

.sa-typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 13px 14px;
}

.sa-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted, #4b5563);
  animation: sa-bounce 1.2s infinite ease-in-out;
}

.sa-dot:nth-of-type(2) {
  animation-delay: 0.15s;
}

.sa-dot:nth-of-type(3) {
  animation-delay: 0.3s;
}

@keyframes sa-bounce {
  0%,
  60%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }

  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sa-dot {
    animation: none;
  }

  .sa-launcher {
    transition: none;
  }
}

.sa-notice {
  flex: none;
  margin: 0;
  padding: 0 16px 8px;
  color: var(--muted, #4b5563);
  font-size: 13px;
}

.sa-notice:empty {
  display: none;
}

.sa-error {
  color: #b91c1c;
}

.sa-error a {
  color: inherit;
}

.sa-composer {
  display: flex;
  flex: none;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border, #e5e7eb);
}

.sa-input {
  flex: 1 1 auto;
  min-width: 0;
  max-height: 120px;
  padding: 9px 12px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 20px;
  background: var(--card, #fff);
  color: var(--text, #1f2937);
  font: inherit;
  resize: none;
}

.sa-input:focus-visible {
  outline: 2px solid var(--brand-dark, #047857);
}

.sa-send {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--brand-dark, #047857);
  color: #fff;
  cursor: pointer;
}

.sa-send:disabled {
  opacity: 0.4;
  cursor: default;
}

.sa-footer {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 16px;
  padding: 0 12px 10px;
  font-size: 12.5px;
}

.sa-count {
  margin-right: auto;
  color: var(--muted, #4b5563);
}

.sa-link {
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--muted, #4b5563);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.sa-link:hover {
  color: var(--text, #1f2937);
}

.sa-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 639px) {
  .sa-window {
    inset: 0;
    width: 100%;
    height: 100dvh;
    border: 0;
    border-radius: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .sa-header {
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }

  .sa-launcher--open {
    display: none;
  }

  .sa-input {
    font-size: 16px; /* stops iOS zooming into the field */
  }

  html.sa-lock {
    overflow: hidden;
  }
}
