/* ============================================================
   CHAT.CSS — Widget chatbot Bâtisseur Numérique
   Dépend des variables CSS de base.css
   ============================================================ */

/* ── Conteneur positionné ─────────────────────────────────── */
.chat-conteneur {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

/* ── Bouton flottant ──────────────────────────────────────── */
.chat-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--couleur-cta);
  color: var(--couleur-blanc);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(5, 150, 105, 0.45);
  transition: background-color var(--transition), transform var(--transition), box-shadow var(--transition);
  flex-shrink: 0;
}

.chat-toggle:hover {
  background-color: var(--couleur-cta-clair);
  transform: scale(1.07);
  box-shadow: 0 6px 22px rgba(5, 150, 105, 0.55);
}

.chat-toggle__fermer {
  display: none;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
}

.chat-toggle--actif svg          { display: none; }
.chat-toggle--actif .chat-toggle__fermer { display: block; }

/* ── Fenêtre de chat ──────────────────────────────────────── */
.chat-fenetre {
  width: 360px;
  height: 480px;
  background: var(--couleur-blanc);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(0.92) translateY(14px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity   0.18s ease;
}

.chat-fenetre--visible {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* ── En-tête ──────────────────────────────────────────────── */
.chat-entete {
  background: var(--couleur-primaire);
  color: var(--couleur-blanc);
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chat-entete__info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.chat-entete__nom {
  font-weight: 700;
  font-size: 0.9rem;
}

.chat-entete__statut {
  font-size: 0.75rem;
  opacity: 0.8;
}

.chat-entete__statut::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  margin-right: 5px;
  vertical-align: middle;
}

.chat-fermer {
  font-family: var(--police);
  font-size: 1rem;
  font-weight: 700;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  padding: 0.25rem 0.45rem;
  border-radius: var(--rayon);
  line-height: 1;
  transition: color var(--transition), background-color var(--transition);
}

.chat-fermer:hover {
  color: var(--couleur-blanc);
  background-color: rgba(255, 255, 255, 0.12);
}

/* ── Fil de messages ──────────────────────────────────────── */
.chat-fil {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  scroll-behavior: smooth;
}

.chat-fil::-webkit-scrollbar { width: 4px; }
.chat-fil::-webkit-scrollbar-track { background: transparent; }
.chat-fil::-webkit-scrollbar-thumb { background: var(--couleur-gris-clair); border-radius: 2px; }

/* ── Bulles ───────────────────────────────────────────────── */
.chat-bulle {
  max-width: 83%;
  padding: 0.6rem 0.875rem;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.5;
  word-break: break-word;
}

.chat-bulle--user {
  background: var(--couleur-accent);
  color: var(--couleur-blanc);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-bulle--assistant {
  background: var(--couleur-surface-tintee);
  color: var(--couleur-texte);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

/* ── Indicateur de frappe (3 points animés) ───────────────── */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0.65rem 0.875rem;
}

.chat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--couleur-gris);
  animation: chat-dot 1.3s infinite ease-in-out;
}

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

@keyframes chat-dot {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0);   }
  30%            { opacity: 1;    transform: translateY(-5px); }
}

/* ── Message système / erreur ─────────────────────────────── */
.chat-bulle-systeme {
  font-size: 0.8rem;
  color: var(--couleur-gris);
  text-align: center;
  padding: 0.25rem 0;
  align-self: center;
}

/* ── Bannière limite atteinte ─────────────────────────────── */
.chat-limite {
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  font-size: 0.82rem;
  color: #92400e;
  line-height: 1.55;
  margin-top: 0.2rem;
}

.chat-lien {
  color: var(--couleur-accent);
  font-weight: 600;
  text-decoration: underline;
}

/* ── Boutons de suggestions ───────────────────────────────── */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.2rem;
}

.chat-suggestion {
  font-family: var(--police);
  font-size: 0.79rem;
  font-weight: 600;
  color: var(--couleur-accent);
  background: transparent;
  border: 1.5px solid var(--couleur-accent);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--transition), color var(--transition);
}

.chat-suggestion:hover {
  background-color: var(--couleur-accent);
  color: var(--couleur-blanc);
}

/* ── Zone de saisie ───────────────────────────────────────── */
.chat-bas {
  border-top: 1px solid var(--couleur-gris-clair);
  padding: 0.6rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  font-family: var(--police);
  font-size: 0.875rem;
  color: var(--couleur-texte);
  background: var(--couleur-fond);
  border: 1.5px solid var(--couleur-gris-clair);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  outline: none;
  min-width: 0;
  transition: border-color var(--transition);
}

.chat-input:focus {
  border-color: var(--couleur-accent);
}

.chat-input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.chat-envoyer {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--couleur-accent);
  color: var(--couleur-blanc);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition), opacity var(--transition);
}

.chat-envoyer:hover:not(:disabled) {
  background: var(--couleur-accent-clair);
}

.chat-envoyer:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── Mobile (fenêtre plein écran) ─────────────────────────── */
@media (max-width: 480px) {
  .chat-conteneur {
    bottom: 16px;
    right: 16px;
  }

  .chat-fenetre {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    transform-origin: bottom center;
  }
}
