/* =============================================================================
   FLEUVA — ÉCRANS D'ACCÈS (connexion, inscription, mot de passe, vérification)
   Panneau bleu nuit à gauche (≥ 1024px : promesse courte, applications en pictogrammes, liens d'aide).
   À droite, la grammaire du logiciel (fleuva-design-system-software-theme.css) : barre supérieure
   blanche filetée comme l'application, formulaire posé directement sur le fond (aucune carte),
   libellés en petites capitales, contrôles compacts, bouton principal du thème (--primary),
   barre d'état en pied de page. Couleurs = variables du thème : le mode sombre
   (html[data-mode="dark"]) suit sans code ici. Classes et attributs utilisés par les scripts
   (auth-password-*, pwd-rules/.met, auth-match-msg, auth-submit, auth-spinner, data-*) conservés.
   ========================================================================== */

.auth-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
}

/* Colonne de travail : barre supérieure, formulaire, barre d'état. */
.auth-main {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

/* ---- Panneau de marque (≥ 1024px) : bleu nuit, promesse courte, pictogrammes, liens d'aide ---- */
.auth-sidebar {
  width: 44%;
  max-width: 600px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  padding: 40px 48px 32px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  color: #ffffff;
  background:
    radial-gradient(circle at 85% 10%, rgba(184, 11, 44, .28) 0, transparent 42%),
    radial-gradient(circle at 0% 100%, rgba(34, 52, 74, .9) 0, transparent 55%),
    #0d1b29;
}
.auth-sidebar-brand img { height: 28px; width: auto; display: block; }

.auth-sidebar-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 28px;
  max-width: 460px;
}

.auth-sidebar-title {
  margin: 0;
  font-size: clamp(30px, 2.9vw, 40px);
  font-weight: 750;
  line-height: 1.12;
  letter-spacing: -.03em;
  color: #ffffff;
}
.auth-sidebar-title span { display: block; color: #f2a3b2; }

.auth-sidebar-text { margin: -14px 0 0; font-size: 15px; line-height: 1.55; color: #b9c5cf; }

/* Applications en pictogrammes : 4 × 2 tuiles, un mot chacune. */
.auth-apps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.auth-apps li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 14px 6px 11px;
  border: 1px solid #22344a;
  border-radius: var(--radius-lg);
  background: rgba(19, 38, 58, .72);
  font-size: 11.5px;
  font-weight: 500;
  color: #c3cdd6;
  text-align: center;
  min-width: 0;
}
.auth-apps li span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-apps .material-symbols-outlined { font-size: 24px; color: #ffffff; }

.auth-proof { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 12.5px; color: #9aabb8; }
.auth-proof li { display: inline-flex; align-items: center; gap: 6px; }
.auth-proof .material-symbols-outlined { font-size: 16px; color: #6fd18f; }

.auth-sidebar-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 18px;
  border-top: 1px solid #22344a;
}
.auth-sidebar-links a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid #22344a;
  border-radius: var(--radius-md);
  font-size: 12.5px;
  font-weight: 600;
  color: #dbe3ea;
  text-decoration: none;
}
.auth-sidebar-links a:hover { background: #13263a; color: #ffffff; border-color: #34495f; }
.auth-sidebar-links .material-symbols-outlined { font-size: 17px; color: #9aabb8; }
.auth-sidebar a:focus-visible { outline-color: #ffffff; }

/* Panneau affiché (≥ 1024px) : il porte déjà le logo et les liens d'aide. Panneau masqué par le super admin :
   logo dans la barre supérieure et liens d'aide dans la barre d'état, à toutes les tailles. */
@media (min-width: 1024px) {
  .auth-shell.has-panel .auth-topbar-brand { visibility: hidden; }
  .auth-shell.has-panel .auth-statusbar-help { display: none !important; }
}
@media (max-width: 1023px) {
  .auth-sidebar { display: none; }
}

.auth-shell a:focus-visible,
.auth-shell button:focus-visible,
.auth-shell select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---- Barre supérieure (même gabarit que la topbar de l'application) ---- */
.auth-topbar {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.auth-topbar-brand .brand { display: inline-flex; align-items: center; }
.auth-topbar-brand .brand-logo { height: 22px; width: auto; object-fit: contain; display: block; }

.auth-topbar-actions { display: flex; align-items: center; gap: 6px; min-width: 0; }

.auth-topbar-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-md);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
}
.auth-topbar-back:hover { background: var(--surface-2); color: var(--text); }
.auth-topbar-back .material-symbols-outlined { font-size: 17px; }

.auth-lang { position: relative; display: inline-flex; align-items: center; margin: 0; }
.auth-lang .material-symbols-outlined {
  position: absolute;
  inset-inline-start: 9px;
  font-size: 16px;
  color: var(--text-muted);
  pointer-events: none;
}
.auth-shell .auth-lang select {
  height: 32px;
  max-width: 190px;
  padding: 0 28px 0 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%235b6b78' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") no-repeat right 9px center;
  font: 600 12.5px var(--font);
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.auth-shell .auth-lang select:hover { border-color: color-mix(in srgb, var(--border), var(--primary) 30%); }

/* ---- Zone de travail : formulaire posé sur le fond, dans le tiers haut ---- */
.auth-body {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: clamp(36px, 10vh, 112px) 20px 56px;
}

.auth-panel { width: 100%; max-width: 380px; }
.auth-shell.is-wide .auth-panel { max-width: 460px; }

/* Repère « Fleuva ERP / Connexion » ou « Espace / Société » (où l'on se connecte). */
.auth-context {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 18px;
  font-size: 12px;
  color: var(--text-muted);
  min-width: 0;
}
.auth-context strong { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-context-sep { color: var(--text-faint); }
.auth-context-mark { width: 10px; height: 10px; border-radius: 2px; background: var(--brand); flex-shrink: 0; }

.auth-panel h1 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -.015em;
  color: var(--text);
}

.auth-panel .lead {
  margin: 0 0 24px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-muted);
}
.auth-panel .lead + .lead { margin-top: -14px; }

/* ---- Messages ---- */
.auth-alert,
.auth-status {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0 0 18px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-inline-start-width: 3px;
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: 13px;
  line-height: 1.45;
}
.auth-alert .material-symbols-outlined { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.auth-alert.success,
.auth-status { border-color: var(--success-border); border-inline-start-color: var(--success); background: var(--success-bg); color: var(--text); }
.auth-alert.success .material-symbols-outlined { color: var(--success); }
.auth-alert.error { border-color: var(--error-border); border-inline-start-color: var(--error); background: var(--error-bg); color: var(--text); }
.auth-alert.error .material-symbols-outlined { color: var(--error); }

/* Pictogramme des pages d'état (lien envoyé, lien expiré) : carré du logiciel, pas une pastille. */
.auth-icon-circle {
  width: 40px;
  height: 40px;
  margin: 0 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--primary);
}
.auth-icon-circle .material-symbols-outlined { font-size: 22px; }
.auth-icon-circle.success { border-color: var(--success-border); background: var(--success-bg); color: var(--success); }

/* ---- Champs ---- */
.auth-shell .auth-field { margin: 0 0 16px; gap: 6px; }

/* Libellés du thème (petites capitales) avec un contraste suffisant sur le fond gris. */
.auth-shell .auth-field label { color: var(--text-muted); }

.auth-shell .auth-field :where(input:not([type="checkbox"], [type="radio"], [type="hidden"])) {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  font: 400 13.5px var(--font);
  color: var(--text);
  box-shadow: var(--shadow);
  transition: border-color var(--fds-transition-fast);
}
.auth-shell .auth-field input::placeholder { color: var(--text-faint); }
/* Focus : anneau bleu pétrole. Le contour rouge du thème, au chargement (champ en autofocus), se lisait comme une erreur. */
.auth-shell .auth-field :where(input:not([type="checkbox"], [type="radio"], [type="hidden"])):focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent);
}
.auth-shell .auth-field input.has-error:focus { border-color: var(--error); box-shadow: 0 0 0 3px color-mix(in srgb, var(--error) 16%, transparent); }
.auth-shell .auth-field :where(input:not([type="checkbox"], [type="radio"], [type="hidden"])):hover {
  border-color: color-mix(in srgb, var(--border), var(--text) 22%);
}
.auth-shell .auth-field input.has-error,
.auth-shell .auth-field .has-error input { border-color: var(--error); background: var(--error-bg); }
.auth-shell .auth-error-text { display: block; margin-top: 2px; font-size: 12px; font-weight: 500; color: var(--error); }

.auth-password-wrap { position: relative; }
.auth-shell .auth-password-wrap input { padding-inline-end: 42px; }
.auth-password-toggle {
  position: absolute;
  inset-inline-end: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.auth-password-toggle:hover { background: var(--surface-2); color: var(--text); }
.auth-password-toggle .material-symbols-outlined { font-size: 18px; }

.auth-shell .grid.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

/* Règles du mot de passe : liste de contrôle compacte. */
.pwd-rules {
  list-style: none;
  margin: -4px 0 16px;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
  font-size: 12px;
  color: var(--text-muted);
}
.pwd-rules li { display: flex; align-items: center; gap: 6px; }
.pwd-rules .material-symbols-outlined { font-size: 15px; color: var(--text-faint); }
.pwd-rules li.met { color: var(--success); }
.pwd-rules li.met .material-symbols-outlined { color: var(--success); }
/* data-reveal="missing" (inscription) : rien pendant la saisie ; à la fin, seulement les critères manquants. */
.pwd-rules[data-reveal="missing"]:not(.revealed),
.pwd-rules[data-reveal="missing"] li.met { display: none; }
.pwd-rules[data-reveal="missing"].revealed li:not(.met),
.pwd-rules[data-reveal="missing"].revealed li:not(.met) .material-symbols-outlined { color: var(--error); }

.auth-match-msg { font-size: 12px; margin: -8px 0 12px; }
.auth-match-msg:empty { display: none; }
.auth-match-msg.error { color: var(--error); }
.auth-match-msg.success { color: var(--success); }

/* ---- Ligne « Se souvenir de moi / Mot de passe oublié » ---- */
.auth-row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -2px 0 20px;
  font-size: 13px;
}
.auth-remember { display: inline-flex; align-items: center; gap: 8px; color: var(--text); cursor: pointer; margin: 0; }
.auth-remember input { width: 15px; height: 15px; margin: 0; accent-color: var(--primary); }

.auth-link { color: var(--primary); font-weight: 600; text-decoration: none; }
.auth-link:hover { text-decoration: underline; text-underline-offset: 2px; }

/* ---- Actions ---- */
.auth-shell .btn.auth-submit {
  width: 100%;
  height: 40px;
  justify-content: center;
  font-size: 13px;
  border-radius: var(--radius-md);
}
.auth-shell .btn.auth-submit:disabled,
.auth-shell .btn.auth-submit[disabled] { opacity: .5; cursor: not-allowed; }

.auth-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, .45);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: auth-spin .7s linear infinite;
}
.btn:not(.btn-primary) .auth-spinner { border-color: var(--border); border-top-color: var(--text); }
@keyframes auth-spin { to { transform: rotate(360deg); } }

/* Connexion avec Google : bouton secondaire du thème, logo officiel. */
.auth-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow);
  font: 600 13px var(--font);
  color: var(--text);
  text-decoration: none;
}
.auth-google:hover { background: var(--surface-2); color: var(--text); border-color: color-mix(in srgb, var(--border), var(--text) 18%); }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-faint);
}
.auth-divider::before,
.auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.auth-shell .g-recaptcha { margin: 2px 0 4px; min-height: 78px; }

.auth-terms { margin: 14px 0 0; font-size: 12px; line-height: 1.55; color: var(--text-muted); }
.auth-terms a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }

.auth-switch {
  margin: 24px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

.auth-back { margin: 22px 0 0; font-size: 13px; }
.auth-back a { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-weight: 600; text-decoration: none; }
.auth-back a:hover { color: var(--text); }
.auth-back .material-symbols-outlined { font-size: 17px; }

/* ---- Barre d'état (pied de page du logiciel) ---- */
.auth-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 20px;
  min-height: 34px;
  padding: 7px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: 11.5px;
  color: var(--text-muted);
}
.auth-statusbar-group { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 16px; }
.auth-statusbar-group > span,
.auth-statusbar-group > a { display: inline-flex; align-items: center; gap: 5px; }
.auth-statusbar .material-symbols-outlined { font-size: 14px; color: var(--text-faint); }
.auth-statusbar a { color: var(--text-muted); text-decoration: none; }
.auth-statusbar a:hover { color: var(--text); text-decoration: underline; }

/* ---- Petits écrans ---- */
@media (max-width: 640px) {
  .auth-topbar { padding: 0 12px; }
  /* Libellé masqué visuellement mais lu par les lecteurs d'écran. */
  .auth-topbar-back-label {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .auth-topbar-back { padding: 0 8px; }
  .auth-shell .auth-lang select { max-width: 150px; }
  .auth-body { padding: 28px 18px 40px; }
  .auth-panel h1 { font-size: 20px; }
  /* 16px : iOS ne zoome pas sur le champ au focus. */
  .auth-shell .auth-field :where(input:not([type="checkbox"], [type="radio"], [type="hidden"])) { height: 42px; font-size: 16px; }
  .auth-shell .btn.auth-submit,
  .auth-google { height: 42px; }
  .auth-statusbar { justify-content: center; text-align: center; padding: 10px 16px; }
  .auth-statusbar-group { justify-content: center; }
}

@media (max-width: 480px) {
  .auth-shell .grid.cols-2 { grid-template-columns: 1fr; }
  .pwd-rules { grid-template-columns: 1fr; }
}

@media (max-width: 340px) {
  .auth-shell .g-recaptcha { transform: scale(.9); transform-origin: 0 0; }
}

/* Connexion hors ligne (public/js/offline/offline-login.js). */
.auth-offline-message { margin: 0 0 14px; padding: 10px 12px; border-radius: 8px; font-size: 13px; line-height: 1.45; border: 1px solid var(--error); color: var(--error); background: transparent; }
.auth-offline-message[data-tone="info"] { border-color: var(--primary); color: var(--text); }
