/* Variables & thèmes */
:root {
  --bg-start: #0b0f19; /* fallback */
  --bg-end: #121421;  /* fallback */
  --modal-bg: #292929; /* fond de la modale */
  --modal-border: rgba(255, 255, 255, 0.06);
  --primary: #115ea3; /* bleu principal */
  --primary-hover: #0f4d8a;
  --link: #5aa7ff;
  --text: #e6eef8;
  --muted: #a7b0bd;
  --input-bg: var(--modal-bg);
  --input-border: rgba(255, 255, 255, 0.14);
  --focus-ring: 0 0 0 3px rgba(24, 90, 188, 0.35);
  --error-color: #D97981;
  --error-bg: rgba(209, 52, 56, 0.1);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
  }
}

/* Reset minimal et base typographique */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: url('../images/fluent_web_dark_2.svg') center center / cover no-repeat fixed,
              linear-gradient(160deg, var(--bg-start), var(--bg-end));
  min-height: 100vh;
  overflow: hidden;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.page-root {
  width: 100vw;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  position: relative;
}

/* Formes abstraites */
.bg-shapes {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: none; /* on laisse le SVG gérer l'arrière-plan */
}

.bg-shapes::before,
.bg-shapes::after {
  content: "";
  position: absolute;
  filter: blur(60px);
  opacity: 0.35;
}

.bg-shapes::before {
  width: 520px;
  height: 520px;
  left: -120px;
  top: -120px;
  background: radial-gradient(circle at 30% 30%, #1a2b4a 0%, #111826 55%, transparent 65%);
}

.bg-shapes::after {
  width: 580px;
  height: 580px;
  right: -160px;
  bottom: -160px;
  background: radial-gradient(circle at 70% 70%, #263a53 0%, #141a27 55%, transparent 70%);
}

/* Canvas étoiles */
#stars-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 0;
}

/* Pied de page */
.page-footer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 12px 16px 16px;
  text-align: center;
  color: var(--muted);
  z-index: 1;
}
.footer-links {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 6px;
  font-size: 12px;
}
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { text-decoration: underline; }
.footer-links .dot { opacity: 0.6; }
.footer-note { margin: 0; font-size: 11px; }
.footer-note a { color: var(--link); text-decoration: none; }
.footer-note a:hover { text-decoration: underline; }

/* Modale */
.login-modal {
  position: relative;
  z-index: 1;
  width: 420px;
  max-width: calc(100vw - 32px);
  background: var(--modal-bg);
  border: 1px solid var(--modal-border);
  border-radius: 12px;
  padding: 32px 32px 24px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  text-align: center;
  transform: translateY(8px);
  opacity: 0;
  animation: modal-in 400ms ease forwards;
}

@keyframes modal-in {
  to { transform: translateY(0); opacity: 1; }
}

.brand { margin-bottom: 8px; }
.brand-logo {
  width: 180px;
  height: auto;
  margin: 0 auto;
  border-radius: 0;
  display: block;
  object-fit: contain;
  background: transparent;
  box-shadow: none;
}

.title {
  font-size: 22px;
  font-weight: 600;
  margin: 2px 0 8px;
}
.subtitle {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 32px;
}

/* Puce d'identité centrée */
.identity-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 12px;
  margin: 0 auto 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
}
.identity-chip[hidden] { display: none !important; margin: 0 !important; padding: 0 !important; }

.login-form { text-align: left; }

.identity-summary {
  display: block;
  width: 100%;
  padding: 0;
  margin: 8px 0 8px;
  border-radius: 0;
  background: transparent;
  border: none;
  color: var(--text);
  font-weight: 600;
}

.field { margin-bottom: 18px; }
.label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

/* Masquer visuellement mais garder pour les lecteurs d'écran */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.input-wrap {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #9eb3c8;
  opacity: 0.8;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"] {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 38px;
  border-radius: 4px;
  border: 1px solid var(--input-border);
  border-bottom: 2px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  outline: none;
  transition: border-bottom-color 160ms ease;
  /* réactiver la sélection dans les champs */
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

/* Labels flottants */
.floating-label {
  position: absolute;
  left: 38px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
  transition: all 0.2s ease-out;
  z-index: 2;
  background: var(--modal-bg);
  padding: 0 4px;
}

.field.focused .floating-label,
.field.has-value .floating-label {
  top: 0;
  font-size: 10px;
  color: var(--muted);
  transform: translateY(-50%);
}

/* Bouton œil pour le mot de passe */
.input-eye {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #a7b0bd;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.input-eye:hover { color: #c7d2e1; }
.input-eye:focus { box-shadow: var(--focus-ring); border-radius: 6px; outline: none; }

input::placeholder { color: #b9c6d6; opacity: 0.7; }

input:focus {
  border-bottom-color: #115ea3;
  box-shadow: none;
}

/* Eviter le soulignement rouge pendant la saisie */
/* Afficher le trait rouge uniquement quand le champ est invalide ET non focalisé */
input[aria-invalid="true"]:not(:focus) {
  border-bottom-color: var(--error-color);
}

.hint-row { margin-top: 8px; }
.hint-link {
  font-size: 12px;
  color: var(--link);
  text-decoration: none;
}
.hint-link:hover { text-decoration: underline; }

.primary-btn {
  margin-top: 8px;
  width: 100%;
  height: 44px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: box-shadow 160ms ease, transform 120ms ease, background 160ms ease;
}
.primary-btn:hover {
  background: var(--primary-hover);
  box-shadow: 0 8px 24px rgba(24, 90, 188, 0.45);
}
.primary-btn:active { transform: translateY(1px); }
.primary-btn:focus { box-shadow: var(--focus-ring); outline: none; }

.secondary-row { margin-top: 14px; text-align: center; }
.muted-text { color: var(--muted); font-size: 13px; margin-right: 4px; }
.lead-text { color: #ffffff; font-size: 13px; margin-right: 6px; }
.secondary-link {
  font-size: 13px;
  color: var(--link);
  text-decoration: none;
}
.secondary-link:hover { text-decoration: underline; }

/* sections outils/notes supprimées */

/* Responsive */
@media (max-width: 480px) {
  body {
    background: var(--modal-bg);
    overflow: auto; /* autoriser le scroll si contenu dépasse */
  }
  #stars-canvas { display: none; }
  .page-root {
    display: block;
    height: auto;
    min-height: 100vh;
    padding: 0 12px 80px; /* espace pour le pied de page fixé */
    place-items: initial;
    position: relative;
    z-index: 5;
  }
  .login-modal {
    width: 100%;
    max-width: none;
    padding: 24px 16px 16px;
    border-radius: 0;
    margin: 12px auto 0; /* coller en haut */
    transform: none;
    animation: none;
    position: relative;
    z-index: 10;
    opacity: 1; /* corrige la disparition en mobile */
    border: none;
    box-shadow: none;
    background: var(--modal-bg); /* même couleur que le fond */
  }
  .security-modal {
    width: 100%;
    max-width: none;
    padding: 0 12px 16px;
    border-radius: 0;
    margin: 0; /* coller aux bords comme une page */
    transform: none;
    animation: none;
    position: static; /* suivre le flux, pas en avant-plan */
    z-index: auto;
    opacity: 1;
    border: none;
    box-shadow: none;
    background: var(--modal-bg); /* même couleur que l'arrière-plan */
  }
  .security-modal .brand { margin: 8px 0; }
  .security-header { margin: 12px 0 20px; }
  .title { font-size: 18px; }
  .subtitle { font-size: 13px; }
  .brand-logo { width: 140px; }
}

/* Message d'erreur */
.error-message {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  margin-bottom: 8px;
  padding: 6px 0;
  animation: errorSlideIn 0.3s ease-out;
}

.error-icon {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--error-color);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.error-icon::before {
  content: "!";
  color: white;
  font-size: 8px;
  font-weight: bold;
  line-height: 1;
}

.error-text {
  color: var(--error-color);
  font-size: 11px;
  font-weight: 400;
  line-height: 1;
  margin: 0;
  white-space: nowrap;
}

@keyframes errorSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Modale de vérification de sécurité */
.security-modal {
  position: relative;
  z-index: 1;
  width: 420px;
  max-width: calc(100vw - 32px);
  background: var(--modal-bg);
  border: 1px solid var(--modal-border);
  border-radius: 12px;
  padding: 32px 32px 24px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  text-align: center;
  transform: translateY(8px);
  opacity: 0;
  animation: modal-in 400ms ease forwards;
}

.security-header {
  margin-bottom: 24px;
}

.security-title {
  font-size: 22px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.security-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.security-icon {
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.security-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.security-message {
  text-align: center;
  max-width: 320px;
}

.security-message p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

.security-btn {
  width: 100%;
  height: 44px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: box-shadow 160ms ease, transform 120ms ease, background 160ms ease;
}

.security-btn:hover {
  background: var(--primary-hover);
  box-shadow: 0 8px 24px rgba(17, 94, 163, 0.45);
}

.security-btn:active {
  transform: translateY(1px);
}

.security-btn:focus {
  box-shadow: 0 0 0 3px rgba(17, 94, 163, 0.35);
  outline: none;
}

/* Lien autre compte dans la modale sécurité */
.security-link {
  display: inline-block;
  color: var(--link);
  font-size: 13px;
  text-decoration: none;
  font-weight: 500;
  margin-top: 32px;
}
.security-link:hover { text-decoration: underline; }

/* Indicateur de chargement */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top: 3px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-text {
  color: var(--text);
  font-size: 14px;
  margin: 0;
  font-weight: 500;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Overrides finaux pour mobile: s'assurer que la modale sécurité se fond avec la page */
@media (max-width: 480px) {
  .security-modal {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 12px 16px !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: var(--modal-bg) !important;
    position: static !important;
    transform: none !important;
    opacity: 1 !important;
  }
}

