/* KIWL floating chat widget — prominent FAB */
#kiwl-chat-root {
  --kiwl-chat-primary: #1a5276;
  --kiwl-chat-accent: #25d366;
  --kiwl-chat-orange: #ff7d11;
  --kiwl-chat-bg: #fff;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  z-index: 999999;
  position: fixed;
  right: 64px;
  bottom: 24px;
}

#kiwl-chat-toggle {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 60px;
  padding: 0 22px 0 18px;
  border: none;
  border-radius: 30px;
  background: linear-gradient(135deg, #ff7d11 0%, #ff9500 50%, #ff7d11 100%);
  background-size: 200% 100%;
  color: #fff;
  cursor: pointer;
  box-shadow:
    0 6px 24px rgba(255, 125, 17, 0.55),
    0 2px 8px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: kiwl-chat-shimmer 3s ease infinite;
}

#kiwl-chat-toggle::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 38px;
  border: 3px solid rgba(255, 125, 17, 0.65);
  animation: kiwl-chat-ring 2.2s ease-out infinite;
  pointer-events: none;
}

#kiwl-chat-toggle:hover {
  transform: scale(1.05) translateY(-2px);
  box-shadow:
    0 10px 32px rgba(255, 125, 17, 0.65),
    0 4px 12px rgba(0, 0, 0, 0.2);
}

#kiwl-chat-toggle.is-open {
  animation: none;
  background: #1a5276;
  box-shadow: 0 4px 16px rgba(26, 82, 118, 0.45);
}

#kiwl-chat-toggle.is-open::before {
  display: none;
}

#kiwl-chat-toggle svg {
  width: 30px;
  height: 30px;
  fill: currentColor;
  flex-shrink: 0;
}

#kiwl-chat-toggle-label {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

#kiwl-chat-toggle .kiwl-chat-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 16px;
  height: 16px;
  background: #25d366;
  border: 2px solid #fff;
  border-radius: 50%;
  animation: kiwl-chat-pulse 1.5s infinite;
}

@keyframes kiwl-chat-shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@keyframes kiwl-chat-ring {
  0% {
    transform: scale(1);
    opacity: 0.85;
  }
  70%, 100% {
    transform: scale(1.18);
    opacity: 0;
  }
}

@keyframes kiwl-chat-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.75; transform: scale(1.15); }
}

#kiwl-chat-teaser {
  position: absolute;
  right: 0;
  bottom: 72px;
  max-width: 220px;
  padding: 10px 14px;
  background: #fff;
  color: #333;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#kiwl-chat-teaser::after {
  content: '';
  position: absolute;
  right: 28px;
  bottom: -8px;
  border: 8px solid transparent;
  border-top-color: #fff;
}

#kiwl-chat-teaser.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#kiwl-chat-teaser-close {
  position: absolute;
  top: 4px;
  right: 6px;
  background: none;
  border: none;
  color: #999;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}

#kiwl-chat-teaser-close:hover {
  color: #333;
}

#kiwl-chat-panel {
  display: none;
  position: absolute;
  right: 0;
  bottom: 76px;
  width: 340px;
  max-width: calc(100vw - 40px);
  background: var(--kiwl-chat-bg);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  flex-direction: column;
  max-height: 480px;
}

#kiwl-chat-panel.is-open {
  display: flex;
  animation: kiwl-chat-slide 0.25s ease;
}

@keyframes kiwl-chat-slide {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.kiwl-chat-header {
  background: linear-gradient(135deg, #1a5276 0%, #2874a6 100%);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.kiwl-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff;
  color: #1a5276;
  font-weight: 700;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kiwl-chat-header-info h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.kiwl-chat-header-info p {
  margin: 2px 0 0;
  font-size: 12px;
  opacity: 0.9;
}

.kiwl-chat-close {
  margin-left: auto;
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.85;
  padding: 0 4px;
}

.kiwl-chat-close:hover {
  opacity: 1;
}

.kiwl-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  background: #f4f6f8;
  min-height: 200px;
  max-height: 300px;
}

.kiwl-chat-msg {
  margin-bottom: 10px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.kiwl-chat-msg.is-bot .kiwl-chat-bubble {
  background: #fff;
  border: 1px solid #e8ecef;
  border-radius: 12px 12px 12px 4px;
  color: #333;
}

.kiwl-chat-msg.is-user {
  justify-content: flex-end;
}

.kiwl-chat-msg.is-user .kiwl-chat-bubble {
  background: #1a5276;
  color: #fff;
  border-radius: 12px 12px 4px 12px;
}

.kiwl-chat-bubble {
  max-width: 88%;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}

.kiwl-chat-bubble strong {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  opacity: 0.85;
}

.kiwl-chat-page-ref {
  margin-top: 6px;
  padding: 8px;
  background: #f0f7fb;
  border-left: 3px solid #2874a6;
  border-radius: 4px;
  font-size: 12px;
  color: #444;
}

.kiwl-chat-page-ref a {
  color: #1a5276;
  word-break: break-all;
}

.kiwl-chat-typing {
  display: flex;
  gap: 4px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid #e8ecef;
  border-radius: 12px;
  width: fit-content;
}

.kiwl-chat-typing span {
  width: 7px;
  height: 7px;
  background: #999;
  border-radius: 50%;
  animation: kiwl-chat-dot 1.2s infinite;
}

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

@keyframes kiwl-chat-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.kiwl-chat-footer {
  padding: 12px;
  border-top: 1px solid #e8ecef;
  background: #fff;
}

.kiwl-chat-wa-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  background: #25d366;
  color: #fff !important;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none !important;
  cursor: pointer;
  transition: background 0.2s;
  box-sizing: border-box;
}

.kiwl-chat-wa-btn:hover {
  background: #1ebe57;
  color: #fff !important;
}

.kiwl-chat-wa-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  flex-shrink: 0;
}

.kiwl-chat-footer-note {
  margin: 8px 0 0;
  font-size: 11px;
  color: #888;
  text-align: center;
}

@media (max-width: 768px) {
  #kiwl-chat-root {
    right: 16px;
    bottom: 20px;
  }

  #kiwl-chat-toggle {
    width: 62px;
    height: 62px;
    padding: 0;
    border-radius: 50%;
  }

  #kiwl-chat-toggle-label {
    display: none;
  }

  #kiwl-chat-teaser {
    right: -4px;
    max-width: 200px;
  }
}

@media (max-width: 480px) {
  #kiwl-chat-panel {
    width: calc(100vw - 32px);
    right: -8px;
  }
}
