/* --- 1. CONFIGURATION & VARIABLES (Mode Sombre par défaut) --- */
:root {
  /* Couleurs de base (Sombre) */
  --bg-space: #020617;
  --glass-bg: rgba(15, 23, 42, 0.75);
  --glass-border: rgba(255, 255, 255, 0.1);
  --text-main: #f8fafc;
  --text-dim: #94a3b8;
  
  /* Accents */
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.5);
  --error: #ef4444;
  --success: #10b981;
  
  /* Système */
  --font-main: 'Outfit', sans-serif;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- 2. ADAPTATION MODE CLAIR --- */
body.lightmode {
  --bg-space: #f1f5f9;
  --glass-bg: rgba(255, 255, 255, 0.8);
  --glass-border: rgba(0, 0, 0, 0.05);
  --text-main: #0f172a;
  --text-dim: #64748b;
  --accent: #2563eb;
}

/* --- 3. RESET & LAYOUT --- */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background-color: var(--bg-space);
  font-family: var(--font-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  transition: background-color 0.5s ease;
}

/* --- 4. DÉCORATIONS SPATIALES --- */
.star-field {
  position: fixed;
  inset: 0;
  background-image: 
    radial-gradient(1px 1px at 10% 10%, #fff, transparent),
    radial-gradient(1px 1px at 50% 20%, #fff, transparent),
    radial-gradient(2px 2px at 80% 40%, #fff, transparent);
  background-size: 400px 400px;
  opacity: 0.3;
  z-index: -2;
  animation: spaceTravel 150s linear infinite;
}

body.lightmode .star-field { opacity: 0.1; filter: invert(1); }

@keyframes spaceTravel {
  from { transform: translateY(0); }
  to { transform: translateY(-1000px); }
}

.planet {
  position: fixed;
  top: -100px;
  right: -100px;
  width: 350px;
  height: 350px;
  background: radial-gradient(circle at 30% 30%, var(--accent), var(--bg-space));
  border-radius: 50%;
  filter: blur(1px);
  box-shadow: inset -20px -20px 60px rgba(0,0,0,0.5), 0 0 50px var(--accent-glow);
  z-index: -1;
  opacity: 0.6;
}

/* --- 5. CARTE DE CONNEXION --- */
.container {
  width: 90%;
  max-width: 440px;
  z-index: 10;
}

.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 32px;
  padding: 40px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
  text-align: center;
}

.title {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 10px;
  background: linear-gradient(to bottom, var(--text-main), var(--text-dim));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-dim);
  font-size: 0.95rem;
  margin-bottom: 35px;
}

/* --- 6. FORMULAIRE --- */
.input-field {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  margin-bottom: 15px;
  transition: var(--transition);
}

body.lightmode .input-field { background: rgba(0, 0, 0, 0.03); }

.input-field:focus-within {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.input-field i { color: var(--text-dim); width: 25px; }

.input-field input {
  width: 100%;
  height: 56px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 1rem;
  font-family: var(--font-main);
}

/* --- 7. BOUTONS --- */
.box-button {
  width: 100%;
  height: 58px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 16px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition: var(--transition);
  margin-top: 20px;
}

.box-button:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
  box-shadow: 0 10px 20px var(--accent-glow);
}

.logout-btn { background: var(--error); }

/* --- 8. FOOTER & LIENS --- */
.form-footer {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--glass-border);
}

.signup-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
  transition: opacity 0.2s;
}

.forgot-link {
  margin-top: 20px;
  display: inline-block;
}

.forgot-link a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.home-return {
  margin-top: 20px;
  display: inline-block;
}

.home-return a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- 9. ALERTES --- */
.error-alert {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--error);
  padding: 15px;
  border-radius: 14px;
  margin-bottom: 20px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* --- 10. RESPONSIVE --- */
@media (max-width: 480px) {
  .glass-card { padding: 30px 20px; border-radius: 24px; }
  .title { font-size: 1.8rem; }
}

/* Consentement & Checkbox */
.consent-container {
    margin: 15px 0 25px;
    text-align: left;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-dim);
    gap: 10px;
}

.checkbox-wrapper a {
    color: var(--accent);
    text-decoration: none;
}

.checkbox-wrapper input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* Ajustement pour les listes d'erreurs */
.error-alert ul {
    margin: 0;
    padding-left: 15px;
    list-style-type: square;
}

.error-alert p {
    margin: 0;
}

/* Animation Rocket au hover du bouton */
.btn-glow:hover .fa-rocket {
    animation: rocketLaunch 0.5s ease forwards;
}

@keyframes rocketLaunch {
    0% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
    100% { transform: translateY(-20px); opacity: 0; }
}

/* --- MODAL TERMS --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: none; /* Caché par défaut */
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    padding: 30px !important;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 1.5rem;
    color: var(--accent);
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

.modal-body {
    overflow-y: auto;
    text-align: left;
    padding-right: 10px;
}

/* Custom Scrollbar pour le modal */
.modal-body::-webkit-scrollbar { width: 5px; }
.modal-body::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 10px; }

.modal-body h3 {
    font-size: 1rem;
    color: var(--text-main);
    margin: 15px 0 5px;
}

.modal-body p {
    font-size: 0.9rem;
    color: var(--text-dim);
    line-height: 1.6;
}

.modal-footer {
    margin-top: 20px;
}