/* ─── AssurBox Chatbot Widget ──────────────────────────────────────────────── */

#assurbox-chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

/* ── Bouton flottant ── */
#assurbox-chat-toggle {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background-color: var(--assurbox-primary, #574AF6);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  margin-left: auto;
}

#assurbox-chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

/* ── Fenêtre ── */
#assurbox-chat-window {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 360px;
  max-width: calc(100vw - 40px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95) translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  max-height: 520px;
}

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

/* ── En-tête ── */
#assurbox-chat-header {
  background: var(--assurbox-primary, #574AF6);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

#assurbox-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

#assurbox-chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

#assurbox-chat-header strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
}

#assurbox-chat-header span {
  font-size: 12px;
  opacity: 0.85;
}

#assurbox-chat-close-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  opacity: 0.8;
  padding: 4px 6px;
  border-radius: 4px;
  transition: opacity 0.15s;
}

#assurbox-chat-close-btn:hover { opacity: 1; }

/* ── Messages ── */
#assurbox-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.assurbox-msg {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.assurbox-msg-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.assurbox-msg-bot .assurbox-msg-bubble {
  background: #f0f0f0;
  color: #1a1a1a;
  border-bottom-left-radius: 4px;
  white-space: normal;
}

.assurbox-msg-bot .assurbox-msg-bubble p {
  margin: 0 0 8px;
}

.assurbox-msg-bot .assurbox-msg-bubble p:last-child {
  margin-bottom: 0;
}

.assurbox-msg-bot .assurbox-msg-bubble ul {
  margin: 0 0 8px;
  padding-left: 20px;
  list-style: disc outside;
}

.assurbox-msg-bot .assurbox-msg-bubble ul:last-child {
  margin-bottom: 0;
}

.assurbox-msg-bot .assurbox-msg-bubble ol {
  margin: 0 0 8px;
  padding-left: 20px;
  list-style: decimal outside;
}

.assurbox-msg-bot .assurbox-msg-bubble ol:last-child {
  margin-bottom: 0;
}

.assurbox-msg-bot .assurbox-msg-bubble li {
  display: list-item;
  margin-bottom: 2px;
}

.assurbox-msg-bot .assurbox-msg-bubble pre {
  background: #e4e4e4;
  border-radius: 6px;
  padding: 8px 10px;
  overflow-x: auto;
  margin: 0 0 8px;
}

.assurbox-msg-bot .assurbox-msg-bubble code {
  font-family: monospace;
  font-size: 13px;
}

.assurbox-msg-bot .assurbox-msg-bubble a {
  color: var(--assurbox-primary, #574AF6);
  text-decoration: underline;
}

.assurbox-msg-user {
  justify-content: flex-end;
}

.assurbox-msg-user .assurbox-msg-bubble {
  background: var(--assurbox-primary, #574AF6);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Indicateur de frappe */
.assurbox-typing .assurbox-msg-bubble {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 12px 16px;
}

.assurbox-dot {
  width: 7px;
  height: 7px;
  background: #888;
  border-radius: 50%;
  animation: assurbox-bounce 1.2s infinite;
}
.assurbox-dot:nth-child(2) { animation-delay: 0.2s; }
.assurbox-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes assurbox-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%            { transform: translateY(-6px); }
}

/* ── Zone de saisie ── */
#assurbox-chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #ebebeb;
  flex-shrink: 0;
}

#assurbox-chat-input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 9px 14px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  line-height: 1.4;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color 0.15s;
}

#assurbox-chat-input:focus {
  border-color: var(--assurbox-primary, #574AF6);
}

#assurbox-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--assurbox-primary, #574AF6);
  border: none;
  cursor: pointer;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

#assurbox-chat-send:hover   { opacity: 0.88; }
#assurbox-chat-send:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Pied ── */
#assurbox-chat-footer {
  text-align: center;
  font-size: 11px;
  color: #aaa;
  padding: 5px 0 8px;
  flex-shrink: 0;
}

#assurbox-chat-footer a {
  color: #aaa;
  text-decoration: none;
}

#assurbox-chat-footer a:hover { text-decoration: underline; }

/* ── Responsive mobile ── */
@media (max-width: 480px) {
  #assurbox-chat-widget {
    bottom: 12px;
    right: 12px;
  }
  #assurbox-chat-window {
    width: calc(100vw - 24px);
    right: -12px;
    bottom: 68px;
    max-height: 70vh;
  }
}
