/* =============================================================================
   Koalucorp Hub — design system (inspiré Linear : sombre, précis, un accent).
   Tokens, composants, états, responsive. Français : tous les libellés.
   ============================================================================= */

/* ---------------------------------------------------------------------------
   1. Jetons
   --------------------------------------------------------------------------- */
:root {
  /* Surfaces — échelle de luminance (plus clair = plus élevé) */
  --fond: #0a0b0d;
  --fond-panneau: #0f1013;
  --surface: #15171c;
  --surface-elevee: #1b1e24;
  --surface-hover: #20232a;

  /* Texte */
  --texte: #f2f3f5;
  --texte-secondaire: #c6cbd4;
  --texte-tertiaire: #8b919c;
  --texte-quaternaire: #5d646e;

  /* Bordures — semi-transparentes, jamais de noir sur noir */
  --bordure: rgba(255, 255, 255, 0.09);
  --bordure-subtile: rgba(255, 255, 255, 0.055);
  --bordure-forte: rgba(255, 255, 255, 0.14);

  /* Accent unique : indigo (réservé aux actions et à l'état actif) */
  --accent: #6e79ff;
  --accent-hover: #828fff;
  --accent-faible: rgba(110, 121, 255, 0.13);
  --accent-texte: #a5aeff;

  /* États */
  --vert: #3fb950;
  --ambre: #d29922;
  --rouge: #f85149;

  /* Géométrie */
  --rayon-s: 6px;
  --rayon-m: 10px;
  --rayon-l: 14px;
  --rayon-pilule: 999px;

  /* Typographie */
  --police: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --police-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Élévation (ombres portées sur fond sombre : sobres, directionnelles) */
  --ombre-menu: 0 12px 32px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.35);

  /* Cadence */
  --cadence: 140ms ease;
}

/* ---------------------------------------------------------------------------
   2. Base
   --------------------------------------------------------------------------- */
* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--fond);
  color: var(--texte);
  font-family: var(--police);
  font-size: 15px;
  line-height: 1.5;
  font-feature-settings: 'cv01', 'ss03';
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

[hidden] { display: none !important; }

/* ---------------------------------------------------------------------------
   3. Écrans d'authentification (premier lancement + connexion)
   Surface « Configure » : un seul panneau, hiérarchie claire, sans décor.
   --------------------------------------------------------------------------- */
.ecran-auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background:
    radial-gradient(900px 420px at 50% -10%, rgba(110, 121, 255, 0.09), transparent 70%),
    var(--fond);
}

.carte-auth {
  width: 100%;
  max-width: 392px;
  padding: 36px 32px 28px;
  background: var(--fond-panneau);
  border: 1px solid var(--bordure-subtile);
  border-radius: var(--rayon-l);
  box-shadow: var(--ombre-menu);
}

.logo {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0 auto 20px;
  border-radius: 11px;
  background: linear-gradient(160deg, var(--accent-hover), var(--accent));
  color: #0a0b0d;
  font-size: 21px;
  font-weight: 590;
  letter-spacing: -0.5px;
}

.titre-auth {
  margin: 0 0 8px;
  font-size: 21px;
  font-weight: 590;
  letter-spacing: -0.3px;
  text-align: center;
}

.sous-titre-auth {
  margin: 0 0 24px;
  color: var(--texte-tertiaire);
  font-size: 14px;
  text-align: center;
  text-wrap: pretty;
}

.champ { display: block; margin-bottom: 14px; }

.libelle-champ {
  display: block;
  margin-bottom: 6px;
  color: var(--texte-secondaire);
  font-size: 13px;
  font-weight: 510;
}

input[type="password"],
input[type="search"] {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-s);
  color: var(--texte);
  font-family: inherit;
  font-size: 14px;
  transition: border-color var(--cadence), box-shadow var(--cadence);
}

input[type="password"]:focus,
input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-faible);
}

input::placeholder { color: var(--texte-quaternaire); }

.controle-mdp { position: relative; display: block; }

.controle-mdp input { padding-right: 72px; }

.bouton-oeil {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  padding: 5px 9px;
  background: transparent;
  border: 0;
  border-radius: var(--rayon-s);
  color: var(--texte-tertiaire);
  font-size: 12px;
  cursor: pointer;
}

.bouton-oeil:hover { color: var(--texte-secondaire); background: var(--surface-elevee); }

.bouton-principal {
  width: 100%;
  margin-top: 6px;
  padding: 10px 16px;
  background: var(--accent);
  border: 0;
  border-radius: var(--rayon-s);
  color: #fff;
  font-size: 14px;
  font-weight: 510;
  cursor: pointer;
  transition: background var(--cadence), transform var(--cadence);
}

.bouton-principal:hover { background: var(--accent-hover); }
.bouton-principal:active { transform: translateY(1px); }
.bouton-principal:disabled { opacity: 0.55; cursor: default; transform: none; }

.note-auth {
  margin: 18px 0 0;
  color: var(--texte-quaternaire);
  font-size: 12px;
  text-align: center;
}

.message-erreur {
  margin: 4px 0 12px;
  padding: 8px 12px;
  background: rgba(248, 81, 73, 0.09);
  border: 1px solid rgba(248, 81, 73, 0.3);
  border-radius: var(--rayon-s);
  color: #ff8a83;
  font-size: 13px;
}

.message-erreur.global { margin: 24px auto; max-width: 480px; text-align: center; }

/* ---------------------------------------------------------------------------
   4. Structure de l'application : barre latérale + contenu
   --------------------------------------------------------------------------- */
#application { display: flex; min-height: 100vh; }

.barre-laterale {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  flex: 0 0 250px;
  height: 100vh;
  padding: 18px 12px 16px;
  background: var(--fond-panneau);
  border-right: 1px solid var(--bordure-subtile);
}

.marque {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px 18px;
}

.logo-petit { width: 30px; height: 30px; margin: 0; border-radius: 8px; font-size: 15px; }

.nom-marque { font-size: 14.5px; font-weight: 590; letter-spacing: -0.2px; }

.navigation { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.element-navigation {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--rayon-s);
  color: var(--texte-tertiaire);
  font-size: 13.5px;
  font-weight: 510;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--cadence), color var(--cadence);
}

.element-navigation:hover { background: var(--surface); color: var(--texte-secondaire); }

.element-navigation.actif {
  background: var(--accent-faible);
  color: var(--accent-texte);
}

.picto-navigation { display: grid; place-items: center; width: 18px; height: 18px; }

.compteur-navigation {
  margin-left: auto;
  min-width: 22px;
  padding: 1px 7px;
  border-radius: var(--rayon-pilule);
  background: var(--surface-elevee);
  color: var(--texte-quaternaire);
  font-size: 11.5px;
  font-weight: 510;
  text-align: center;
}

.pastille-bientot {
  margin-left: auto;
  padding: 1px 6px;
  border-radius: var(--rayon-pilule);
  border: 1px solid var(--bordure-subtile);
  color: var(--texte-quaternaire);
  font-family: var(--police-mono);
  font-size: 10px;
}

.element-navigation.bientot { opacity: 0.6; cursor: default; }

.pied-barre { padding: 10px 8px 0; border-top: 1px solid var(--bordure-subtile); }

.lien-deconnexion {
  padding: 0;
  background: none;
  border: 0;
  color: var(--texte-tertiaire);
  font-size: 13px;
  cursor: pointer;
}

.lien-deconnexion:hover { color: var(--texte-secondaire); }

.version { margin: 8px 0 0; color: var(--texte-quaternaire); font-size: 11.5px; }

.contenu {
  flex: 1;
  min-width: 0;
  max-width: 1180px;
  margin: 0 auto;
  padding: 34px 40px 64px;
}

/* ---------------------------------------------------------------------------
   5. En-tête de page, recherche, filtres
   --------------------------------------------------------------------------- */
.entete {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.titre-page {
  margin: 0 0 4px;
  font-size: 27px;
  font-weight: 590;
  letter-spacing: -0.6px;
}

.sous-titre-page {
  margin: 0;
  color: var(--texte-tertiaire);
  font-size: 14px;
}

.recherche {
  position: relative;
  width: 240px;
}

.recherche input {
  padding-left: 32px;
  background: var(--surface);
  border-radius: var(--rayon-s);
}

.picto-recherche {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--texte-quaternaire);
  pointer-events: none;
}

.filtres {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.puce-filtre {
  padding: 6px 13px;
  background: transparent;
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-pilule);
  color: var(--texte-secondaire);
  font-size: 12.5px;
  font-weight: 510;
  cursor: pointer;
  transition: background var(--cadence), border-color var(--cadence), color var(--cadence);
}

.puce-filtre:hover { background: var(--surface-elevee); }

.puce-filtre.actif {
  background: var(--accent-faible);
  border-color: rgba(110, 121, 255, 0.4);
  color: var(--accent-texte);
}

/* ---------------------------------------------------------------------------
   6. Organigramme (façon PDF : hiérarchie visuelle, lignes de connexion)
   --------------------------------------------------------------------------- */
.arborescence {
  padding-top: 6px;
  overflow-x: auto;
}

.scene-organigramme {
  position: relative;
  min-width: 100%;
  width: max-content;
  padding: 10px 30px 34px;
}

.corps-organigramme {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 34px;
  width: max-content;
  min-width: 100%;
}

/* --- Nœuds -------------------------------------------------------------- */
.noeud-org {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 148px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-top-width: 3px;
  border-radius: var(--rayon-m);
  text-align: left;
  font: inherit;
  color: var(--texte);
  cursor: pointer;
  transition: background var(--cadence), border-color var(--cadence), transform var(--cadence);
}

.noeud-org:hover {
  background: var(--surface-hover);
  transform: translateY(-1px);
}

.noeud-org.attenue { opacity: 0.45; }

.noeud-org.noeud-sommet {
  cursor: default;
  width: 196px;
  text-align: center;
  align-items: center;
}

/* Teintes par branche — couleurs du PDF adaptées au thème sombre */
.org-david {
  border-top-color: #d9a441;
  border-color: rgba(217, 164, 65, 0.55);
  background: rgba(217, 164, 65, 0.09);
}

.org-orchestre {
  border-top-color: var(--accent);
  background: var(--accent-faible);
}

.org-pilote { border-top-color: #4f8fd6; }
.org-specialiste { border-top-color: #5a6b85; }
.org-perso {
  border-top-color: #8e6bb8;
  border-color: rgba(142, 107, 184, 0.4);
  background: rgba(142, 107, 184, 0.08);
}

.org-marketing { border-top-color: #148f8f; }
.org-juridique { border-top-color: #5a6a7a; }
.org-autre { border-top-color: var(--bordure-forte); }

.entete-noeud-org {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.nom-noeud-org {
  min-width: 0;
  font-weight: 590;
  font-size: 12.5px;
  line-height: 1.3;
  overflow-wrap: break-word;
}

.role-noeud-org {
  color: var(--texte-tertiaire);
  font-size: 11px;
  line-height: 1.4;
  overflow-wrap: break-word;
}

.acces-noeud-org {
  color: var(--texte-quaternaire);
  font-size: 10px;
  line-height: 1.4;
  overflow-wrap: break-word;
}

.statut-noeud-org {
  margin-top: 2px;
  color: var(--texte-quaternaire);
  font-size: 10.5px;
}

/* --- Structure : sommet + personnels ------------------------------------ */
.rang-tete-organigramme {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 90px;
  width: max-content;
  min-width: 100%;
}

.colonne-sommet-organigramme {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.colonne-personnels-organigramme {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 8px;
}

.titre-personnels-organigramme {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 510;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--texte-quaternaire);
}

/* --- Rangée des piliers -------------------------------------------------- */
.rang-piliers-organigramme {
  display: flex;
  align-items: flex-start;
  gap: 22px;
  width: max-content;
}

.colonne-pilier-org {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
}

.sous-agents-org {
  display: flex;
  gap: 12px;
}

.sous-agents-org .noeud-org { width: 118px; }
.sous-agents-org .nom-noeud-org { font-size: 11px; }

.sous-agents-org.grille {
  display: grid;
  grid-template-columns: repeat(2, 118px);
  gap: 12px 14px;
}

.sous-agents-org.grille .noeud-org { width: 118px; }

/* --- Lignes de connexion ------------------------------------------------- */
.lignes-organigramme {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.ligne-organigramme {
  fill: none;
  stroke: var(--bordure-forte);
  stroke-width: 1.4;
}

/* --- Agents hors organigramme + squelettes ------------------------------- */
.autres-agents-org {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 680px;
}

.autres-agents-org .noeud-org { width: 100%; max-width: 420px; }

.squelette-noeud-org {
  height: 84px;
  width: 148px;
  border-radius: var(--rayon-m);
}

.rang-piliers-organigramme .squelette-noeud-org { width: 148px; }

.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 590;
  letter-spacing: 0.2px;
  color: #0a0b0d;
}

/* Teintes d'avatar par groupe — l'accent reste l'unique couleur vive */
.avatar-pilote { background: linear-gradient(160deg, var(--accent-hover), var(--accent)); }
.avatar-specialiste { background: #4d5566; }
.avatar-perso { background: #2f9e7a; }
.avatar-orchestre { background: #8b6fc4; }
.avatar-autre { background: #6b6f78; }

/* Statut */
.statut { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }

.point-statut { width: 7px; height: 7px; border-radius: 50%; }

.statut-prêt { color: var(--texte-tertiaire); }
.statut-prêt .point-statut { background: var(--vert); box-shadow: 0 0 6px rgba(63, 185, 80, 0.5); }

.statut-en-mission { color: #d9b564; }
.statut-en-mission .point-statut { background: var(--ambre); animation: pulsation 1.6s ease-in-out infinite; }

.statut-inconnu { color: var(--texte-quaternaire); }
.statut-inconnu .point-statut { background: var(--texte-quaternaire); }

@keyframes pulsation {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.etat-vide {
  margin: 40px 0;
  color: var(--texte-tertiaire);
  text-align: center;
}

/* Squelettes de chargement */
.squelette {
  height: 158px;
  border-radius: var(--rayon-m);
  background: linear-gradient(100deg, var(--surface) 40%, var(--surface-elevee) 50%, var(--surface) 60%);
  background-size: 200% 100%;
  animation: balayage 1.4s infinite;
}

/* Squelette du tiroir fiche agent (pleine hauteur, sans coins arrondis). */
.squelette-fiche { height: 100%; border-radius: 0; }

/* Identité de la fiche agent : le titre peut être tronqué proprement. */
.identite-fiche-titre { min-width: 0; }

/* Champ de formulaire pleine largeur (modales). */
.champ-large { width: 100%; }

@keyframes balayage {
  to { background-position: -200% 0; }
}

/* ---------------------------------------------------------------------------
   7. Fiche agent (tiroir latéral)
   Surface « Inspect » : lecture d'un objet, boutons discrets.
   --------------------------------------------------------------------------- */
.voile {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 40;
  animation: apparition 160ms ease;
}

@keyframes apparition { from { opacity: 0; } }

.fiche-agent {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(460px, 92vw);
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: var(--fond-panneau);
  border-left: 1px solid var(--bordure);
  box-shadow: var(--ombre-menu);
  animation: glissement 220ms cubic-bezier(0.2, 0.8, 0.3, 1);
  overflow-y: auto;
}

@keyframes glissement { from { transform: translateX(40px); opacity: 0; } }

.entete-fiche {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 22px 22px 18px;
}

.avatar-grand { width: 46px; height: 46px; border-radius: 11px; font-size: 16px; }

.titre-fiche {
  margin: 2px 0 2px;
  font-size: 18px;
  font-weight: 590;
  letter-spacing: -0.25px;
  overflow-wrap: anywhere;
}

.role-fiche { margin: 0; color: var(--texte-secondaire); font-size: 13.5px; }

.bouton-fermer {
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  background: transparent;
  border: 1px solid var(--bordure-subtile);
  border-radius: var(--rayon-s);
  color: var(--texte-tertiaire);
  font-size: 15px;
  cursor: pointer;
  transition: background var(--cadence), color var(--cadence);
}

.bouton-fermer:hover { background: var(--surface-elevee); color: var(--texte); }

.badges-fiche {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 22px 6px;
}

.badge-groupe {
  padding: 2px 9px;
  border-radius: var(--rayon-pilule);
  border: 1px solid var(--bordure-subtile);
  color: var(--texte-tertiaire);
  font-size: 11.5px;
  font-weight: 510;
}

.corps-fiche { padding: 12px 22px 22px; display: flex; flex-direction: column; gap: 18px; }

.bloc-fiche h3 {
  margin: 0 0 6px;
  color: var(--texte-quaternaire);
  font-size: 11px;
  font-weight: 590;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.bloc-fiche p { margin: 0; color: var(--texte-secondaire); font-size: 13.5px; }

.liste-acces { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }

.liste-acces li {
  padding: 3px 10px;
  background: var(--surface);
  border: 1px solid var(--bordure-subtile);
  border-radius: var(--rayon-pilule);
  color: var(--texte-secondaire);
  font-family: var(--police-mono);
  font-size: 11.5px;
}

.ligne-membre {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 9px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--rayon-s);
  color: var(--texte-secondaire);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  transition: background var(--cadence), border-color var(--cadence);
}

.ligne-membre:hover { background: var(--surface); border-color: var(--bordure-subtile); }

.ligne-membre .avatar { width: 24px; height: 24px; border-radius: 6px; font-size: 10px; }

.chemin-profil {
  margin: 0;
  padding: 7px 10px;
  background: var(--surface);
  border-radius: var(--rayon-s);
  color: var(--texte-tertiaire);
  font-family: var(--police-mono);
  font-size: 11.5px;
  overflow-wrap: anywhere;
}

.pied-fiche {
  margin-top: auto;
  padding: 16px 22px 20px;
  border-top: 1px solid var(--bordure-subtile);
}

.bouton-discuter {
  width: 100%;
  padding: 10px 16px;
  background: var(--accent);
  border: 0;
  border-radius: var(--rayon-s);
  color: #fff;
  font-size: 14px;
  font-weight: 510;
  cursor: pointer;
  transition: filter var(--cadence);
}

.bouton-discuter:hover { filter: brightness(1.1); }

.note-m2 {
  margin: 9px 0 0;
  color: var(--texte-quaternaire);
  font-size: 12px;
  text-align: center;
}

/* ---------------------------------------------------------------------------
   8. Notifications (toast)
   --------------------------------------------------------------------------- */
.zone-notification {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.notification {
  padding: 9px 16px;
  background: var(--surface-elevee);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-m);
  box-shadow: var(--ombre-menu);
  color: var(--texte-secondaire);
  font-size: 13px;
  animation: apparition 160ms ease;
}

.notification.erreur { border-color: rgba(248, 81, 73, 0.4); color: #ff8a83; }

/* ---------------------------------------------------------------------------
   9. Responsive
   --------------------------------------------------------------------------- */
@media (max-width: 900px) {
  /* La barre latérale devient un bandeau de navigation en haut : plus aucun
     chevauchement avec le contenu (notamment la saisie du chat). */
  .barre-laterale {
    position: sticky;
    top: 0;
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    width: 100%;
    height: auto;
    padding: 8px 10px;
    border-right: 0;
    border-bottom: 1px solid var(--bordure-subtile);
    z-index: 30;
  }

  #application { flex-direction: column; }

  .marque { display: none; }

  .navigation {
    flex-direction: row;
    flex: 1;
    justify-content: flex-start;
    overflow-x: auto;
  }

  .element-navigation { flex-direction: column; gap: 3px; padding: 5px 12px; font-size: 10.5px; }

  .compteur-navigation, .pastille-bientot { display: none; }

  .colonne-agents { display: none; }
  .pied-barre { display: flex; align-items: center; padding: 0 4px 0 8px; border: 0; }
  .version { display: none; }

  .contenu { order: 1; padding: 20px 16px 32px; }

  .recherche { width: 100%; }

  /* Chat : l'application occupe exactement l'écran, la saisie reste en bas. */
  body.section-chat #application {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  body.section-chat .contenu {
    height: auto;
    flex: 1;
    min-height: 0;
  }
}

@media (max-width: 520px) {
  .entete { flex-direction: column; }
  .carte-auth { padding: 28px 22px 22px; }
}

/* ---------------------------------------------------------------------------
   9. M2 — Arborescence, explorateur de fichiers, modale
   --------------------------------------------------------------------------- */

/* --- Barre d'outils & bascule de vue ------------------------------------ */
.barre-outils {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.bascule-vue {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--fond-panneau);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-m);
}

.bouton-bascule {
  border: 0;
  background: transparent;
  color: var(--texte-tertiaire);
  font: inherit;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: var(--rayon-s);
  cursor: pointer;
  transition: background var(--cadence), color var(--cadence);
}

.bouton-bascule:hover { color: var(--texte); }

.bouton-bascule.actif {
  background: var(--surface-elevee);
  color: var(--texte);
  box-shadow: inset 0 0 0 1px var(--bordure-forte);
}

/* --- Nœuds partagés (organigramme + scène d'activité) ---------------------- */
/* Le style visuel des cartes est défini par .noeud-org (section 6) ; les
   classes ci-dessous ne portent que ce qui est commun (avatars, marquage). */
.avatar-mini {
  width: 26px;
  height: 26px;
  font-size: 10.5px;
  flex: none;
}

.titre-section-arbre {
  font-size: 11.5px;
  font-weight: 510;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--texte-quaternaire);
  margin: 0 0 4px;
}

/* --- Explorateur de fichiers --------------------------------------------- */
.selecteur-agent { display: flex; align-items: center; gap: 10px; }

.libelle-selecteur {
  font-size: 12px;
  font-weight: 510;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--texte-quaternaire);
}

.selecteur-agent select {
  background: var(--surface);
  color: var(--texte);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-m);
  font: inherit;
  font-size: 13.5px;
  padding: 9px 34px 9px 12px;
  min-width: 220px;
  cursor: pointer;
  transition: border-color var(--cadence);
}

.selecteur-agent select:hover { border-color: var(--bordure-forte); }

.ligne-explorateur {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.fildariane {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.lien-fildariane {
  border: 0;
  background: transparent;
  color: var(--texte-tertiaire);
  font: inherit;
  font-size: 13px;
  padding: 4px 6px;
  border-radius: var(--rayon-s);
  cursor: pointer;
  transition: color var(--cadence), background var(--cadence);
}

.lien-fildariane:hover { color: var(--texte); background: var(--surface-elevee); }

.lien-fildariane:last-of-type { color: var(--texte); font-weight: 590; }

.actions-explorateur { display: flex; gap: 10px; align-items: center; }

.bouton-secondaire {
  background: var(--surface);
  color: var(--texte);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-m);
  font: inherit;
  font-size: 13.5px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background var(--cadence), border-color var(--cadence);
}

.bouton-secondaire:hover { background: var(--surface-hover); border-color: var(--bordure-forte); }

.bouton-principal.petit { padding: 9px 16px; font-size: 13.5px; }

.bouton-danger {
  background: rgba(248, 81, 73, 0.12);
  color: #ff8a84;
  border: 1px solid rgba(248, 81, 73, 0.35);
  border-radius: var(--rayon-m);
  font: inherit;
  font-size: 13.5px;
  font-weight: 510;
  padding: 9px 16px;
  cursor: pointer;
  transition: background var(--cadence), border-color var(--cadence);
}

.bouton-danger:hover { background: rgba(248, 81, 73, 0.22); }

.liste-entrees {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ligne-entree {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--bordure-subtile);
  border-radius: var(--rayon-m);
  cursor: default;
  transition: background var(--cadence), border-color var(--cadence);
}

.ligne-entree:hover { background: var(--surface-hover); border-color: var(--bordure); }

.picto-entree {
  display: inline-flex;
  align-items: center;
  color: var(--texte-tertiaire);
  flex: none;
}

.nom-entree {
  font-size: 13.5px;
  font-weight: 510;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta-entree {
  color: var(--texte-quaternaire);
  font-size: 12px;
  flex: none;
  margin-left: auto;
}

.actions-ligne { display: flex; gap: 6px; flex: none; align-items: center; }

.action-ligne {
  border: 0;
  background: transparent;
  color: var(--texte-tertiaire);
  font: inherit;
  font-size: 12.5px;
  padding: 5px 9px;
  border-radius: var(--rayon-s);
  cursor: pointer;
  transition: color var(--cadence), background var(--cadence);
}

.action-ligne:hover { color: var(--texte); background: var(--surface-elevee); }

.action-ligne.danger:hover { color: #ff8a84; background: rgba(248, 81, 73, 0.12); }

.chevron-ligne { color: var(--texte-quaternaire); font-size: 16px; line-height: 1; }

.zone-depot {
  border: 1.5px dashed var(--bordure-forte);
  border-radius: var(--rayon-l);
  padding: 26px 20px;
  text-align: center;
  color: var(--texte-tertiaire);
  font-size: 13.5px;
  margin-bottom: 14px;
  cursor: pointer;
  background: var(--fond-panneau);
  transition: background var(--cadence), border-color var(--cadence), color var(--cadence);
}

.zone-depot.survol {
  border-color: var(--accent);
  color: var(--accent-texte);
  background: var(--accent-faible);
}

.zone-depot p { margin: 0; }

.entete-resultats {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 12px;
}

.titre-resultats { font-size: 14px; font-weight: 590; margin: 0; }

/* --- Modale --------------------------------------------------------------- */
.modale {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 40;
  pointer-events: none;
}

.carte-modale {
  pointer-events: auto;
  width: 100%;
  max-width: 440px;
  background: var(--fond-panneau);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-l);
  box-shadow: var(--ombre-menu);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.carte-modale.large { max-width: min(980px, 100%); height: min(85vh, 780px); }

.entete-modale {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.titre-modale {
  font-size: 16px;
  font-weight: 590;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.champ-modale {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-m);
  color: var(--texte);
  font: inherit;
  font-size: 14px;
  padding: 10px 12px;
}

.champ-modale:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-faible);
}

.actions-modale {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.texte-modale { color: var(--texte-secondaire); font-size: 14px; margin: 0; line-height: 1.55; }

.corps-apercu {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--fond);
  border: 1px solid var(--bordure-subtile);
  border-radius: var(--rayon-m);
  overflow: auto;
  padding: 12px;
}

.apercu-image { max-width: 100%; max-height: 100%; border-radius: var(--rayon-s); }

.apercu-pdf { width: 100%; height: 100%; min-height: 420px; border: 0; border-radius: var(--rayon-s); }

.apercu-texte {
  margin: 0;
  width: 100%;
  max-height: 100%;
  overflow: auto;
  font-family: var(--police-mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--texte-secondaire);
  white-space: pre-wrap;
  word-break: break-word;
}

.apercu-texte-chargement { color: var(--texte-tertiaire); font-size: 13px; }

/* --- Bouton « documents » de la fiche agent ------------------------------ */
.bouton-documents {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-m);
  color: var(--texte);
  font: inherit;
  font-size: 13.5px;
  font-weight: 510;
  padding: 11px 14px;
  cursor: pointer;
  text-align: left;
  transition: background var(--cadence), border-color var(--cadence);
}

.bouton-documents:hover { background: var(--surface-hover); border-color: var(--bordure-forte); }

.bouton-documents .chevron-bouton { margin-left: auto; color: var(--texte-tertiaire); }

/* --- Responsive M2 --------------------------------------------------------- */
@media (max-width: 900px) {
  .meta-entree { display: none; }

  .ligne-explorateur { flex-direction: column; align-items: stretch; }

  .actions-explorateur { justify-content: flex-end; }

  .selecteur-agent select { flex: 1; min-width: 0; width: 100%; }

  .selecteur-agent { width: 100%; }
}

/* ---------------------------------------------------------------------------
   11. M3 — Lecteur d'activité (relecture animée des échanges)
   --------------------------------------------------------------------------- */

.lecteur {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin-bottom: 16px;
  background: var(--fond-panneau);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-m);
}

.bouton-lecteur {
  border: 1px solid var(--bordure);
  background: var(--surface);
  color: var(--texte-secondaire);
  font: inherit;
  font-size: 13px;
  font-weight: 510;
  padding: 7px 13px;
  border-radius: var(--rayon-s);
  cursor: pointer;
  transition: background var(--cadence), border-color var(--cadence), color var(--cadence);
}

.bouton-lecteur:hover { background: var(--surface-hover); border-color: var(--bordure-forte); color: var(--texte); }

.bouton-lecteur.principal {
  min-width: 108px;
  background: var(--accent-faible);
  border-color: rgba(110, 121, 255, 0.4);
  color: var(--accent-texte);
}

.bouton-lecteur.principal:hover { background: rgba(110, 121, 255, 0.22); }

.vitesse, .periode {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  background: var(--fond);
  border: 1px solid var(--bordure-subtile);
  border-radius: var(--rayon-s);
}

.puce-vitesse, .puce-periode {
  border: 0;
  background: transparent;
  color: var(--texte-tertiaire);
  font: inherit;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: background var(--cadence), color var(--cadence);
}

.puce-vitesse { font-family: var(--police-mono); }

.puce-vitesse:hover, .puce-periode:hover { color: var(--texte); }

.puce-vitesse.actif, .puce-periode.actif {
  background: var(--surface-elevee);
  color: var(--texte);
  box-shadow: inset 0 0 0 1px var(--bordure-forte);
}

.barre-progression {
  position: relative;
  flex: 1 1 180px;
  min-width: 120px;
  height: 22px;
  display: flex;
  align-items: center;
  cursor: pointer;
  border-radius: var(--rayon-pilule);
}

.barre-progression::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 6px;
  border-radius: var(--rayon-pilule);
  background: var(--surface-elevee);
}

.remplissage-progression {
  position: relative;
  height: 6px;
  width: 0;
  border-radius: var(--rayon-pilule);
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  box-shadow: 0 0 10px rgba(110, 121, 255, 0.45);
  transition: width 80ms linear;
}

/* --- Scène : arbre + calque des connexions -------------------------------- */
.scene-activite {
  position: relative;
  padding: 10px 0 26px;
  overflow-x: auto;
}

.arbre-activite { margin: 0; }

.calque-activite {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.connexion-active {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-linecap: round;
  filter: drop-shadow(0 0 4px rgba(110, 121, 255, 0.7));
}

.connexion-passee {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.1;
  stroke-linecap: round;
  stroke-dasharray: 3 5;
  opacity: 0.28;
}

.coeur-voyageur {
  fill: #fff;
  stroke: var(--accent);
  stroke-width: 1.5;
}

.halo-voyageur {
  fill: var(--accent);
  opacity: 0.25;
  animation: pulsation-halo 1.4s ease-in-out infinite;
}

@keyframes pulsation-halo {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 0.08; }
}

.noeud-arbre.marque { position: relative; z-index: 1; }

.noeud-arbre.marque-emetteur {
  border-color: rgba(110, 121, 255, 0.55);
  box-shadow: 0 0 0 1px rgba(110, 121, 255, 0.35), 0 0 16px rgba(110, 121, 255, 0.18);
}

.noeud-arbre.marque-destinataire {
  border-color: rgba(130, 143, 255, 0.65);
  box-shadow: 0 0 0 1px rgba(130, 143, 255, 0.45), 0 0 20px rgba(130, 143, 255, 0.28);
}

/* --- Carte de l'échange en cours (flottante, cliquable) -------------------- */
.carte-echange {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  max-width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  background: var(--surface-elevee);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-m);
  box-shadow: var(--ombre-menu);
  color: var(--texte);
  text-align: left;
  font: inherit;
  cursor: pointer;
  animation: apparition 200ms ease;
}

.carte-echange:hover { border-color: var(--bordure-forte); }

.entete-echange {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 590;
}

.acteur-echange { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.fleche-echange { color: var(--accent); }

.resume-echange {
  color: var(--texte-secondaire);
  font-size: 13px;
  line-height: 1.45;
}

.meta-echange {
  color: var(--texte-quaternaire);
  font-size: 11.5px;
}

.badge-type {
  align-self: flex-start;
  padding: 1px 8px;
  border-radius: var(--rayon-pilule);
  border: 1px solid var(--bordure-subtile);
  font-size: 11px;
  font-weight: 510;
  text-transform: capitalize;
}

.type-mission { color: var(--accent-texte); border-color: rgba(110, 121, 255, 0.4); background: rgba(110, 121, 255, 0.1); }
.type-sous-traitance { color: #d9b564; border-color: rgba(210, 153, 34, 0.4); background: rgba(210, 153, 34, 0.08); }
.type-compte-rendu { color: #7ee2a8; border-color: rgba(63, 185, 80, 0.4); background: rgba(63, 185, 80, 0.08); }

.badge-statut {
  padding: 1px 8px;
  border-radius: var(--rayon-pilule);
  font-size: 11px;
  font-weight: 510;
}

.statut-termine { color: #7ee2a8; background: rgba(63, 185, 80, 0.12); }
.statut-erreur { color: #ff8a83; background: rgba(248, 81, 73, 0.12); }

.lecture-terminee {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 5px 14px;
  background: var(--surface-elevee);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-pilule);
  color: var(--texte-tertiaire);
  font-size: 12.5px;
  z-index: 3;
}

/* --- Popup d'un échange : message complet ---------------------------------- */
.metadonnees-echange {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.date-echange { color: var(--texte-tertiaire); font-size: 12.5px; }

.resume-popup {
  margin: 0;
  color: var(--texte);
  font-size: 14px;
  font-weight: 510;
}

.contenu-echange {
  background: var(--fond);
  border: 1px solid var(--bordure-subtile);
  border-radius: var(--rayon-m);
  padding: 12px;
  max-height: 40vh;
  overflow: auto;
}

.contenu-echange .apercu-texte { max-height: none; }

/* --- État vide de l'activité ------------------------------------------------ */
.etat-vide-activite {
  margin: 36px auto;
  max-width: 520px;
  padding: 40px 32px;
  background: var(--fond-panneau);
  border: 1px solid var(--bordure-subtile);
  border-radius: var(--rayon-l);
  text-align: center;
}

.picto-vide-activite {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  border-radius: 50%;
  border: 1px dashed var(--bordure-forte);
  color: var(--texte-tertiaire);
  font-size: 22px;
}

.etat-vide-activite h2 {
  margin: 0 0 8px;
  font-size: 16.5px;
  font-weight: 590;
}

.etat-vide-activite p {
  margin: 0 0 18px;
  color: var(--texte-tertiaire);
  font-size: 13.5px;
  line-height: 1.6;
}

.etat-vide-activite code {
  padding: 1px 6px;
  background: var(--surface);
  border-radius: 4px;
  color: var(--texte-secondaire);
  font-family: var(--police-mono);
  font-size: 12px;
}

/* --- Indicateur de stockage (quota) ------------------------------------------ */
.indicateur-stockage {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 6px;
}

.libelle-stockage {
  color: var(--texte-quaternaire);
  font-size: 11px;
  font-weight: 510;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.jauge-stockage {
  width: 72px;
  height: 6px;
  border-radius: var(--rayon-pilule);
  background: var(--surface-elevee);
  overflow: hidden;
}

.remplissage-jauge {
  display: block;
  height: 100%;
  border-radius: var(--rayon-pilule);
  background: var(--accent);
  opacity: 0.8;
}

.valeur-stockage {
  color: var(--texte-tertiaire);
  font-size: 12px;
  font-family: var(--police-mono);
}

/* --- Responsive M3 ------------------------------------------------------------ */
@media (max-width: 900px) {
  .barre-progression { flex-basis: 100%; order: 5; }

  .carte-echange {
    position: static;
    max-width: none;
    margin-bottom: 14px;
  }

  .indicateur-stockage { display: none; }
}

/* ---------------------------------------------------------------------------
   9b. Sidebar conversations + chat réel (M4)
   --------------------------------------------------------------------------- */

.colonne-agents {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--bordure-subtile);
}

.recherche-conversations {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 2px 8px;
  padding: 6px 9px;
  border: 1px solid var(--bordure-subtile);
  border-radius: var(--rayon-s);
  background: var(--surface);
  color: var(--texte-quaternaire);
}

.recherche-conversations input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--texte-principal);
  font-size: 12.5px;
  outline: none;
}

.recherche-conversations input::placeholder { color: var(--texte-quaternaire); }

.liste-conversations {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 2px;
}

.ligne-conversation {
  display: flex;
  align-items: center;
  gap: 2px;
}

.ligne-conversation.enfant { padding-left: 20px; }

.entree-conversation {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  padding: 6px 7px;
  border: 0;
  border-radius: var(--rayon-s);
  background: none;
  color: var(--texte-secondaire);
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  transition: background var(--cadence);
}

.entree-conversation:hover { background: var(--surface); }

.entree-conversation.actif {
  background: var(--accent-faible);
  color: var(--accent-texte);
}

.etat-vide-conversations {
  margin: 10px 6px;
  color: var(--texte-quaternaire);
  font-size: 12px;
}

.fleche-pli {
  display: grid;
  place-items: center;
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--texte-quaternaire);
  cursor: pointer;
}

.fleche-pli svg { transition: transform var(--cadence); }
.fleche-pli.ouvert svg { transform: rotate(90deg); }

.nom-entree-conversation {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.point-agent {
  flex: 0 0 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--texte-quaternaire);
}

.point-agent.pret { background: #3ecf8e; }
.point-agent.mission { background: #f5b75a; animation: pulsation-statut 1.6s ease-in-out infinite; }
.point-agent.reflexion { background: var(--accent); animation: pulsation-statut 1s ease-in-out infinite; }

@keyframes pulsation-statut {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.dernier-agent {
  max-width: 92px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--texte-quaternaire);
  font-size: 10.5px;
}

/* --- Page chat --- */

.entete-chat {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--bordure-subtile);
}

.avatar-conversation {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 10px;
  font-size: 14px;
}

.identite-chat { flex: 1; min-width: 0; }

.identite-chat h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 590;
  letter-spacing: -0.2px;
}

.identite-chat p {
  margin: 2px 0 0;
  color: var(--texte-tertiaire);
  font-size: 12.5px;
}

.lien-fiche-chat {
  color: var(--texte-tertiaire);
  font-size: 12.5px;
  text-decoration: none;
}

.lien-fiche-chat:hover { color: var(--accent-texte); }

.etat-vide-chat { padding: 64px 24px; text-align: center; }

.etat-vide-chat h2 { margin: 14px 0 6px; font-size: 16px; }

.etat-vide-chat p {
  max-width: 420px;
  margin: 0 auto;
  color: var(--texte-tertiaire);
  font-size: 13.5px;
  line-height: 1.6;
}

/* --- Page chat : hauteur pleine, fil défilant, saisie fixe en bas --------- */
body.section-chat .contenu {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 24px;
}

body.section-chat .entete { flex: none; margin-bottom: 14px; }

body.section-chat #page-chat {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.entete-chat { flex: none; }

.etat-vide-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
}

.zone-chat {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
}

.fil-chat {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 0 6px;
  overflow-y: auto;
}

.bulle {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.bulle.utilisateur {
  align-self: flex-end;
  background: var(--accent-faible);
  color: var(--accent-texte);
  border-bottom-right-radius: 4px;
}

.bulle.agent {
  align-self: flex-start;
  background: var(--surface-elevee);
  color: var(--texte-principal);
  border-bottom-left-radius: 4px;
}

.bulle.systeme {
  align-self: center;
  max-width: 88%;
  background: none;
  border: 1px dashed var(--bordure-subtile);
  color: var(--texte-quaternaire);
  font-size: 12.5px;
}

.ligne-bulle { display: flex; flex-direction: column; }

.ligne-bulle.utilisateur { align-items: flex-end; }
.ligne-bulle.agent { align-items: flex-start; }
.ligne-bulle.systeme { align-items: center; }

.horodatage-bulle {
  margin: 3px 4px 0;
  color: var(--texte-quaternaire);
  font-size: 10.5px;
  font-family: var(--police-mono);
}

.indicateur-reflexion {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 4px 12px;
  color: var(--texte-tertiaire);
  font-size: 12.5px;
  font-style: italic;
}

.points-reflexion { display: inline-flex; gap: 3px; }

.points-reflexion i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: rebond-point 1.2s ease-in-out infinite;
}

.points-reflexion i:nth-child(2) { animation-delay: 0.15s; }
.points-reflexion i:nth-child(3) { animation-delay: 0.3s; }

@keyframes rebond-point {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.formulaire-chat {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--bordure-subtile);
}

/* Le bouton « Envoyer » hérite de .bouton-principal (width: 100 %) : dans la
   rangée de saisie il ne doit pas écraser le champ de texte. */
.formulaire-chat .bouton-principal {
  width: auto;
  flex: none;
  margin-top: 0;
  padding: 11px 18px;
}

.champ-message {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  max-height: 160px;
  padding: 10px 12px;
  border: 1px solid var(--bordure-subtile);
  border-radius: var(--rayon-s);
  background: var(--surface);
  color: var(--texte-principal);
  font-size: 13.5px;
  font-family: inherit;
  line-height: 1.5;
  resize: none;
  outline: none;
  overflow-y: auto;
}

.champ-message:focus { border-color: var(--accent); }

.champ-message:disabled { opacity: 0.6; }

.note-chat {
  flex: none;
  margin: 8px 0 0;
  color: var(--texte-quaternaire);
  font-size: 11.5px;
  text-align: center;
}

/* --- Responsive M4 ------------------------------------------------------------ */
@media (max-width: 900px) {
  body.section-chat .entete { display: none; }

  body.section-chat .contenu { padding: 14px 14px 16px; }

  .bulle { max-width: 86%; }

  .note-chat { font-size: 11px; }
}

/* ---------------------------------------------------------------------------
   10. Mouvement réduit
   --------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
