/* = Module messagerie — styles propres aux gabarits de templates/messagerie/.
   Un block utilisé par un second module remonte dans components.css.
   Créé au lot 3 bis-3 du chantier CSS (15/09/2026) : tout le CSS de la messagerie
   vivait dans les \3c style> de ses gabarits. Chargé sur toutes les pages dans
   l'ordre fixé par templates/partials/feuilles_de_style.html. */

/* ── Messagerie : détail conversation ── */
.conv-layout {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: var(--space-6);
  max-width: 1100px;
  margin: 0 auto;
}

/* Le seuil etait a 1100 px et non a 768, parce que la contrainte n'est pas la
   largeur de la fenetre mais la largeur DISPONIBLE : il faut d'abord retirer
   la barre de navigation de l'application (~76 px) et celle de la messagerie
   (280 px). A 770 px il restait 330 px a partager entre les 240 px fixes de la
   colonne « Participants » et la conversation -- qui tombait a 69 px de large,
   un caractere par ligne. Le trou n'etait pas sous 768, il etait juste
   au-dessus. Releve au controle du 03/09/2026.
   Lot D-8 (21/09/2026) : ramene a l'echelle des seuils (tokens.css), et pas au
   palier le plus proche (1024) -- mesure a 1030 px, la conversation tombait a
   340 px, la largeur d'un telephone, a cote de 240 px de participants. Sous
   1280 (le bureau etroit, la ou la sidebar se retracte), les participants
   passent sous la conversation, qui garde toute la largeur. */
@media (width < 1280px) {
  .conv-layout {
    grid-template-columns: 1fr;
  }
}

/* Header */
.conv-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3-5);
}

.conv-header__back {
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: var(--text-20);

  /* 44 x 44 : c'est le seul geste de navigation du detail vers la liste sur
     telephone, et il mesurait 22 x 35. */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  margin-left: calc(-1 * var(--space-2));
}

.conv-header__back:hover {
  color: var(--color-text);
}

/* Lien objet métier */
.conv-objet {
  font-size: var(--text-13);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-3-5);
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg-subtle);
  border-radius: var(--radius-md);
}

.conv-messages__feed {
  min-height: 300px;
  max-height: 600px;
  overflow-y: auto;
  padding: var(--space-3-5);
}

/* Formulaire d'envoi */
.conv-send {
  border-top: 1px solid var(--color-border);
  padding: var(--space-3) var(--space-3-5);
  display: flex;
  gap: var(--space-2);
  align-items: flex-end;
}

.conv-send__input,
.conv-send__highlights {
  box-sizing: border-box;
  width: 100%;
  min-height: 2.5rem;
  max-height: 120px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-14);
  font-family: inherit;
  line-height: var(--leading-normal);
  letter-spacing: normal;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.conv-send__input {
  position: relative;
  z-index: 1;
  display: block;
  background: transparent; /* laisse voir le calque derrière */
  color: var(--color-text);
  resize: vertical;
  overflow-y: auto;
}

.conv-send__input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 15%, transparent);
}

/* Calque de surlignage : même boîte, derrière, texte invisible sauf <mark> */
.conv-send__highlights {
  position: absolute;
  inset: 0;
  z-index: 0;
  margin: 0;
  border-color: transparent;
  color: transparent;
  pointer-events: none;
  overflow: hidden;
  background: transparent;
}

.conv-send__highlights mark {
  background: var(--color-primary-light);
  color: transparent;
  border-radius: var(--radius-sm);
}

.conv-send__actions {
  display: flex;
  gap: var(--space-1-5);
}

.conv-send__file-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--color-text-secondary);
  transition: background 0.15s;
}

.conv-send__file-label:hover {
  background: var(--color-bg-hover);
}

.conv-send__file-name {
  font-size: var(--text-12);
  color: var(--color-text-secondary);
  padding: var(--space-1) var(--space-2);
  background: var(--color-bg-hover);
  border-radius: var(--radius-sm);
  display: none;
}

/* Réponse inline */

/* Sidebar participants */
.conv-sidebar {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3-5);
}

.conv-sidebar__participant {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1-5) 0;
  font-size: var(--text-14);
}

.conv-sidebar__participant-mute {
  color: var(--color-text-secondary);
  font-size: var(--text-12);
}

.messagerie-filtres {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  margin-bottom: var(--space-3-5);
  flex-wrap: wrap;
}

.messagerie-filtres__search {
  display: flex;
  gap: var(--space-2);
  flex: 1;
  min-width: 200px;
}

.msg {
  display: flex;
  gap: var(--space-2-5);
  padding: var(--space-2) 0;
}

.msg--own {
  flex-direction: row-reverse;
}

.msg--system {
  justify-content: center;
  padding: var(--space-1-5) 0;
}

.msg__body {
  max-width: 70%;
  min-width: 0;
}

.msg--own .msg__body {
  align-items: flex-end;
}

.msg__header {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin-bottom: var(--space-0-5);
}

.msg--own .msg__header {
  flex-direction: row-reverse;
}

.msg__auteur {
  font-size: var(--text-13);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

.msg__date {
  font-size: var(--text-11);
  color: var(--color-text-secondary);
}

.msg__contenu {
  font-size: var(--text-14);
  line-height: var(--leading-snug);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-xl);
  word-break: break-word;
  background: var(--color-bg-hover);
}

.msg--own .msg__contenu {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-bottom-right-radius: 4px;
}

.msg:not(.msg--own) .msg__contenu {
  border-bottom-left-radius: 4px;
}

/* Message parent (quote) */
.msg__quote {
  font-size: var(--text-12);
  padding: var(--space-1-5) var(--space-2-5);
  margin-bottom: var(--space-1);
  border-left: 2px solid var(--color-primary);
  background: var(--color-bg-hover);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
}

.msg__quote-auteur {
  font-weight: var(--weight-semibold);
}

/* Pièce jointe */
.msg__attachment {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1-5);
  padding: var(--space-1-5) var(--space-2-5);
  background: var(--color-bg-hover);
  border-radius: var(--radius-md);
  font-size: var(--text-12);
  margin-top: var(--space-1-5);
  text-decoration: none;
  color: var(--color-primary);
}

.msg--own .msg__attachment {
  color: var(--color-text-inverse);
  background: color-mix(in srgb, var(--color-surface) 20%, transparent);
}

/* Actions */
.msg__actions {
  display: flex;
  gap: var(--space-1);
  margin-top: var(--space-0-5);
  opacity: 0;
  transition: opacity 0.15s;
}

.msg:hover .msg__actions {
  opacity: 1;
}

/* Message système */
.msg--system .msg__system-text {
  font-size: var(--text-12);
  color: var(--color-text-secondary);
  font-style: italic;
  padding: var(--space-1) var(--space-3);
  background: var(--color-bg-subtle);
  border-radius: var(--radius-pill);
}

/* Message supprimé */
.msg__deleted {
  font-size: var(--text-13);
  font-style: italic;
  color: var(--color-text-secondary);
  padding: var(--space-2) var(--space-3);
}

/* @mention highlight (N+3.4) */
.msg-mention {
  display: inline-block;
  padding: 0 var(--space-1);
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  border-radius: var(--radius-xs);
  font-weight: var(--weight-semibold);
  font-size: 0.95em;
}

/* UX-J : layout 2 colonnes (sidebar gauche + main droite) */
.msg-layout {
  display: flex;
  min-height: calc(100vh - 80px);
  margin: calc(-1 * var(--space-4));
  background: var(--color-bg);
}

.msg-main {
  flex: 1;
  overflow-y: auto;
  min-width: 0;
  padding: var(--space-4) var(--space-6);
}

/* Mobile : la barre latérale disparaît, le contenu prend toute la largeur.
   .....................................................................
   Ce bloc bascule sur `body.msg-conv-active`, une classe que PERSONNE ne
   posait — ni gabarit, ni JS, nulle part dans le dépôt. Conséquence :
   `.msg-main` restait masqué sur les deux écrans. Ouvrir une conversation
   changeait le titre de la page et n'affichait rien : ni messages, ni zone
   de saisie, ni retour. Le module entier était inutilisable sous 768 px.
   Relevé au test navigateur du 03/09/2026.

   La classe n'est pas rétablie, elle est supprimée : elle n'avait de sens
   que pour choisir entre deux panneaux, or il n'y a rien à choisir. La barre
   latérale est un confort de grand écran — sur la liste elle double une
   liste déjà présente, et sur le détail elle vole la place de la
   conversation. Tout ce qu'elle offre (le « + », la navigation entre
   conversations) existe sur l'écran de liste, que la flèche « Retour »
   atteint en un geste.

   L'ancienne règle masquait aussi `.msg-main` sur la liste : les onglets,
   les filtres, la recherche et le bouton « Nouvelle conversation »
   n'existaient pas non plus sur téléphone. */
@media (width <= 768px) {
  .msg-sidebar {
    display: none;
  }

  .msg-main {
    padding: var(--space-3) var(--space-4);
  }
}

.msg-sidebar {
  width: 280px;
  background: var(--color-bg-subtle);
  border-right: 1px solid var(--color-border);
  height: 100%;
  overflow-y: auto;
  flex-shrink: 0;
}

.msg-sidebar__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  gap: var(--space-1);
}

.msg-sidebar__search {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border);
}

.msg-sidebar__section {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-bg-hover);
}

.msg-sidebar__section-title {
  font-size: var(--text-11);
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: var(--space-1) var(--space-4) var(--space-1-5);
}

.msg-sidebar__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1-5) var(--space-4);
  text-decoration: none;
  color: var(--color-text);
  font-size: var(--text-13);
  transition: background 0.12s;
}

.msg-sidebar__item:hover {
  background: var(--color-bg-hover);
}

.msg-sidebar__item--active {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  font-weight: var(--weight-semibold);
}

.msg-sidebar__item--unread .msg-sidebar__item-name {
  font-weight: var(--weight-semibold);
}

.msg-sidebar__item-icon {
  color: var(--color-text-muted);
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}

.msg-sidebar__item--active .msg-sidebar__item-icon {
  color: var(--color-primary);
}

.msg-sidebar__item-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.widget-discussions__title-icon {
  vertical-align: -2px;
}

.widget-discussions__item {
  display: block;
  padding: var(--space-2-5) var(--space-3);
  background: var(--color-bg-subtle);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}

.widget-discussions__item:hover {
  background: var(--color-bg-hover);
}

.widget-discussions__item-sujet {
  font-weight: var(--weight-semibold);
  font-size: var(--text-14);
}

.widget-discussions__item-preview {
  font-size: var(--text-12);
  color: var(--color-text-secondary);
  margin-top: var(--space-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
