/* ==========================================================================
   Modula UI — fondation mobile-first partagée (refonte 2026).
   Marque : bleu océan profond + or académique. Poppins.
   Chargée par les pages refondues (auth d'abord), indépendante de styles.css.
   ========================================================================== */

:root {
  /* Bleu de marque */
  --brand-900: #0A3251;
  --brand-800: #0E4268;
  --brand-700: #145C8F;
  --brand-600: #1C6FA8;
  --brand-300: #8FBEDC;
  --brand-100: #DCE9F3;
  --brand-50:  #EEF5FA;
  /* Or de marque (accent) */
  --gold-600: #B7791F;
  --gold-500: #D69E2E;
  --gold-300: #F0C674;
  /* Neutres */
  --ink:       #141C2B;
  --ink-soft:  #36425A;
  --muted:     #61708A;
  --line:      #D9E0EC;
  --line-soft: #EAEEF6;
  --bg:        #EEF2F8;
  --surface:   #FFFFFF;
  --surface-2: #F4F7FB;
  /* États */
  --success:   #1B9A5F;
  --danger:    #C0392B;
  --danger-bg: #FBEAE8;
  /* Rayons / ombres */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-pill: 999px;
  --sh-sm: 0 1px 2px rgba(16, 33, 60, .06), 0 2px 6px rgba(16, 33, 60, .05);
  --sh-md: 0 8px 24px rgba(16, 33, 60, .10);
  --sh-lg: 0 24px 60px rgba(13, 38, 71, .22);
  /* Typo */
  --font: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --fs-display: clamp(1.7rem, 1.2rem + 2.4vw, 2.5rem);
  --fs-h1: clamp(1.5rem, 1.15rem + 1.7vw, 2rem);
  --fs-h2: clamp(1.2rem, 1.02rem + .9vw, 1.5rem);
  --fs-body: 1rem;
  --fs-sm: .875rem;
  --fs-xs: .78rem;
  /* Divers */
  --ease: cubic-bezier(.2, .7, .25, 1);
  --maxw: 1180px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

/* --- Reset / base ------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
a { color: var(--brand-700); text-decoration: none; }
a:hover { color: var(--brand-800); }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 3px solid var(--brand-300); outline-offset: 2px; border-radius: 6px; }
.mui-hide { display: none !important; }
.hidden { display: none !important; } /* compat JS existant */

/* --- Boutons ------------------------------------------------------------ */
.mui-btn {
  appearance: none;
  border: 1px solid transparent;
  font: 600 1rem/1 var(--font);
  border-radius: var(--r-pill);
  padding: 15px 22px;
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease),
              background .18s var(--ease), border-color .18s var(--ease), color .18s var(--ease);
}
.mui-btn--block { width: 100%; }
.mui-btn--primary {
  color: #fff;
  background: linear-gradient(180deg, var(--brand-600), var(--brand-700));
  box-shadow: 0 10px 22px rgba(20, 92, 143, .32);
}
.mui-btn--primary:hover { transform: translateY(-1px); box-shadow: 0 14px 28px rgba(20, 92, 143, .4); }
.mui-btn--primary:active { transform: translateY(0); box-shadow: 0 6px 14px rgba(20, 92, 143, .3); }
.mui-btn--ghost {
  color: var(--brand-700);
  background: var(--surface);
  border-color: var(--line);
}
.mui-btn--ghost:hover { border-color: var(--brand-300); background: var(--brand-50); }

/* compat : le bouton submit existant porte la classe .primary-btn */
.primary-btn {
  appearance: none; border: 0; cursor: pointer;
  width: 100%;
  color: #fff;
  font: 600 1.02rem/1 var(--font);
  border-radius: var(--r-pill);
  padding: 16px 22px;
  min-height: 54px;
  background: linear-gradient(180deg, var(--brand-600), var(--brand-700));
  box-shadow: 0 10px 22px rgba(20, 92, 143, .32);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
}
.primary-btn:hover { transform: translateY(-1px); box-shadow: 0 14px 28px rgba(20, 92, 143, .4); }
.primary-btn:active { transform: translateY(0); }

/* --- Champs de formulaire ---------------------------------------------- */
.form-field { display: grid; gap: 7px; margin-bottom: 16px; }
.form-field > label {
  font-size: var(--fs-sm); font-weight: 600; color: var(--ink-soft);
  letter-spacing: .01em;
}
.form-field input {
  width: 100%;
  font: 500 1rem/1.2 var(--font); /* 16px : évite le zoom iOS */
  color: var(--ink);
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px;
  min-height: 52px;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease), background .16s var(--ease);
}
.form-field input::placeholder { color: #9AA6B8; }
.form-field input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--brand-600);
  box-shadow: 0 0 0 4px var(--brand-100);
}
.input-with-toggle { position: relative; display: flex; align-items: center; }
.input-with-toggle input { padding-right: 92px; }
.toggle-visibility {
  position: absolute; right: 8px;
  border: 0; background: transparent;
  color: var(--brand-700); font: 600 var(--fs-sm) var(--font);
  padding: 8px 12px; border-radius: var(--r-sm); cursor: pointer;
  transition: background .15s var(--ease);
}
.toggle-visibility:hover { background: var(--brand-50); }

/* Conditions de mot de passe */
.password-conditions { margin: -2px 0 18px; }
.helper-text { font-size: var(--fs-sm); color: var(--muted); margin-bottom: 8px; }
.conditions-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.condition-item {
  display: flex; align-items: center; gap: 9px;
  font-size: var(--fs-sm); color: var(--muted);
  transition: color .15s var(--ease);
}
.condition-item .condition-icon {
  width: 20px; height: 20px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; font-size: .72rem; font-weight: 700;
  background: var(--line-soft); color: var(--muted);
  transition: background .2s var(--ease), color .2s var(--ease), transform .2s var(--ease);
}
.condition-item.valid { color: var(--success); }
.condition-item.valid .condition-icon {
  background: rgba(27, 154, 95, .15); color: var(--success); transform: scale(1.06);
}

/* --- Alertes ------------------------------------------------------------ */
.error-box {
  background: var(--danger-bg);
  border: 1px solid rgba(192, 57, 43, .25);
  color: #8E2A20;
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-size: var(--fs-sm);
  margin-bottom: 16px;
  display: grid; gap: 4px;
}

.success-box {
  background: rgba(27, 154, 95, .1);
  border: 1px solid rgba(27, 154, 95, .3);
  color: #126B45;
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-size: var(--fs-sm);
  margin-bottom: 16px;
}

/* --- OAuth -------------------------------------------------------------- */
.oauth-box { margin-bottom: 18px; display: grid; gap: 12px; }

/* Bouton Apple (HIG : noir, plein, pilule) */
.apple-btn-container { display: flex; justify-content: center; }
.apple-signin-btn {
  width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  appearance: none; cursor: pointer;
  background: #000; color: #fff; border: 0;
  border-radius: var(--r-pill);
  min-height: 48px; padding: 12px 20px;
  font: 600 1rem/1 var(--font);
  transition: transform .16s var(--ease), opacity .16s var(--ease);
}
.apple-signin-btn:hover { transform: translateY(-1px); }
.apple-signin-btn:disabled { opacity: .5; cursor: default; transform: none; }
.apple-signin-icon { display: inline-flex; }
.apple-signin-icon svg { width: 15px; height: 18px; fill: #fff; margin-top: -2px; }

/* Lien "mot de passe oublié" */
.form-footer { display: flex; justify-content: flex-end; margin: -4px 0 18px; }
.form-footer a { font-size: var(--fs-sm); font-weight: 600; color: var(--brand-700); }

/* Bouton secondaire (renvoyer le code) */
.ghost-btn {
  appearance: none; cursor: pointer; width: 100%;
  background: var(--surface); color: var(--brand-700);
  border: 1.5px solid var(--line); border-radius: var(--r-pill);
  min-height: 48px; padding: 12px 18px;
  font: 600 .95rem/1 var(--font);
  transition: background .16s var(--ease), border-color .16s var(--ease);
}
.ghost-btn:hover { background: var(--brand-50); border-color: var(--brand-300); }
.inline-btn { margin-top: 10px; }

/* Sous-formulaires de réinitialisation */
.reset-form { display: block; }
.helper-text.small { font-size: var(--fs-xs); }
.back-to-login { font-weight: 600; }

.google-btn-container { display: flex; justify-content: center; min-height: 44px; }
.google-btn-container > div { width: 100% !important; }
.oauth-divider {
  display: flex; align-items: center; gap: 14px;
  margin-top: 18px; color: var(--muted); font-size: var(--fs-sm);
}
.oauth-divider::before, .oauth-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}

/* ==========================================================================
   Layout AUTH (sign_in / login) — split mobile-first
   ========================================================================== */
.auth-page { background: var(--bg); }
.auth {
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr;
}

/* Panneau de marque (haut sur mobile, colonne gauche sur desktop) */
.auth__brand {
  position: relative;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(120% 80% at 85% -10%, rgba(214, 158, 46, .35), transparent 55%),
    linear-gradient(155deg, var(--brand-700) 0%, var(--brand-800) 55%, var(--brand-900) 100%);
  padding: calc(20px + var(--safe-t)) 22px 24px;
}
/* texture pointillée subtile pour la profondeur */
.auth__brand::before {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .14) 1px, transparent 1.4px);
  background-size: 22px 22px;
  mask-image: linear-gradient(180deg, #000 0%, transparent 80%);
  opacity: .5; pointer-events: none;
}
.auth__brand-inner { position: relative; z-index: 1; max-width: 460px; margin: 0 auto; width: 100%; }
.auth__logo {
  display: inline-flex; align-items: center; gap: 11px;
  color: #fff; font-weight: 700; font-size: 1.18rem; letter-spacing: .01em;
}
.auth__logo img {
  width: 38px; height: 38px; border-radius: 10px; object-fit: cover;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .25);
}
.auth__logo:hover { color: var(--gold-300); }
.auth__tagline {
  font-size: clamp(1.15rem, 1rem + 1.6vw, 1.7rem);
  font-weight: 600; line-height: 1.25; letter-spacing: -.01em;
  margin-top: 16px; max-width: 18ch;
}
.auth__tagline b { color: var(--gold-300); font-weight: 700; }
.auth__points { display: none; }

/* Panneau formulaire */
.auth__panel {
  display: flex; justify-content: center; align-items: flex-start;
  padding: 22px 18px calc(40px + var(--safe-b));
}
.auth-card { width: 100%; max-width: 440px; }
.auth-card__head { margin-bottom: 20px; }
.auth-card__head h1 {
  font-size: var(--fs-h1); font-weight: 700; letter-spacing: -.015em; color: var(--ink);
}
.auth-card__head p { color: var(--muted); margin-top: 7px; font-size: .98rem; }
.auth-footer {
  margin-top: 20px; text-align: center; font-size: var(--fs-sm); color: var(--muted);
}
.auth-footer a { font-weight: 600; }

/* Carte translucide qui chevauche le panneau de marque sur mobile */
@media (max-width: 859px) {
  .auth__brand { padding-bottom: 56px; }
  .auth__panel { margin-top: -34px; }
  .auth-card {
    background: var(--surface);
    border-radius: var(--r-xl);
    box-shadow: var(--sh-lg);
    padding: 26px 20px 28px;
  }
}

/* Desktop : deux colonnes plein écran */
@media (min-width: 860px) {
  .auth { grid-template-rows: none; grid-template-columns: 0.95fr 1.05fr; }
  .auth__brand {
    padding: 56px 52px;
    display: flex; flex-direction: column; justify-content: center;
  }
  .auth__tagline { margin-top: 26px; }
  .auth__points {
    display: grid; gap: 14px; margin-top: 34px; max-width: 30ch;
  }
  .auth__points li {
    position: relative; list-style: none; padding-left: 32px;
    font-size: .98rem; color: rgba(255, 255, 255, .88);
  }
  .auth__points li::before {
    content: "✓"; position: absolute; left: 0; top: -1px;
    width: 22px; height: 22px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: .72rem; font-weight: 700; color: var(--brand-800);
    background: var(--gold-300);
  }
  .auth__panel { padding: 56px; align-items: center; }
  .auth-card { max-width: 420px; }
}

/* --- Apparition orchestrée au chargement -------------------------------- */
@keyframes mui-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.auth__brand-inner > *, .auth-card > * { animation: mui-rise .6s var(--ease) both; }
.auth-card > *:nth-child(1) { animation-delay: .04s; }
.auth-card > *:nth-child(2) { animation-delay: .10s; }
.auth-card > *:nth-child(3) { animation-delay: .16s; }
.auth-card > *:nth-child(4) { animation-delay: .22s; }
.auth-card > *:nth-child(n+5) { animation-delay: .28s; }

/* ==========================================================================
   PREMIUM SEREIN — extension du système (2026-05-29)
   Additif : aucun token/selecteur existant n'est modifié → l'auth en prod
   reste identique. Dark mode STRICTEMENT opt-in via [data-theme="dark"]
   (jamais via prefers-color-scheme) pour ne pas altérer les pages live.
   ========================================================================== */
:root {
  --brand-500: #2E86C2;
  --surface-3: #EFF4FA;
  --faint:     #94A3B8;
  --r-xs: 8px;
  --sh-xs: 0 1px 2px rgba(15, 27, 45, .05);
  --top-glow: inset 0 1px 0 rgba(255, 255, 255, .7);
  /* États sémantiques (fonds doux + accents) */
  --success-bg: #E7F6ED;
  --warning:    #D97706;
  --warning-bg: #FCF1E2;
  --info:       #1C6FA8;
  --info-bg:    #E7F1F8;
  --live:       #E11D48;   /* réservé aux sessions en direct */
  /* Motion étendu */
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --t-fast: .16s; --t: .22s; --t-slow: .42s;
  /* Échelle d'espacement (miroir des tokens Flutter AppSpacing) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;
}

/* --- Thème sombre « nuit de marque » (opt-in) -------------------------- */
[data-theme="dark"] {
  --brand-700: #3D8FCB; --brand-600: #5AA1D6; --brand-300: #2C5F86;
  --brand-100: #1B3A55; --brand-50: #142B41;
  --ink: #EAF0F8; --ink-soft: #C2CEDF; --muted: #93A1B8; --faint: #64748B;
  --bg: #0B1220; --surface: #141D30; --surface-2: #101829; --surface-3: #1A2540;
  --line: #26334C; --line-soft: #1E2A40;
  --top-glow: inset 0 1px 0 rgba(255, 255, 255, .05);
  --success-bg: rgba(22, 163, 74, .16);
  --warning-bg: rgba(217, 119, 6, .16);
  --info-bg: rgba(28, 111, 168, .18);
  --danger-bg: rgba(192, 57, 43, .18);
  --sh-xs: 0 1px 2px rgba(0, 0, 0, .4);
  --sh-sm: 0 2px 8px rgba(0, 0, 0, .45);
  --sh-md: 0 12px 30px rgba(0, 0, 0, .5);
  --sh-lg: 0 28px 64px rgba(0, 0, 0, .6);
  color-scheme: dark;
}
[data-theme="dark"] body { background: var(--bg); color: var(--ink); }
/* transition douce lors de la bascule de thème (hors reduced-motion) */
.mui-theme-anim, .mui-theme-anim * {
  transition: background-color var(--t) var(--ease), color var(--t) var(--ease),
              border-color var(--t) var(--ease);
}

/* --- Eyebrow / titres de section --------------------------------------- */
.mui-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: var(--fs-xs); font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; color: var(--brand-700);
}
.mui-eyebrow::before { content: ""; width: 22px; height: 1.5px; background: var(--brand-300); border-radius: 2px; }

/* --- Carte générique flottante ----------------------------------------- */
.mui-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--sh-sm), var(--top-glow);
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease), border-color var(--t) var(--ease);
}
.mui-card--lift:hover { transform: translateY(-4px); box-shadow: var(--sh-md), var(--top-glow); border-color: var(--brand-300); }

/* --- Badges ------------------------------------------------------------- */
.mui-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-xs); font-weight: 700; line-height: 1;
  padding: 6px 11px; border-radius: var(--r-pill);
}
.mui-badge--live { color: #fff; background: linear-gradient(180deg, #F43F5E, var(--live)); box-shadow: 0 6px 16px rgba(225, 29, 72, .36); }
.mui-badge--new  { color: var(--brand-800); background: var(--brand-100); }
.mui-badge--gold { color: #5A3A05; background: linear-gradient(180deg, var(--gold-300), var(--gold-500)); }
.mui-badge--soft { color: var(--ink-soft); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--sh-xs); }
.mui-ping { width: 7px; height: 7px; border-radius: 50%; background: #fff; position: relative; }
.mui-ping::after { content: ""; position: absolute; inset: -3px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .7); animation: mui-ping 1.5s var(--ease) infinite; }
@keyframes mui-ping { 0% { transform: scale(.7); opacity: .9; } 80%, 100% { transform: scale(1.9); opacity: 0; } }

/* --- Progress ----------------------------------------------------------- */
.mui-progress { height: 9px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.mui-progress > i { display: block; height: 100%; border-radius: var(--r-pill); background: linear-gradient(90deg, var(--brand-600), var(--brand-500)); }

/* --- Toggle de thème ---------------------------------------------------- */
.mui-theme-toggle {
  width: 44px; height: 44px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; display: grid; place-items: center; box-shadow: var(--sh-xs);
  transition: transform var(--t-fast) var(--ease), border-color var(--t) var(--ease);
}
.mui-theme-toggle:hover { transform: translateY(-1px); border-color: var(--brand-300); }
.mui-theme-toggle svg { width: 19px; height: 19px; }
.mui-theme-toggle .mui-moon { display: none; }
[data-theme="dark"] .mui-theme-toggle .mui-sun { display: none; }
[data-theme="dark"] .mui-theme-toggle .mui-moon { display: block; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
