/* Floating container */
.api-chat-float {
  position: fixed;
  bottom: 18px;
  z-index: 999999;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

/* Teaser message above FAB */
.api-chat-teaser {
  background: var(--chatbot-tertiary, #f9e0eb);
  color: #000;
  padding: 8px 42px 8px 24px;
  border-radius: var(--chatbot-radius, 14px);
  font-size: 14px;
  line-height: 1.4;
  max-width: 240px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
}

.api-chat-teaser.hidden {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

/* Floating Action Button (FAB) */
.api-chat-fab {
  width: 56px;
  height: 56px;
  border-radius: var(--chatbot-radius, 999px);
  border: none;
  background: var(--chatbot-secondary, #f4c7db);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  position: relative;
  display: grid;
  place-items: center;
  transition: all 0.3s ease;
  overflow: visible;
}

.api-chat-fab.open {
  color: #000;
  background: var(--chatbot-primary, #e06299);
  transform: scale(1.05);
}

.api-chat-fab.open .api-chat-fab-icon {
  align-items: center;
}

.api-chat-fab:not(.open):hover {
  background: var(--chatbot-primary, #e06299);
  transform: translateY(-2px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.22);
}

.api-chat-fab-icon {
  font-size: 22px;
  font-weight: 700;
  color: #000;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.api-chat-fab-icon img {
  pointer-events: none;
  width: 70px;
  height: auto;
  max-width: none;
  display: block;
}

/* Notification badge */
.api-chat-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #e11d48;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 2px solid #fff;
}

/* Chat panel */
.api-chat-panel {
  position: absolute;
  bottom: 70px;
  width: min(380px, calc(100vw - 36px));
  height: min(520px, calc(100vh - 140px));
  max-height: calc(100vh - 140px);
  background: var(--chatbot-bg, #fff);
  border: 1px solid var(--chatbot-panel-border, #e6e6e6);
  border-radius: var(--chatbot-radius, 14px);
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  transform: translateY(10px);
  opacity: 0;
  pointer-events: none;
  transition:
    transform 160ms ease,
    opacity 160ms ease;
}

.api-chat-panel.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Header */
.api-chat-header {
  flex: 0 0 auto;
  min-height: 62px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  text-align: left;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--chatbot-header-text, #fff);
  background: var(--chatbot-header-bg, #e85d9a);
}

/* Messages */
.api-chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px;
  background: var(--chatbot-messages-bg, #fafafa);
}

/* Scrollbar styling */
.api-chat-messages::-webkit-scrollbar {
  width: 6px;
}

.api-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.api-chat-messages::-webkit-scrollbar-thumb {
  background: var(--chatbot-scrollbar, #d0d0d0);
  border-radius: 3px;
}

.api-chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--chatbot-primary, #e85d9a);
}

.api-chat-message {
  display: flex;
  margin: 10px 0;
}

.api-chat-message.user {
  justify-content: flex-end;
}

.api-chat-message .bubble {
  max-width: 82%;
  padding: 10px 12px;
  border-radius: var(--chatbot-radius, 14px);
  line-height: 1.25;
  white-space: pre-wrap;
  word-break: break-word;
  border: none;
  background: var(--chatbot-tertiary, #f9e0eb);
  color: #000;
}

.api-chat-message.user .bubble {
  background: var(--chatbot-user-bubble, #fff);
  color: var(--chatbot-text, #000);
  border: none;
}

/* Welcome bubble */
.api-chat-welcome-bubble {
  display: inline-flex;
  flex-direction: row;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  padding: 0 32px 0 0;
  background: var(--chatbot-tertiary, #f9e0eb);
  border-radius: var(--chatbot-radius, 14px);
  max-width: 90%;
  min-height: 62px;
}

.api-chat-welcome-bubble.no-icon {
  padding-left: 24px;
}

.api-chat-welcome-icon-box {
  width: 62px;
  height: 62px;
  flex-shrink: 0;
  background: var(--chatbot-secondary, #f4c7db);
  border-radius: var(--chatbot-radius, 14px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.api-chat-welcome-icon-box img {
  max-width: 45px;
  max-height: 45px;
  object-fit: contain;
}

.api-chat-welcome-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: #000;
  line-height: 1.3;
  font-size: 14px;
}

/* Quick replies */
.api-chat-quick-replies {
  padding: 12px;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.api-chat-quick-reply {
  padding: 10px 14px;
  border-radius: var(--chatbot-radius, 14px);
  border: none;
  background: var(--chatbot-user-bubble, #fff);
  color: var(--chatbot-text, #000);
  cursor: pointer;
  font-size: 14px;
  text-align: left;
  transition: all 0.3s ease;
  display: inline-block;
  width: fit-content;
}

.api-chat-quick-reply:hover {
  background: var(--chatbot-primary, #e85d9a);
  border-color: var(--chatbot-primary, #e85d9a);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Input */
.api-chat-form {
  flex: 0 0 auto;
  padding: 10px 12px;
  background: var(--chatbot-messages-bg, #fafafa);
  position: relative;
}

.api-chat-input {
  width: 100%;
  padding: 12px 50px 12px 16px;
  border-radius: 24px;
  border: 1px solid var(--chatbot-input-border, #ccc);
  outline: none;
  color: var(--chatbot-text, #000);
  background: var(--chatbot-bg, #fff);
  font-size: 14px;
}

.api-chat-input::placeholder {
  color: #999;
}

.api-chat-send {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  font-size: 0;
  padding: 0;
}

.api-chat-send::before {
  content: "";
  width: 20px;
  height: 20px;
  mask-image: url('data:image/svg+xml;utf8,<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12.332 0.546875C13.2617 0 14.4375 0.792969 14.2734 1.88672L12.6602 12.4688C12.5781 12.8789 12.3594 13.207 12.0039 13.4258C11.7852 13.5352 11.5664 13.5898 11.3477 13.5898C11.1836 13.5898 11.0195 13.5625 10.8555 13.4805L7.79297 12.2227L6.58984 13.8359C5.85156 14.8477 4.23828 14.3281 4.23828 13.043V10.7461L1.09375 9.46094C0.0820312 9.05078 0 7.65625 0.957031 7.10938L12.332 0.546875ZM5.55078 13.043L6.53516 11.7031L5.55078 11.293V13.043ZM11.3477 12.2773L12.9883 1.66797L1.61328 8.23047L4.53906 9.46094L10.3359 4.42969C10.7188 4.07422 11.2656 4.56641 10.9922 5.00391L7.13672 10.5273L11.3477 12.2773Z" fill="black"/></svg>');
  -webkit-mask-image: url('data:image/svg+xml;utf8,<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12.332 0.546875C13.2617 0 14.4375 0.792969 14.2734 1.88672L12.6602 12.4688C12.5781 12.8789 12.3594 13.207 12.0039 13.4258C11.7852 13.5352 11.5664 13.5898 11.3477 13.5898C11.1836 13.5898 11.0195 13.5625 10.8555 13.4805L7.79297 12.2227L6.58984 13.8359C5.85156 14.8477 4.23828 14.3281 4.23828 13.043V10.7461L1.09375 9.46094C0.0820312 9.05078 0 7.65625 0.957031 7.10938L12.332 0.546875ZM5.55078 13.043L6.53516 11.7031L5.55078 11.293V13.043ZM11.3477 12.2773L12.9883 1.66797L1.61328 8.23047L4.53906 9.46094L10.3359 4.42969C10.7188 4.07422 11.2656 4.56641 10.9922 5.00391L7.13672 10.5273L11.3477 12.2773Z" fill="black"/></svg>');
  mask-size: contain;
  -webkit-mask-size: contain;
  mask-repeat: no-repeat;
  -webkit-mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-position: center;
  background-color: var(--chatbot-text, #000);
  transition: all 0.3s ease;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.api-chat-send:hover::before {
  background-color: var(--chatbot-primary, #e85d9a);
}

.api-chat-send:hover {
  color: var(--chatbot-primary, #e85d9a);
  background: rgba(0, 0, 0, 0.05);
}

/* Mobile tweak */
@media (max-width: 420px) {
  .api-chat-panel {
    height: 70vh;
  }
}
