/* PreviMax Teams
 *
 * Une feuille, pas de framework, pas d'etape de compilation. Le deploiement est
 * un `firebase deploy`, sans npm install ni bundler, ce qui compte pour une
 * equipe qui n'a pas de developpeur pour relancer une chaine de build.
 *
 * Le parti pris visuel : lisible avant d'etre joli. Les gens qui vont vivre
 * dedans huit heures par jour ne sont pas developpeurs, donc les cibles sont
 * grandes, les libelles sont des mots et pas des icones seules, et le poste de
 * chacun est toujours visible a cote de son nom.
 */

:root {
  color-scheme: light;

  --encre: #0f2436;
  --encre-2: #5a7184;
  --encre-3: #8da2b5;
  --papier: #f4f6f9;
  --carte: #ffffff;
  --trait: #e2e8f0;
  --trait-fort: #cbd6e2;

  --marque: #102a43;
  --marque-clair: #1d4e7a;
  --accent: #0e7c86;
  --accent-doux: #e6f4f5;

  --succes: #1b7f4d;
  --succes-doux: #e6f5ec;
  --alerte: #a8650b;
  --alerte-doux: #fdf3e3;
  --danger: #b3261e;
  --danger-doux: #fdecea;

  --rayon: 10px;
  --rayon-s: 6px;
  --ombre: 0 1px 2px rgba(15, 36, 54, .06), 0 4px 12px rgba(15, 36, 54, .05);
  --ombre-forte: 0 8px 32px rgba(15, 36, 54, .16);

  --barre: 252px;
  --police: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --encre: #e8eef5;
    --encre-2: #9fb3c6;
    --encre-3: #6f869b;
    --papier: #0b1622;
    --carte: #122330;
    --trait: #23384a;
    --trait-fort: #32506a;
    --marque: #0a1b22;
    --marque-clair: #2b6fa5;
    --accent: #3fb3bd;
    --accent-doux: #10323a;
    --succes-doux: #0f2b1d;
    --alerte-doux: #2e2210;
    --danger-doux: #2e1512;
    --ombre: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 12px rgba(0, 0, 0, .3);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --encre: #e8eef5;
  --encre-2: #9fb3c6;
  --encre-3: #6f869b;
  --papier: #0b1622;
  --carte: #122330;
  --trait: #23384a;
  --trait-fort: #32506a;
  --marque-clair: #2b6fa5;
  --accent: #3fb3bd;
  --accent-doux: #10323a;
  --succes-doux: #0f2b1d;
  --alerte-doux: #2e2210;
  --danger-doux: #2e1512;
}

* { box-sizing: border-box; }

/* L'attribut hidden doit gagner, toujours.
 *
 * Le navigateur applique `display: none` a [hidden] par sa feuille par defaut,
 * mais n'importe quelle regle d'auteur la surclasse. Et `.modale` porte
 * `display: grid`, `.panneau` porte `display: flex` : les deux sont en
 * `position: fixed; inset: 0` avec un z-index eleve.
 *
 * Consequence sans cette regle : la modale recouvre l'ecran entier en
 * permanence, invisible mais presente, et intercepte chaque clic. Plus rien
 * n'est cliquable dans l'application, pas meme le bouton Se connecter.
 *
 * Trouve en chargeant le site deploye dans un vrai navigateur. Ni la
 * verification syntaxique ni le controle des imports ne pouvaient le voir :
 * tout le JavaScript etait correct, c'est une ligne de CSS qui rendait
 * l'application inutilisable. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--papier);
  color: var(--encre);
  font: 15px/1.55 var(--police);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--marque-clair); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ------------------------------------------------------------------ marque */

.marque { display: flex; align-items: center; gap: 12px; }
.marque h1 { font-size: 19px; }
.marque p { color: var(--encre-2); font-size: 13px; }

.marque-logo {
  width: 40px; height: 40px; flex: 0 0 40px;
  border-radius: var(--rayon-s);
  background: var(--marque);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px; letter-spacing: .02em;
}

.marque-compacte { padding: 18px 18px 14px; }
.marque-compacte strong { display: block; font-size: 15px; }
.marque-compacte span { color: var(--encre-2); font-size: 12.5px; }

/* --------------------------------------------------------------- connexion */

.connexion {
  min-height: 100%;
  display: grid; place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(1100px 500px at 50% -10%, var(--accent-doux), transparent),
    var(--papier);
}

.connexion-carte {
  width: 100%; max-width: 408px;
  background: var(--carte);
  border: 1px solid var(--trait);
  border-radius: 14px;
  padding: 30px 28px 24px;
  box-shadow: var(--ombre);
}

.connexion-carte .marque { margin-bottom: 24px; }

.connexion-carte label {
  display: block;
  margin: 14px 0 6px;
  font-size: 13px; font-weight: 600;
  color: var(--encre-2);
}

.connexion-carte input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--trait-fort);
  border-radius: var(--rayon-s);
  background: var(--carte);
  color: var(--encre);
  font: inherit;
}

.connexion-carte button[type="submit"] { margin-top: 20px; }

.separateur {
  display: flex; align-items: center; gap: 12px;
  margin: 18px 0;
  color: var(--encre-3); font-size: 12.5px;
}
.separateur::before, .separateur::after {
  content: ""; flex: 1; height: 1px; background: var(--trait);
}

.note-connexion {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--trait);
  color: var(--encre-2);
  font-size: 12.5px;
}

/* ------------------------------------------------------------------ boutons */

.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: var(--rayon-s);
  font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .06s;
}
.bouton:active { transform: translateY(1px); }
.bouton[disabled] { opacity: .55; cursor: not-allowed; }

.bouton-principal { background: var(--marque); color: #fff; }
.bouton-principal:hover:not([disabled]) { background: var(--marque-clair); }

.bouton-contour {
  background: var(--carte); color: var(--encre);
  border-color: var(--trait-fort);
}
.bouton-contour:hover:not([disabled]) { border-color: var(--encre-3); }

.bouton-accent { background: var(--accent); color: #fff; }
.bouton-succes { background: var(--succes); color: #fff; }
.bouton-danger { background: var(--danger); color: #fff; }
.bouton-discret { background: transparent; color: var(--encre-2); }
.bouton-discret:hover { background: var(--papier); color: var(--encre); }

.bouton-large { width: 100%; padding: 11px 16px; }
.bouton-petit { padding: 6px 10px; font-size: 13px; }

.bouton-icone {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px;
  border: 0; border-radius: var(--rayon-s);
  background: transparent; color: var(--encre-2);
  cursor: pointer; position: relative;
}
.bouton-icone:hover { background: var(--papier); color: var(--encre); }

.lien-discret {
  background: 0; border: 0; padding: 0;
  margin-top: 14px;
  color: var(--marque-clair);
  font: inherit; font-size: 13px;
  cursor: pointer; text-decoration: underline;
}

/* -------------------------------------------------------------- mise en page */

.app { display: flex; min-height: 100vh; }

.barre-laterale {
  width: var(--barre); flex: 0 0 var(--barre);
  background: var(--carte);
  border-right: 1px solid var(--trait);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}

.navigation { flex: 1; overflow-y: auto; padding: 8px 10px 16px; }

.nav-groupe {
  margin: 14px 8px 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--encre-3);
}

.nav-lien {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--rayon-s);
  color: var(--encre);
  text-decoration: none;
  font-size: 14.5px;
}
.nav-lien:hover { background: var(--papier); }
.nav-lien[aria-current="page"] {
  background: var(--accent-doux);
  color: var(--accent);
  font-weight: 600;
}
.nav-lien svg { flex: 0 0 18px; opacity: .85; }
.nav-compteur {
  margin-left: auto;
  min-width: 20px; padding: 1px 6px;
  border-radius: 10px;
  background: var(--danger); color: #fff;
  font-size: 11.5px; font-weight: 700; text-align: center;
}

.moi {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--trait);
}
.moi-texte { min-width: 0; flex: 1; }
.moi-texte strong { display: block; font-size: 13.5px; }
.moi-texte span {
  display: block;
  color: var(--encre-2); font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.zone { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.entete {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 22px;
  background: var(--carte);
  border-bottom: 1px solid var(--trait);
  position: sticky; top: 0; z-index: 20;
}
.entete-titre { flex: 1; min-width: 0; }
.entete-titre h2 { font-size: 18px; }
.entete-titre p { color: var(--encre-2); font-size: 13px; }
.entete-actions { display: flex; align-items: center; gap: 4px; }

.menu-mobile { display: none; }

.vue { flex: 1; padding: 22px; max-width: 1180px; width: 100%; }
.vue:focus { outline: none; }

/* --------------------------------------------------------------- composants */

.carte {
  background: var(--carte);
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  padding: 18px;
  box-shadow: var(--ombre);
}

.grille { display: grid; gap: 14px; }
.grille-2 { grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }
.grille-3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grille-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.bloc-titre {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 14px;
}
.bloc-titre h3 { font-size: 15.5px; }
.bloc-titre p { color: var(--encre-2); font-size: 13px; }

.statistique .valeur { font-size: 27px; font-weight: 700; letter-spacing: -.02em; }
.statistique .libelle { color: var(--encre-2); font-size: 13px; margin-top: 2px; }

.avatar {
  width: 36px; height: 36px; flex: 0 0 36px;
  border-radius: 50%;
  background: var(--marque-clair); color: #fff;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
  background-size: cover; background-position: center;
}
.avatar-s { width: 28px; height: 28px; flex-basis: 28px; font-size: 11px; }
.avatar-l { width: 54px; height: 54px; flex-basis: 54px; font-size: 18px; }

.etiquette {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--papier); color: var(--encre-2);
  font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
}
.etiquette-dg { background: var(--marque); color: #fff; }
.etiquette-dir { background: var(--accent-doux); color: var(--accent); }
.etiquette-resp { background: var(--alerte-doux); color: var(--alerte); }
.etiquette-succes { background: var(--succes-doux); color: var(--succes); }
.etiquette-alerte { background: var(--alerte-doux); color: var(--alerte); }
.etiquette-danger { background: var(--danger-doux); color: var(--danger); }

.liste { display: flex; flex-direction: column; }
.liste-element {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--trait);
}
.liste-element:last-child { border-bottom: 0; }
.liste-corps { flex: 1; min-width: 0; }
.liste-corps strong { display: block; font-size: 14.5px; }
.liste-corps span { color: var(--encre-2); font-size: 13px; }

.vide {
  padding: 34px 20px;
  text-align: center;
  color: var(--encre-2);
  border: 1px dashed var(--trait-fort);
  border-radius: var(--rayon);
}
.vide strong { display: block; color: var(--encre); margin-bottom: 4px; }

.champ { margin-bottom: 14px; }
.champ label {
  display: block; margin-bottom: 5px;
  font-size: 13px; font-weight: 600; color: var(--encre-2);
}
.champ input, .champ select, .champ textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--trait-fort);
  border-radius: var(--rayon-s);
  background: var(--carte); color: var(--encre);
  font: inherit;
}
.champ textarea { min-height: 110px; resize: vertical; }
.champ .aide { margin-top: 4px; color: var(--encre-3); font-size: 12px; }
.champs-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

.barre-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pousse-droite { margin-left: auto; }

.message { margin-top: 12px; font-size: 13.5px; min-height: 18px; }
.message-erreur { color: var(--danger); }
.message-succes { color: var(--succes); }

/* -------------------------------------------------------- organigramme */

/* Le conteneur defile, et son contenu est centre SANS etre coupe.
 *
 * Le piege : `justify-content: center` dans un conteneur en overflow rend le
 * debordement de gauche inatteignable. Le navigateur centre, la partie qui
 * depasse sort des deux cotes, et le defilement ne peut pas remonter avant le
 * point de depart. Resultat observe : la premiere direction de la rangee etait
 * tronquee et aucun geste ne permettait de l'atteindre.
 *
 * Deux protections, parce qu'une seule ne couvre pas tous les navigateurs.
 * `width: max-content` avec des marges automatiques centre l'arbre quand il
 * tient et le laisse commencer au bord quand il deborde. Et `safe center`
 * demande explicitement au navigateur de basculer en alignement de debut
 * plutot que de couper, la ou il est reconnu. */
.organigramme {
  overflow-x: auto;
  padding: 8px 4px 24px;
}

.organigramme > .og-noeud {
  width: max-content;
  min-width: 100%;
  margin-inline: auto;
}

.og-niveau {
  display: flex; gap: 16px;
  justify-content: center;
  justify-content: safe center;
  flex-wrap: wrap;
}

.og-noeud { display: flex; flex-direction: column; align-items: center; }

.og-carte {
  min-width: 206px; max-width: 250px;
  background: var(--carte);
  border: 1px solid var(--trait);
  border-top: 3px solid var(--unite-couleur, var(--marque-clair));
  border-radius: var(--rayon);
  padding: 12px 14px;
  box-shadow: var(--ombre);
  text-align: center;
  position: relative;
}
.og-carte.og-dg { border-top-width: 5px; }
.og-unite { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--encre-3); }
.og-titre { font-size: 14px; font-weight: 600; margin: 4px 0 2px; }
.og-personne { display: flex; align-items: center; gap: 8px; justify-content: center; margin-top: 8px; }
.og-personne span { font-size: 13px; }
.og-vacant { color: var(--alerte); font-size: 12.5px; font-weight: 600; }

.og-trait { width: 2px; height: 18px; background: var(--trait-fort); }
.og-enfants {
  display: flex; gap: 16px; position: relative; padding-top: 18px;
  justify-content: center;
  justify-content: safe center;
}
.og-enfants::before {
  content: ""; position: absolute; top: 0; left: 10%; right: 10%;
  height: 2px; background: var(--trait-fort);
}
.og-enfants > .og-noeud { position: relative; }
.og-enfants > .og-noeud::before {
  content: ""; position: absolute; top: -18px; left: 50%;
  width: 2px; height: 18px; background: var(--trait-fort);
}
.og-enfants:only-child::before { display: none; }

/* --------------------------------------------------------------- messagerie */

.messagerie {
  display: grid; grid-template-columns: 290px 1fr;
  gap: 0;
  background: var(--carte);
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  overflow: hidden;
  height: calc(100vh - 150px); min-height: 440px;
}
.conversations { border-right: 1px solid var(--trait); overflow-y: auto; }
.conversation-ligne {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--trait);
  cursor: pointer;
  text-align: left; width: 100%;
  background: transparent; border-left: 0; border-right: 0; border-top: 0;
  color: inherit; font: inherit;
}
.conversation-ligne:hover { background: var(--papier); }
.conversation-ligne[aria-selected="true"] { background: var(--accent-doux); }
.conversation-ligne .liste-corps span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

.fil { display: flex; flex-direction: column; min-width: 0; }
.fil-entete { padding: 12px 16px; border-bottom: 1px solid var(--trait); display: flex; align-items: center; gap: 10px; }
.fil-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.fil-saisie { border-top: 1px solid var(--trait); padding: 10px 12px; display: flex; gap: 8px; }
.fil-saisie textarea {
  flex: 1; min-height: 42px; max-height: 140px; resize: vertical;
  padding: 10px 12px;
  border: 1px solid var(--trait-fort); border-radius: var(--rayon-s);
  background: var(--carte); color: var(--encre); font: inherit;
}

.bulle { max-width: 76%; padding: 9px 13px; border-radius: 14px; background: var(--papier); }
.bulle-moi { align-self: flex-end; background: var(--marque); color: #fff; }
.bulle-auteur { font-size: 11.5px; font-weight: 700; margin-bottom: 2px; opacity: .85; }
.bulle-poste { font-size: 10.5px; opacity: .7; font-weight: 600; }
.bulle-heure { font-size: 10.5px; opacity: .65; margin-top: 3px; text-align: right; }

/* ---------------------------------------------------------------- circuits */

.circuit { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 10px 0; }
.circuit-etape {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--trait-fort);
  border-radius: 20px;
  font-size: 12.5px;
  background: var(--carte);
}
.circuit-etape.faite { border-color: var(--succes); background: var(--succes-doux); color: var(--succes); }
.circuit-etape.courante { border-color: var(--alerte); background: var(--alerte-doux); color: var(--alerte); font-weight: 700; }
.circuit-etape.refusee { border-color: var(--danger); background: var(--danger-doux); color: var(--danger); }
.circuit-fleche { color: var(--encre-3); }

.progression { height: 6px; background: var(--trait); border-radius: 4px; overflow: hidden; }
.progression > span { display: block; height: 100%; background: var(--accent); }

/* ------------------------------------------------------- panneau et modale */

.panneau {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(400px, 100%);
  background: var(--carte);
  border-left: 1px solid var(--trait);
  box-shadow: var(--ombre-forte);
  z-index: 60;
  display: flex; flex-direction: column;
}
.panneau-entete {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--trait);
}
.panneau-corps { flex: 1; overflow-y: auto; padding: 8px 18px 18px; }

.voile { position: fixed; inset: 0; background: rgba(8, 20, 32, .45); z-index: 50; }

.modale {
  position: fixed; inset: 0; z-index: 70;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(8, 20, 32, .5);
  overflow-y: auto;
}
.modale-carte {
  width: 100%; max-width: 560px;
  background: var(--carte);
  border-radius: 14px;
  padding: 22px;
  box-shadow: var(--ombre-forte);
}
.modale-carte h3 { margin-bottom: 4px; }
.modale-carte > p { color: var(--encre-2); font-size: 13.5px; margin-bottom: 16px; }

.pastille {
  position: absolute; top: 5px; right: 5px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--carte);
}

.toasts {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  z-index: 90;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 11px 17px;
  border-radius: 22px;
  background: var(--encre); color: var(--papier);
  font-size: 13.5px; font-weight: 600;
  box-shadow: var(--ombre-forte);
}
.toast-erreur { background: var(--danger); color: #fff; }
.toast-succes { background: var(--succes); color: #fff; }

/* -------------------------------------------------------------- responsive */

@media (max-width: 900px) {
  .barre-laterale {
    position: fixed; inset: 0 auto 0 0; z-index: 55;
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  .barre-laterale.ouverte { transform: none; }
  .menu-mobile { display: inline-grid; }
  .vue { padding: 16px; }
  .champs-2 { grid-template-columns: 1fr; }
  .messagerie { grid-template-columns: 1fr; height: auto; }
  .conversations { border-right: 0; border-bottom: 1px solid var(--trait); max-height: 240px; }
  .fil-messages { min-height: 300px; }
}

@media print {
  .barre-laterale, .entete-actions, .menu-mobile, .toasts { display: none; }
  body { background: #fff; }
  .carte { box-shadow: none; break-inside: avoid; }
}
