/* © 2026 Yoann Crom — Vicious Studio. Logiciel propriétaire, tous droits réservés (LICENSE). Réf. VS-2026-8EFE48 */
/* La refonte de l'onglet 🏢 Agences (2026-10-14) : les chiffres, le lien de vente sur une ligne, trier / chercher /
   filtrer, les soldes bas qui se voient, et la fiche d'une agence dans un panneau sur le côté. Seulement les couleurs
   de console.css (le rose de Vicious Studio sur noir) et leurs teintes transparentes. */

/* La largeur du panneau : il laisse toujours une bande du voile à gauche, où s'affichent les messages (rien ne cache
   un bouton du panneau) */
:root { --largeur-fiche: min(600px, calc(100vw - 240px)); }
@media (max-width: 700px) { :root { --largeur-fiche: calc(100vw - 24px); } }

/* ---------- Les chiffres du haut ---------- */
.chiffres-agences { margin: 10px 0 14px; }
.chiffres-agences .quoi .petit-texte { font-size: 12px; }
@keyframes agences-chiffre-bouge { 0% { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(250,5,110,.25); } 100% { box-shadow: 0 0 0 0 rgba(250,5,110,0); } }
.chiffre-carte.a-bouge { animation: agences-chiffre-bouge 1.4s ease-out; }

/* ---------- 🛒 Le lien de vente, sur une ligne ---------- */
#vue-agences .carte-vente { padding: 10px 14px; gap: 8px; }
.carte-vente .vente-ligne { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.carte-vente .vente-titre { font-weight: 700; white-space: nowrap; }
.carte-vente .vente-ligne .champ { flex: 1; min-width: 200px; width: auto; padding: 6px 10px; }
.carte-vente .alerte { padding: 8px 12px; }
.carte-vente details > summary { cursor: pointer; color: var(--doux); font-size: 13px; }
.carte-vente details > summary:hover { color: var(--texte); }
.carte-vente details .aide { margin: 6px 0 0; }
.carte-vente .vente-sans-compte > summary { color: var(--texte); font-size: 14px; }

/* ---------- Trier, chercher, filtrer ---------- */
.outils-agences { margin: 2px 0 10px; }
.outils-agences .puces { margin: 6px 0; }
.outils-agences .puce .fleche { color: var(--accent); font-weight: 700; }
.ligne-recherche { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.ligne-recherche .champ { flex: 1 1 260px; width: auto; max-width: 440px; padding: 7px 11px; }
.ligne-recherche .puces { margin: 0; }
#phrase-tri-agences { margin: 6px 0 0; }

/* ---------- Le tableau ---------- */
/* les titres longs (« Dernière connexion ») reviennent à la ligne, la flèche reste collée au mot ; le nom de l'agence
   garde de la place (revue du 2026-10-14 : « Studio Lumière » passait sur deux lignes) */
.tableau-agences th .tri-entete { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-transform: inherit;
  letter-spacing: inherit; white-space: normal; text-align: left; cursor: pointer; }
.tableau-agences th .tri-entete .fleche { white-space: nowrap; }
.tableau-agences td:first-child { min-width: 170px; }
.tableau-agences th .tri-entete:hover, .tableau-agences th[aria-sort] .tri-entete { color: var(--texte); }
.tableau-agences th .tri-entete .fleche { color: var(--accent); }
.tableau-agences tr.cliquable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tableau-agences .medaille { font-size: 15px; }
.tableau-agences .badge { white-space: nowrap; margin: 1px 0; }
/* son espace, épinglé en haut */
.tableau-agences tr.ton-espace:not(:hover) td { background: rgba(250,5,110,.05); }
.tableau-agences tr.ton-espace td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
/* un solde bas (la pastille ⚠ du serveur) se voit de loin */
.tableau-agences tr.solde-bas td:first-child { box-shadow: inset 3px 0 0 var(--alerte); }
.tableau-agences tr.solde-bas .col-solde b { color: var(--alerte); }
.tableau-agences .badge-alerte { background: rgba(245,177,76,.16); color: var(--alerte); }
.tableau-agences tr.suspendue td { color: var(--doux); }
/* la barre du solde : la part de cette agence face au plus gros solde */
.barre-solde { display: block; width: 90px; height: 4px; margin-top: 5px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.barre-solde i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
@media (max-width: 1000px) { .barre-solde { width: 60px; } }
.tableau-agences tr.solde-bas .barre-solde i { background: var(--alerte); }
/* un tri choisi, une agence qui vient d'arriver ou qui a bougé : un petit signe */
@keyframes agences-trie { from { opacity: .3; } }
.tableau-agences tr.trie td { animation: agences-trie .3s ease-out; }
@keyframes agences-ligne-bouge { 0% { background: rgba(250,5,110,.24); } 100% { background: transparent; } }
.tableau-agences tr.a-bouge td, .tableau-agences tr.nouvelle td { animation: agences-ligne-bouge 1.8s ease-out; }
.tableau-agences .vide .bouton { margin-left: 8px; }

/* ---------- La fiche d'une agence : un panneau à droite, sur un voile ---------- */
#vue-agences #fiche-agence { position: fixed; top: 0; right: 0; bottom: 0; z-index: 9; width: var(--largeur-fiche); margin: 0;
  padding: 0 22px 40px; border-radius: 14px 0 0 14px; border-right: 0; overflow-y: auto; overscroll-behavior: contain;
  box-shadow: -24px 0 48px rgba(0,0,0,.55); outline: none; }
#vue-agences #fiche-agence:not([hidden]) { animation: agences-fiche-entre .22s ease-out; }
@keyframes agences-fiche-entre { from { transform: translateX(40px); opacity: 0; } }
.voile-fiche { display: none; position: fixed; inset: 0; z-index: 8; background: rgba(0,0,0,.6); cursor: pointer; }
#fiche-agence:not([hidden]) + .voile-fiche { display: block; animation: agences-voile-entre .2s ease-out; }
/* panneau ouvert : la molette sur le voile ne fait plus défiler la liste cachée derrière (revue du 2026-10-14) */
html:has(#vue-agences:not([hidden]) #fiche-agence:not([hidden])) { overflow: hidden; }
@keyframes agences-voile-entre { from { opacity: 0; } }
/* les messages (toasts) passent dans la bande du voile, à gauche du panneau : jamais sur un bouton de la fiche */
@media (min-width: 701px) {
  body:has(#vue-agences:not([hidden]) #fiche-agence:not([hidden])) .toasts {
    right: auto; left: 16px; max-width: calc(100vw - var(--largeur-fiche) - 32px); }
}

/* le haut du panneau reste visible quand on descend : le nom, ✕, et les puces pour sauter à une section */
#fiche-agence .tete { position: sticky; top: 0; z-index: 1; background: var(--surface); margin: 0 0 4px; padding: 16px 0 8px;
  border-bottom: 1px solid var(--bord); gap: 8px 12px; }
#fiche-agence .tete h3 { font-size: 20px; overflow-wrap: anywhere; }
#fiche-agence .fermer-fiche { border: 1px solid var(--bord); font-size: 15px; line-height: 1; padding: 7px 11px; }
#fiche-agence .fermer-fiche:hover { border-color: var(--accent); color: var(--texte); }
#fiche-agence .fiche-sommaire { flex-basis: 100%; margin: 2px 0 0; gap: 5px; }
#fiche-agence .fiche-sommaire .puce { padding: 3px 10px; font-size: 12.5px; }
.fiche-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 2px; }
.fiche-bloc { border-top: 1px solid var(--bord); margin-top: 16px; scroll-margin-top: 136px; }
#fiche-agence .fiche-bloc h2 { margin: 14px 0 8px; color: var(--texte); }
#fiche-agence .fiche-bloc:first-of-type { border-top: 0; margin-top: 6px; }
.fiche-chiffres { display: grid; grid-template-columns: minmax(150px, 1.5fr) repeat(3, minmax(0, 1fr)); gap: 8px; margin: 8px 0 10px; }
.fiche-chiffres .chiffre-carte { padding: 10px 12px; min-width: 0; }
.fiche-chiffres .chiffre-carte .valeur { font-size: 20px; }
.fiche-chiffres .fiche-solde .valeur { font-size: 28px; white-space: nowrap; }
.fiche-solde.bas { border-color: rgba(245,177,76,.6); background: rgba(245,177,76,.08); }
.fiche-solde.bas .valeur { color: var(--alerte); }
.fiche-bravo { color: var(--ok); font-weight: 700; margin-left: 4px; }
@keyframes agences-solde-fete { 0% { box-shadow: 0 0 0 0 rgba(250,5,110,.6); transform: scale(1.03); } 100% { box-shadow: 0 0 0 16px rgba(250,5,110,0); transform: none; } }
.fiche-solde.fete { animation: agences-solde-fete 1.3s ease-out; }
/* seuls les petits badges du haut et des comptes restent sur une ligne : l'état d'un iPhone (« absent du compte
   iRemotech — plus facturé, à reprendre ») revient à la ligne, son prix reste visible (revue du 2026-10-14) */
#fiche-agence .bouton.petit, #fiche-agence .tete .badge, #fiche-agence .badges-compte .badge { white-space: nowrap; }
.fiche-en-attente { display: block; color: var(--alerte); }
.comptes-fiche td:first-child { overflow-wrap: anywhere; }
.badges-compte { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.fiche-plus { margin-top: 8px; }
.fiche-plus > summary { cursor: pointer; color: var(--doux); font-size: 13px; }
.fiche-plus .tableau { margin-top: 8px; }
@media (max-width: 560px) { .fiche-chiffres { grid-template-columns: 1fr 1fr; } }

@media (prefers-reduced-motion: reduce) {
  .chiffre-carte.a-bouge, .tableau-agences tr.trie td, .tableau-agences tr.a-bouge td, .tableau-agences tr.nouvelle td,
  #vue-agences #fiche-agence:not([hidden]), #fiche-agence:not([hidden]) + .voile-fiche, .fiche-solde.fete { animation: none; }
}
