/* The website's FAQ chat (JW-3918): floating button + chat window, bottom right.
   Markup is built by /new-design/js/website-chat.js. Every rule is under .jtw-chat,
   and the basics (font, box model, button and input looks) are set here on purpose,
   so no page's own styles reach in and the chat looks the same everywhere. */

.jtw-chat {
  --jtw-blue: #265CFF;
  --jtw-blue-dark: #113DD9;
  --jtw-blue-soft: #EBF1FF;
  --jtw-ink: #1f2937;
  --jtw-muted: #6b7280;
  --jtw-line: #e5e7eb;
  position: fixed;
  right: 15px;
  bottom: 20px;
  /* above page content and the scroll-to-top button, below the cookie banner (99998+) */
  z-index: 9990;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-family: 'gordita', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--jtw-ink);
  text-align: left;
}

.jtw-chat *,
.jtw-chat *::before,
.jtw-chat *::after {
  box-sizing: border-box;
}

.jtw-chat button {
  font: inherit;
  cursor: pointer;
  border: 0;
  margin: 0;
}

/* The page's scroll-to-top button sits in the same corner: lift it above the chat button. */
body.jtw-chat-on button.scroll-top {
  bottom: 88px;
  right: 25px;
}

/* ---------------------------------------------------------------- button */

.jtw-chat__launcher {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: 50%;
  background: var(--jtw-blue);
  color: #fff;
  box-shadow: 0 8px 24px rgba(17, 61, 217, 0.35);
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.jtw-chat__launcher:hover {
  background: var(--jtw-blue-dark);
}

.jtw-chat__launcher:active {
  transform: scale(0.96);
}

.jtw-chat__launcher:focus-visible,
.jtw-chat__minimise:focus-visible,
.jtw-chat__chip:focus-visible,
.jtw-chat__send:focus-visible {
  outline: 3px solid var(--jtw-blue-soft);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- window */

.jtw-chat__panel {
  display: flex;
  flex-direction: column;
  width: calc(100vw - 30px);
  max-width: 380px;
  height: min(600px, calc(100vh - 110px));
  height: min(600px, calc(100dvh - 110px));
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--jtw-line);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
}

.jtw-chat__panel[hidden] {
  display: none;
}

.jtw-chat__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--jtw-blue), var(--jtw-blue-dark));
  color: #fff;
}

.jtw-chat__title {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
  font-weight: 700;
  color: #fff;
}

.jtw-chat__subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.88);
}

.jtw-chat__minimise {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  color: #fff;
}

.jtw-chat__minimise:hover {
  background: rgba(255, 255, 255, 0.16);
}

/* ---------------------------------------------------------------- messages */

.jtw-chat__list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  background: #f8fafc;
  scroll-behavior: smooth;
}

.jtw-chat__list > * + * {
  margin-top: 12px;
}

.jtw-chat__row {
  display: flex;
}

.jtw-chat__row--bot {
  align-items: flex-end;
  gap: 8px;
}

.jtw-chat__row--user {
  flex-direction: column;
  align-items: flex-end;
}

.jtw-chat__col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 85%;
  min-width: 0;
}

.jtw-chat__avatar {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--jtw-blue-soft);
  color: var(--jtw-blue);
}

.jtw-chat__bubble {
  padding: 10px 14px;
  border-radius: 16px;
  overflow-wrap: anywhere;
}

.jtw-chat__bubble--bot {
  border-bottom-left-radius: 4px;
  background: #fff;
  color: var(--jtw-ink);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.jtw-chat__bubble--user {
  max-width: 85%;
  border-bottom-right-radius: 4px;
  background: var(--jtw-blue);
  color: #fff;
  white-space: pre-line;
}

.jtw-chat__bubble p {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  color: inherit;
}

.jtw-chat__bubble p + p,
.jtw-chat__bubble p + .jtw-chat__bullet,
.jtw-chat__bullet + p {
  margin-top: 6px;
}

.jtw-chat__bullet {
  display: flex;
  gap: 6px;
}

.jtw-chat__bubble a {
  color: var(--jtw-blue);
  text-decoration: underline;
}

.jtw-chat__time {
  margin-top: 4px;
  font-size: 11px;
  color: #9ca3af;
}

.jtw-chat__chips {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding-left: 36px;
}

.jtw-chat .jtw-chat__chip {
  padding: 7px 14px;
  border: 1px solid var(--jtw-line);
  border-radius: 999px;
  background: #fff;
  color: var(--jtw-ink);
  font-size: 13px;
  text-align: left;
}

.jtw-chat .jtw-chat__chip:hover {
  border-color: #BAD2FF;
  background: var(--jtw-blue-soft);
}

.jtw-chat__dots {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.jtw-chat__dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9ca3af;
  animation: jtw-chat-bounce 1s infinite ease-in-out;
}

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

@keyframes jtw-chat-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

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

.jtw-chat__form {
  margin: 0;
  padding: 12px;
  border-top: 1px solid var(--jtw-line);
  background: #fff;
}

.jtw-chat__demos {
  margin: 0 0 10px;
}

.jtw-chat .jtw-chat__demos-title {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--jtw-muted);
}

.jtw-chat__demos-row {
  display: flex;
  gap: 8px;
}

.jtw-chat .jtw-chat__demo {
  display: flex;
  flex: 1 1 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 2px 6px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid #BAD2FF;
  border-radius: 12px;
  background: var(--jtw-blue-soft);
  color: var(--jtw-blue-dark);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
}

.jtw-chat .jtw-chat__demo svg {
  flex-shrink: 0;
}

.jtw-chat .jtw-chat__demo small {
  flex-basis: 100%;
  font-size: 11px;
  font-weight: 400;
  color: var(--jtw-muted);
}

.jtw-chat .jtw-chat__demo:hover,
.jtw-chat .jtw-chat__demo:focus-visible {
  background: #dde8ff;
  color: var(--jtw-blue-dark);
  text-decoration: none;
}

.jtw-chat__field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  background: #fff;
}

.jtw-chat__field:focus-within {
  border-color: var(--jtw-blue);
  box-shadow: 0 0 0 3px var(--jtw-blue-soft);
}

.jtw-chat .jtw-chat__input {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  height: auto;
  margin: 0;
  padding: 6px 0;
  border: 0;
  border-radius: 0;
  outline: 0;
  box-shadow: none;
  background: transparent;
  color: var(--jtw-ink);
  /* 16px: iOS zooms the page when a focused input is smaller */
  font: inherit;
  font-size: 16px;
}

.jtw-chat .jtw-chat__send {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  background: var(--jtw-blue);
  color: #fff;
}

.jtw-chat .jtw-chat__send:disabled {
  background: #d1d5db;
  cursor: default;
}

.jtw-chat__disclaimer {
  margin: 8px 0 0;
  font-size: 11px;
  line-height: 1.35;
  color: var(--jtw-muted);
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .jtw-chat__dots span { animation: none; }
  .jtw-chat__list { scroll-behavior: auto; }
  .jtw-chat__launcher { transition: none; }
}

@media print {
  .jtw-chat { display: none; }
}
