/* ==========================================================================
   ProCanvas AI Support Chatbot Widget — Modern Glassmorphism & SaaS Design
   ========================================================================== */

/* --- Bouton flottant du launcher --- */
.cb-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #7D2AE8 0%, #9B51E0 60%, #00C4CC 140%);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 20px 12px 14px;
  box-shadow: 0 10px 28px -4px rgba(125, 42, 232, 0.45);
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
  user-select: none;
}

.cb-launcher:hover {
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 16px 36px -4px rgba(125, 42, 232, 0.6);
}

.cb-launcher:active {
  transform: translateY(0) scale(0.98);
}

.cb-launcher-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: grid;
  place-items: center;
  position: relative;
}

.cb-launcher-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.cb-launcher-emblem {
  width: 22px;
  height: 22px;
  object-fit: contain;
  display: block;
}

.cb-avatar-emblem {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
}

.cb-launcher-online {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  background: #10B981;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.7);
}

.cb-launcher-label {
  font-family: var(--font-display, 'Plus Jakarta Sans', sans-serif);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: -0.01em;
}

.cb-launcher-badge {
  background: #00C4CC;
  color: #101438;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 2px;
}

/* --- Fenêtre de chat --- */
.cb-window {
  position: fixed;
  bottom: 84px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 120px);
  background: #FFFFFF;
  border: 1px solid rgba(227, 233, 245, 0.85);
  border-radius: 24px;
  box-shadow: 0 24px 60px rgba(16, 20, 56, 0.18), 0 8px 24px rgba(125, 42, 232, 0.12);
  z-index: 151;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Header */
.cb-header {
  background: linear-gradient(135deg, #101438 0%, #2a1a6b 60%, #5b2ee5 130%);
  color: #FFFFFF;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.cb-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cb-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7D2AE8, #00C4CC);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.cb-header-title {
  font-family: var(--font-display, 'Plus Jakarta Sans', sans-serif);
  font-weight: 800;
  font-size: 0.96rem;
  line-height: 1.2;
}

.cb-header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  color: rgba(255, 255, 255, 0.78);
  margin-top: 2px;
}

.cb-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10B981;
  box-shadow: 0 0 6px #10B981;
}

.cb-close-btn {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 15px;
  transition: background 0.2s;
}

.cb-close-btn:hover {
  background: rgba(255, 255, 255, 0.24);
}

/* Zone des messages */
.cb-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #F8FAFC;
  scroll-behavior: smooth;
}

.cb-body::-webkit-scrollbar {
  width: 5px;
}
.cb-body::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 10px;
}

/* Bulles */
.cb-msg {
  display: flex;
  flex-direction: column;
  max-width: 84%;
  animation: cbFadeIn 0.25s ease-out;
}

@keyframes cbFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.cb-msg.bot {
  align-self: flex-start;
}

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

.cb-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.88rem;
  line-height: 1.45;
  word-break: break-word;
}

.cb-msg.bot .cb-bubble {
  background: #FFFFFF;
  color: #101438;
  border: 1px solid #E2E8F0;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(16, 20, 56, 0.04);
}

.cb-msg.user .cb-bubble {
  background: linear-gradient(135deg, #7D2AE8 0%, #9B51E0 100%);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(125, 42, 232, 0.25);
}

.cb-time {
  font-size: 0.68rem;
  color: #94A3B8;
  margin-top: 4px;
  padding: 0 4px;
}

.cb-msg.user .cb-time {
  text-align: right;
}

/* Boutons d'action dans les réponses du bot */
.cb-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.cb-action-btn {
  background: var(--purple-tint, #F1E9FF);
  color: #7D2AE8;
  border: 1px solid rgba(125, 42, 232, 0.25);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
}

.cb-action-btn:hover {
  background: #7D2AE8;
  color: #FFFFFF;
  transform: translateY(-1px);
}

.cb-action-btn.primary {
  background: linear-gradient(135deg, #7D2AE8, #00C4CC);
  color: #FFFFFF;
  border: none;
}

/* Suggestions rapides (chips) */
.cb-chips-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.cb-chips-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: #64748B;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}

.cb-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cb-chip {
  background: #FFFFFF;
  color: #334155;
  border: 1px solid #CBD5E1;
  border-radius: 999px;
  font-size: 0.78rem;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.cb-chip:hover {
  border-color: #7D2AE8;
  color: #7D2AE8;
  background: #FAF5FF;
}

/* Indicateur de frappe (Typing) */
.cb-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.cb-dot {
  width: 7px;
  height: 7px;
  background: #94A3B8;
  border-radius: 50%;
  animation: cbBounce 1.4s infinite ease-in-out both;
}

.cb-dot:nth-child(1) { animation-delay: -0.32s; }
.cb-dot:nth-child(2) { animation-delay: -0.16s; }
.cb-dot:nth-child(3) { animation-delay: 0s; }

@keyframes cbBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Zone d'envoi */
.cb-footer {
  padding: 12px 14px;
  background: #FFFFFF;
  border-top: 1px solid #E2E8F0;
}

.cb-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #F1F5F9;
  border: 1px solid #E2E8F0;
  border-radius: 999px;
  padding: 4px 6px 4px 14px;
  transition: border-color 0.2s, background 0.2s;
}

.cb-form:focus-within {
  background: #FFFFFF;
  border-color: #7D2AE8;
  box-shadow: 0 0 0 3px rgba(125, 42, 232, 0.12);
}

.cb-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 0.88rem;
  color: #101438;
}

.cb-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7D2AE8, #9B51E0);
  color: #FFFFFF;
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.2s, opacity 0.2s;
  flex-shrink: 0;
}

.cb-send-btn:hover {
  transform: scale(1.08);
}

.cb-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.cb-send-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Adaptation Mobile : Bouton rond et compact comme WhatsApp avec l'emblème */
@media (max-width: 860px) {
  #procanvasChatbot .cb-launcher,
  .cb-launcher {
    bottom: 74px !important;
    right: 14px !important;
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    min-height: 48px !important;
    max-width: 48px !important;
    max-height: 48px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0 !important;
    background: linear-gradient(135deg, #7D2AE8 0%, #00C4CC 140%) !important;
    box-shadow: 0 8px 24px -2px rgba(125, 42, 232, 0.6), 0 3px 8px rgba(0, 0, 0, 0.18) !important;
    border: 2px solid rgba(255, 255, 255, 0.4) !important;
    z-index: 100 !important;
  }

  #procanvasChatbot .cb-launcher-label,
  #procanvasChatbot .cb-launcher-badge,
  .cb-launcher-label,
  .cb-launcher-badge,
  #cbLauncherLabel,
  #cbLauncherBadge {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  #procanvasChatbot .cb-launcher-icon,
  .cb-launcher-icon {
    width: 100% !important;
    height: 100% !important;
    background: transparent !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #procanvasChatbot .cb-launcher-emblem,
  .cb-launcher-emblem {
    width: 26px !important;
    height: 26px !important;
    object-fit: contain !important;
    display: block !important;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25)) !important;
  }

  #procanvasChatbot .cb-launcher-online,
  .cb-launcher-online {
    position: absolute !important;
    bottom: 2px !important;
    right: 2px !important;
    width: 10px !important;
    height: 10px !important;
    border: 2px solid #fff !important;
    border-radius: 50% !important;
    background: #10B981 !important;
  }

  #procanvasChatbot .cb-window,
  .cb-window {
    bottom: 74px !important;
    right: 12px !important;
    left: 12px !important;
    width: auto !important;
    height: 520px !important;
    max-height: calc(100vh - 90px) !important;
    border-radius: 20px !important;
  }
}
