/* =========================================================
   PEAKBED — AUTH
   Écrans d'inscription / connexion / création de mot de passe.
   Suit les tokens de base.css (Direction C).
   ========================================================= */

/* ---------- Overlay ---------- */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-top: calc(20px + var(--safe-top));
  padding-bottom: calc(20px + var(--safe-bottom));
  background: var(--overlay);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: authOverlayIn var(--dur-base) var(--ease-out);
  overflow-y: auto;
}

.auth-overlay.closing {
  animation: authOverlayOut 200ms var(--ease) forwards;
}

@keyframes authOverlayIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes authOverlayOut { from { opacity: 1; } to { opacity: 0; } }

/* ---------- Carte ---------- */
.auth-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line-1);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-4);
  padding: 28px 24px 24px;
  text-align: center;
  animation: authCardIn var(--dur-slow) var(--ease-out);
}

@keyframes authCardIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.auth-overlay.closing .auth-card {
  transform: translateY(8px) scale(0.98);
  opacity: 0;
  transition: all 180ms var(--ease);
}

/* ---------- Bouton fermer ---------- */
.auth-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-4);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.auth-close svg { width: 17px; height: 17px; }
.auth-close:hover { background: var(--surface-2); color: var(--ink-2); }

/* ---------- En-tête agent ---------- */
.auth-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.auth-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: 2px solid var(--line-2);
}

.auth-avatar-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--t-18);
  font-weight: var(--w-bold);
  letter-spacing: var(--ls-tight);
}

.auth-agent-name {
  font-size: var(--t-16);
  font-weight: var(--w-semibold);
  color: var(--ink-1);
  letter-spacing: var(--ls-tight);
}

/* ---------- Icône d'état ---------- */
.auth-icon {
  font-size: 40px;
  line-height: 1;
  margin: 4px 0 14px;
}

/* ---------- Textes ---------- */
.auth-title {
  font-size: var(--t-20);
  font-weight: var(--w-bold);
  color: var(--ink-1);
  letter-spacing: var(--ls-display);
  line-height: var(--lh-snug);
  margin-bottom: 8px;
}

.auth-text {
  font-size: var(--t-14);
  color: var(--ink-3);
  line-height: var(--lh-normal);
  margin-bottom: 20px;
}
.auth-text strong { color: var(--ink-2); font-weight: var(--w-semibold); }

/* ---------- Formulaire ---------- */
.auth-form {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.auth-label {
  font-size: var(--t-12);
  font-weight: var(--w-semibold);
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: var(--ls-wider);
  margin-bottom: 6px;
}
.auth-form .auth-label:not(:first-child) { margin-top: 14px; }

.auth-input {
  width: 100%;
  padding: 13px 14px;
  font-size: var(--t-16); /* 16px : empêche le zoom automatique sur iOS */
  font-family: inherit;
  color: var(--ink-1);
  background: var(--surface-2);
  border: 1.5px solid var(--line-1);
  border-radius: var(--r-md);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.auth-input::placeholder { color: var(--ink-5); }
.auth-input:focus {
  border-color: var(--accent);
  background: var(--surface);
}

/* ---------- Message d'erreur ---------- */
.auth-error {
  display: none;
  margin-top: 12px;
  padding: 10px 12px;
  font-size: var(--t-13);
  line-height: var(--lh-snug);
  text-align: left;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--r-sm);
}
.auth-error.visible { display: block; }

/* ---------- Boutons ---------- */
.auth-btn {
  width: 100%;
  margin-top: 18px;
  padding: 14px;
  min-height: 48px; /* cible tactile confortable */
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--t-15);
  font-weight: var(--w-semibold);
  font-family: inherit;
  border: 0;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.auth-btn:active:not(:disabled) { transform: scale(0.985); }
.auth-btn:disabled { opacity: 0.65; cursor: default; }

.auth-btn-primary {
  background: var(--accent);
  color: var(--accent-foreground);
}
.auth-btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.auth-btn-ghost {
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--line-1);
}
.auth-btn-ghost:hover:not(:disabled) { background: var(--surface-sunken); }

.auth-link {
  margin-top: 12px;
  padding: 6px;
  font-size: var(--t-13);
  font-family: inherit;
  color: var(--ink-4);
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.auth-link:hover { color: var(--accent); }
.auth-link:disabled { opacity: 0.6; cursor: default; }

/* ---------- Spinner ---------- */
.auth-spinner {
  width: 17px;
  height: 17px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: authSpin 620ms linear infinite;
}
@keyframes authSpin { to { transform: rotate(360deg); } }

/* =========================================================
   Cartes agent verrouillées (liste d'accueil)
   ---------------------------------------------------------
   Presque toutes les fiches sont ouvertes. Ne reste verrouillée que la
   frontière de la buanderie : sa fiche vue des autres métiers, et toutes les
   autres fiches vues de la buanderie. (Le Chef, lui, n'a aucun cadenas.)
   ========================================================= */
.agent-card-locked {
  position: relative;
  opacity: 0.42;
  filter: grayscale(0.85);
  cursor: not-allowed;
}
.agent-card-locked:hover { transform: none; }

.agent-card-lock {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 13px;
  line-height: 1;
  opacity: 0.85;
  pointer-events: none;
}

/* =========================================================
   Bandeau « vous consultez la fiche d'un collègue »
   ---------------------------------------------------------
   Sur la fiche d'un collègue, la rémunération et les blocs personnels sont
   retirés. Sans ce bandeau, l'agent croirait sa propre paie disparue.
   ========================================================= */
.fiche-consultation {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 14px;
  padding: 11px 13px;
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-3);
}
.fiche-consultation-icone {
  flex: 0 0 auto;
  font-size: 15px;
  line-height: 1.35;
}
.fiche-consultation-texte strong { color: var(--ink-1); font-weight: 600; }

/* ---------- Bouton de déconnexion (header) ---------- */
.btn-logout svg { display: block; }
.btn-logout:hover { color: var(--danger); }

/* =========================================================
   Dark mode
   ========================================================= */
@media (prefers-color-scheme: dark) {
  .auth-card {
    background: var(--bg-elevated);
    border-color: var(--line-1);
  }

  .auth-input {
    background: var(--surface-sunken);
    border-color: var(--line-2);
  }
  .auth-input:focus {
    background: var(--surface-2);
    border-color: var(--accent);
  }

  .auth-error {
    /* --danger-soft est clair : illisible sur fond sombre. */
    color: #ff9c9c;
    background: rgba(177, 50, 50, 0.16);
  }

  .auth-avatar { border-color: var(--line-2); }

  .auth-btn-ghost {
    background: var(--surface-2);
    border-color: var(--line-2);
  }

  .agent-card-locked { opacity: 0.35; }

  /* .fiche-consultation n'a rien à redéfinir : elle n'utilise que des
     variables (--surface-2, --line-2, --ink-1/3, --accent) qui basculent
     déjà d'elles-mêmes dans base.css. */
}

/* =========================================================
   Petits écrans
   ========================================================= */
@media (max-width: 380px) {
  .auth-card  { padding: 24px 18px 20px; }
  .auth-title { font-size: var(--t-18); }
  .auth-avatar { width: 52px; height: 52px; }
}
