/* ============================================================
   Authentification — styles pour login-shell, idle-modal, toast,
   bouton logout.
   Réutilise les CSS variables définies dans le <style> inline
   de index.html (--terracotta, --bg, --bg-card, --ink, etc.).
   ============================================================ */

/* ------------------------------------------------------------
   IMPORTANT : force l'attribut HTML `hidden` à toujours gagner.
   Sans cette règle, nos sélecteurs ID ci-dessous (ex: #idle-modal
   avec `display: flex`) ont une spécificité (1,0,0) qui écrase
   la règle user-agent par défaut `[hidden] { display: none }`
   (spécificité 0,1,0). Conséquence : un <div id="idle-modal" hidden>
   s'afficherait malgré tout. Cette règle globale empêche ce piège.
   ------------------------------------------------------------ */
[hidden] {
  display: none !important;
}

/* ===== Login shell ===== */
#login-shell {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg, #F4EFE6) 0%, var(--bg-warm, #EFE4D2) 100%);
  z-index: 100;
  font-family: 'Inter', sans-serif;
}

#login-shell .login-card {
  background: var(--bg-card, #FBF7EF);
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(42, 31, 20, 0.12);
  width: 100%;
  max-width: 380px;
  border: 1px solid var(--line-soft, #E8DFCB);
}

#login-shell h1 {
  font-family: 'Fraunces', serif;
  font-size: 28px;
  font-weight: 500;
  margin: 0 0 4px;
  color: var(--terracotta, #B25A3A);
}

#login-shell .subtitle {
  font-size: 13px;
  color: var(--ink-mute, #8A7860);
  margin: 0 0 28px;
}

#login-shell label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-soft, #5A4A38);
  margin: 16px 0 6px;
}

#login-shell input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line, #D9CDB8);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--ink, #2A1F14);
  box-sizing: border-box;
}

#login-shell input:focus {
  outline: none;
  border-color: var(--terracotta, #B25A3A);
  box-shadow: 0 0 0 3px var(--terracotta-soft, #E8C9B8);
}

#login-shell button[type="submit"] {
  margin-top: 24px;
  width: 100%;
  padding: 12px;
  background: var(--terracotta, #B25A3A);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

#login-shell button[type="submit"]:hover:not(:disabled) {
  background: #964a30;
}

#login-shell button[type="submit"]:disabled {
  background: var(--ink-mute, #8A7860);
  cursor: not-allowed;
}

#login-error {
  margin-top: 16px;
  padding: 10px 12px;
  background: #fdecea;
  color: #b00020;
  border-radius: 6px;
  font-size: 13px;
  border: 1px solid #f5c6c0;
}

/* ===== 2FA email (code à 6 chiffres reçu par mail) ===== */
#email2fa-error {
  margin-top: 16px;
  padding: 10px 12px;
  background: #fdecea;
  color: #b00020;
  border-radius: 6px;
  font-size: 13px;
  border: 1px solid #f5c6c0;
}
#email2fa-code {
  text-align: center;
  letter-spacing: 8px;
  font-size: 22px;
  font-family: 'Courier New', monospace;
}
#email2fa-target {
  font-weight: 600;
  color: var(--ink, #2A1F14);
}
/* Bouton secondaire réutilisé pour "Renvoyer le code" et "Recommencer".
   La classe .twofa-back conserve son nom : factorise un style commun de
   bouton-lien sous les boutons principaux (héritage du prototype). */
.twofa-back {
  margin-top: 12px;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--ink-mute, #8A7860);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
}
.twofa-back:hover:not(:disabled) { color: var(--terracotta, #B25A3A); }
.twofa-back:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  text-decoration: none;
}

/* ===== Logout button (header) ===== */
#logout-btn {
  margin-left: 12px;
  padding: 6px 12px;
  background: transparent;
  color: var(--ink-soft, #5A4A38);
  border: 1px solid var(--line, #D9CDB8);
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

#logout-btn:hover {
  background: var(--bg-warm, #EFE4D2);
  border-color: var(--terracotta, #B25A3A);
  color: var(--terracotta, #B25A3A);
}

/* ===== Idle warning modal ===== */
#idle-modal {
  position: fixed;
  inset: 0;
  background: rgba(42, 31, 20, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  font-family: 'Inter', sans-serif;
}

#idle-modal .idle-card {
  background: var(--bg-card, #FBF7EF);
  padding: 32px 40px;
  border-radius: 16px;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

#idle-modal h2 {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 500;
  margin: 0 0 12px;
  color: var(--terracotta, #B25A3A);
}

#idle-modal p {
  font-size: 14px;
  color: var(--ink-soft, #5A4A38);
  margin: 0 0 16px;
}

#idle-modal .idle-countdown {
  font-family: 'Fraunces', serif;
  font-size: 48px;
  font-weight: 500;
  color: var(--terracotta, #B25A3A);
  margin: 20px 0;
}

#idle-modal .idle-countdown #idle-countdown {
  display: inline-block;
  min-width: 60px;
}

#idle-modal button {
  padding: 12px 28px;
  background: var(--terracotta, #B25A3A);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

#idle-modal button:hover {
  background: #964a30;
}

/* ===== Toast ===== */
#toast {
  position: fixed;
  top: 24px;
  left: 50%;
  padding: 12px 24px;
  background: var(--ink, #2A1F14);
  color: #fff;
  border-radius: 8px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  z-index: 300;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-50%) translateY(-12px);
  transition: opacity 0.25s, transform 0.25s;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  max-width: 90vw;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#toast[data-type="error"] {
  background: #b00020;
}

#toast[data-type="info"] {
  background: var(--info, #5C7A8B);
}
