/* ============================================
   W2K ASSISTANT — CHATBOT WIDGET
   FacBTP | W2K-Digital 2025
   ============================================ */

/* ── Bouton flottant ── */
#w2k-chat-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9990;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #1E3A5F 0%, #2d5a8e 100%);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 13px 20px 13px 14px;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(30,58,95,0.45);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  transition: transform 0.2s, box-shadow 0.2s;
  user-select: none;
}
#w2k-chat-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 32px rgba(30,58,95,0.5);
}
#w2k-chat-btn .cb-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #F5A623, #e08c10);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
#w2k-chat-btn .cb-badge {
  position: absolute;
  top: -6px;
  right: -4px;
  background: #ef4444;
  color: #fff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: cb-pulse 2s infinite;
}
@keyframes cb-pulse {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.15); }
}

/* ── Fenêtre chat ── */
#w2k-chat-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 9991;
  width: 370px;
  max-width: calc(100vw - 40px);
  height: 520px;
  max-height: calc(100vh - 130px);
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: cb-open 0.25s ease;
}
@keyframes cb-open {
  from { transform: scale(0.8); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
#w2k-chat-window.cb-hidden {
  display: none;
}

/* ── Header ── */
.cb-header {
  background: linear-gradient(135deg, #1E3A5F 0%, #2d5a8e 100%);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.cb-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #F5A623, #e08c10);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.cb-header-info { flex: 1; }
.cb-header-name {
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  font-family: 'Montserrat', sans-serif;
}
.cb-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: #93c5fd;
  margin-top: 1px;
}
.cb-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  animation: cb-blink 2.5s infinite;
}
@keyframes cb-blink {
  0%,100% { opacity:1; }
  50%     { opacity:0.4; }
}
.cb-close-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}
.cb-close-btn:hover { background: rgba(255,255,255,0.25); }

/* ── Messages ── */
.cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.cb-messages::-webkit-scrollbar { width: 4px; }
.cb-messages::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 4px; }

/* Bulles */
.cb-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 88%;
}
.cb-msg--bot { align-self: flex-start; }
.cb-msg--user { align-self: flex-end; flex-direction: row-reverse; }

.cb-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #F5A623, #e08c10);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  flex-shrink: 0;
  margin-bottom: 2px;
}
.cb-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.85rem;
  line-height: 1.55;
  font-family: 'Inter', sans-serif;
  white-space: pre-wrap;
  word-break: break-word;
}
.cb-msg--bot .cb-msg-bubble {
  background: #f3f4f6;
  color: #111827;
  border-bottom-left-radius: 4px;
}
.cb-msg--user .cb-msg-bubble {
  background: linear-gradient(135deg, #1E3A5F, #2d5a8e);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.cb-msg-bubble b, .cb-msg-bubble strong {
  font-weight: 700;
}

/* Timestamp */
.cb-msg-time {
  font-size: 0.68rem;
  color: #9ca3af;
  text-align: center;
  margin: 4px 0 2px;
  align-self: center;
}

/* Typing indicator */
.cb-typing {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  align-self: flex-start;
}
.cb-typing-dots {
  background: #f3f4f6;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
  display: flex;
  gap: 4px;
  align-items: center;
}
.cb-typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9ca3af;
  animation: cb-dot-bounce 1.3s infinite;
}
.cb-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.cb-typing-dots span:nth-child(3) { animation-delay: 0.30s; }
@keyframes cb-dot-bounce {
  0%,80%,100% { transform: translateY(0); }
  40%         { transform: translateY(-6px); }
}

/* ── Réponses rapides ── */
.cb-quick-replies {
  padding: 6px 14px 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex-shrink: 0;
  border-top: 1px solid #f3f4f6;
}
.cb-qr-btn {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}
.cb-qr-btn:hover {
  background: #dbeafe;
  transform: translateY(-1px);
}

/* ── Zone saisie ── */
.cb-input-area {
  padding: 10px 12px 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  background: #fff;
  border-top: 1px solid #f3f4f6;
  flex-shrink: 0;
}
#w2k-chat-input {
  flex: 1;
  border: 1.5px solid #e5e7eb;
  border-radius: 24px;
  padding: 9px 16px;
  font-size: 0.875rem;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color 0.2s;
  color: #111827;
  background: #f9fafb;
}
#w2k-chat-input:focus {
  border-color: #1E3A5F;
  background: #fff;
}
#w2k-chat-input::placeholder { color: #9ca3af; }
.cb-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1E3A5F, #2d5a8e);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
  transition: transform 0.15s, box-shadow 0.15s;
}
.cb-send-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(30,58,95,0.35);
}
.cb-send-btn:active { transform: scale(0.95); }

/* ── Formulaire agent ── */
.cb-agent-form {
  background: #eff6ff;
  border: 1.5px solid #bfdbfe;
  border-radius: 12px;
  padding: 12px 14px;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: 'Inter', sans-serif;
}
.cb-agent-form label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #1e40af;
}
.cb-agent-form input {
  border: 1.5px solid #bfdbfe;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.82rem;
  font-family: 'Inter', sans-serif;
  outline: none;
  background: #fff;
  color: #111827;
  transition: border-color 0.2s;
}
.cb-agent-form input:focus { border-color: #1E3A5F; }
.cb-agent-submit {
  background: #1E3A5F;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: background 0.2s;
}
.cb-agent-submit:hover { background: #2d5a8e; }

/* ── Responsive mobile ── */
@media (max-width: 480px) {
  #w2k-chat-btn { bottom: 20px; right: 16px; }
  #w2k-chat-window {
    bottom: 84px;
    right: 8px;
    left: 8px;
    width: auto;
    max-width: none;
    height: 480px;
  }
}
