/*
 * Le module Discussions : rangées de la liste, fil de bulles, composeur,
 * pièces jointes, dépôt par glisser. Le style d'une bulle vient de qui parle
 * (`.est-moi`), jamais de sa couleur d'avatar.
 */
.disc { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 10px; border-radius: var(--tb-rayon); text-align: left; transition: background var(--tb-duree); }
.disc + .disc { margin-top: 2px; }
.disc:hover { background: var(--tb-surface-3); text-decoration: none; }
.disc.est-active { background: var(--tb-surface); box-shadow: inset 0 0 0 1px var(--tb-bordure); }
.disc-texte { flex: 1; min-width: 0; }
.disc-ligne { display: flex; align-items: baseline; gap: 8px; }
.disc-titre { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--tb-texte); }
.disc-quand { font-size: 11.5px; color: var(--tb-texte-3); flex: none; }
.disc-apercu { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--tb-texte-2); overflow: hidden; }
.disc-apercu > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.disc.a-non-lus .disc-apercu { color: var(--tb-texte); font-weight: 500; }
.disc-badge { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--tb-accent); color: var(--tb-accent-encre); font-size: 11.5px; font-weight: 700; line-height: 20px; text-align: center; }
.disc-apercu .tape { color: var(--tb-accent); font-style: italic; }
.bandeau { margin: 0 8px 10px; padding: 12px 14px; border: 1px solid var(--tb-bordure); border-radius: var(--tb-rayon); background: var(--tb-surface); font-size: 13px; color: var(--tb-texte-2); }
.bandeau-actions { display: flex; gap: 6px; margin-top: 10px; }
.bandeau-actions .btn { height: 30px; padding: 0 12px; font-size: 13px; }
.liste-vide { padding: 40px 16px; text-align: center; color: var(--tb-texte-3); display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* Tête du fil */
.fil-tete-texte { flex: 1; min-width: 0; }
.fil-tete-titre { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fil-tete-titre input { font: inherit; border: 0; border-bottom: 1px solid var(--tb-accent); background: transparent; outline: none; width: 100%; }
.fil-tete-sous { font-size: 12px; color: var(--tb-texte-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fil-tete-sous .est-en-ligne { color: var(--tb-ok); font-weight: 500; }
.menu { position: relative; }
.menu-liste { position: absolute; right: 0; top: calc(100% + 4px); min-width: 200px; padding: 6px; background: var(--tb-surface); border: 1px solid var(--tb-bordure); border-radius: var(--tb-rayon); box-shadow: var(--tb-ombre); z-index: 20; display: flex; flex-direction: column; }
.menu-liste button { display: block; width: 100%; padding: 8px 10px; border-radius: var(--tb-rayon-s); text-align: left; }
.menu-liste button:hover { background: var(--tb-surface-3); }
.menu-liste .est-danger { color: var(--tb-danger); }

/* Messages */
.jour { display: flex; align-items: center; gap: 12px; margin: 14px 0 10px; font-size: 11.5px; color: var(--tb-texte-3); text-transform: uppercase; letter-spacing: .05em; }
.jour::before, .jour::after { content: ''; flex: 1; height: 1px; background: var(--tb-bordure); }
.fil-debut { padding: 8px; text-align: center; font-size: 12px; color: var(--tb-texte-3); }
.fil-encore { display: block; margin: 0 auto 8px; }
.grp { display: flex; gap: 10px; margin-bottom: 10px; max-width: min(78%, 720px); animation: bulle-in var(--tb-duree) ease-out; }
@keyframes bulle-in { from { opacity: 0; transform: translateY(4px); } }
.grp.est-moi { margin-left: auto; flex-direction: row-reverse; }
.grp .avatar { align-self: flex-end; }
.grp-corps { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.grp.est-moi .grp-corps { align-items: flex-end; }
.grp-auteur { font-size: 11.5px; color: var(--tb-texte-3); margin: 0 0 2px 4px; }
.msg { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; max-width: 100%; }
.grp.est-moi .msg { align-items: flex-end; }
.bulle { padding: 8px 12px; border-radius: var(--tb-rayon-bulle); background: var(--tb-bulle-autre); color: var(--tb-bulle-autre-encre); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.grp:not(.est-moi) .msg + .msg .bulle, .grp:not(.est-moi) .msg:not(:last-child) .bulle { border-bottom-left-radius: 5px; }
.grp:not(.est-moi) .msg + .msg .bulle { border-top-left-radius: 5px; }
.grp.est-moi .bulle { background: var(--tb-bulle-moi); color: var(--tb-bulle-moi-encre); }
.grp.est-moi .msg:not(:last-child) .bulle { border-bottom-right-radius: 5px; }
.grp.est-moi .msg + .msg .bulle { border-top-right-radius: 5px; }
.bulle a { color: inherit; text-decoration: underline; }
.bulle.est-retire { font-style: italic; opacity: .7; }
.msg-meta { display: flex; gap: 6px; align-items: center; font-size: 10.5px; color: var(--tb-texte-3); padding: 0 6px; }
.msg-meta .est-echec { color: var(--tb-danger); cursor: pointer; }
/* La barre d'outils est collée à la bulle : l'écart visuel est une marge INTERNE transparente,
   sinon le survol se perd dans le vide avant le clic (bug vu le 2026-09-05). */
.msg-outils { position: absolute; top: -6px; display: none; padding: 2px 0; z-index: 2; }
.grp:not(.est-moi) .msg-outils { left: 100%; padding-left: 6px; }
.grp.est-moi .msg-outils { right: 100%; padding-right: 6px; }
.msg-outils-boite { display: flex; gap: 2px; padding: 2px; background: var(--tb-surface); border: 1px solid var(--tb-bordure); border-radius: var(--tb-rayon-s); box-shadow: var(--tb-ombre); }
.msg:hover .msg-outils, .msg:focus-within .msg-outils, .msg.est-ouvert .msg-outils { display: block; }
/* Écran étroit : à côté de la bulle, la barre sortirait du fil ; elle passe au-dessus. */
@media (max-width: 760px) {
  .msg-outils, .grp:not(.est-moi) .msg-outils, .grp.est-moi .msg-outils { top: auto; bottom: 100%; left: auto; right: auto; padding: 0 0 4px; }
  .grp:not(.est-moi) .msg-outils { left: 0; }
  .grp.est-moi .msg-outils { right: 0; }
}
.msg-outils button { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 4px; color: var(--tb-texte-2); }
.msg-outils button:hover { background: var(--tb-surface-3); color: var(--tb-texte); }
.msg-edit textarea { width: 100%; min-height: 60px; padding: 8px 10px; border: 1px solid var(--tb-accent); border-radius: var(--tb-rayon); background: var(--tb-surface); color: var(--tb-texte); resize: vertical; }
.msg-edit-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 4px; }
.lu { display: flex; justify-content: flex-end; gap: 4px; margin: -4px 4px 8px 0; }
.lu .avatar { width: 16px; height: 16px; font-size: 7px; }

/* Fichiers dans les bulles */
.pj-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 4px; max-width: 420px; }
.pj-images.une { grid-template-columns: 1fr; }
.pj-image { display: block; border-radius: 10px; overflow: hidden; background: var(--tb-surface-3); aspect-ratio: var(--ar, 4/3); }
.pj-image img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--tb-duree); }
.pj-image:hover img { transform: scale(1.02); }
.pj-fichier { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--tb-bulle-autre); color: var(--tb-texte); max-width: 340px; }
.grp.est-moi .pj-fichier { background: color-mix(in srgb, var(--tb-bulle-moi) 88%, #000); color: var(--tb-bulle-moi-encre); }
.pj-fichier:hover { text-decoration: none; filter: brightness(.96); }
.pj-icone { flex: none; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; background: color-mix(in srgb, currentColor 12%, transparent); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.pj-texte { min-width: 0; }
.pj-nom { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pj-taille { display: block; font-size: 11.5px; opacity: .75; }

/* Composeur */
.composeur { padding: 8px 18px 16px; background: var(--tb-surface); }
.composeur-ligne { display: flex; align-items: flex-end; gap: 6px; padding: 6px 6px 6px 8px; background: var(--tb-fond); border: 1px solid var(--tb-bordure); border-radius: 24px; transition: border-color var(--tb-duree), box-shadow var(--tb-duree), background var(--tb-duree); }
.composeur-ligne:focus-within { background: var(--tb-surface); border-color: var(--tb-bordure-2); box-shadow: var(--tb-ombre); }
.composeur-texte { flex: 1; min-width: 0; max-height: 180px; padding: 7px 4px; border: 0; background: transparent; resize: none; outline: none; line-height: 1.4; }
.composeur-joindre { flex: none; }
.composeur-envoyer { flex: none; border-radius: 50%; }
.composeur-fichiers { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px 8px; }
.brouillon-pj { position: relative; display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--tb-bordure); border-radius: var(--tb-rayon); background: var(--tb-surface); font-size: 12.5px; max-width: 240px; }
.brouillon-pj img { width: 40px; height: 40px; object-fit: cover; border-radius: 5px; flex: none; }
.brouillon-pj .pj-texte { flex: 1; min-width: 0; }
.brouillon-pj .pj-nom { max-width: 160px; }
.brouillon-pj .barre { position: absolute; left: 6px; right: 6px; bottom: 3px; height: 3px; border-radius: 2px; background: var(--tb-surface-3); overflow: hidden; }
.brouillon-pj .barre i { display: block; height: 100%; width: var(--p, 0%); background: var(--tb-accent); transition: width var(--tb-duree); }
.brouillon-pj.est-echec { border-color: var(--tb-danger); }
.brouillon-pj .retirer { flex: none; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; color: var(--tb-texte-3); }
.brouillon-pj .retirer:hover { background: var(--tb-surface-3); color: var(--tb-danger); }
.depot { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--tb-accent) 10%, var(--tb-fond)); border: 2px dashed var(--tb-accent); border-radius: 12px; margin: 8px; z-index: 10; font-size: 18px; font-weight: 600; color: var(--tb-accent); pointer-events: none; }

/* Résultats de recherche dans le fil */
.msg .bulle mark { background: color-mix(in srgb, var(--tb-alerte) 40%, transparent); color: inherit; border-radius: 2px; }
.msg.est-cible .bulle { box-shadow: 0 0 0 2px var(--tb-alerte); }
