/* Safeguard live chat widget.
   Blue launcher, navy header, white panel with the site's rounded corners, brand
   orange pill buttons and crisp (tight, two-layer) shadows. Colours, fonts and
   radius come from the site tokens, with fallbacks for pages that lack them. */

.sg-chat {
  --sg-chat-blue: var(--sg-blue, #1769A1);
  --sg-chat-orange: var(--sg-orange, #FB7523);
  --sg-chat-navy: var(--sg-navy, #0C2D44);
  --sg-chat-ink: var(--sg-ink, #1E2A33);
  --sg-chat-muted: var(--sg-muted, #5A6B77);
  --sg-chat-line: var(--sg-line, #D7E3EC);
  --sg-chat-wash: var(--sg-blue-wash, #ffffff);
  --sg-chat-radius: var(--sg-radius, 12px);
  --sg-chat-grad-blue: var(--sg-grad-blue, linear-gradient(135deg, #2F8FD6 0%, #1769A1 55%, #124E7A 100%));
  --sg-chat-grad-orange: var(--sg-grad-orange, linear-gradient(135deg, #FF9446 0%, #FB7523 50%, #EC5E10 100%));
  --sg-chat-grad-orange-hover: var(--sg-grad-orange-hover, linear-gradient(135deg, #F98133 0%, #E7661D 50%, #D4540C 100%));
  --sg-chat-font-head: var(--sg-font-head, "Chakra Petch", ui-sans-serif, sans-serif);
  --sg-chat-font-body: var(--sg-font-body, "Inter", ui-sans-serif, system-ui, sans-serif);
  --sg-chat-font-btn: var(--sg-font-btn, "Montserrat", ui-sans-serif, sans-serif);
  --sg-chat-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --sg-chat-dur: 0.32s;

  position: fixed;
  right: clamp(1rem, 3vw, 1.5rem);
  bottom: clamp(1rem, 3vw, 1.5rem);
  z-index: 110;
  font-family: var(--sg-chat-font-body);
}

body:has(.sg-mobile-bar:not([aria-hidden="true"])) .sg-chat {
  bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px));
}

/* ---- Launcher: blue pill with an icon and "Chat"; a circle on phones ---- */
.sg-chat__toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 3.5rem;
  min-width: 3.5rem;
  padding: 0 1.3rem 0 1.1rem;
  border: 0;
  border-radius: 999px;
  background: var(--sg-chat-grad-blue);
  color: #fff;
  font-family: var(--sg-chat-font-btn);
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 1px rgb(12 45 68 / 14%), 0 8px 16px -8px rgb(23 105 161 / 65%);
  transition:
    box-shadow 0.25s ease-out,
    padding 0.28s var(--sg-chat-ease),
    border-radius 0.28s var(--sg-chat-ease),
    transform 0.25s ease-out;
}

.sg-chat .sg-chat__toggle:hover,
.sg-chat .sg-chat__toggle:focus-visible {
  background: var(--sg-chat-grad-blue);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 1px 1px rgb(12 45 68 / 14%), 0 12px 20px -8px rgb(23 105 161 / 75%);
}

.sg-chat.is-open .sg-chat__toggle {
  padding: 0;
  border-radius: 50%;
  transform: none;
}

.sg-chat__toggle:focus-visible {
  outline: 3px solid var(--sg-chat-orange);
  outline-offset: 3px;
}

/* The site stylesheet sets `.sg-chat .sg-icon { width/height: auto !important }`,
   so each icon takes its size from the width and height attributes in the markup. */
.sg-chat .sg-icon {
  display: block;
  color: currentColor;
}

.sg-chat__toggle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    opacity 0.22s ease,
    transform 0.28s var(--sg-chat-ease);
}

.sg-chat__toggle-icon--close {
  position: absolute;
  opacity: 0;
  transform: rotate(-45deg) scale(0.65);
}

.sg-chat.is-open .sg-chat__toggle-icon--open {
  opacity: 0;
  transform: rotate(45deg) scale(0.65);
}

.sg-chat.is-open .sg-chat__toggle-icon--close {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.sg-chat__toggle-label {
  max-width: 4rem;
  overflow: hidden;
  white-space: nowrap;
  transition:
    opacity 0.22s ease,
    max-width 0.28s var(--sg-chat-ease),
    margin 0.28s var(--sg-chat-ease);
}

.sg-chat.is-open .sg-chat__toggle-label {
  max-width: 0;
  opacity: 0;
  margin: 0;
}

/* ---- Panel ---- */
.sg-chat__panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.75rem);
  display: flex;
  flex-direction: column;
  width: min(100vw - 2rem, 23rem);
  height: min(86vh, 42rem);
  border-radius: var(--sg-chat-radius);
  background: #fff;
  box-shadow: 0 1px 2px rgb(12 45 68 / 8%), 0 18px 32px -14px rgb(12 45 68 / 35%);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(0.85rem) scale(0.94);
  transform-origin: bottom right;
  transition:
    opacity var(--sg-chat-dur) var(--sg-chat-ease),
    transform var(--sg-chat-dur) var(--sg-chat-ease),
    visibility 0s linear var(--sg-chat-dur);
}

.sg-chat.is-open .sg-chat__panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  transition:
    opacity var(--sg-chat-dur) var(--sg-chat-ease),
    transform var(--sg-chat-dur) var(--sg-chat-ease),
    visibility 0s linear 0s;
}

/* Header: navy, a blue icon badge, the title, then "New chat" and close. */
.sg-chat__head {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 0.75rem 0.85rem 0.9rem;
  background: linear-gradient(135deg, #0C2D44 0%, #0E3A5C 60%, #124E7A 140%);
  color: #fff;
}

.sg-chat__badge {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--sg-chat-grad-blue);
  color: #fff;
  box-shadow: 0 0 0 2px rgb(255 255 255 / 18%);
}

.sg-chat__head-text {
  flex: 1;
  min-width: 0;
}

.sg-chat__title {
  margin: 0;
  font-family: var(--sg-chat-font-head);
  overflow: hidden;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: #fff;
}

.sg-chat__head-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.sg-chat .sg-chat__new {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid rgb(255 255 255 / 35%);
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font-family: var(--sg-chat-font-btn);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.25s ease-out, border-color 0.25s ease-out;
}

.sg-chat .sg-chat__new:hover,
.sg-chat .sg-chat__new:focus-visible {
  border-color: #fff;
  background: rgb(255 255 255 / 12%);
  color: #fff;
}

.sg-chat .sg-chat__close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: background-color 0.25s ease-out;
}

.sg-chat .sg-chat__close:hover,
.sg-chat .sg-chat__close:focus-visible {
  background: rgb(255 255 255 / 14%);
  color: #fff;
}

.sg-chat__messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 0;
  padding: 1rem 1.1rem;
  overflow-y: auto;
  background: #fff;
}

/* ---- Start form ---- */
.sg-chat__intro {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--sg-chat-ink);
}

.sg-chat__note {
  margin: -0.25rem 0 0.15rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--sg-chat-muted);
}

.sg-chat__field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  width: 100%;
  box-sizing: border-box;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--sg-chat-ink);
}

.sg-chat__field-input {
  box-sizing: border-box;
  width: 100%;
  min-height: 2.6rem;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--sg-chat-line);
  border-radius: 10px;
  background: #fff;
  font-family: var(--sg-chat-font-body);
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.3;
  color: var(--sg-chat-ink);
  appearance: none;
  transition: border-color 0.25s ease-out, box-shadow 0.25s ease-out;
}

textarea.sg-chat__field-input {
  min-height: 4.5rem;
  resize: vertical;
}

.sg-chat__field-input:focus {
  outline: 0;
  border-color: var(--sg-chat-blue);
  box-shadow: 0 0 0 3px rgb(23 105 161 / 18%);
}

/* The site's orange pill button. */
.sg-chat .sg-chat__lead-submit {
  box-sizing: border-box;
  width: 100%;
  min-height: 3rem;
  margin-top: 0.25rem;
  padding: 0 1.5rem;
  border: 0;
  border-radius: 999px;
  background: var(--sg-chat-grad-orange);
  color: #fff;
  font-family: var(--sg-chat-font-btn);
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 12px 24px -12px rgb(251 117 35 / 55%);
  transition: background 0.25s ease-out, box-shadow 0.25s ease-out;
}

.sg-chat .sg-chat__lead-submit:hover:not(:disabled),
.sg-chat .sg-chat__lead-submit:focus-visible:not(:disabled) {
  background: var(--sg-chat-grad-orange-hover);
  color: #fff;
  box-shadow: 0 14px 26px -12px rgb(251 117 35 / 65%);
}

.sg-chat .sg-chat__lead-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.sg-chat__error {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: #b3261e;
}

.sg-chat__lead {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

/* ---- Messages ---- */
.sg-chat__msg {
  max-width: 88%;
  padding: 0.65rem 0.9rem;
  border-radius: 14px;
  font-size: 0.9375rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.sg-chat__msg--bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--sg-chat-line);
  border-bottom-left-radius: 4px;
  color: var(--sg-chat-ink);
}

.sg-chat__msg--agent {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--sg-chat-line);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgb(12 45 68 / 6%);
  color: var(--sg-chat-ink);
}

.sg-chat__msg--system {
  align-self: center;
  max-width: 100%;
  padding: 0.25rem 0.25rem;
  background: transparent;
  color: var(--sg-chat-muted);
  font-size: 0.8125rem;
  text-align: center;
}

.sg-chat__msg--user {
  align-self: flex-end;
  background: var(--sg-chat-grad-blue);
  border-bottom-right-radius: 4px;
  color: #fff;
}

/* ---- Composer ---- */
#sg-chat-form.sg-chat__form {
  display: flex;
  flex-shrink: 0;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--sg-chat-line);
  background: #fff;
}

#sg-chat-form.sg-chat__form[hidden] {
  display: none;
}

.sg-chat__input {
  flex: 1;
  box-sizing: border-box;
  min-height: 2.75rem;
  max-height: 7rem;
  padding: 0.65rem 0.9rem;
  overflow-y: auto;
  scrollbar-width: thin;
  border: 1px solid var(--sg-chat-line);
  border-radius: 22px;
  resize: none;
  font-family: var(--sg-chat-font-body);
  font-size: 0.9375rem;
  line-height: 1.4;
  color: var(--sg-chat-ink);
  transition: border-color 0.25s ease-out, box-shadow 0.25s ease-out;
}

.sg-chat__input:focus {
  outline: 0;
  border-color: var(--sg-chat-blue);
  box-shadow: 0 0 0 3px rgb(23 105 161 / 18%);
}

.sg-chat .sg-chat__send {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--sg-chat-grad-orange);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 16px -8px rgb(251 117 35 / 55%);
  transition: background 0.25s ease-out, box-shadow 0.25s ease-out;
}

.sg-chat .sg-chat__send:hover:not(:disabled),
.sg-chat .sg-chat__send:focus-visible:not(:disabled) {
  background: var(--sg-chat-grad-orange-hover);
  color: #fff;
}

.sg-chat .sg-chat__send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.sg-chat__messages .sg-chat__lead,
.sg-chat__messages > .sg-chat__form {
  flex-shrink: 0;
}

/* ---- Small screens ---- */
@media (max-width: 480px) {
  .sg-chat__panel {
    width: min(100vw - 1.25rem, 23rem);
    height: min(84vh, 42rem);
  }

  .sg-chat__toggle-label {
    display: none;
  }

  .sg-chat__toggle {
    width: 3.5rem;
    min-width: 3.5rem;
    padding: 0;
    border-radius: 50%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sg-chat__typing-dots span {
    animation: none;
    opacity: 0.7;
  }

  .sg-chat__panel,
  .sg-chat__toggle,
  .sg-chat__toggle-icon,
  .sg-chat__toggle-label {
    transition: none;
  }

  .sg-chat__panel,
  .sg-chat.is-open .sg-chat__panel {
    transform: none;
  }

  .sg-chat .sg-chat__toggle:hover,
  .sg-chat .sg-chat__toggle:focus-visible {
    transform: none;
  }
}

/* ---- Components kept from earlier versions (quote card, chips, OTP) ---- */
.sg-chat__inline-actions {
  align-self: stretch;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.15rem;
}

.sg-chat__welcome-actions {
  margin-top: 0.35rem;
  padding-top: 0.15rem;
}

.sg-chat__chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.25rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--sg-chat-line);
  border-radius: 999px;
  background: #fff;
  color: var(--sg-chat-navy);
  font-family: var(--sg-chat-font-body);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.sg-chat .sg-chat__chip:hover,
.sg-chat .sg-chat__chip:focus-visible {
  background: var(--sg-chat-wash);
  border-color: var(--sg-chat-blue);
  color: var(--sg-chat-navy);
}

.sg-chat__chip--primary {
  background: var(--sg-chat-wash);
  border-color: var(--sg-chat-blue);
  color: var(--sg-chat-blue);
}

.sg-chat .sg-chat__chip--primary:hover,
.sg-chat .sg-chat__chip--primary:focus-visible {
  background: var(--sg-chat-blue);
  border-color: var(--sg-chat-blue);
  color: #fff;
}

.sg-chat__chip--link {
  color: var(--sg-chat-blue);
}

.sg-chat .sg-chat__chip--link:hover,
.sg-chat .sg-chat__chip--link:focus-visible {
  color: var(--sg-chat-navy);
}

/* Legacy action class, keep readable on theme button:hover overrides */
.sg-chat__action {
  flex: 1 1 calc(50% - 0.25rem);
  min-height: 2.25rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--sg-chat-line);
  border-radius: 999px;
  background: #fff;
  color: var(--sg-chat-navy);
  font-family: var(--sg-chat-font-body);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.sg-chat .sg-chat__action:hover,
.sg-chat .sg-chat__action:focus-visible {
  background: var(--sg-chat-wash);
  border-color: var(--sg-chat-blue);
  color: var(--sg-chat-navy);
}

.sg-chat__quote-card {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.85rem;
  border: 1px solid var(--sg-chat-line);
  background: #fff;
}

.sg-chat__quote-title {
  margin: 0;
  font-family: var(--sg-chat-font-head);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sg-chat-muted);
}

.sg-chat__quote-total {
  margin: 0;
  font-family: var(--sg-chat-font-head);
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--sg-chat-navy);
}

.sg-chat__quote-meta {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--sg-chat-muted);
}

.sg-chat__quote-list {
  margin: 0.25rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.8125rem;
  color: var(--sg-chat-ink);
}

.sg-chat__quote-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.35rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--sg-chat-line);
}

.sg-chat__quiz {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.sg-chat__route-card {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.85rem;
  border: 1px solid var(--sg-chat-line);
  background: var(--sg-chat-wash);
}

.sg-chat__route-link {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--sg-chat-blue);
  text-decoration: none;
}

.sg-chat__route-link:hover {
  text-decoration: underline;
}

.sg-chat__handoff-form {
  background: #fff;
  border-color: #c7d9e8;
  box-shadow: 0 1px 0 rgba(15, 45, 74, 0.04);
}

.sg-chat__handoff-title {
  margin: 0;
  font-family: var(--sg-chat-font-head);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sg-chat-navy);
}

.sg-chat__agent-escape {
  margin-top: 0.25rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--sg-chat-line);
}

.sg-chat__msg--typing {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  color: var(--sg-chat-muted);
  font-style: normal;
}

.sg-chat__typing-label {
  font-size: 0.875rem;
}

.sg-chat__typing-dots {
  display: inline-flex;
  align-items: flex-end;
  gap: 0.2rem;
  height: 1rem;
  margin-left: 0.1rem;
}

.sg-chat__typing-dots span {
  display: block;
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 50%;
  background: var(--sg-chat-blue);
  animation: sg-chat-dot 1.2s ease-in-out infinite;
}

.sg-chat__typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.sg-chat__typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes sg-chat-dot {
  0%,
  60%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  30% {
    opacity: 1;
    transform: translateY(-0.35rem);
  }
}

.sg-chat__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;
}

.hidden {
  display: none !important;
}

.sg-chat__quote-intro {
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--sg-chat-muted);
}

.sg-chat__quote-summary {
  margin: 0 0 0.75rem;
  padding-left: 1.1rem;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--sg-chat-ink);
}

.sg-chat__otp-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.sg-chat__otp-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding: 0.65rem;
  border: 1px solid var(--sg-chat-line);
  background: var(--sg-chat-wash);
}

.sg-chat__otp-input {
  flex: 1 1 6rem;
  min-width: 6rem;
  text-align: center;
  letter-spacing: 0.25em;
}

.sg-chat__otp-verified {
  margin: 0.35rem 0 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--sg-chat-blue);
}

.sg-chat__otp-hint {
  flex: 1 1 100%;
  margin: 0;
  font-size: 0.75rem;
  color: var(--sg-chat-muted);
}

.sg-chat__consent {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0.65rem 0;
  font-size: 0.8125rem;
  line-height: 1.35;
  color: var(--sg-chat-ink);
}

