/* Composants communs selon les maquettes (audit « respect des maquettes » du 28/11/2026, écarts T4).
   Référence : maquettes/systeme-de-design-LFC-2026-11-08.html (« boutons · 44 px de haut partout », état vide dans une carte,
   une alerte = une carte seule), ecrans-LFC-2026-11-13.html (boutons d'une carte alignés), V85 (listes en carte, cibles 44 px).
   Feuille de surcharge : chargée après les autres, sélecteurs précis ; aucune règle métier, aucun accès ne change. */

/* 1. Puces de filtre à 44 px à toutes les largeurs (elles l'étaient déjà au doigt, design-system.css V146 ; 31 px à l'ordinateur). */
:is(.chip, .filter, .qr-filter) { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; }
.cal-nav { width: 44px; height: 44px; }
.cal-today { min-height: 44px; }

/* Au téléphone, les filtres des chantiers sur une seule ligne qui glisse au doigt (« Terminés » seul sur une 2e ligne). */
@media (max-width: 700px) {
  #sites-filters { flex-wrap: nowrap; overflow-x: auto; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding-bottom: 2px; }
  #sites-filters::-webkit-scrollbar { display: none; }
  #sites-filters .chip { flex: none; scroll-snap-align: start; white-space: nowrap; }
}

/* 2. Stock : l'alerte « retour immobilisé faute de motif » est une carte seule, pas une carte dans la carte verte
   (le bloc « À réutiliser » ne garde son cadre que lorsqu'il a une liste à montrer). */
.reuse-block.reuse-blocked-only { padding: 0; border: 0; border-radius: 0; background: transparent; }

/* 3. « Rien pour l'instant » : toujours la même carte d'état vide, à toutes les largeurs (mobile.css ne la dessinait qu'au téléphone). */
.content .empty-state { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 32px 20px; text-align: center; color: var(--muted); }
.content .empty-state p { margin: 6px 0 0; }
#messages-page > p.team-empty,
#messages-page .conv-groupe > p.team-empty { margin: 0; padding: 24px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); text-align: center; color: var(--muted); }

/* 4. Demandes, « Besoins du … » : le libellé sur sa ligne, puis les deux réponses côte à côte, de même largeur et de 44 px. */
[data-besoin-attendu] .tache-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; gap: 8px; }
[data-besoin-attendu] .tache-actions > small { grid-column: 1 / -1; }
[data-besoin-attendu] .tache-actions .button { min-height: 44px; white-space: normal; line-height: 1.2; }
@media (min-width: 701px) { [data-besoin-attendu] .tache-actions { grid-template-columns: repeat(2, minmax(140px, max-content)); } }

/* 5. L'anneau n'apparaît qu'au clavier (:focus-visible). Au doigt, le survol « collé » après un toucher (iPhone, tablette)
   entourait une tuile dès l'ouverture d'une page : on l'efface là où il n'y a pas de souris. */
:where(button, a, [tabindex]):focus:not(:focus-visible) { outline: none; }
@media (hover: none), (pointer: coarse) {
  .metric.is-clickable:hover:not(:focus-visible) { outline: none; transform: none; box-shadow: none; border-color: var(--line); }
  #metrics .metric[data-couleur]:hover:not(:focus-visible) { filter: none; border-color: var(--tuile-filet) !important; }
}

/* 6. Chantiers au téléphone : la recherche et la liste d'abord ; les imports Cogilog (rares, seulement pour les profils qui les ont)
   descendent sous la liste, en boutons discrets et tous du même style. */
@media (max-width: 700px) {
  #sites-view:not(.hidden) { display: flex; flex-direction: column; }
  #sites-view > .page-heading { display: contents; }
  #sites-view > .page-heading > div { margin-bottom: 20px; }
  #sites-view > .sites-toolbar, #sites-view > .sites-list { order: 1; }
  /* Décision d'Eduardo du 29/11/2026 : un seul bouton « Importer depuis Cogilog » en haut (imports-telephone.js) ; il ouvre les trois imports. */
  #sites-view > .page-heading > label.button { order: 0; display: none; margin-bottom: 8px; min-height: 44px; font-size: 14px; font-weight: 600; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); box-shadow: none; }
  #sites-view.imports-ouverts > .page-heading > label.button:not([hidden]) { display: flex; }
  #sites-view > .page-heading > .imports-cogilog-ouvrir { order: 0; min-height: 44px; margin-bottom: 12px; }
  #sites-view > .sites-list { margin-bottom: 14px; }
}

/* V240 (§431) : « Mon compte » en trois vues — moi, comptes de l'application, réglages de la direction — et la liste courte des comptes. */
#account-dialog .compte-retour { display: none; }
#account-dialog[data-compte-vue="comptes"] .compte-retour, #account-dialog[data-compte-vue="reglages"] .compte-retour { display: inline-flex; align-items: center; min-height: 44px; margin: 4px 0 8px; padding: 0 4px; border: 0; background: none; color: var(--p-acier-fonce, #2b5b84); font: inherit; font-weight: 700; font-size: 17px; cursor: pointer; }
#account-dialog[data-compte-vue="moi"] :is(#accounts-section, #nouveautes-suivi-section, #seuils-section, #parts-mo-section, #perimetre-section, #relais-section, #agent-section) { display: none !important; }
#account-dialog[data-compte-vue="comptes"] .account-panel > :not(.dialog-head, .compte-retour, #accounts-section) { display: none !important; }
#account-dialog[data-compte-vue="reglages"] .account-panel > :not(.dialog-head, .compte-retour, #nouveautes-suivi-section, #seuils-section, #parts-mo-section, #perimetre-section, #relais-section, #agent-section) { display: none !important; }
#account-dialog .compte-aller { display: grid; gap: 8px; margin: 14px 0; }
#account-dialog .compte-aller[hidden], #account-dialog .compte-aller-bouton[hidden] { display: none; }
#account-dialog .compte-aller-bouton { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 0 16px; border: 1px solid var(--line, #dbe2e8); border-radius: 14px; background: #ffffff; color: var(--navy, #102a43); font: inherit; font-weight: 700; font-size: 16px; text-align: left; cursor: pointer; }
#account-dialog .account-droits-aide { display: none; }
#account-dialog #accounts-code-app[hidden] { display: none; }
#account-dialog .accounts-outils { display: grid; gap: 10px; margin: 10px 0 4px; }
#account-dialog .accounts-outils [data-accounts-ajouter] { min-height: 48px; }
#account-dialog .accounts-recherche input { width: 100%; box-sizing: border-box; min-height: 44px; padding: 0 12px; border: 1px solid var(--line, #dbe2e8); border-radius: 10px; font: inherit; font-size: 16px; }
#account-dialog .accounts-onglets { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; border-radius: 12px; background: #eef2f6; }
#account-dialog .accounts-onglets button { min-height: 44px; border: 0; border-radius: 9px; background: transparent; color: var(--navy, #102a43); font: inherit; font-weight: 600; cursor: pointer; }
#account-dialog .accounts-onglets button[aria-selected="true"] { background: #ffffff; box-shadow: 0 1px 3px rgba(16, 42, 67, .15); }
#account-dialog #account-create-form[hidden] { display: none; }
#account-dialog .account-row { display: block; padding: 0; opacity: 1; }
#account-dialog .account-row[hidden] { display: none; }
#account-dialog .account-ouvrir { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 10px; width: 100%; min-height: 56px; padding: 10px 12px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
#account-dialog .account-row.inactive .account-ouvrir { color: #5b6b7c; }
#account-dialog .account-profil { color: #5b6b7c; font-size: 14px; }
#account-dialog .account-chevron { font-size: 22px; color: #8a99a8; transition: transform .15s; }
#account-dialog .account-row.ouvert .account-chevron { transform: rotate(90deg); }
#account-dialog .account-actions { display: none; }
#account-dialog .account-row.ouvert .account-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 12px 12px; }
#account-dialog .account-actions > :is(select, button) { flex: 1 1 140px; min-height: 44px; }
#account-dialog .account-actions > :is(.account-droit, .account-remplacant, .account-remplacant-note, .account-rename) { flex: 1 0 100%; }
#account-dialog .account-droit-aide { display: block; margin-left: 28px; color: #5b6b7c; font-size: 13px; font-weight: 400; }
#account-dialog .button.danger { color: #a8281f; border-color: #e3b3ae; }
#account-dialog .accounts-supprimes { margin-top: 14px; color: #5b6b7c; }
#account-dialog .accounts-supprimes[hidden], #account-dialog .accounts-supprimes:empty { display: none; }
#account-dialog .accounts-supprimes summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; }
#account-dialog .accounts-supprimes ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
#account-dialog #accounts-batch[hidden] { display: none; }

/* V246 (§437) — « Voir le bon entier » / « Voir le devis entier » : la pièce, section par section, toutes ses lignes. */
.piece-voir { min-height: 44px; margin: 8px 0; }
.piece-detail { width: min(760px, calc(100vw - 16px)); max-height: 88vh; padding: 16px; border: 0; border-radius: 16px; box-sizing: border-box; overflow: auto; }
.piece-tete { display: flex; justify-content: space-between; align-items: center; gap: 12px; position: sticky; top: -16px; margin: -16px -16px 8px; padding: 12px 16px; background: var(--p-blanc, #fff); border-bottom: 1px solid var(--line, #d6dde6); z-index: 1; }
.piece-tete h2 { margin: 0; font-size: 19px; overflow-wrap: anywhere; }
.piece-tete .button { min-height: 44px; flex: none; }
.piece-entete { margin: 0 0 12px; overflow-wrap: anywhere; }
.piece-section { margin: 14px 0; padding: 10px 0 0; border-top: 1px solid var(--line, #d6dde6); }
.piece-section.a-ranger { border-top: 2px solid var(--red, #b42318); }
.piece-section h4 { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; margin: 0 0 8px; overflow-wrap: anywhere; }
.piece-montant { margin-left: auto; font-weight: 700; }
.piece-table-wrap { overflow-x: auto; }
.piece-lignes { width: 100%; border-collapse: collapse; font-size: 14px; }
.piece-lignes th { text-align: left; font-size: 12px; color: var(--muted, #4b5b6b); font-weight: 600; padding: 4px 6px; border-bottom: 1px solid var(--line, #d6dde6); }
.piece-lignes td { padding: 6px; vertical-align: top; border-bottom: 1px solid var(--line-soft, #eef1f5); }
.piece-lignes .piece-libelle { white-space: pre-wrap; overflow-wrap: anywhere; }
.piece-lignes td:first-child { min-width: 160px; }
.piece-nombre { text-align: right; white-space: nowrap; }
.piece-texte td { font-style: italic; color: var(--muted, #4b5b6b); white-space: pre-wrap; overflow-wrap: anywhere; }
.piece-calcul { display: none; }
@media (max-width: 600px) {
  .piece-lignes, .piece-lignes tbody { display: block; }
  .piece-lignes thead, .piece-lignes td:not(:first-child) { display: none; }
  #piece-detail-dialog .piece-lignes tr { display: block; margin: 0; padding: 8px 0; border: 0; border-bottom: 1px solid var(--line-soft, #eef1f5); border-radius: 0; background: none; box-shadow: none; }
  #piece-detail-dialog .piece-lignes td { display: block; padding: 0; border: 0; min-width: 0; }
  #piece-detail-dialog .piece-lignes td:not(:first-child) { display: none; }
  .piece-calcul { display: block; margin-top: 4px; text-align: right; font-size: 14px; }
}

/* V247 (§438) — « ‹ » : revenir à l'écran précédent, sur toutes les pages sauf l'accueil (même dessin que celui de la fiche chantier). */
.retour-ecran { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; display: inline-grid; place-items: center; background: rgba(15, 42, 71, .55); color: var(--p-blanc, #fff); cursor: pointer; padding: 0; margin-right: 8px; }
.retour-ecran[hidden] { display: none; }
.retour-ecran svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.retour-ecran:focus-visible { outline: 3px solid var(--p-ambre, #f2b632); outline-offset: 2px; }
.topbar .retour-ecran { align-self: center; }
.employee-brand .retour-ecran { margin-right: 4px; }
