/* 🗂️ CONTACTS — l'annuaire de CRM (Léo, 24/10/2026 : « défiler vers le bas
   comme ça c'est pas propre, trouve autre chose qu'une liste sans fin »).

   Une barre (recherche, commercial, période, pastilles d'étape), un tableau
   d'une ligne par personne, des pages. Sur un téléphone, chaque ligne devient
   une carte compacte : la page ne défile jamais en largeur.

   🎨 Le thème arrive PAR-DESSUS (le chantier `design-lux` réécrit ecran.css) :
   ici, AUCUNE couleur ni police en dur — les variables de `:root` d'ecran.css
   seulement. Les cartes viennent d'ecran.css (`#historique > *` : fond et
   filet) ; la pastille du statut (`.statut-pastille`) et l'avatar
   (`.lead-initiales`) sont ceux du Suivi client.
   Contrastes MESURÉS par script le 24/10/2026, sur les valeurs de `:root` et
   les fonds réels : le texte le plus pâle (`--libelle`) fait 5,4:1 sur le fond
   de page, 5,3:1 sur un en-tête survolé ; « aujourd'hui » (`--vert`) 5,2:1 sur
   une ligne survolée. Les traits qui PORTENT une information : le filet d'une
   pastille (`--libelle`, 5,9:1 — `--trait-fort` ne faisait que 1,5:1),
   l'anneau du clavier (`--vert`, 4,9:1 sur la ligne au clavier). Les filets
   entre les lignes sont décoratifs.
   ♿ L'anneau des commandes et des champs (recherche, menus, pages) est celui
   d'ecran.css, en `--vert`, depuis le 25/10/2026 : la retouche qui le
   remplaçait ici n'a plus lieu d'être. */

.visuellement-cache { position: absolute !important; width: 1px; height: 1px; margin: -1px;
  padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.contacts-entete { justify-content: flex-start; align-items: baseline; gap: .35rem 1rem;
  flex-wrap: wrap; }
.contacts-compte { color: var(--libelle); font-size: .92rem; font-variant-numeric: tabular-nums; }

/* ── La barre ────────────────────────────────────────────────────────────── */
#historique > .contacts-barre { position: relative; padding: .9rem 1rem; margin-bottom: 1rem;
  display: flex; flex-direction: column; gap: .8rem; }
.contacts-champs { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; }
.contacts-recherche { flex: 1 1 18rem; min-width: 0; max-width: 30rem; display: flex; }
.contacts-recherche input { width: 100%; min-width: 0; }
.contacts-choix { display: inline-flex; align-items: center; gap: .45rem; min-width: 0; }
.contacts-choix-nom { font-size: .86rem; color: var(--libelle); white-space: nowrap; }
.contacts-choix select { min-width: 8.5rem; }
.contacts-tri-etroit { display: none; }

/* Les pastilles d'étape : une enfoncée à la fois. Enfoncée, elle s'inverse
   (encre sur fond) : pas une couleur de plus, l'état se lit aussi sans elle
   (`aria-pressed`). */
.contacts-pastilles { display: flex; flex-wrap: wrap; gap: .4rem; }
.contacts-pastille { display: inline-flex; align-items: center; gap: .45rem; padding: .28rem .75rem;
  border-radius: 999px; border: 1px solid var(--libelle); background: var(--fond);
  color: var(--encre-douce); font-size: .84rem; font-weight: 500; box-shadow: none;
  white-space: nowrap; }
.contacts-pastille:hover:not(:disabled) { background: var(--fond-gris); border-color: var(--encre-douce);
  color: var(--encre); }
.contacts-pastille-n { font-size: .78rem; font-weight: 600; color: var(--libelle);
  font-variant-numeric: tabular-nums; }
.contacts-pastille[aria-pressed="true"],
.contacts-pastille[aria-pressed="true"]:hover:not(:disabled) { background: var(--encre);
  border-color: var(--encre); color: var(--fond); }
.contacts-pastille[aria-pressed="true"] .contacts-pastille-n { color: var(--fond-gris); }

/* ── Le tableau ──────────────────────────────────────────────────────────── */
#historique > .contacts-tableau { position: relative; padding: 0; overflow: hidden;
  transition: opacity .15s ease; }
.contacts-tableau.recharge { opacity: .6; }
/* ↔️ Entre 760 et 1 300 px, le tableau peut dépasser sa carte : il y défile,
   et l'ombre au bord le dit (`--indice-defilement` d'ecran.css, 25/10/2026). */
.contacts-defile { overflow-x: auto; background: var(--indice-defilement);
  overscroll-behavior-x: contain; }
.contacts-tableau.est-vide .contacts-defile { display: none; }
.contacts-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.contacts-table thead th { padding: 0; text-align: left; white-space: nowrap; background: var(--fond-doux);
  border-bottom: 1px solid var(--trait); font-size: .78rem; font-weight: 500; color: var(--libelle); }
/* L'en-tête EST le bouton de tri : toute la case se clique. */
.contacts-trier { display: flex; align-items: center; gap: .3rem; width: 100%; padding: .65rem .75rem;
  border: 0; border-radius: 0; background: none; box-shadow: none; color: inherit; font: inherit;
  text-align: left; }
.contacts-trier:hover:not(:disabled) { background: var(--fond-gris); border-color: transparent;
  color: var(--encre); }
.contacts-trier:active:not(:disabled) { background: var(--fond-gris); }
.contacts-trier:focus-visible { outline: 3px solid var(--vert); outline-offset: -3px; }
.contacts-table th.trie .contacts-trier { color: var(--encre); font-weight: 600; }
.contacts-fleche { min-width: .8em; color: var(--encre); font-weight: 600; }
/* La flèche de survol dit qu'une colonne se trie avant qu'on clique. */
.contacts-table th:not(.trie) .contacts-trier:hover .contacts-fleche::after { content: "↕"; color: var(--libelle); }
.contacts-table th.c-appels .contacts-trier, .contacts-table th.c-budget .contacts-trier {
  justify-content: flex-end; }

.contacts-table td { padding: .6rem .75rem; border-bottom: 1px solid var(--trait-doux);
  vertical-align: middle; color: var(--encre); }
.contacts-ligne { cursor: pointer; }
.contacts-ligne:last-child td { border-bottom: 0; }
.contacts-ligne:hover td { background: var(--fond-doux); }
.contacts-ligne:has(.contacts-ouvrir:focus-visible) td { background: var(--vert-clair); }
.contacts-ligne:has(.contacts-ouvrir:focus-visible) { outline: 3px solid var(--vert); outline-offset: -3px; }
.contacts-ligne[aria-busy="true"] td { opacity: .6; }

.c-contact { white-space: nowrap; }
.c-contact .lead-initiales { display: inline-grid; vertical-align: middle; }
.contacts-qui { display: inline-flex; flex-direction: column; vertical-align: middle; min-width: 0;
  max-width: 17rem; margin-left: .7rem; }
.contacts-ouvrir { padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none;
  color: var(--encre); font-weight: 600; font-size: .92rem; text-align: left; line-height: 1.3;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contacts-ouvrir:hover:not(:disabled), .contacts-ouvrir:active:not(:disabled) { background: none;
  text-decoration: underline; text-underline-offset: 2px; }
.contacts-ouvrir:focus-visible { outline: none; }
.contacts-numero { font-family: var(--police-chiffres); font-size: .8rem; color: var(--libelle); }

.c-statut { white-space: nowrap; }
.contacts-etape { display: block; margin-top: .2rem; font-size: .76rem; color: var(--libelle); }
.c-commercial, .c-dernier, .c-prochain { white-space: nowrap; }
.c-appels, .c-budget { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.c-ville { max-width: 11rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contacts-unite { display: none; }
.contacts-table td.c-saut { display: none; }
.contacts-jamais, .contacts-rien { color: var(--libelle); }
.contacts-rdv.aujourdhui { color: var(--vert); font-weight: 600; }
.contacts-rdv.retard { color: var(--rouge); font-weight: 600; }

/* ── Vide, et aucun résultat ─────────────────────────────────────────────── */
.contacts-vide { padding: 2.75rem 1.5rem; text-align: center; }
.contacts-vide-titre { margin: 0 0 .35rem; font-size: 1rem; font-weight: 600; color: var(--encre); }
.contacts-vide-texte { margin: 0 auto 1.1rem; max-width: 34rem; font-size: .9rem; color: var(--libelle); }
.contacts-vide-texte:empty { display: none; }

/* ── Les pages ───────────────────────────────────────────────────────────── */
.contacts-pages { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem 1.1rem;
  padding: .7rem 1rem; border-top: 1px solid var(--trait); background: var(--fond-doux); }
.contacts-plage { font-size: .86rem; color: var(--encre-douce); font-variant-numeric: tabular-nums; }
.contacts-par-page { display: inline-flex; align-items: center; gap: .4rem; font-size: .86rem;
  color: var(--libelle); }
.contacts-pagination { margin-left: auto; display: flex; align-items: center; gap: .3rem; }
.contacts-numeros { display: inline-flex; align-items: center; gap: .25rem; }
.contacts-page { min-width: 2.15rem; padding: .3rem .6rem; font-size: .86rem;
  font-variant-numeric: tabular-nums; }
.contacts-page[aria-current="page"], .contacts-page[aria-current="page"]:hover:not(:disabled) {
  background: var(--encre); border-color: var(--encre); color: var(--fond); font-weight: 600; }
.contacts-ellipse { padding: 0 .2rem; color: var(--libelle); }
.contacts-page-sur { display: none; font-size: .86rem; color: var(--encre-douce); }

/* Entre 1 000 et 1 300 px, la colonne de navigation mange la place : le
   tableau défile dans SA carte, jamais la page. */
@media (max-width: 1300px) {
  .contacts-qui { max-width: 12rem; }
  .c-ville { max-width: 8rem; }
}

/* ── 📱 Téléphone : une CARTE par personne ───────────────────────────────── */
@media (max-width: 760px) {
  #historique { padding: 1rem; }
  /* La barre en grille : la recherche, puis deux menus côte à côte (le nom
     au-dessus), puis le tri. */
  .contacts-champs { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .6rem .75rem; }
  .contacts-recherche { grid-column: 1 / -1; max-width: none; }
  .contacts-choix { flex-direction: column; align-items: stretch; gap: .2rem; }
  .contacts-choix select { width: 100%; min-width: 0; }
  .contacts-tri-etroit { display: flex; grid-column: 1 / -1; }
  /* Les pastilles défilent dans leur rangée, pas la page. */
  .contacts-pastilles { flex-wrap: nowrap; overflow-x: auto; margin: 0 -1rem; padding: 0 1rem .1rem;
    scrollbar-width: none; }
  .contacts-pastilles::-webkit-scrollbar { display: none; }

  .contacts-table thead { display: none; }
  .contacts-table, .contacts-table tbody { display: block; }
  .contacts-ligne { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .45rem;
    padding: .8rem 1rem; border-bottom: 1px solid var(--trait-doux); }
  .contacts-ligne:last-child { border-bottom: 0; }
  .contacts-table td { display: block; padding: 0; border: 0; background: none;
    font-size: .82rem; color: var(--encre-douce); }
  .contacts-ligne:hover td, .contacts-ligne:has(.contacts-ouvrir:focus-visible) td { background: none; }
  .contacts-ligne:hover { background: var(--fond-doux); }
  .contacts-ligne:has(.contacts-ouvrir:focus-visible) { background: var(--vert-clair); }
  .contacts-table td.sans-valeur { display: none; }

  /* Ligne 1 : qui, et son statut. Les lignes suivantes s'alignent sous le
     nom (l'avatar + son écart). */
  /* Le nom prend la ligne, le statut se range à sa droite : tout le reste
     passe dessous. */
  .contacts-table td.c-contact { order: 1; flex: 1 1 55%; min-width: 0; display: flex; align-items: center;
    white-space: normal; color: var(--encre); font-size: inherit; }
  .contacts-qui { max-width: none; flex: 1; }
  .contacts-table td.c-statut { order: 2; flex: 0 0 auto; text-align: right; }
  .contacts-etape { display: none; }
  .contacts-table td.c-dernier { order: 3; padding-left: 2.85rem; }
  .contacts-table td.c-dernier::before { content: attr(data-libelle) " "; }
  .contacts-table tr.jamais-appele td.c-dernier::before { content: none; }
  .contacts-table tr.jamais-appele td.c-appels { display: none; }
  .contacts-table td.c-appels { order: 4; text-align: left; }
  .contacts-table td.c-appels::before { content: "· "; }
  .contacts-unite { display: inline; }
  /* Le saut : une case vide de toute la largeur, haute de rien. */
  .contacts-table td.c-saut { display: block; order: 5; flex: 1 0 100%; height: 0; margin-bottom: -.3rem; }
  .contacts-table td.c-prochain { order: 6; flex: 1 0 100%; padding-left: 2.85rem; }
  .contacts-table td.c-prochain::before { content: attr(data-libelle) " : "; }
  .contacts-table td.c-commercial { order: 7; padding-left: 2.85rem; }
  .contacts-table td.c-ville { order: 8; max-width: none; }
  .contacts-table td.c-budget { order: 9; }
  .contacts-table td.c-ville::before, .contacts-table td.c-budget::before { content: "· "; }
  /* Sans commercial (un lead à personne), la ville ouvre la ligne. */
  .contacts-table td.c-commercial.sans-valeur ~ td.c-ville { padding-left: 2.85rem; }
  .contacts-table td.c-commercial.sans-valeur ~ td.c-ville::before { content: none; }

  .contacts-pages { gap: .6rem; }
  .contacts-pagination { margin-left: 0; width: 100%; justify-content: space-between; }
  .contacts-numeros { display: none; }
  .contacts-page-sur { display: inline; }
}
