/* Chat commun de l'établissement : drawer #chat_drawer (_templates2/_modal/chat.php, _js2/chat-drawer.js).
   Chargé sur toutes les pages (_templates2/css.php). Pas de @layer dans ce fichier. */

/* pastille du bouton du header */
.chat-bouton {
  position: relative;
}

.chat-badge {
  position: absolute;
  top: 0.1rem;
  right: 0.05rem;
  min-width: 1.05rem;
  height: 1.05rem;
  padding: 0 0.25rem;
  border-radius: 9999px;
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 1.05rem;
  text-align: center;
  color: #fff;
  background-color: var(--primary);
  box-shadow: 0 0 0 2px var(--background);
  pointer-events: none;
}

.chat-badge.hidden {
  display: none;
}

/* drawer : en-tête et saisie fixes, fil défilant (fermé, il garde "hidden") */
#chat_drawer:not(.hidden) {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#chat_contenu {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

#chat_contenu .chat-entete-icone {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.65rem;
  font-size: 1.15rem;
  color: #7c3aed;
  background-color: color-mix(in oklab, #7c3aed 12%, var(--card));
}

#chat_contenu .chat-fil {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  background-color: var(--muted);
}

/* séparateur de jour */
#chat_contenu .chat-jour {
  display: flex;
  justify-content: center;
  margin: 0.85rem 0 0.5rem;
}

#chat_contenu .chat-jour span {
  padding: 0.15rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--secondary-foreground);
  background-color: var(--card);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.06);
}

/* un message */
#chat_contenu .chat-message {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

#chat_contenu .chat-message.chat-suite {
  margin-top: 0.15rem;
}

#chat_contenu .chat-message.chat-moi {
  justify-content: flex-end;
}

#chat_contenu .chat-avatar {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 700;
  color: #7c3aed;
  background-color: color-mix(in oklab, #7c3aed 14%, var(--card));
}

#chat_contenu .chat-suite .chat-avatar {
  visibility: hidden;
}

#chat_contenu .chat-bulle-zone {
  display: flex;
  flex-direction: column;
  max-width: 78%;
  min-width: 0;
}

#chat_contenu .chat-auteur {
  margin: 0 0 0.2rem 0.6rem;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--secondary-foreground);
}

#chat_contenu .chat-bulle {
  padding: 0.45rem 0.7rem 0.35rem;
  border-radius: 0.9rem 0.9rem 0.9rem 0.25rem;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--foreground);
  background-color: var(--card);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.06);
  overflow-wrap: anywhere;
}

#chat_contenu .chat-moi .chat-bulle {
  border-radius: 0.9rem 0.9rem 0.25rem 0.9rem;
  color: #fff;
  background-color: var(--primary);
}

#chat_contenu .chat-heure {
  float: right;
  margin: 0.35rem 0 0 0.6rem;
  font-size: 0.625rem;
  line-height: 1;
  color: var(--secondary-foreground);
}

#chat_contenu .chat-moi .chat-heure {
  color: rgb(255 255 255 / 0.75);
}

/* suppression d'un de ses messages : visible au survol, rouge à la confirmation */
#chat_contenu .chat-supprimer {
  order: -1;
  align-self: center;
  padding: 0.25rem;
  border-radius: 0.4rem;
  font-size: 0.8rem;
  color: var(--secondary-foreground);
  opacity: 0;
  cursor: pointer;
  transition: opacity 0.15s;
}

#chat_contenu .chat-message:hover .chat-supprimer,
#chat_contenu .chat-supprimer.chat-confirmer {
  opacity: 1;
}

#chat_contenu .chat-supprimer.chat-confirmer {
  color: #fff;
  background-color: var(--destructive);
}

/* état vide, chargement */
#chat_contenu .chat-vide {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  margin: 2.5rem 0.5rem;
  text-align: center;
}

#chat_contenu .chat-vide.hidden,
#chat_contenu .chat-chargement.hidden {
  display: none;
}

#chat_contenu .chat-vide-icone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 9999px;
  font-size: 1.4rem;
  color: #7c3aed;
  background-color: color-mix(in oklab, #7c3aed 12%, var(--card));
}

#chat_contenu .chat-chargement {
  display: flex;
  justify-content: center;
  padding: 2rem 0;
}

/* saisie */
#chat_contenu .chat-saisie {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
}

#chat_contenu .chat-saisie textarea {
  flex: 1 1 auto;
  min-height: 2.5rem;
  max-height: 140px;
  resize: none;
  font-size: 0.8125rem;
}
