/* ==========================================================================
   Comptes — un trousseau de clés pour les sites de jeu
   Palette : ardoise bleutée + laiton (le métal des clés) + sarcelle pour l'action
   ========================================================================== */

:root {
  --fond:        #e9edf2;
  --surface:     #ffffff;
  --encre:       #1e2633;
  --encre-douce: #586274;
  --trait:       #cfd6df;
  --bande:       #f3f5f8;
  --laiton:      #a77a22;
  --laiton-pale: #f6ecd6;
  --action:      #1d5f6a;
  --action-fonce:#154850;
  --danger:      #a3352b;
  --ok:          #2d6a3e;
  --alerte:      #8a5a00;
  --rayon:       6px;
  --police: "Segoe UI", "Noto Sans", "Helvetica Neue", system-ui, -apple-system, Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond:        #161b23;
    --surface:     #1f2630;
    --encre:       #e6e9ee;
    --encre-douce: #9aa4b3;
    --trait:       #343e4c;
    --bande:       #252d39;
    --laiton:      #d6a54a;
    --laiton-pale: #3a3020;
    --action:      #4fa3ae;
    --action-fonce:#6dbcc6;
    --danger:      #e07a6f;
    --ok:          #7cc48f;
    --alerte:      #e3b45c;
    color-scheme: dark;
  }
}

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

html { font-size: 100%; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--encre);
  font: 1rem/1.5 var(--police);
}

a { color: var(--action); }
a:hover { color: var(--action-fonce); }
:focus-visible { outline: 3px solid var(--laiton); outline-offset: 2px; }

h1 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 1rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h2:not(:first-child) { margin-top: 1.5rem; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .9em; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* --- Barre supérieure ---------------------------------------------------- */

.barre {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem;
  padding: .75rem clamp(1rem, 3vw, 2rem);
  background: var(--surface);
  border-bottom: 1px solid var(--trait);
}
.marque {
  display: inline-flex; align-items: center; gap: .55rem;
  font-weight: 700; font-size: 1.1rem; color: var(--encre); text-decoration: none;
}
/* L'anneau du trousseau */
.anneau {
  width: 1.1rem; height: 1.1rem; border-radius: 50%;
  border: 3px solid var(--laiton);
  box-shadow: .35rem .3rem 0 -.2rem var(--laiton);
}
.barre nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.barre nav a { color: var(--encre-douce); text-decoration: none; padding: .25rem 0; border-bottom: 2px solid transparent; }
.barre nav a:hover { color: var(--encre); }
.barre nav a[aria-current="page"] { color: var(--encre); border-bottom-color: var(--laiton); }
.deconnexion { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.qui { color: var(--encre-douce); font-size: .9rem; }

main { padding: 1.5rem clamp(1rem, 3vw, 2rem) 4rem; max-width: 1400px; margin: 0 auto; }

/* --- Blocs ---------------------------------------------------------------- */

.carte {
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}
.carte-etroite { max-width: 26rem; margin: 3rem auto; }
.colonnes { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: 0 1.5rem; }
.titre-page { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 1rem; }
.fil { margin: 0 0 .25rem; font-size: .9rem; }
.aide { color: var(--encre-douce); font-size: .9rem; margin: .25rem 0 .75rem; max-width: 70ch; }
.facultatif { color: var(--encre-douce); font-weight: 400; font-size: .85rem; }
.zone-danger { border-color: var(--danger); }
.zone-danger h2 { color: var(--danger); }

.infos { display: grid; grid-template-columns: auto 1fr; gap: .25rem 1rem; margin: 1rem 0 0; font-size: .9rem; }
.infos dt { color: var(--encre-douce); }
.infos dd { margin: 0; }

.liste-sites { list-style: none; padding: 0; margin: 0 0 1rem; }
.liste-sites li { display: flex; align-items: center; gap: .75rem; padding: .5rem 0; border-bottom: 1px solid var(--trait); }
.liste-sites li:last-child { border-bottom: 0; }
.liste-sites a { font-weight: 600; }

.pastille {
  display: inline-block; font-size: .8rem; font-weight: 600;
  padding: .05rem .5rem; border-radius: 1rem;
  background: var(--laiton-pale); color: var(--laiton);
}
.pastille-off { background: var(--bande); color: var(--encre-douce); vertical-align: middle; }
.code-appli { font-size: 1rem; font-weight: 400; color: var(--encre-douce); }

/* --- Messages ------------------------------------------------------------- */

.flash { padding: .75rem 1rem; border-radius: var(--rayon); border-left: 4px solid; background: var(--surface); margin: 0 0 1rem; }
.flash-ok     { border-color: var(--ok); }
.flash-erreur { border-color: var(--danger); }
.flash-alerte { border-color: var(--alerte); }

.secret {
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem;
  padding: 1rem 1.25rem; margin-bottom: 1.5rem;
  background: var(--laiton-pale); border: 1px solid var(--laiton); border-radius: var(--rayon);
}
.secret p { margin: 0; flex-basis: 100%; }
.secret code { font-size: 1.15rem; padding: .3rem .6rem; background: var(--surface); border-radius: 4px; user-select: all; word-break: break-all; }

/* --- Formulaires ---------------------------------------------------------- */

label { display: block; font-weight: 600; font-size: .9rem; }
input[type=text], input[type=email], input[type=password], input[type=url],
input[type=search], input[type=number], select {
  display: block; width: 100%; margin-top: .3rem;
  padding: .5rem .65rem;
  font: inherit; font-weight: 400; color: var(--encre);
  background: var(--surface); border: 1px solid var(--trait); border-radius: 4px;
}
input:focus { border-color: var(--action); }
input.court { width: 5.5rem; }
input[type=checkbox] { accent-color: var(--action); width: 1.05rem; height: 1.05rem; margin: 0; vertical-align: middle; }
label.case { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; }
legend { font-weight: 600; font-size: .9rem; margin-bottom: .4rem; padding: 0; }

.pile { display: grid; gap: .9rem; }
.pile .bouton { justify-self: start; }
.formulaire-grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); gap: 1rem 1.5rem; }
.pleine-largeur { grid-column: 1 / -1; }
.ligne { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem 1rem; margin-top: 1rem; }
.ligne label { flex: 1 1 12rem; }
.ligne-compacte { margin: 0; align-items: center; flex-wrap: nowrap; }
.ligne-compacte input { margin-top: 0; }
.filtres label { flex: 0 1 14rem; }

.bouton {
  display: inline-block; cursor: pointer;
  padding: .55rem 1.1rem;
  font: inherit; font-weight: 600; text-decoration: none;
  color: #fff; background: var(--action);
  border: 1px solid var(--action); border-radius: 4px;
}
.bouton:hover { background: var(--action-fonce); border-color: var(--action-fonce); color: #fff; }
.bouton-second { color: var(--action); background: transparent; }
.bouton-second:hover { color: var(--action-fonce); background: var(--bande); }
.bouton-danger { background: var(--danger); border-color: var(--danger); }
.bouton-danger:hover { background: var(--danger); filter: brightness(.9); }
.bouton:disabled { opacity: .5; cursor: default; }
@media (prefers-color-scheme: dark) {
  .bouton:not(.bouton-second) { color: #10161d; }
  .bouton:not(.bouton-second):hover { color: #10161d; }
}
.lien { background: none; border: 0; padding: 0; font: inherit; color: var(--action); cursor: pointer; text-decoration: underline; }
.lien-danger { color: var(--danger); }

/* --- Grille des accès : l'élément central ------------------------------- */

.outils-grille { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem 2rem; margin-bottom: 1rem; }
.filtre { flex: 0 1 22rem; }

.grille-defilement { overflow-x: auto; border: 1px solid var(--trait); border-radius: var(--rayon); background: var(--surface); }

.grille { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .95rem; }
.grille th, .grille td { padding: .45rem .75rem; border-bottom: 1px solid var(--trait); text-align: center; white-space: nowrap; }
.grille thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
.grille .tete-appli { font-size: 1rem; padding-top: .7rem; border-bottom: 0; }
.grille .tete-appli a { color: var(--encre); text-decoration: none; }
.grille .tete-appli a:hover { text-decoration: underline; }
.grille .sous-tete { font-weight: 600; font-size: .8rem; color: var(--encre-douce); }
.grille .debut-appli { border-left: 1px solid var(--trait); }
.grille .bande { background: var(--bande); }
.grille thead .bande { background: var(--bande); }

.grille .col-compte {
  text-align: left; position: sticky; left: 0; z-index: 2;
  background: var(--surface); min-width: 13rem;
}
.grille thead .col-compte { z-index: 3; vertical-align: bottom; }
.grille tbody .col-compte a { font-weight: 600; color: var(--encre); text-decoration: none; }
.grille tbody .col-compte a:hover { text-decoration: underline; }
.grille .login { display: block; font-weight: 400; font-size: .8rem; color: var(--encre-douce); }
.grille tbody tr:last-child > * { border-bottom: 0; }
.grille tbody tr:hover > * { background-image: linear-gradient(rgba(127,127,127,.06), rgba(127,127,127,.06)); }

/* Les rôles sont en laiton, l'accès en sarcelle : on lit la grille d'un coup d'œil */
.grille .case-role { accent-color: var(--laiton); }
.grille input[type=checkbox] { width: 1.2rem; height: 1.2rem; cursor: pointer; }

.grille tr.inactif .col-compte a { color: var(--encre-douce); text-decoration: line-through; }
.grille tr.modifie > .col-compte { box-shadow: inset 4px 0 0 var(--laiton); }
.grille tr[hidden] { display: none; }
.vide { color: var(--encre-douce); text-align: center; padding: 2rem !important; }

.barre-enregistrer {
  position: sticky; bottom: 0;
  display: flex; justify-content: flex-end; align-items: center; gap: 1rem;
  padding: .75rem 0; margin-bottom: 1.5rem;
  background: linear-gradient(transparent, var(--fond) 35%);
}
#compteur-modifs { color: var(--laiton); font-weight: 600; font-size: .9rem; }

/* --- Tableaux simples ----------------------------------------------------- */

.tableau { border-collapse: collapse; width: 100%; font-size: .92rem; }
.tableau th, .tableau td { padding: .5rem .75rem; border-bottom: 1px solid var(--trait); text-align: left; vertical-align: middle; }
.tableau thead th { color: var(--encre-douce); font-size: .82rem; }
.tableau tbody tr:last-child td { border-bottom: 0; }
.tableau tr.inactif td { color: var(--encre-douce); }
.carte .grille-defilement { border: 0; }

.resultat { font-weight: 600; }
.resultat-ok { color: var(--ok); }
.resultat-mauvais_mdp, .resultat-inconnu, .resultat-bloque { color: var(--danger); }
.resultat-inactif, .resultat-sans_acces { color: var(--alerte); }

@media (max-width: 640px) {
  .deconnexion { margin-left: 0; width: 100%; justify-content: space-between; }
  .grille .col-compte { min-width: 9rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
