/* ============================================================
   iBudgex Website Assistant Chatbot — chatbot.css
   Style cohérent avec ibudgex.com (violet #4158d0 → rose #c850c0)
   ============================================================ */

:root {
  --cb-grad:        linear-gradient(135deg, #c850c0 0%, #4158d0 100%);
  --cb-grad-rev:    linear-gradient(135deg, #4158d0 0%, #c850c0 100%);
  --cb-primary:     #4158d0;
  --cb-secondary:   #c850c0;
  --cb-bg:          #ffffff;
  --cb-surface:     #f7f8ff;
  --cb-border:      #e8eaf6;
  --cb-text:        #1e1e2e;
  --cb-muted:       #6b7280;
  --cb-bot-bubble:  #f0f0ff;
  --cb-shadow:      0 24px 64px rgba(65, 88, 208, 0.22);
  --cb-shadow-sm:   0 6px 20px rgba(65, 88, 208, 0.18);
  --cb-radius:      22px;
  --cb-width:       380px;
  --cb-height:      560px;
  --cb-z:           99999;
}

/* ── Toggle Button ── */
#cb-toggle {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--cb-grad);
  border: none;
  cursor: pointer;
  box-shadow: var(--cb-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--cb-z);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
  outline: none;
}

#cb-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 28px 72px rgba(200, 80, 192, 0.4);
}

#cb-toggle:active {
  transform: scale(0.95);
}

#cb-toggle .cb-icon,
#cb-toggle .cb-close {
  position: absolute;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

#cb-toggle .cb-icon svg,
#cb-toggle .cb-close svg {
  width: 24px;
  height: 24px;
  fill: #fff;
}

#cb-toggle .cb-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

#cb-toggle.open .cb-icon {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

#cb-toggle.open .cb-close {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* Pulse ring */
#cb-toggle::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: var(--cb-grad);
  opacity: 0.2;
  animation: cb-pulse 2.5s ease-in-out infinite;
  z-index: -1;
}

@keyframes cb-pulse {
  0%, 100% { transform: scale(1);    opacity: 0.2; }
  50%       { transform: scale(1.18); opacity: 0; }
}

/* Badge */
#cb-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ff4757;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  font-family: 'Rubik', sans-serif;
}

/* ── Chat Window ── */
#cb-window {
  position: fixed;
  bottom: 106px;
  right: 30px;
  width: var(--cb-width);
  height: var(--cb-height);
  background: var(--cb-bg);
  border-radius: var(--cb-radius);
  box-shadow: var(--cb-shadow);
  display: flex;
  flex-direction: column;
  z-index: calc(var(--cb-z) - 1);
  overflow: hidden;
  border: 1px solid rgba(65, 88, 208, 0.1);

  opacity: 0;
  transform: translateY(24px) scale(0.94);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: bottom right;
}

#cb-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Header ── */
.cb-header {
  background: var(--cb-grad);
  padding: 15px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.cb-header::after {
  content: '';
  position: absolute;
  top: -30px;
  right: -30px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
}

.cb-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  border: 2px solid rgba(255,255,255,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
  flex-shrink: 0;
}

.cb-avatar svg { width: 20px; height: 20px; fill: #fff; }

.cb-header-info { flex: 1; min-width: 0; }

.cb-header-name {
  color: #fff;
  font-family: 'Rubik', sans-serif;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
}

.cb-header-status {
  color: rgba(255,255,255,0.82);
  font-family: 'Rubik', sans-serif;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.cb-header-status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  display: inline-block;
  animation: cb-blink 2s infinite;
}

@keyframes cb-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

.cb-header-actions { display: flex; gap: 6px; }

.cb-header-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.cb-header-btn:hover { background: rgba(255,255,255,0.28); }

/* ── Messages ── */
.cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--cb-surface);
  scroll-behavior: smooth;
}

.cb-messages::-webkit-scrollbar { width: 4px; }
.cb-messages::-webkit-scrollbar-track { background: transparent; }
.cb-messages::-webkit-scrollbar-thumb {
  background: rgba(65, 88, 208, 0.25);
  border-radius: 4px;
}

/* ── Bubbles ── */
.cb-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  animation: cb-msg-in 0.28s ease;
}

@keyframes cb-msg-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cb-msg.user { flex-direction: row-reverse; }

.cb-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.cb-msg.bot .cb-msg-avatar  { background: var(--cb-grad); color: #fff; }
.cb-msg.user .cb-msg-avatar { background: #e8eaf6; color: var(--cb-primary); }

.cb-msg-avatar svg { width: 14px; height: 14px; fill: currentColor; }
.cb-msg.bot .cb-msg-avatar svg  { fill: #fff; }
.cb-msg.user .cb-msg-avatar svg { fill: var(--cb-primary); }

.cb-msg-content {
  max-width: 78%;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.cb-msg.user .cb-msg-content { align-items: flex-end; }

.cb-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  font-family: 'Rubik', sans-serif;
}

.cb-msg.bot .cb-bubble {
  background: var(--cb-bot-bubble);
  color: var(--cb-text);
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(65, 88, 208, 0.1);
}

.cb-msg.user .cb-bubble {
  background: var(--cb-grad);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.cb-msg-time {
  font-size: 11px;
  color: var(--cb-muted);
  padding: 0 4px;
  font-family: 'Rubik', sans-serif;
}

/* ── Typing ── */
.cb-typing {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.cb-typing .cb-msg-avatar {
  background: var(--cb-grad);
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.cb-typing .cb-msg-avatar svg { width: 14px; height: 14px; fill: #fff; }

.cb-typing-bubble {
  background: var(--cb-bot-bubble);
  border: 1px solid rgba(65, 88, 208, 0.1);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.cb-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cb-grad);
  background: #4158d0;
  animation: cb-dots 1.2s infinite;
}

.cb-dot:nth-child(2) { animation-delay: 0.2s; }
.cb-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes cb-dots {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
  40%            { transform: scale(1);   opacity: 1; }
}

/* ── Quick Replies ── */
.cb-quick-replies {
  padding: 8px 14px 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  background: var(--cb-surface);
  border-top: 1px solid var(--cb-border);
  flex-shrink: 0;
}

.cb-quick-btn {
  padding: 6px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--cb-primary);
  background: transparent;
  color: var(--cb-primary);
  font-size: 12px;
  font-family: 'Rubik', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.cb-quick-btn:hover {
  background: var(--cb-grad);
  border-color: transparent;
  color: #fff;
}

/* ── Input Area ── */
.cb-input-area {
  padding: 12px 14px 14px;
  background: var(--cb-bg);
  border-top: 1px solid var(--cb-border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}

.cb-input-wrap { flex: 1; }

#cb-input {
  width: 100%;
  border: 1.5px solid var(--cb-border);
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: 'Rubik', sans-serif;
  color: var(--cb-text);
  background: var(--cb-surface);
  outline: none;
  resize: none;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color 0.2s;
  line-height: 1.4;
}

#cb-input:focus {
  border-color: var(--cb-primary);
  background: #fff;
}

#cb-input::placeholder { color: var(--cb-muted); }

#cb-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--cb-grad);
  border: none;
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: var(--cb-shadow-sm);
}

#cb-send:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 24px rgba(200, 80, 192, 0.45);
}

#cb-send:active  { transform: scale(0.95); }
#cb-send:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* ── Welcome ── */
.cb-welcome {
  text-align: center;
  padding: 8px 8px 2px;
}

.cb-welcome-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--cb-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff;
  margin: 0 auto 10px;
  box-shadow: var(--cb-shadow-sm);
}

.cb-welcome-icon svg { width: 26px; height: 26px; fill: #fff; }

.cb-welcome h4 {
  font-family: 'Rubik', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--cb-text);
  margin-bottom: 5px;
}

.cb-welcome p {
  font-family: 'Rubik', sans-serif;
  font-size: 13px;
  color: var(--cb-muted);
  line-height: 1.5;
  margin: 0 0 14px;
}

/* ── CTA Button (bienvenue) ── */
.cb-cta-btn {
  display: inline-block;
  background: var(--cb-grad);
  color: #fff !important;
  font-family: 'Rubik', sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 20px;
  border-radius: 50px;
  text-decoration: none !important;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 14px rgba(200, 80, 192, 0.35);
  letter-spacing: 0.3px;
}

.cb-cta-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(200, 80, 192, 0.5);
  color: #fff !important;
  text-decoration: none !important;
}

/* ── Bouton CTA inline sous les bulles bot ── */
.cb-inline-cta {
  display: inline-block;
  margin-top: 8px;
  background: var(--cb-grad);
  color: #fff !important;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 16px;
  border-radius: 50px;
  text-decoration: none !important;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 3px 10px rgba(200, 80, 192, 0.35);
  letter-spacing: 0.3px;
}

.cb-inline-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(200, 80, 192, 0.5);
  color: #fff !important;
  text-decoration: none !important;
}

/* ── Liens cliquables dans les bulles ── */
.cb-bubble .cb-link {
  color: var(--cb-primary);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.2s ease;
}

.cb-bubble .cb-link:hover {
  color: var(--cb-secondary);
}

.cb-msg.user .cb-bubble .cb-link {
  color: rgba(255,255,255,0.9);
  text-decoration-color: rgba(255,255,255,0.6);
}

/* ── Responsive ── */
@media (max-width: 480px) {
  #cb-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
    border: none;
  }

  #cb-toggle {
    bottom: 20px;
    right: 20px;
  }
}
