/* ==========================================================================
   Parcinfo - feuille de style centrale (un seul endroit pour tout changement
   d'interface). Les couleurs viennent de config/theme.php, injectees en
   variables CSS par resources/views/partials/theme-vars.blade.php.
   ========================================================================== */

@font-face {
  font-family: "Inter";
  src: url("/fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --police-titre: "Inter", "Segoe UI", system-ui, sans-serif;
  --police-texte: "Inter", "Segoe UI", system-ui, sans-serif;
  --rayon: 12px;
  --rayon-petit: 9px;
  --ombre: 0 1px 2px rgba(23, 26, 33, 0.05), 0 4px 16px rgba(23, 26, 33, 0.04);
  --duree: 180ms;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--police-texte);
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--encre);
  font-feature-settings: "cv11", "ss03";
  -webkit-font-smoothing: antialiased;
  background: var(--fond);
}

h1, h2, h3 {
  font-family: var(--police-titre);
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
}

h1 { font-size: clamp(1.5rem, 1.3rem + 0.8vw, 1.75rem); font-weight: 700; }
h2 { font-size: 1.125rem; }
p { margin: 0 0 1rem; }
a { color: var(--brand); text-underline-offset: 3px; }

/* Accessibilite : lien d'evitement et focus toujours visibles */
.lien-evitement {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: var(--encre);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: var(--rayon-petit);
  z-index: 10;
  transition: top var(--duree);
}
.lien-evitement:focus { top: 1rem; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Boutons et champs (cibles tactiles de 44 px minimum) ---------- */

.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0 1.125rem;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--brand);
  border: 1px solid var(--brand);
  border-radius: var(--rayon-petit);
  cursor: pointer;
  touch-action: manipulation;
  transition: background var(--duree), transform var(--duree);
}
.bouton:hover { background: var(--brand-hover); }
.bouton:active { transform: translateY(1px); }
.bouton[aria-busy="true"] { opacity: 0.75; cursor: progress; }
.bouton--plein { width: 100%; }
.bouton--discret {
  color: var(--encre);
  background: transparent;
  border-color: var(--bordure);
  min-height: 44px;
}
.bouton--discret:hover { background: var(--brand-soft); border-color: var(--brand); }

.champ { margin-bottom: 1.25rem; }
.champ label { display: block; font-weight: 600; margin-bottom: 0.375rem; }
.champ .aide { display: block; font-size: 0.875rem; color: var(--encre-douce); margin-top: 0.375rem; }

.saisie {
  display: flex;
  align-items: stretch;
}
.saisie input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 0.875rem;
  font: inherit;
  color: var(--encre);
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-petit);
  transition: border-color var(--duree), box-shadow var(--duree);
}
.saisie input:hover { border-color: var(--encre-douce); }
.saisie input:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft), 0 0 0 4px var(--accent);
}
.saisie input[aria-invalid="true"] { border-color: var(--danger); }
.saisie--avec-bouton input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.saisie__bouton {
  min-width: 48px;
  min-height: 48px;
  padding: 0 0.875rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--encre);
  background: var(--brand-soft);
  border: 1px solid var(--bordure);
  border-left: 0;
  border-radius: 0 var(--rayon-petit) var(--rayon-petit) 0;
  cursor: pointer;
}
.saisie__bouton:hover { border-color: var(--brand); }

.erreur {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  margin-top: 0.5rem;
  padding: 0.625rem 0.75rem;
  font-size: 0.9375rem;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--rayon-petit);
}
.erreur svg { flex: none; margin-top: 2px; }

/* ---------- Page de connexion (carte centree) ---------- */

.connexion {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 2rem 1rem;
  background: var(--fond);
}
.connexion__formulaire { width: 100%; max-width: 30rem; }
.connexion__carte {
  width: 100%;
  padding: 2.25rem 2rem 2rem;
  background: #fff;
  border: 1px solid var(--bordure);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(23, 26, 33, 0.04), 0 12px 32px rgba(23, 26, 33, 0.07);
}
.connexion__carte .logo { display: flex; justify-content: center; margin-bottom: 1.5rem; }
.connexion__carte h1 {
  margin: 0;
  padding-bottom: 1.25rem;
  font-size: 1.5rem;
  text-align: center;
  border-bottom: 1px solid var(--bordure);
}
.connexion__sous-titre { margin: 1.25rem 0 1.5rem; text-align: center; color: var(--encre-douce); }
.connexion__carte h1 + form { margin-top: 1.5rem; }
.connexion__carte .etiquette-console { display: table; margin: 0 auto 1rem; }

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  font-family: var(--police-titre);
  font-size: 1.375rem;
  font-weight: 600;
  color: inherit;
  text-decoration: none;
}
.logo__pastille {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--brand);
  background: #fff;
}
.logo--sombre .logo__pastille { color: #fff; background: var(--brand); }
.logo--sombre { color: var(--encre); }

.etiquette-console {
  display: inline-block;
  padding: 0.25rem 0.625rem;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 999px;
}
.champ__entete { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.champ__entete label { margin-bottom: 0.375rem; }
.champ__entete a { font-size: 0.9375rem; font-weight: 600; }

@media (max-width: 30rem) {
  .connexion { padding: 1rem 0.75rem; align-items: start; }
  .connexion__carte { padding: 1.75rem 1.25rem 1.5rem; }
}

/* ---------- Gabarit applicatif ---------- */

.page {
  width: 100%;
  max-width: 64rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

/* ---------- Gabarit applicatif : barre laterale claire (le menu d'un seul endroit) ---------- */

.appli { display: flex; flex-wrap: wrap; min-height: 100vh; }
.appli > .page { flex: 999 1 36rem; min-width: 0; width: auto; max-width: 76rem; margin: 0; padding: 1.75rem 1.25rem 4rem; }

.lateral {
  flex: 1 0 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--bordure);
}
.lateral__logo { font-size: 1rem; }
.lateral__compte { display: flex; align-items: center; gap: 0.625rem; margin-left: auto; font-size: 0.875rem; }
.lateral__nom { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.lateral__nom a { font-weight: 600; color: var(--encre); text-decoration: none; }
.lateral__nom a:hover { color: var(--brand); }
.lateral__sortie { padding: 0; min-height: 0; font: inherit; font-size: 0.8125rem; color: var(--encre-douce); background: none; border: 0; text-align: left; cursor: pointer; }
.lateral__sortie:hover { color: var(--brand); text-decoration: underline; }
.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 50%;
}

@media (min-width: 62rem) {
  .appli > .page { padding: 2rem 2.25rem 4rem; }
  .lateral {
    flex: 0 0 15.5rem;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 1.25rem;
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100vh;
    padding: 1.25rem 0.875rem;
    border-bottom: 0;
    border-right: 1px solid var(--bordure);
  }
  .lateral__logo { padding: 0 0.5rem; font-size: 1.0625rem; }
  .lateral__compte { margin: auto 0 0; padding: 0.875rem 0.5rem 0; border-top: 1px solid var(--bordure); }
}
.page__titre { margin-bottom: 1.5rem; }
.page__titre p { color: var(--encre-douce); margin: 0; }

.carte {
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
}
.carte--vide { padding: 2.5rem 1.5rem; text-align: center; }
.carte--vide code {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.375rem 0.625rem;
  font-size: 0.875rem;
  background: var(--fond);
  border-radius: 6px;
}

.tableau-conteneur { overflow-x: auto; }
table.tableau { width: 100%; border-collapse: collapse; min-width: 36rem; }
.tableau th,
.tableau td { padding: 0.875rem 1rem; text-align: left; border-bottom: 1px solid var(--bordure); }
.tableau th { font-size: 0.8125rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--encre-douce); }
.tableau tr:last-child td { border-bottom: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.125rem 0.625rem;
  font-size: 0.8125rem;
  font-weight: 700;
  border-radius: 999px;
}
.badge--actif { color: #166534; background: #DCFCE7; }
.badge--suspendu { color: var(--danger); background: var(--danger-soft); }

/* ---------- Pages d'erreur ---------- */

.erreur-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 2rem 1.25rem;
  text-align: center;
}
.erreur-page__code {
  font-family: var(--police-titre);
  font-size: clamp(4rem, 3rem + 6vw, 7rem);
  line-height: 1;
  color: var(--brand);
}

/* ---------- Mouvement : discret, et coupe si l'utilisateur le demande ---------- */

@media (prefers-reduced-motion: no-preference) {
  .connexion__carte,
  .page { animation: apparition 320ms ease-out both; }
}
@keyframes apparition {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ==========================================================================
   Lot 2a : navigation, formulaires, alertes, listes
   ========================================================================== */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.nav { display: flex; flex: 1 1 auto; flex-wrap: wrap; gap: 0.25rem; }
.nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  min-height: 44px;
  padding: 0 0.75rem;
  color: #3F4654;
  font-weight: 500;
  text-decoration: none;
  border-radius: var(--rayon-petit);
  transition: background var(--duree), color var(--duree);
}
.nav svg { flex: none; }
.nav a:hover { color: var(--encre); background: var(--fond); }
.nav a[aria-current="page"] { color: var(--brand); background: var(--brand-soft); font-weight: 600; }
@media (min-width: 62rem) {
  .nav { flex: 0 0 auto; flex-direction: column; flex-wrap: nowrap; gap: 2px; }
}

.page__titre--actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.alerte {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  padding: 0.75rem 1rem;
  border-radius: var(--rayon-petit);
  border: 1px solid transparent;
}
.alerte--succes { color: var(--brand); background: var(--brand-soft); border-color: var(--brand); }
.alerte--info { color: var(--encre); background: #EEF1F7; border-color: #B8C2D9; }
.alerte--erreur { color: var(--danger); background: var(--danger-soft); border-color: var(--danger); }

.formulaire { max-width: 40rem; padding: 1.5rem; margin-bottom: 1.5rem; }
.formulaire h2 { margin-bottom: 0.75rem; }
.formulaire form + form { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--bordure); }

.groupe { margin: 0 0 1.25rem; padding: 0; border: 0; min-width: 0; }
.groupe legend { padding: 0; margin-bottom: 0.75rem; font-weight: 700; font-size: 1.0625rem; }

.facultatif { font-weight: 400; color: var(--encre-douce); font-size: 0.875rem; }

select {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 0 0.875rem;
  font: inherit;
  color: var(--encre);
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-petit);
}
select:focus-visible { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft), 0 0 0 4px var(--accent); }

.rangee-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 0.5rem; }

.bouton { text-decoration: none; }
.bouton--danger { background: var(--danger); border-color: var(--danger); }
.bouton--danger:hover { background: #7E1F1F; }
.bouton--inactif { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.permissions__groupe { margin-bottom: 1rem; }
.permissions__groupe h3 { margin: 0 0 0.25rem; font-family: var(--police-texte); font-size: 0.9375rem; letter-spacing: 0; color: var(--encre-douce); }
.case {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 44px;
  padding: 0 0.25rem;
  cursor: pointer;
}
.case input { width: 22px; height: 22px; flex: none; accent-color: var(--brand); }

.badge--info { color: #2B3A67; background: #E3E8F6; }

.mdp-temporaire {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin: 0.75rem 0;
  padding: 0.75rem 1rem;
  background: var(--fond);
  border: 1px dashed var(--brand);
  border-radius: var(--rayon-petit);
}
.mdp-temporaire code {
  flex: 1 1 14rem;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  word-break: break-all;
}

.liste-definition { display: grid; grid-template-columns: max-content 1fr; gap: 0.5rem 1.5rem; margin: 0; }
.liste-definition dt { color: var(--encre-douce); }
.liste-definition dd { margin: 0; font-weight: 600; word-break: break-word; }

.cartes { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; }
.carte--lien { display: block; padding: 1.25rem; color: inherit; text-decoration: none; transition: border-color var(--duree), transform var(--duree); }
.carte--lien:hover { border-color: var(--brand); transform: translateY(-2px); }
.carte--lien h2 { margin-bottom: 0.25rem; }
.carte--lien p { margin: 0; color: var(--encre-douce); }

.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.25rem; }
.pagination__page { color: var(--encre-douce); }

/* ---------- Parc informatique (lot 3) ---------- */

.saisie textarea {
  flex: 1;
  min-width: 0;
  min-height: 6rem;
  padding: 0.75rem 0.875rem;
  font: inherit;
  color: var(--encre);
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-petit);
  resize: vertical;
}
.saisie textarea:hover { border-color: var(--encre-douce); }
.saisie textarea:focus-visible { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft), 0 0 0 4px var(--accent); }
.saisie textarea[aria-invalid="true"],
.saisie select[aria-invalid="true"] { border-color: var(--danger); }
.saisie input[type="file"] { padding: 0.625rem 0.875rem; }

.formulaire--large { max-width: 56rem; }
.grille-champs { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); column-gap: 1.25rem; }

.filtres { display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; align-items: flex-end; padding: 1rem; margin-bottom: 1rem; }
.filtres .champ { margin: 0; flex: 1 1 10rem; }
.filtres .champ--large { flex: 2 1 16rem; }
.filtres .rangee-actions { margin: 0; }

.pastilles { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1rem; padding: 0; list-style: none; }
.pastille {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 40px;
  padding: 0 0.875rem;
  color: var(--encre);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: 999px;
}
.pastille:hover { border-color: var(--brand); }
.pastille--active { color: var(--brand); background: var(--brand-soft); border-color: var(--brand); }

.badge--alerte { color: #7A4A00; background: #FBEBC8; }
.badge--neutre { color: var(--encre-douce); background: var(--fond); border: 1px solid var(--bordure); }

.rangee-actions--centre { justify-content: center; }
.texte-libre { white-space: pre-line; }
.liste-erreurs { margin: 0.5rem 0 0; padding-left: 1.25rem; }
.liste-etapes { margin: 0 0 1rem; padding-left: 1.25rem; }
.liste-etapes li { margin-bottom: 0.375rem; }

/* ---------- Tickets (lot 4) ---------- */

.liste-tickets { margin: 0; padding: 0; list-style: none; }
.liste-tickets li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.75rem; padding: 0.625rem 0; border-bottom: 1px solid var(--bordure); }
.liste-tickets li:last-child { border-bottom: 0; }

.fil { margin: 0 0 1.25rem; padding: 0; list-style: none; }
.fil__item { margin-bottom: 0.75rem; padding: 0.875rem 1rem; background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--rayon-petit); }
.fil__item--solution { border-color: var(--brand); background: var(--brand-soft); }
.fil__item--evenement { padding: 0.375rem 0.875rem; color: var(--encre-douce); font-size: 0.9375rem; background: transparent; border-style: dashed; }
.fil__entete { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; align-items: baseline; margin-bottom: 0.25rem; }
.fil__entete small { color: var(--encre-douce); }
.fil__texte { margin: 0; white-space: pre-line; word-break: break-word; }

/* ---------- Interventions et QR codes (lot 5) ---------- */

.totaux { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 0 0 1rem; padding: 0; list-style: none; }
.totaux li { flex: 1 1 10rem; padding: 0.75rem 1rem; background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--rayon-petit); }
.totaux span { display: block; font-size: 0.8125rem; color: var(--encre-douce); }
.totaux strong { font-size: 1.125rem; white-space: nowrap; }

.cellule-montant { white-space: nowrap; text-align: right; }
.tableau th.cellule-montant { text-align: right; }

.qr-carte { display: flex; flex-wrap: wrap; align-items: center; gap: 1.25rem; }
.qr-carte .qr { flex: 0 0 9rem; width: 9rem; }
.qr svg { display: block; width: 100%; height: auto; }

.etiquettes { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.75rem; margin: 0 0 1.5rem; padding: 0; list-style: none; }
.etiquette { display: flex; align-items: center; gap: 0.75rem; padding: 0.625rem; background: #fff; border: 1px dashed var(--encre-douce); border-radius: var(--rayon-petit); break-inside: avoid; }
.etiquette .qr { flex: 0 0 5.5rem; width: 5.5rem; }
.etiquette__texte { min-width: 0; line-height: 1.25; }
.etiquette__texte strong { display: block; font-size: 1rem; }
.etiquette__texte span { display: block; font-size: 0.8125rem; word-break: break-word; }
.etiquette__texte small { display: block; margin-top: 0.25rem; font-size: 0.6875rem; color: var(--encre-douce); }

@media print {
  @page { margin: 10mm; }
  body { background: #fff; }
  .lateral, .lien-evitement, .alerte, .page__titre, .sans-impression { display: none !important; }
  .appli > .page, .page { padding: 0; max-width: none; }
  .etiquettes { grid-template-columns: repeat(3, 1fr); gap: 4mm; }
  .etiquette { border-color: #000; }
}

@media (max-width: 40rem) {
  .liste-definition { grid-template-columns: 1fr; }
  .lateral .nav { order: 3; flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .carte--lien:hover { transform: none; }
}

/* ==========================================================================
   Lot 2b : liens secondaires des pages de connexion, choix du mode d'acces
   ========================================================================== */

.connexion__carte .alerte { margin-bottom: 1.5rem; }

.lien-secondaire {
  margin: 1.25rem 0 0;
  text-align: center;
}
.lien-secondaire a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.5rem;
  font-weight: 600;
}

.aide-connexion {
  margin: 1.75rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--bordure);
  font-size: 0.9375rem;
  color: var(--encre-douce);
  overflow-wrap: anywhere;
}

.case--choix {
  align-items: flex-start;
  gap: 0.875rem;
  min-height: 0;
  padding: 0.875rem 1rem;
  margin-bottom: 0.5rem;
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-petit);
  transition: border-color var(--duree), background var(--duree);
}
.case--choix input { margin-top: 0.15rem; }
.case--choix small { color: var(--encre-douce); font-size: 0.875rem; }
.case--choix:hover { border-color: var(--brand); }
.case--choix:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
