/* Hirely — design tokens et base commune (formulaire public + back-office) */
:root {
  --bg: #f6f7f9; --card: #ffffff; --ink: #1a2233; --muted: #66707f;
  --line: #e3e6ea; --brand: #2456e6; --brand-ink: #ffffff;
  --ok: #157a45; --warn: #96660f; --danger: #c0392b; --danger-bg: #fdecea;
  --flag: #c0392b; --radius: 12px; --shadow: 0 1px 3px rgba(16, 24, 40, .08);
  --st-a_trier: #64748b; --st-preselectionne: #0b7d73; --st-contacte: #2563eb; --st-entretien: #7c3aed;
  --st-offre: #96660f; --st-recrute: #157a45; --st-refuse: #c0392b; --st-vivier: #0e7490;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10141c; --card: #1a2130; --ink: #e8ecf3; --muted: #94a0b3;
    --line: #2a3346; --brand: #4d7bff; --danger-bg: #3a1f1c; --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3 { line-height: 1.25; }
a { color: var(--brand); }
button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
label { display: block; font-weight: 600; margin: 14px 0 4px; font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.btn {
  display: inline-block; background: var(--brand); color: var(--brand-ink); border: 0;
  border-radius: 10px; padding: 11px 18px; font-weight: 650;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-sm { padding: 6px 10px; border-radius: 8px; font-size: 13px; }
.err { color: var(--danger); font-size: 13px; margin-top: 3px; }
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 650;
  color: #fff; background: var(--muted); white-space: nowrap;
}
.badge.site { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.flag {
  display: inline-flex; align-items: center; gap: 5px; background: var(--danger-bg); color: var(--danger);
  border: 1px solid var(--danger); border-radius: 8px; padding: 3px 8px; font-size: 12.5px; font-weight: 650;
}
.liste-info { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 10px 2px; font-size: 13px; }

/* Barres de statistiques — CSS pur, aucune bibliothèque de graphiques (zéro dépendance) */
.bar { display: inline-block; flex: 1; height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; }
.stat-l { display: flex; align-items: center; gap: 10px; margin: 7px 0; }
.stat-lbl { flex: 0 0 168px; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-n { flex: 0 0 46px; text-align: right; }
.stat-taux { flex: 0 0 52px; text-align: right; font-size: 12.5px; }
@media (max-width: 640px) { .stat-lbl { flex-basis: 96px; } .stat-taux { flex-basis: 40px; } }
/* « Par besoin » : le libellé EST l'information (poste — réf), il lui faut de la place —
   168 px coupaient tous les postes au même endroit. L'ellipse reste pour les extrêmes. */
.libelles-larges .stat-lbl { flex-basis: 280px; }
@media (max-width: 640px) { .libelles-larges .stat-lbl { flex-basis: 42%; } }
/* Ligne « Par besoin » : le libellé est un lien vers la fiche du besoin */
.stat-lien { color: inherit; text-decoration: none; }
.stat-lien:hover, .stat-lien:focus-visible { color: var(--brand); text-decoration: underline; }

/* Doublon : information, pas alerte — volontairement distinct du rouge des signalements (.flag) */
.dup {
  display: inline-flex; align-items: center; gap: 5px;
  background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn);
  border: 1px solid var(--warn); border-radius: 8px; padding: 3px 8px; font-size: 12.5px; font-weight: 650;
}
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0; }
.toolbar select, .toolbar input { width: auto; min-width: 120px; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr.row { cursor: pointer; }
tr.row:hover { background: color-mix(in srgb, var(--brand) 6%, transparent); }
.muted { color: var(--muted); }
.right { text-align: right; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
dialog {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink);
  max-width: 560px; width: calc(100vw - 32px); padding: 22px; box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(10, 14, 22, .45); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); border-radius: 10px; padding: 10px 18px;
  font-weight: 600; box-shadow: var(--shadow); z-index: 99; animation: fadein .18s ease;
}
@keyframes fadein { from { opacity: 0; transform: translate(-50%, 8px); } }
.timeline { list-style: none; padding: 0; margin: 8px 0; }
.timeline li { padding: 6px 0 6px 16px; border-left: 2px solid var(--line); font-size: 13.5px; }
.timeline .muted { font-size: 12px; }

/* Puces KPI cliquables : le raccourci du matin — un clic filtre la liste, un re-clic l'enlève */
.kpi-clic { cursor: pointer; user-select: none; }
.kpi-clic:hover { border-color: var(--brand); }
.kpi-on { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }

/* Sections de l'onglet Stats : ce que la période pilote, puis le cumulatif — la frontière
   doit se voir de loin, l'aide enfouie dans un bloc ne suffisait pas */
.stats-section { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 26px 0 12px; padding-top: 14px; border-top: 2px solid var(--line); }
.stats-section:first-child { margin-top: 4px; padding-top: 0; border-top: 0; }
.stats-section h2 { margin: 0; font-size: 17px; }

/* Fiche candidat : la barre d'action reste visible quelle que soit la longueur de la fiche —
   changer un statut en haut ne doit pas obliger à chercher « Enregistrer » plus bas */
.fiche-footer {
  position: sticky; bottom: -22px; /* colle au bord du dialogue malgré son padding */
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border-top: 1px solid var(--line);
  margin: 18px -22px -22px; padding: 12px 22px;
}
/* Droit d'effacement : replié en bas de fiche — un geste annuel n'occupe pas la position n° 1 */
.rgpd-bloc { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.rgpd-bloc summary { cursor: pointer; color: var(--muted); font-size: 13px; }

/* Étape d'entonnoir jamais portée par l'historique : compte hérité, pas mesuré — grisée */
.etape-heritee { opacity: .55; }

/* Formulaire public, petit écran : l'indicatif écrasait le numéro (~90 px pour LE champ
   critique du matching). Les deux s'empilent, chacun pleine largeur. */
@media (max-width: 480px) {
  .tel-row { flex-wrap: wrap; }
  .tel-row select, .tel-row input { flex: 1 1 100% !important; width: 100% !important; }
}

/* Back-office, petit écran : nav sur une ligne défilable (elle se cassait en deux lignes
   mêlées au badge utilisateur), et la liste candidats en CARTES — un tableau à défilement
   horizontal cache statut et date, l'essentiel du tri. */
@media (max-width: 700px) {
  /* !important : le <style> inline d'index.html (flex-wrap: wrap) passe après cette feuille */
  nav.top { flex-wrap: nowrap !important; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  nav.top .tab { white-space: nowrap; }
  nav.top #whoami { display: none; } /* l'entreprise reste dans le titre de l'onglet */
}
@media (max-width: 640px) {
  #tbl-candidats thead { display: none; }
  #tbl-candidats, #tbl-candidats tbody { display: block; }
  #tbl-candidats tr.row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      'sel cand statut'
      'sel poste date'
      'sel canal canal';
    gap: 2px 10px; align-items: start;
    padding: 10px 6px; border-bottom: 1px solid var(--line);
  }
  #tbl-candidats tr.row td { display: block; border: 0; padding: 0; background: none; }
  #tbl-candidats tr.row td:nth-child(1) { grid-area: sel; padding-top: 3px; }
  #tbl-candidats tr.row td:nth-child(2) { grid-area: cand; }
  #tbl-candidats tr.row td:nth-child(3) { grid-area: poste; font-size: 13px; color: var(--muted); }
  #tbl-candidats tr.row td:nth-child(4) { grid-area: canal; font-size: 12px; color: var(--muted); }
  #tbl-candidats tr.row td:nth-child(5) { grid-area: statut; justify-self: end; }
  #tbl-candidats tr.row td:nth-child(6) { grid-area: date; justify-self: end; font-size: 12px; color: var(--muted); }
}

/* Petit écran : les puces KPI se partagent la largeur au lieu de laisser des trous */
@media (max-width: 640px) { .kpi { flex: 1 1 auto; } }

/* Petit écran : le pied de fiche passait la méta « reçu le… » en colonne étroite et
   poussait « Enregistrer → suivant » hors écran. La méta prend sa ligne, les boutons
   se partagent la leur — rien ne sort du cadre. */
@media (max-width: 640px) {
  .fiche-footer { flex-wrap: wrap; }
  .fiche-footer .hint { flex: 1 1 100%; }
  .fiche-footer button { flex: 1 1 auto; }
}

/* Petit écran : Besoins en cartes — le tableau coupait statut, objectif et candidats,
   exactement ce qu'on vient y lire (même leçon que la liste candidats). */
@media (max-width: 640px) {
  #tbl-besoins thead { display: none; }
  #tbl-besoins, #tbl-besoins tbody { display: block; }
  #tbl-besoins tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      'ref statut'
      'poste poste'
      'compte site';
    gap: 2px 10px; align-items: start;
    padding: 10px 6px; border-bottom: 1px solid var(--line);
  }
  #tbl-besoins tbody tr td { display: block; border: 0; padding: 0; background: none; }
  #tbl-besoins tbody tr td:nth-child(1) { grid-area: ref; }
  #tbl-besoins tbody tr td:nth-child(2) { grid-area: poste; font-size: 13px; }
  #tbl-besoins tbody tr td:nth-child(3), /* département */
  #tbl-besoins tbody tr td:nth-child(5), /* ouvert le */
  #tbl-besoins tbody tr td:nth-child(8) { display: none; } /* candidats (lien) — la fiche les donne */
  #tbl-besoins tbody tr td:nth-child(4) { grid-area: site; justify-self: end; font-size: 13px; }
  #tbl-besoins tbody tr td:nth-child(6) { grid-area: statut; justify-self: end; text-align: right; }
  #tbl-besoins tbody tr td:nth-child(7) { grid-area: compte; font-size: 13px; }
  /* Ligne « état vide » : une seule cellule, pas de grille */
  #tbl-besoins tbody tr:has(td[colspan]) { display: block; }
}

/* Petit écran : Signalements en cartes — motif et contact étaient tronqués mi-mot. */
@media (max-width: 640px) {
  #tbl-signalements thead { display: none; }
  #tbl-signalements, #tbl-signalements tbody { display: block; }
  #tbl-signalements tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      'nom statut'
      'contact contact'
      'motif motif'
      'expire lever';
    gap: 2px 10px; align-items: start;
    padding: 10px 6px; border-bottom: 1px solid var(--line);
  }
  #tbl-signalements tbody tr td { display: block; border: 0; padding: 0; background: none; }
  #tbl-signalements tbody tr td:nth-child(1) { grid-area: nom; }
  #tbl-signalements tbody tr td:nth-child(2) { grid-area: contact; font-size: 13px; overflow-wrap: anywhere; }
  #tbl-signalements tbody tr td:nth-child(3) { grid-area: motif; font-size: 13px; }
  #tbl-signalements tbody tr td:nth-child(4) { display: none; } /* auteur — déjà masqué (hide-sm) */
  #tbl-signalements tbody tr td:nth-child(5) { grid-area: expire; font-size: 13px; color: var(--muted); align-self: center; }
  #tbl-signalements tbody tr td:nth-child(5):not(:empty)::before { content: 'expire le '; }
  #tbl-signalements tbody tr td:nth-child(6) { grid-area: statut; justify-self: end; }
  #tbl-signalements tbody tr td:nth-child(7) { grid-area: lever; justify-self: end; }
  #tbl-signalements tbody tr:has(td[colspan]) { display: block; }
}

/* Petit écran : les tableaux de Stats et Réglages défilent DANS leur bloc — sans quoi
   c'est la page entière qui glisse horizontalement (Par recruteur, Équipe…). */
@media (max-width: 720px) {
  #stats-vue table, #tab-reglages table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  #stats-vue table tbody, #tab-reglages table tbody { display: table-row-group; }
  #stats-vue table thead, #tab-reglages table thead { display: table-header-group; }
}

/* Navigation de fiche en mode triage : ‹ position › à droite du titre */
.fiche-nav { margin-left: auto; display: flex; align-items: center; gap: 6px; white-space: nowrap; }

/* Attente réseau > 250 ms : barre fine qui défile en haut — « rien ne bouge » fait re-cliquer */
body.reseau-attente::before {
  content: ''; position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 100;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
  background-size: 40% 100%; background-repeat: no-repeat;
  animation: reseau-defile 1s linear infinite;
}
@keyframes reseau-defile { from { background-position: -40% 0; } to { background-position: 140% 0; } }
@media (prefers-reduced-motion: reduce) {
  body.reseau-attente::before { animation: none; background: var(--brand); }
}
.toast.erreur { background: var(--danger); color: #fff; }

/* Lignes-boutons et puces : le clavier est un citoyen de première classe */
tr.row:focus-visible, .kpi-clic:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
tr.row { cursor: pointer; }
/* La cellule de sélection entière est la cible tactile, pas la case de 13 px */
#tbl-candidats td:first-child { cursor: pointer; min-width: 40px; }
/* Pointage après embauche : l'état sélectionné est un ÉTAT (sombre), pas un bouton d'action */
.pointage-on { background: var(--ink); color: var(--card); border-color: var(--ink); }
