:root {
  --cb-bg: #0e0f14;
  --cb-panel: #15171f;
  --cb-panel-2: #1b1e29;
  --cb-border: rgba(255, 255, 255, 0.08);
  --cb-text: #eef0f6;
  --cb-text-dim: #9aa0b4;
  --cb-accent-1: #7c5cfc;
  --cb-accent-2: #22d3ee;
  --cb-gradient: linear-gradient(135deg, var(--cb-accent-1), var(--cb-accent-2));
  --cb-whatsapp: #25d366;
  --cb-whatsapp-dark: #1ebe5a;
  --cb-radius: 18px;
  --cb-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.3);
}

#cb-launcher {
  position: fixed;
  bottom: 22px;
  right: 22px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  z-index: 9999;
  background: var(--cb-panel);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--cb-shadow);
  animation: cb-float 3.2s ease-in-out infinite;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  padding: 0;
}
#cb-launcher::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: var(--cb-gradient);
  opacity: 0.55;
  filter: blur(10px);
  z-index: -1;
  animation: cb-pulse 2.4s ease-in-out infinite;
}
#cb-launcher:hover { transform: scale(1.08) rotate(-4deg); }
#cb-launcher svg { width: 30px; height: 30px; display: block; }
#cb-launcher.cb-hidden { transform: scale(0); opacity: 0; pointer-events: none; }

@keyframes cb-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
@keyframes cb-pulse {
  0%, 100% { opacity: 0.45; transform: scale(1); }
  50% { opacity: 0.75; transform: scale(1.12); }
}

.cb-bot-eye { fill: #fff; }
.cb-bot-face { animation: cb-blink 4.5s ease-in-out infinite; transform-origin: center; }
@keyframes cb-blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.15); }
}

#cb-window {
  position: fixed;
  bottom: 22px;
  right: 22px;
  width: 360px;
  max-width: calc(100vw - 28px);
  height: 500px;
  max-height: calc(100vh - 100px);
  background: var(--cb-panel);
  border: 1px solid var(--cb-border);
  border-radius: var(--cb-radius);
  box-shadow: var(--cb-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  transform: translateY(24px) scale(0.92);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s ease;
}
#cb-window.cb-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

#cb-header {
  background: var(--cb-gradient);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
#cb-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#cb-header-avatar svg { width: 20px; height: 20px; }
#cb-header-text { flex: 1; min-width: 0; }
#cb-header-title { font-weight: 700; font-size: 14.5px; line-height: 1.2; }
#cb-header-status {
  font-size: 11.5px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}
#cb-header-status .cb-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  animation: cb-dot-pulse 1.8s infinite;
}
@keyframes cb-dot-pulse {
  0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6); }
  70% { box-shadow: 0 0 0 6px rgba(74, 222, 128, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}
#cb-close {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s ease, transform 0.2s ease;
}
#cb-close:hover { background: rgba(255, 255, 255, 0.28); transform: rotate(90deg); }
#cb-close svg { width: 14px; height: 14px; }

#cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background:
    radial-gradient(ellipse at top right, rgba(124, 92, 252, 0.08), transparent 55%),
    var(--cb-bg);
}
#cb-messages::-webkit-scrollbar { width: 6px; }
#cb-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }

.cb-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: cb-rise 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
.cb-row.cb-user { justify-content: flex-end; }
@keyframes cb-rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.cb-avatar-sm {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--cb-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cb-avatar-sm svg { width: 15px; height: 15px; }

.cb-msg {
  max-width: 76%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.cb-msg.cb-bot {
  background: var(--cb-panel-2);
  color: var(--cb-text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--cb-border);
}
.cb-msg.cb-user {
  background: var(--cb-gradient);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.cb-typing-dots {
  display: flex;
  gap: 4px;
  padding: 4px 2px;
}
.cb-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cb-text-dim);
  animation: cb-bounce 1.1s infinite ease-in-out;
}
.cb-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.cb-typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes cb-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.cb-whatsapp-btn {
  align-self: flex-start;
  margin-left: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: linear-gradient(135deg, var(--cb-whatsapp), var(--cb-whatsapp-dark));
  color: #fff;
  text-decoration: none;
  padding: 9px 16px;
  border-radius: 22px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(37, 211, 102, 0.35);
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.18s ease;
  animation: cb-rise 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.cb-whatsapp-btn:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 10px 22px rgba(37, 211, 102, 0.45);
}
.cb-whatsapp-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

#cb-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--cb-border);
  background: var(--cb-panel);
}
#cb-input {
  flex: 1;
  background: var(--cb-panel-2);
  border: 1px solid var(--cb-border);
  color: var(--cb-text);
  border-radius: 22px;
  padding: 10px 15px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.2s ease;
}
#cb-input::placeholder { color: var(--cb-text-dim); }
#cb-input:focus { border-color: var(--cb-accent-2); }

#cb-send {
  background: var(--cb-gradient);
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#cb-send:hover { transform: scale(1.08); }
#cb-send:active { transform: scale(0.94); }
#cb-send svg { width: 16px; height: 16px; }

@media (prefers-reduced-motion: reduce) {
  #cb-launcher, #cb-launcher::before, .cb-bot-face, .cb-row, .cb-typing-dots span, .cb-whatsapp-btn {
    animation: none !important;
  }
  #cb-window { transition: opacity 0.15s ease; }
}
