#credit-chat-root,
#credit-chat-root * {
  box-sizing: border-box;
}

#credit-chat-root {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 999999;
  font-family: "Manrope", Arial, sans-serif;
  color: #172033;
}

/* Floating launcher */
#credit-chat-launcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  padding: 10px 14px 10px 10px;
  border: 1px solid rgba(0, 90, 156, 0.16);
  border-radius: 999px;
  background: #ffffff;
  color: #0f2740;
  box-shadow: 0 14px 40px rgba(15, 39, 64, 0.16);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}


.credit-chat-launcher-hidden {
  display: none !important;
}

#credit-chat-launcher:hover {
  transform: translateY(-2px);
  border-color: rgba(0, 90, 156, 0.32);
  box-shadow: 0 18px 44px rgba(15, 39, 64, 0.2);
}

.credit-chat-launcher-avatar {
  position: relative;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, #086cad, #004c84);
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .04em;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}

.credit-chat-launcher-avatar::before {
  content: "";
  position: absolute;
  inset: -5px;
  border: 2px solid rgba(0, 90, 156, .18);
  border-radius: 50%;
  animation: creditChatPulse 2.2s ease-out infinite;
}

.credit-chat-online {
  position: absolute;
  right: 0;
  bottom: 1px;
  width: 11px;
  height: 11px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: #22c55e;
}

.credit-chat-launcher-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.12;
}

.credit-chat-launcher-copy strong {
  font-size: 13px;
  font-weight: 800;
}

.credit-chat-launcher-copy small {
  margin-top: 4px;
  color: #718096;
  font-size: 11px;
  font-weight: 600;
}

.credit-chat-launcher-arrow {
  color: #005a9c;
  font-size: 18px;
  font-weight: 700;
}

/* Mini dialog */
#credit-chat-box {
  width: 370px;
  max-width: calc(100vw - 28px);
  max-height: min(620px, calc(100vh - 110px));
  margin-bottom: 12px;
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(17, 24, 39, .08);
  border-radius: 24px;
  background: #ffffff;
  box-shadow:
    0 30px 80px rgba(13, 38, 59, .20),
    0 8px 28px rgba(13, 38, 59, .10);
  transform-origin: bottom right;
}

#credit-chat-box.credit-chat-open {
  display: flex;
  animation: creditChatOpen .24s ease-out;
}

.credit-chat-topbar {
  position: relative;
  padding: 16px 16px 14px;
  background:
    radial-gradient(circle at 85% 10%, rgba(255,255,255,.16), transparent 34%),
    linear-gradient(135deg, #005a9c 0%, #0d6fac 55%, #194c73 100%);
  color: #ffffff;
}

.credit-chat-topbar-main {
  display: flex;
  align-items: center;
  gap: 11px;
  padding-right: 42px;
}

.credit-chat-avatar {
  position: relative;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 50%;
  background: rgba(255,255,255,.14);
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .04em;
  backdrop-filter: blur(8px);
}

.credit-chat-avatar .credit-chat-online {
  border-color: #0b649d;
}

.credit-chat-heading {
  min-width: 0;
}

.credit-chat-heading strong {
  display: block;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
}

.credit-chat-heading span {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 600;
  opacity: .92;
}

.credit-chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 3px rgba(74,222,128,.16);
}

.credit-chat-close {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.13);
  color: #ffffff;
  font: inherit;
  font-size: 20px;
  cursor: pointer;
  transition: background .2s ease, transform .2s ease;
}

.credit-chat-close:hover {
  background: rgba(255,255,255,.22);
  transform: rotate(4deg);
}

.credit-chat-body {
  min-height: 320px;
  max-height: 470px;
  overflow-y: auto;
  padding: 16px;
  background:
    linear-gradient(rgba(248,250,252,.94), rgba(248,250,252,.94)),
    radial-gradient(circle at 10% 10%, rgba(0,90,156,.05), transparent 30%);
  scroll-behavior: smooth;
}

.credit-chat-body::-webkit-scrollbar {
  width: 6px;
}
.credit-chat-body::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: #d6dee7;
}

/* Messages */
.credit-chat-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 11px;
}

.credit-chat-row.user {
  justify-content: flex-end;
}

.credit-chat-mini-avatar {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #005a9c;
  color: #ffffff;
  font-size: 9px;
  font-weight: 800;
}

.credit-chat-bubble {
  max-width: 82%;
  padding: 11px 13px;
  border: 1px solid #e7edf3;
  border-radius: 7px 16px 16px 16px;
  background: #ffffff;
  color: #243447;
  font-size: 13px;
  line-height: 1.48;
  box-shadow: 0 4px 14px rgba(26, 44, 66, .055);
}

.credit-chat-row.user .credit-chat-bubble {
  border-color: #005a9c;
  border-radius: 16px 7px 16px 16px;
  background: #005a9c;
  color: #ffffff;
}

.credit-chat-meta {
  margin: 2px 0 10px 34px;
  color: #94a3b8;
  font-size: 10px;
  font-weight: 600;
}

/* Typing dots */
.credit-chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 48px;
}

.credit-chat-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8ba0b4;
  animation: creditChatTyping 1.15s infinite ease-in-out;
}

.credit-chat-typing i:nth-child(2) { animation-delay: .12s; }
.credit-chat-typing i:nth-child(3) { animation-delay: .24s; }

/* Quick replies */
.credit-chat-options {
  display: grid;
  gap: 8px;
  margin: 12px 0 4px 34px;
}

.credit-chat-option {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #dce5ee;
  border-radius: 13px;
  background: #ffffff;
  color: #213547;
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease;
}

.credit-chat-option:hover {
  transform: translateY(-1px);
  border-color: #8ab6d5;
  background: #f4f9fc;
  box-shadow: 0 6px 16px rgba(0,90,156,.08);
}

.credit-chat-option span {
  margin-right: 7px;
}

/* CTA cards */
.credit-chat-actions {
  display: grid;
  gap: 8px;
  margin: 13px 0 0 34px;
}

.credit-chat-action {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border: 1px solid #e1e8ef;
  border-radius: 14px;
  background: #ffffff;
  color: #18344d;
  text-decoration: none;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.credit-chat-action:hover {
  transform: translateY(-1px);
  border-color: #9cbfd8;
  box-shadow: 0 8px 18px rgba(0,90,156,.08);
}

.credit-chat-action.primary {
  border-color: transparent;
  background: linear-gradient(135deg, #005a9c, #0c70ad);
  color: #ffffff;
}

.credit-chat-action-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #eef6fb;
  font-size: 16px;
}

.credit-chat-action.primary .credit-chat-action-icon {
  background: rgba(255,255,255,.15);
}

.credit-chat-action-copy {
  min-width: 0;
}

.credit-chat-action-copy strong {
  display: block;
  font-size: 12.5px;
  font-weight: 800;
}

.credit-chat-action-copy small {
  display: block;
  margin-top: 2px;
  color: #74869a;
  font-size: 10.5px;
  font-weight: 600;
}

.credit-chat-action.primary .credit-chat-action-copy small {
  color: rgba(255,255,255,.82);
}

.credit-chat-action-arrow {
  margin-left: auto;
  font-size: 17px;
  font-weight: 700;
}

.credit-chat-back {
  margin: 11px 0 0 34px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #5c7185;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.credit-chat-back:hover {
  color: #005a9c;
}

.credit-chat-footer {
  display: flex;
  justify-content: center;
  padding: 9px 12px 10px;
  border-top: 1px solid #edf1f5;
  background: #ffffff;
  color: #9aa8b6;
  font-size: 9.5px;
  font-weight: 600;
}

@keyframes creditChatOpen {
  from {
    opacity: 0;
    transform: translateY(12px) scale(.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes creditChatPulse {
  0% { transform: scale(.92); opacity: .6; }
  70% { transform: scale(1.22); opacity: 0; }
  100% { transform: scale(1.22); opacity: 0; }
}

@keyframes creditChatTyping {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30% { transform: translateY(-3px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  #credit-chat-box.credit-chat-open,
  .credit-chat-launcher-avatar::before,
  .credit-chat-typing i {
    animation: none;
  }
}

@media (max-width: 600px) {
  #credit-chat-root {
    right: 12px;
    bottom: 12px;
    left: 12px;
  }

  #credit-chat-box {
    width: 100%;
    max-width: none;
    max-height: calc(100vh - 90px);
    border-radius: 20px;
  }

  .credit-chat-body {
    max-height: calc(100vh - 235px);
  }

  #credit-chat-launcher {
    margin-left: auto;
  }

  .credit-chat-launcher-copy {
    display: none;
  }

  #credit-chat-launcher {
    padding: 8px;
  }

  .credit-chat-launcher-arrow {
    display: none;
  }
}


/* Avoid overlap between chat launcher and back-to-top button */
body:has(#credit-chat-root) .back-to-top {
  right: 24px !important;
  bottom: 96px !important;
}

/* Hide back-to-top while the chat panel is open */
body.credit-chat-open-state .back-to-top {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transform: translateY(12px) !important;
}

@media (max-width: 600px) {
  body:has(#credit-chat-root) .back-to-top {
    right: 18px !important;
    bottom: 82px !important;
  }
}

/* =========================================================
   CHAT ATTENTION — premium entrance + typed message
========================================================= */

/* Normal, subtle pulse after the intro */
#credit-chat-launcher {
  animation: creditChatLauncherIdlePulse 3.2s ease-in-out infinite;
  transform-origin: right center;
  will-change: transform, box-shadow;
}

/* First attention moment after entering the page */
#credit-chat-launcher.credit-chat-attention {
  animation: creditChatLauncherAttention 1.05s cubic-bezier(.22, 1, .36, 1) both;
  min-width: 292px;
  padding-right: 18px;
  border-color: rgba(0, 90, 156, .34);
  box-shadow:
    0 22px 56px rgba(15, 39, 64, .24),
    0 0 0 8px rgba(0, 90, 156, .07);
}

/* Make the copy visible during the attention sequence, also on mobile */
#credit-chat-launcher.credit-chat-attention .credit-chat-launcher-copy {
  display: flex;
  min-width: 0;
}

#credit-chat-launcher.credit-chat-attention .credit-chat-launcher-copy strong {
  position: relative;
  color: #063f69;
  font-size: 14px;
  letter-spacing: -.01em;
  white-space: nowrap;
}

/* Typewriter caret */
#credit-chat-launcher.credit-chat-attention .credit-chat-launcher-copy strong::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 3px;
  vertical-align: -1px;
  border-radius: 2px;
  background: #005a9c;
  animation: creditChatCaretBlink .72s steps(1) infinite;
}

#credit-chat-launcher.credit-chat-attention .credit-chat-launcher-copy small {
  color: #60758a;
}

/* Small settle animation when normal copy comes back */
#credit-chat-launcher.credit-chat-after-attention {
  animation: creditChatLauncherSettle .85s cubic-bezier(.22, 1, .36, 1) both;
}

@keyframes creditChatLauncherAttention {
  0% {
    opacity: 0;
    transform: translateY(14px) scale(.86);
  }

  58% {
    opacity: 1;
    transform: translateY(-2px) scale(1.105);
  }

  78% {
    transform: translateY(0) scale(.985);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1.035);
  }
}

@keyframes creditChatLauncherSettle {
  0% {
    transform: scale(1.035);
  }

  45% {
    transform: scale(.985);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes creditChatLauncherIdlePulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow:
      0 14px 40px rgba(15, 39, 64, .16),
      0 0 0 0 rgba(0, 90, 156, .22);
  }

  50% {
    transform: scale(1.035);
    box-shadow:
      0 18px 46px rgba(15, 39, 64, .21),
      0 0 0 10px rgba(0, 90, 156, 0);
  }
}

@keyframes creditChatCaretBlink {
  0%, 48% { opacity: 1; }
  49%, 100% { opacity: 0; }
}

/* Keep hover responsive */
#credit-chat-launcher:hover {
  animation-play-state: paused;
  transform: translateY(-2px) scale(1.015);
}

/* Stop attention animations when the chat is open / launcher hidden */
#credit-chat-launcher.credit-chat-launcher-hidden,
body.credit-chat-open-state #credit-chat-launcher {
  animation: none;
}

@media (max-width: 600px) {
  #credit-chat-launcher.credit-chat-attention {
    max-width: calc(100vw - 24px);
    min-width: min(292px, calc(100vw - 24px));
    padding: 9px 14px 9px 9px;
  }

  #credit-chat-launcher.credit-chat-attention .credit-chat-launcher-arrow {
    display: inline;
  }

  #credit-chat-launcher.credit-chat-attention .credit-chat-launcher-copy strong {
    font-size: 13px;
  }

  #credit-chat-launcher.credit-chat-attention .credit-chat-launcher-copy small {
    font-size: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #credit-chat-launcher,
  #credit-chat-launcher.credit-chat-attention,
  #credit-chat-launcher.credit-chat-after-attention,
  #credit-chat-launcher.credit-chat-attention .credit-chat-launcher-copy strong::after {
    animation: none;
  }
}
