/**
 * ZPayso Assistant floating chat widget
 */
.zp-chatbot {
  --zp-chat-navy: #37517e;
  --zp-chat-accent: #47b2e4;
  --zp-chat-cta: #519AFF;
  --zp-chat-surface: #ffffff;
  --zp-chat-bg: #f4f7fb;
  --zp-chat-text: #2c3e50;
  --zp-chat-muted: #6b7c93;
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 1080;
  font-family: "Poppins", "Jost", sans-serif;
}

.zp-chatbot-launcher {
  width: 3.5rem;
  height: 3.5rem;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(145deg, var(--zp-chat-cta), var(--zp-chat-navy));
  color: #fff;
  box-shadow: 0 10px 28px rgba(55, 81, 126, 0.35);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.zp-chatbot-launcher:hover,
.zp-chatbot-launcher:focus-visible {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 14px 32px rgba(55, 81, 126, 0.42);
  outline: none;
}

.zp-chatbot-launcher i {
  font-size: 1.35rem;
  line-height: 1;
}

.zp-chatbot-panel {
  position: absolute;
  right: 0;
  bottom: calc(3.5rem + 0.75rem);
  width: min(380px, calc(100vw - 2rem));
  height: min(540px, calc(100vh - 6.5rem));
  background: var(--zp-chat-surface);
  border-radius: 1rem;
  box-shadow: 0 18px 48px rgba(17, 36, 68, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  border: 1px solid rgba(55, 81, 126, 0.08);
}

.zp-chatbot.is-open .zp-chatbot-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.zp-chatbot-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  background: linear-gradient(120deg, var(--zp-chat-navy), #2a4066 55%, var(--zp-chat-accent));
  color: #fff;
}

.zp-chatbot-avatar {
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.zp-chatbot-avatar img {
  width: 1.55rem;
  height: auto;
  display: block;
}

.zp-chatbot-title {
  flex: 1;
  min-width: 0;
}

.zp-chatbot-title strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
}

.zp-chatbot-title span {
  display: block;
  font-size: 0.72rem;
  opacity: 0.85;
  margin-top: 0.15rem;
}

.zp-chatbot-close {
  border: 0;
  background: transparent;
  color: #fff;
  width: 2rem;
  height: 2rem;
  border-radius: 0.4rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
}

.zp-chatbot-close:hover,
.zp-chatbot-close:focus-visible {
  background: rgba(255, 255, 255, 0.14);
  outline: none;
  opacity: 1;
}

.zp-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: var(--zp-chat-bg);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.zp-chatbot-msg {
  max-width: 88%;
  padding: 0.7rem 0.85rem;
  border-radius: 0.85rem;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--zp-chat-text);
  white-space: pre-wrap;
  word-break: break-word;
}

.zp-chatbot-msg--bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid rgba(55, 81, 126, 0.08);
  border-bottom-left-radius: 0.25rem;
}

.zp-chatbot-msg--user {
  align-self: flex-end;
  background: var(--zp-chat-cta);
  color: #fff;
  border-bottom-right-radius: 0.25rem;
}

.zp-chatbot-msg--error {
  align-self: stretch;
  max-width: 100%;
  background: #fff1f0;
  color: #a12622;
  border: 1px solid #f5c2c0;
  font-size: 0.8rem;
}

.zp-chatbot-typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 0.28rem;
  padding: 0.75rem 0.9rem;
  background: #fff;
  border-radius: 0.85rem;
  border: 1px solid rgba(55, 81, 126, 0.08);
}

.zp-chatbot-typing span {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 999px;
  background: var(--zp-chat-muted);
  animation: zp-chat-bounce 1.1s infinite ease-in-out;
}

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

@keyframes zp-chat-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.zp-chatbot-composer {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid rgba(55, 81, 126, 0.1);
  background: #fff;
}

.zp-chatbot-composer input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(55, 81, 126, 0.18);
  border-radius: 0.65rem;
  padding: 0.65rem 0.8rem;
  font-size: 0.875rem;
  color: var(--zp-chat-text);
  outline: none;
}

.zp-chatbot-composer input:focus {
  border-color: var(--zp-chat-accent);
  box-shadow: 0 0 0 3px rgba(71, 178, 228, 0.2);
}

.zp-chatbot-composer button {
  border: 0;
  border-radius: 0.65rem;
  background: var(--zp-chat-navy);
  color: #fff;
  padding: 0 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.zp-chatbot-composer button:hover:not(:disabled),
.zp-chatbot-composer button:focus-visible:not(:disabled) {
  background: var(--zp-chat-cta);
  outline: none;
}

.zp-chatbot-composer button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.zp-chatbot-footnote {
  padding: 0 0.85rem 0.65rem;
  font-size: 0.68rem;
  color: var(--zp-chat-muted);
  background: #fff;
  text-align: center;
}

.zp-chatbot .visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 480px) {
  .zp-chatbot {
    right: 0.85rem;
    bottom: 0.85rem;
  }

  .zp-chatbot-panel {
    width: calc(100vw - 1.7rem);
    height: min(70vh, calc(100vh - 5.5rem));
  }

  body:has(.zp-chatbot) .scroll-top.active {
    bottom: 5rem;
  }
}

/* Keep site scroll-top above the chat launcher (not overlapping) */
body.has-zp-chatbot .scroll-top.active,
body:has(.zp-chatbot) .scroll-top.active {
  right: 1.35rem;
  bottom: 5.25rem;
}
