/*
 * 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: var(--tb-sp-3); width: 100%; padding: 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); }
.disc-texte { flex: 1; min-width: 0; }
.disc-ligne { display: flex; align-items: baseline; gap: 8px; }
.disc-titre { flex: 1; min-width: 0; font-size: var(--tb-t-m); font-weight: 600; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--tb-texte); }
.disc-quand { font-size: var(--tb-t-xs); color: var(--tb-texte-3); flex: none; font-variant-numeric: tabular-nums; }
.disc-apercu { display: flex; align-items: center; gap: 6px; margin-top: 1px; font-size: var(--tb-t-s); 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: 19px; height: 19px; padding: 0 6px; border-radius: 10px; background: var(--tb-accent); color: var(--tb-accent-encre); font-size: var(--tb-t-xs); line-height: 19px; 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: 44px var(--tb-sp-4); text-align: center; color: var(--tb-texte-3); display: flex; flex-direction: column; gap: var(--tb-sp-3); align-items: center; }

/* Tête du fil */
.fil-tete-texte { flex: 1; min-width: 0; }
.fil-tete-titre { font-size: var(--tb-t-l); font-weight: 600; letter-spacing: -.01em; 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: var(--tb-t-s); 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 */
/* Le jour se pose en pastille centrée : deux filets qui traversent le fil le coupent en deux. */
.jour { display: flex; justify-content: center; margin: 20px 0 14px; }
.jour span { display: inline-block; padding: 3px 11px; border-radius: 999px; background: var(--tb-surface-2); color: var(--tb-texte-3); font-size: var(--tb-t-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.fil-debut { padding: var(--tb-sp-2); text-align: center; font-size: var(--tb-t-s); 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: 3px; min-width: 0; }
.grp.est-moi .grp-corps { align-items: flex-end; }
.grp-auteur { font-size: var(--tb-t-xs); color: var(--tb-texte-3); margin: 0 0 3px 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: 9px 13px; 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 7px; font-variant-numeric: tabular-nums; }
.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: 3px; background: color-mix(in srgb, var(--tb-surface) 88%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid var(--tb-bordure); border-radius: 999px; 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: 50%; 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: var(--tb-sp-2) var(--tb-sp-4) var(--tb-sp-4); 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; }

/* Enregistreur vocal : remplace la ligne du composeur pendant la prise. */
.composeur-micro { flex: none; }
.enregistreur { display: flex; align-items: center; gap: 10px; margin: 8px 18px 16px; padding: 6px 6px 6px 8px; background: var(--tb-surface); border: 1px solid var(--tb-bordure-2); border-radius: 24px; box-shadow: var(--tb-ombre); }
.enregistreur-point { width: 10px; height: 10px; border-radius: 50%; background: var(--tb-danger); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .enregistreur-point { animation: none; } }
.enregistreur .btn { flex: none; }
.enregistreur-libelle { flex: none; font-size: 13px; color: var(--tb-texte-2); white-space: nowrap; }
.enregistreur-onde { flex: 1; min-width: 48px; display: flex; align-items: center; justify-content: flex-end; gap: 2px; height: 28px; overflow: hidden; }
@media (max-width: 560px) { .enregistreur-libelle { display: none; } }
.enregistreur-onde i { flex: none; width: 3px; height: 4px; border-radius: 2px; background: var(--tb-accent); transition: height 80ms; }
.enregistreur-temps { flex: none; font: 500 13px var(--tb-mono); color: var(--tb-texte); min-width: 40px; text-align: right; }
.enregistreur-envoyer { border-radius: 50%; }
.enregistreur-annuler { color: var(--tb-texte-3); }
.enregistreur-annuler:hover { color: var(--tb-danger); }

/* Lecteur d'un message vocal, dans la bulle. */
.vocal { display: flex; align-items: center; gap: 10px; width: min(300px, 70vw); padding: 8px 12px 8px 8px; border-radius: 18px; background: var(--tb-bulle-autre); color: var(--tb-texte); }
.grp.est-moi .vocal { background: var(--tb-bulle-moi); color: var(--tb-bulle-moi-encre); }
.vocal-btn { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, currentColor 14%, transparent); color: inherit; }
.vocal-btn:hover { background: color-mix(in srgb, currentColor 24%, transparent); }
.vocal-piste { flex: 1; height: 24px; display: flex; align-items: center; cursor: pointer; }
.vocal-barre { position: relative; width: 100%; height: 4px; border-radius: 2px; background: color-mix(in srgb, currentColor 25%, transparent); }
.vocal-barre i { position: absolute; left: 0; top: 0; bottom: 0; width: var(--p, 0%); border-radius: 2px; background: currentColor; }
.vocal-temps { flex: none; font: 500 12px var(--tb-mono); opacity: .85; min-width: 34px; text-align: right; }

/* « Fait / pas fait » (R18) : le geste est un outil du survol (carré à cocher, vert quand c'est fait) ;
   la marque, elle, reste lisible sans survol dans la ligne de méta. */
.outil-fait.est-actif { color: var(--tb-ok); }
.outil-fait:hover { color: var(--tb-ok); }
.msg-marque { display: inline-flex; align-items: center; gap: 3px; padding: 1px 6px 1px 4px; border-radius: 999px; background: color-mix(in srgb, var(--tb-ok) 14%, transparent); color: var(--tb-ok); font-weight: 600; }
.msg.est-fait .bulle, .msg.est-fait .pj-images, .msg.est-fait .pj-fichier, .msg.est-fait .vocal { opacity: .58; }

/* Sélection multiple (R17) : une case par message, visible en mode sélection ; la barre d'actions
   prend la place du composeur. */
/* La zone sensible du message s'étend jusqu'au rond : sans ce tampon, la souris quitte le message en
   chemin, le rond s'efface et devient inatteignable (même piège que la barre d'outils, 2026-09-06). */
.grp:not(.est-moi) .msg::before, .grp.est-moi .msg::before { content: ''; position: absolute; top: -4px; bottom: -4px; width: 42px; }
.grp:not(.est-moi) .msg::before { left: -42px; }
.grp.est-moi .msg::before { right: -42px; }

/* Le rond de sélection vit sur le côté : visible au survol du message, permanent en mode sélection. */
/* Aligné en HAUT du message, sur la même ligne que la barre d'outils de l'autre côté (demande du 2026-09-06) :
   les deux gestes se répondent au lieu de flotter à des hauteurs différentes. */
.msg-coche { display: block; position: absolute; top: 1px; margin: 0; line-height: 0; opacity: 0; pointer-events: none; transition: opacity var(--tb-duree); }
.msg:hover .msg-coche, .msg:focus-within .msg-coche { opacity: .55; pointer-events: auto; }
.msg-coche:hover { opacity: 1 !important; }
@media (hover: none) { .msg-coche { opacity: 0; } }
.grp:not(.est-moi) .msg-coche { left: -32px; }
.grp.est-moi .msg-coche { right: -32px; }
/* Ronde comme un bouton radio : la sélection ne se confond pas avec la case « fait ». */
.msg-coche input { appearance: none; -webkit-appearance: none; width: 19px; height: 19px; margin: 0; border: 1.6px solid var(--tb-bordure-2); border-radius: 50%; background: var(--tb-surface); cursor: pointer; position: relative; transition: background var(--tb-duree), border-color var(--tb-duree); }
.msg-coche input:checked { border-color: var(--tb-accent); }
.msg-coche input:checked::after { content: ''; position: absolute; inset: 3.4px; border-radius: 50%; background: var(--tb-accent); }
.fil.est-selection .msg-coche { opacity: 1; pointer-events: auto; }
.fil.est-selection .msg-outils { display: none !important; }
.fil.est-selection .fil-messages { padding-left: 52px; padding-right: 52px; }
.fil-messages { padding-left: 46px; padding-right: 46px; }
@media (max-width: 560px) { .fil-messages, .fil.est-selection .fil-messages { padding-left: 34px; padding-right: 34px; } .grp:not(.est-moi) .msg-coche { left: -26px; } .grp.est-moi .msg-coche { right: -26px; } }
.fil.est-selection .msg { cursor: pointer; }
.fil.est-selection .msg .bulle a, .fil.est-selection .msg .pj-image, .fil.est-selection .msg .pj-fichier { pointer-events: none; }
.msg.est-selectionne .bulle, .msg.est-selectionne .pj-images, .msg.est-selectionne .pj-fichier, .msg.est-selectionne .vocal { box-shadow: 0 0 0 2px var(--tb-accent); border-radius: var(--tb-rayon-bulle); }
.selection { display: flex; align-items: center; gap: var(--tb-sp-2); padding: var(--tb-sp-3) var(--tb-sp-4); background: var(--tb-surface); border-top: 1px solid var(--tb-bordure); }
.selection-n { font-weight: 600; }
.cases-defilantes { max-height: 40vh; overflow-y: auto; }
@media (max-width: 560px) { .selection .btn:not(.btn-icone) { padding: 0 8px; font-size: 12.5px; } }

/* 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); }
