/* =========================================================
   Assistant Chat ABIMEDIA - fenêtre ancrée en bas à droite
   (style messenger : barre réduite en bas / fenêtre ouverte)
   ========================================================= */

#abichat-widget {
  position: fixed;
  right: 24px;
  bottom: 0;
  z-index: 99999;
  font-family: Inter, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* --------- Fenêtre --------- */

#abichat-window {
  width: 360px;
  max-width: calc(100vw - 32px);
  background: #fff;
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -2px 32px rgba(17, 24, 39, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Corps : hauteur animée entre réduit et ouvert */
#abichat-body {
  display: flex;
  flex-direction: column;
  height: 460px;
  max-height: calc(100vh - 140px);
  transition: height 0.28s ease, max-height 0.28s ease;
  overflow: hidden;
}

#abichat-window.abichat-min #abichat-body {
  height: 0;
  max-height: 0;
}

/* --------- Barre de titre (toujours visible) --------- */

#abichat-header {
  background: linear-gradient(135deg, #0b69f6, #0847a8);
  color: #fff;
  padding: 11px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
}

#abichat-header-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#abichat-header-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  flex: 1;
  min-width: 0;
}

#abichat-header-title {
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#abichat-header-status {
  font-size: 0.7rem;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 5px;
}

#abichat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  display: inline-block;
  animation: abichatPulse 2s infinite;
}

@keyframes abichatPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Badge "1 nouveau message" : visible seulement quand la fenêtre est réduite */
#abichat-header-badge {
  display: none;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: #e11d48;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  flex-shrink: 0;
}

#abichat-window.abichat-min #abichat-header-badge.abichat-badge-on {
  display: flex;
}

#abichat-btn-minimize,
#abichat-btn-end,
#abichat-btn-email {
  background: transparent;
  border: none;
  color: #fff;
  opacity: 0.85;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  flex-shrink: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}

#abichat-btn-minimize:hover,
#abichat-btn-end:hover,
#abichat-btn-email:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.14);
}

/* Les boutons e-mail et "fin de conversation" n'ont pas de sens quand la fenêtre est réduite */
#abichat-window.abichat-min #abichat-btn-end,
#abichat-window.abichat-min #abichat-btn-email {
  display: none;
}

/* --------- Liens dans les messages --------- */

.abichat-msg .abichat-link {
  text-decoration: underline;
  word-break: break-all;
  font-weight: 600;
}

.abichat-msg--bot .abichat-link {
  color: #0b69f6;
}

.abichat-msg--bot .abichat-link:hover {
  color: #084fc0;
}

.abichat-msg--user .abichat-link {
  color: #fff;
}

/* --------- Zone messages --------- */

#abichat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f6f8fb;
}

#abichat-messages::-webkit-scrollbar {
  width: 5px;
}

#abichat-messages::-webkit-scrollbar-thumb {
  background: #d7dce2;
  border-radius: 10px;
}

.abichat-msg {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.87rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: abichatIn 0.25s ease;
}

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

.abichat-msg--bot {
  background: #fff;
  border: 1px solid #e7eaee;
  color: #1f2937;
  align-self: flex-start;
  border-bottom-left-radius: 5px;
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.05);
}

.abichat-msg--user {
  background: linear-gradient(135deg, #0b69f6, #0a5cd8);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 5px;
}

/* --------- Indicateur "en train d'écrire" --------- */

.abichat-typing {
  padding-top: 13px;
  padding-bottom: 13px;
}

.abichat-typing span {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 3px;
  border-radius: 50%;
  background: #9aa1ab;
  animation: abichatBlink 1.2s infinite ease-in-out;
}

.abichat-typing span:nth-child(2) { animation-delay: 0.2s; }
.abichat-typing span:nth-child(3) { animation-delay: 0.4s; }

.abichat-slow-note {
  font-style: italic;
  color: #6b7280;
  font-size: 0.8rem;
}

@keyframes abichatBlink {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}

/* --------- Suggestions (chips) --------- */

#abichat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 10px 14px 8px;
  background: #f6f8fb;
  flex-shrink: 0;
  max-height: 150px;
  overflow-y: auto;
}

#abichat-suggestions.abichat-suggestions-hidden {
  display: none;
}

#abichat-suggestions-title {
  flex-basis: 100%;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #98a2b3;
  margin-bottom: 2px;
}

#abichat-suggestions-toggle-row {
  display: none;
  padding: 6px 14px 2px;
  background: #f6f8fb;
  flex-shrink: 0;
}

#abichat-suggestions-toggle-row.abichat-toggle-visible {
  display: block;
}

#abichat-suggestions-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: none;
  color: #0b69f6;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  padding: 3px 0;
}

#abichat-suggestions-toggle:hover {
  text-decoration: underline;
}

.abichat-chip {
  border: 1.5px solid #cfe0fd;
  background: #fff;
  color: #0b69f6;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.abichat-chip:hover {
  background: #0b69f6;
  border-color: #0b69f6;
  color: #fff;
}

/* --------- Zone de saisie --------- */

#abichat-form {
  display: flex;
  border-top: 1px solid #eef0f3;
  padding: 10px 12px;
  gap: 8px;
  background: #fff;
  flex-shrink: 0;
}

#abichat-input {
  flex: 1;
  border: 1.5px solid #e5e7eb;
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 0.87rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#abichat-input:focus {
  border-color: #0b69f6;
  box-shadow: 0 0 0 3px rgba(11, 105, 246, 0.12);
}

#abichat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #0b69f6, #0a5cd8);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

#abichat-send:hover {
  transform: scale(1.07);
}

#abichat-send:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
}

/* --------- Note de bas de fenêtre --------- */

#abichat-footer-note {
  font-size: 0.66rem;
  color: #9aa1ab;
  text-align: center;
  padding: 0 12px 8px;
  background: #fff;
  flex-shrink: 0;
}

/* --------- Mobile --------- */

@media (max-width: 480px) {
  #abichat-widget {
    right: 10px;
  }

  #abichat-window {
    width: calc(100vw - 20px);
  }

  #abichat-body {
    max-height: calc(100vh - 130px);
  }
}
