/* Widget de chat en direct — bulle flottante + panneau, sur toutes les pages.
   Direction : verre dépoli, aplats pastel, angles très arrondis, peu d'ombre
   dure — cohérent avec le reste du site (voir --turquoise/--marine/--violet). */

#cb-chat-bubble {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--turquoise, #50DDC4), var(--turquoise-dark, #26BCA1));
  box-shadow: 0 12px 28px rgba(38, 188, 161, 0.35);
  border: none;
  cursor: pointer;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s cubic-bezier(.34,1.56,.64,1), box-shadow 0.2s ease;
}
#cb-chat-bubble:hover { transform: scale(1.06); box-shadow: 0 14px 32px rgba(38, 188, 161, 0.45); }
#cb-chat-bubble:active { transform: scale(0.96); }

#cb-chat-bubble .cb-chat-icon {
  position: absolute;
  width: 24px;
  height: 24px;
  transition: opacity 0.2s ease, transform 0.25s cubic-bezier(.34,1.56,.64,1);
}
#cb-chat-bubble .cb-chat-icon-close { opacity: 0; transform: rotate(-45deg) scale(0.6); }
#cb-chat-bubble.open .cb-chat-icon-chat { opacity: 0; transform: rotate(45deg) scale(0.6); }
#cb-chat-bubble.open .cb-chat-icon-close { opacity: 1; transform: rotate(0) scale(1); }

#cb-chat-panel {
  position: fixed;
  right: 24px;
  bottom: 96px;
  width: 372px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 140px);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 28px;
  box-shadow: 0 24px 60px rgba(35, 48, 72, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 2000;
  font-family: 'Poppins', sans-serif;
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.2s ease, transform 0.25s cubic-bezier(.34,1.2,.64,1), visibility 0.25s;
  transform-origin: bottom right;
}
#cb-chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  visibility: visible;
}

#cb-chat-header {
  background: linear-gradient(120deg, var(--green-100, #E9FBF8), rgba(248, 246, 254, 0.9));
  color: var(--marine, #233048);
  padding: 20px 20px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(35, 48, 72, 0.06);
}
#cb-chat-header-title { display: flex; align-items: center; gap: 7px; }
#cb-chat-header strong { font-size: 0.98rem; font-weight: 700; letter-spacing: -0.01em; }
#cb-chat-status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--turquoise-dark, #26BCA1);
  box-shadow: 0 0 0 3px rgba(38, 188, 161, 0.2);
  display: inline-block;
}
#cb-chat-header span {
  font-size: 0.76rem; opacity: 0.6; display: block; margin-top: 2px; font-weight: 400;
}
#cb-chat-close {
  background: rgba(35, 48, 72, 0.06);
  border: none;
  color: var(--marine, #233048);
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease;
  flex-shrink: 0;
}
#cb-chat-close:hover { background: rgba(35, 48, 72, 0.12); }
#cb-chat-close svg { width: 14px; height: 14px; }

/* Mention IA (règlement IA art. 50, revue juridique du 02/10/2026). */
#cb-chat-ai-notice {
  font-size: 0.72rem; line-height: 1.4; color: var(--slate, #5b6b82);
  background: #F8F6FE; padding: 8px 16px;
  border-bottom: 1px solid rgba(35, 48, 72, 0.06);
}
#cb-chat-ai-notice a { color: inherit; text-decoration: underline; }

#cb-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: linear-gradient(160deg, rgba(233, 251, 248, 0.5) 0%, rgba(255, 255, 255, 0) 40%),
              linear-gradient(-20deg, rgba(248, 246, 254, 0.6) 0%, rgba(255, 255, 255, 0) 45%);
}
#cb-chat-messages::-webkit-scrollbar { width: 5px; }
#cb-chat-messages::-webkit-scrollbar-thumb { background: rgba(35,48,72,0.12); border-radius: 10px; }

.cb-chat-msg {
  max-width: 84%;
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 0.87rem;
  line-height: 1.48;
  white-space: pre-wrap;
  word-break: break-word;
  animation: cb-chat-pop 0.2s cubic-bezier(.34,1.4,.64,1);
}
@keyframes cb-chat-pop {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.cb-chat-msg.user {
  align-self: flex-end;
  background: var(--marine, #233048);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.cb-chat-msg.assistant {
  align-self: flex-start;
  background: #fff;
  color: var(--marine, #233048);
  box-shadow: 0 2px 10px rgba(35, 48, 72, 0.07);
  border-bottom-left-radius: 6px;
}
.cb-chat-msg.human {
  align-self: flex-start;
  background: var(--violet-100, #F8F6FE);
  color: var(--marine, #233048);
  box-shadow: 0 2px 10px rgba(80, 34, 211, 0.08);
  border-bottom-left-radius: 6px;
}
.cb-chat-msg-label {
  display: block;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  opacity: 0.45;
  margin-bottom: 4px;
}

#cb-chat-typing {
  align-self: flex-start;
  margin: 0 16px 6px;
  padding: 11px 16px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(35, 48, 72, 0.07);
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  display: none;
  gap: 4px;
  width: fit-content;
}
#cb-chat-typing.visible { display: flex; }
#cb-chat-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--slate, #5b6b82);
  opacity: 0.5;
  animation: cb-chat-bounce 1.1s infinite ease-in-out;
}
#cb-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
#cb-chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes cb-chat-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 0.9; }
}

#cb-chat-human-btn {
  border: none;
  background: none;
  color: var(--violet-700, #5022D3);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 16px 10px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: gap 0.15s ease;
}
#cb-chat-human-btn:hover { gap: 8px; }

#cb-chat-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px 16px;
  background: transparent;
}
#cb-chat-input {
  flex: 1;
  border: none;
  background: #fff;
  box-shadow: inset 0 0 0 1.5px rgba(35, 48, 72, 0.08);
  border-radius: 20px;
  padding: 11px 18px;
  font-family: inherit;
  font-size: 0.87rem;
  resize: none;
  max-height: 80px;
  color: var(--marine, #233048);
  transition: box-shadow 0.15s ease;
}
#cb-chat-input::placeholder { color: #9AA6B4; }
#cb-chat-input:focus {
  outline: none;
  box-shadow: inset 0 0 0 1.5px var(--turquoise, #50DDC4);
}
#cb-chat-send {
  background: #E7ECF1;
  border: none;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  min-width: 42px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.15s ease;
}
#cb-chat-send svg { width: 17px; height: 17px; transition: stroke 0.15s ease; }
#cb-chat-send.ready { background: var(--turquoise, #50DDC4); }
#cb-chat-send.ready svg { stroke: var(--marine, #233048); }
#cb-chat-send:not(:disabled):hover { transform: scale(1.05); }
#cb-chat-send:disabled { opacity: 0.5; cursor: default; }

@media (max-width: 480px) {
  #cb-chat-panel {
    right: 16px;
    left: 16px;
    width: auto;
    bottom: 88px;
    border-radius: 22px;
  }
  #cb-chat-bubble { right: 16px; bottom: 16px; }
}
