/* Composants communs (maquette B) : boutons, champs, alertes, attente, fenêtres, pastilles. */

/* --- Boutons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--rayon-petit);
  border: 1px solid var(--filet-fort);
  background: var(--carte);
  color: var(--encre);
  font-weight: 600;
  text-align: center;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.btn:hover {
  border-color: var(--encre);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn[aria-busy="true"] {
  cursor: progress;
}

.btn.primaire {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--sur-accent);
}

.btn.primaire:hover:not(:disabled) {
  background: var(--accent-fort);
  border-color: var(--accent-fort);
}

.btn.danger {
  color: var(--echec-t);
  border-color: var(--danger-bord);
}

.btn.danger:hover:not(:disabled) {
  background: var(--echec-f);
  border-color: var(--echec-t);
}

.btn.petit {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.875rem;
}

.btn.lien {
  border-color: transparent;
  background: none;
  color: var(--accent);
  padding: 0 6px;
}

.btn.lien:hover {
  text-decoration: underline;
  border-color: transparent;
}

.btn.large {
  width: 100%;
}

/* --- Champs --- */
.formulaire {
  display: flex;
  flex-direction: column;
}

.champ + .champ {
  margin-top: 16px;
}

.champ label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}

.champ-aide {
  margin: -2px 0 6px;
  color: var(--sourdine);
  font-size: 0.875rem;
}

.champ input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--bord-champ);
  border-radius: var(--rayon-petit);
  padding: 0 12px;
  font: inherit;
  background: var(--carte);
  color: var(--encre);
}

.champ input:hover {
  border-color: var(--sourdine);
}

.champ input:disabled {
  background: var(--champ-inactif);
  color: var(--sourdine);
}

.champ input[aria-invalid="true"] {
  border-color: var(--echec-t);
}

/* Code à usage unique : chiffres larges et espacés (maquette « Code de vérification »). */
.champ input.code {
  font-family: var(--chasse);
  font-size: 1.375rem;
  letter-spacing: 0.3em;
  text-align: center;
}

.champ-erreur {
  margin-top: 4px;
  color: var(--echec-t);
  font-size: 0.875rem;
  font-weight: 600;
}

.champ-erreur:empty {
  display: none;
}

/* Mot de passe avec bouton œil. */
.mdp {
  position: relative;
}

.mdp input {
  padding-right: 48px;
}

/* Edge ajoute son propre œil : un seul bouton, le nôtre (étiqueté, testé). */
.mdp input::-ms-reveal,
.mdp input::-ms-clear {
  display: none;
}

.mdp .voir {
  position: absolute;
  right: 1px;
  top: 1px;
  bottom: 1px;
  width: 44px;
  border: 0;
  border-radius: var(--rayon-petit);
  background: none;
  color: var(--sourdine);
  display: flex;
  align-items: center;
  justify-content: center;
}

.mdp .voir:hover {
  color: var(--encre);
}

/* --- Messages --- */
.message:empty {
  display: none;
}

.alerte {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--rayon);
  border: 1px solid var(--echec-bord);
  background: var(--echec-f);
  color: var(--echec-t);
  overflow-wrap: anywhere;
}

.alerte > svg {
  margin-top: 2px;
}

.alerte-texte {
  min-width: 0;
}

.alerte .message-erreur {
  color: var(--echec-t);
  font-weight: 600;
}

.alerte p + p {
  margin-top: 2px;
  color: var(--encre);
}

.alerte details {
  margin-top: 8px;
  font-size: 0.875rem;
  color: var(--encre);
}

/* Résumé replié : garde son triangle (list-item) ; cible de 44 px par le remplissage. */
.alerte summary {
  display: list-item;
  width: max-content;
  padding: 12px 0;
  margin: -12px 0;
  color: var(--accent);
  cursor: pointer;
}

.alerte details[open] summary {
  margin-bottom: 0;
}

.alerte dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
}

.alerte dt {
  color: var(--sourdine);
}

.alerte dd {
  margin: 0;
}

.message-info {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--rayon);
  background: var(--cours-f);
  color: var(--encre);
}

/* Attente : rond tournant (immobile si prefers-reduced-motion). */
.attente {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--rayon);
  background: var(--cours-f);
  color: var(--encre);
}

.attente .btn {
  margin-top: 10px;
  background: var(--carte);
}

.rond {
  display: inline-block;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border-radius: 50%;
  border: 2.5px solid var(--rond);
  border-top-color: var(--accent);
  animation: tour 0.9s linear infinite;
  flex: none;
}

@keyframes tour {
  to {
    transform: rotate(360deg);
  }
}

.chargement {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 0;
  color: var(--sourdine);
}

.etat-erreur {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.fraicheur {
  color: var(--sourdine);
  font-size: 0.8125rem;
}

/* --- Fenêtre modale --- */
.voile {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: var(--voile);
}

.modale {
  width: min(520px, 100%);
  max-height: calc(100vh - 24px);
  overflow: auto;
  border-radius: 12px;
  color: var(--encre);
  background: var(--carte);
  box-shadow: 0 12px 40px var(--ombre-modale);
}

.modale:focus {
  outline: none;
}

.modale-titre {
  padding: 24px 24px 0;
}

.modale-corps {
  padding: 14px 24px 24px;
}

.modale-corps > .sous,
.modale-corps > div > .sous:first-child,
.formulaire > .sous:first-child {
  margin-bottom: 16px;
}

.pied-modale {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.etape-pied {
  margin-right: auto;
  color: var(--sourdine);
  font-size: 0.875rem;
}

/* --- Pastilles de statut et d'état (icône + texte) --- */
.statut,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: max-content;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  background: var(--retire-f);
  color: var(--retire-t);
  white-space: nowrap;
}

.statut svg,
.badge svg {
  width: 1.05em;
  height: 1.05em;
}

.statut-pointe {
  color: var(--ok-t);
  background: var(--ok-f);
}

.statut-en-cours {
  color: var(--cours-t);
  background: var(--cours-f);
}

.statut-echec {
  color: var(--echec-t);
  background: var(--echec-f);
}

.statut-manque {
  color: var(--manque-t);
  background: var(--manque-f);
}

.statut-retire-du-planning {
  color: var(--retire-t);
  background: var(--retire-f);
}

.badge {
  background: var(--ok-f);
  color: var(--ok-t);
}

.badge.defaut {
  background: var(--echec-f);
  color: var(--echec-t);
}

.badge.desactive {
  background: var(--retire-f);
  color: var(--retire-t);
}

/* --- Filtres (onglets Actifs / Désactivés) --- */
.filtres {
  display: flex;
  gap: 4px;
  width: max-content;
  max-width: 100%;
  padding: 3px;
  border-radius: var(--rayon);
  background: var(--filtres-fond);
}

.filtre {
  min-height: 36px;
  padding: 6px 14px;
  border: 0;
  border-radius: var(--rayon-petit);
  background: none;
  color: var(--sourdine);
  font-weight: 600;
}

.filtre[aria-selected="true"],
.filtre[aria-pressed="true"] {
  background: var(--carte);
  color: var(--encre);
  box-shadow: 0 1px 2px var(--ombre-filtre);
}

/* --- Cases à cocher en cartes --- */
.liste-cases {
  list-style: none;
  margin: 0;
  padding: 0;
}

.liste-cases li + li {
  margin-top: 8px;
}

.coche {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: var(--cible);
  padding: 10px 12px;
  border: 1px solid var(--filet);
  border-radius: var(--rayon);
  font-weight: 500;
  cursor: pointer;
}

.coche:hover {
  border-color: var(--filet-fort);
}

.coche input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
  flex: none;
}

.coche small {
  margin-left: auto;
  color: var(--sourdine);
  font-weight: 400;
  text-align: right;
}

.outils-liste {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

@media (max-width: 720px) {
  /* Cibles tactiles d'au moins 44 px sur téléphone. */
  .btn,
  .btn.petit,
  .filtre {
    min-height: var(--cible);
  }

  .etape-pied {
    flex-basis: 100%;
  }

  .pied-modale .btn {
    flex: 1 1 auto;
  }

  .modale-titre {
    padding: 20px 18px 0;
  }

  .modale-corps {
    padding: 12px 18px 20px;
  }
}

/* --- Phase 8 : composants partagés des écrans Accueil, Historique, Paramètres --- */

/* Section d'un écran (titre h2 + contenu). */
.bloc > h2 {
  margin-bottom: 12px;
}

/* Message de retour (statut ou erreur) posé par un module ; vide, il disparaît (voir plus haut). */
p.message {
  padding: 10px 14px;
  border-radius: var(--rayon);
  background: var(--cours-f);
  color: var(--encre);
}

.pied-formulaire {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.champ select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--bord-champ);
  border-radius: var(--rayon-petit);
  padding: 0 10px;
  font: inherit;
  background: var(--carte);
  color: var(--encre);
}

/* Sous-navigation de Paramètres : pastilles-liens, la page courante en accent. */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: var(--cible);
  padding: 0 16px;
  border: 1px solid var(--filet-fort);
  border-radius: 999px;
  background: var(--carte);
  color: var(--encre);
  font-weight: 600;
  text-decoration: none;
}

.chip:hover {
  border-color: var(--accent);
}

.chip[aria-current="page"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--sur-accent);
}

/* Groupe de réglages : une carte, une ligne par réglage. */
.groupe {
  margin-bottom: 14px;
  border: 1px solid var(--filet);
  border-radius: var(--rayon);
  background: var(--carte);
}

.reglage {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
}

.reglage + .reglage {
  border-top: 1px solid var(--filet);
}

.reglage .nom {
  font-weight: 600;
}

.reglage .champ {
  flex: 0 1 320px;
}

/* Réglage avec champ : le champ à gauche, son unité juste à côté, alignée sur la saisie. */
.reglage:has(> .champ) {
  align-items: flex-end;
  justify-content: flex-start;
}

.reglage > .champ + small {
  padding-bottom: 10px;
}

.bloc > .btn {
  margin-top: 10px;
}

a.btn {
  text-decoration: none;
}

/* Interrupteur (role="switch") : état porté par aria-checked, texte « Active / En pause » à côté. */
.interrupteur-bloc {
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.interrupteur {
  position: relative;
  flex: none;
  width: 56px;
  height: var(--cible);
  padding: 0;
  border: 2px solid var(--bord-champ);
  border-radius: 999px;
  background: var(--champ-inactif);
  cursor: pointer;
}

.interrupteur::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 5px;
  width: 22px;
  height: 22px;
  margin-top: -11px;
  border-radius: 50%;
  background: var(--bord-champ);
  transition: left 0.15s;
}

.interrupteur[aria-checked="true"] {
  border-color: var(--accent);
  background: var(--accent);
}

.interrupteur[aria-checked="true"]::after {
  left: 27px;
  background: var(--sur-accent);
}

@media (prefers-reduced-motion: reduce) {
  .interrupteur::after {
    transition: none;
  }
}

/* Tableaux de pointages, de comptes et de journaux : même gabarit que le tableau du mois (.tableau,
   empilé en cartes sous 720 px) ; les actions d'une ligne passent à la ligne. */
.tableau-comptes .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tableau pre {
  margin: 6px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.8125rem;
}

.tableau summary {
  min-height: 32px;
  color: var(--accent);
  cursor: pointer;
}

@media (max-width: 720px) {
  .interrupteur {
    min-width: 56px;
  }

  .reglage {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .reglage .champ {
    flex-basis: auto;
  }

  .reglage:has(> .champ) {
    align-items: stretch;
  }

  .reglage > .champ + small {
    padding-bottom: 0;
  }

  .chip,
  .tableau summary {
    min-height: var(--cible);
  }

  .tableau summary {
    display: flex;
    align-items: center;
  }
}
