/*
 * ANPE ADET — pages d'authentification (connexion, mot de passe oublié...).
 * Autonome : ne dépend ni de Metronic ni de Tailwind (page légère, rapide sur
 * connexion lente). Charger après anpe-tokens.css.
 */
*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body.anpe-auth {
    font-family: var(--anpe-font-body);
    font-size: 16px;
    line-height: 1.5;
    color: var(--anpe-ink);
    background: var(--anpe-ground);
    -webkit-font-smoothing: antialiased;
}

.auth a { color: var(--anpe-blue); text-decoration: none; }
.auth a:hover { color: var(--anpe-blue-active); text-decoration: underline; }
.auth a:focus-visible, .auth button:focus-visible { outline: 3px solid var(--anpe-sun); outline-offset: 2px; border-radius: 6px; }

/* ----- Structure : formulaire à gauche, panneau de marque à droite ----- */
.auth {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-height: 100vh;
}

.auth__form {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 32px;
    padding: 48px 64px;
    background: var(--anpe-ground);
}

.auth__brand-row { display: flex; align-items: center; gap: 14px; }
.auth__logo { height: 54px; width: auto; mix-blend-mode: multiply; display: block; }
.auth__brand-sep { width: 1px; height: 32px; background: var(--anpe-line-strong); }
.auth__brand-name { font-size: 13px; line-height: 1.3; font-weight: 500; color: var(--anpe-muted); }

.auth__main { display: flex; flex-direction: column; gap: 28px; width: 100%; max-width: 432px; margin: 0 auto; }

.auth__heading h1 {
    margin: 0 0 10px;
    font-family: var(--anpe-font-display);
    font-weight: 700;
    font-size: clamp(34px, 3.4vw, 44px);
    line-height: 1.05;
    letter-spacing: -0.02em;
    text-wrap: balance;
}
.auth__heading p { margin: 0; font-size: 17px; line-height: 1.5; color: var(--anpe-muted); }

.auth__footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; font-size: 13px; color: var(--anpe-muted); }
.auth__secure { display: inline-flex; align-items: center; gap: 8px; }
.auth__secure::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--anpe-green); }

/* ----- Formulaire ----- */
.auth-form { display: flex; flex-direction: column; gap: 20px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.field label { font-size: 14px; font-weight: 600; }
.field__head a { font-size: 14px; font-weight: 500; }
.field__hint { font-size: 14px; color: var(--anpe-muted); }
.field__error { font-size: 14px; font-weight: 500; color: var(--anpe-red); }

.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > svg { position: absolute; left: 16px; width: 20px; height: 20px; color: var(--anpe-muted); pointer-events: none; }
.input {
    width: 100%;
    height: 52px;
    padding: 0 16px 0 46px;
    font: inherit;
    font-size: 16px; /* 16px minimum : évite le zoom automatique sur iPhone */
    color: var(--anpe-ink);
    background: var(--anpe-surface);
    border: 1.5px solid var(--anpe-line-strong);
    border-radius: var(--anpe-radius);
}
.input::placeholder { color: #7A8096; }
.input:focus { outline: 3px solid var(--anpe-sun); outline-offset: 1px; border-color: var(--anpe-blue); }
.input[aria-invalid="true"] { border-color: var(--anpe-red); }
.input--has-toggle { padding-right: 52px; }
.input[readonly] { background: var(--anpe-readonly); color: var(--anpe-muted); }

.input-toggle {
    position: absolute; right: 4px;
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: 0; border-radius: 10px;
    color: var(--anpe-muted); cursor: pointer;
}
.input-toggle:hover { color: var(--anpe-ink); }

.btn-anpe {
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; height: 54px; margin-top: 4px;
    font: inherit; font-size: 17px; font-weight: 600;
    color: #fff; background: var(--anpe-primary);
    border: 0; border-radius: var(--anpe-radius);
    box-shadow: 0 1px 0 var(--anpe-blue-active), 0 8px 20px rgba(30, 69, 200, 0.22);
    cursor: pointer;
}
.btn-anpe:hover { background: var(--anpe-primary-active); }
.btn-anpe:disabled { opacity: 0.75; cursor: progress; }
.btn-anpe svg { width: 20px; height: 20px; }
.btn-anpe--ghost {
    background: transparent; color: var(--anpe-blue); box-shadow: none;
    border: 1.5px solid var(--anpe-blue-line);
}
.btn-anpe--ghost:hover { background: var(--anpe-blue-light); }
.auth-actions { display: flex; flex-direction: column; gap: 12px; }
a.btn-anpe { text-decoration: none; }
a.btn-anpe:hover { text-decoration: none; }

/* Case à cocher (« Se souvenir de moi ») */
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; font-weight: 500; color: var(--anpe-ink); cursor: pointer; align-self: flex-start; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--anpe-primary); cursor: pointer; }
.check input:focus-visible { outline: 3px solid var(--anpe-sun); outline-offset: 2px; }

/* Séparateur « ou » entre deux façons de faire */
.auth-or { display: flex; align-items: center; gap: 14px; font-size: 14px; color: var(--anpe-muted); }
.auth-or::before, .auth-or::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--anpe-line); }

/* Saisie du code reçu par SMS */
.input--code { letter-spacing: 0.4em; font-variant-numeric: tabular-nums; font-weight: 600; }
.auth-note { margin: 0; font-size: 14px; line-height: 1.5; color: var(--anpe-muted); }

/* ----- Messages ----- */
.alert-anpe { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--anpe-radius); font-size: 15px; line-height: 1.45; border: 1px solid; }
.alert-anpe svg { flex-shrink: 0; width: 20px; height: 20px; margin-top: 1px; }
.alert-anpe ul { margin: 0; padding: 0; list-style: none; }
.alert-anpe--error { background: var(--anpe-red-light); border-color: var(--anpe-red-line); color: var(--anpe-red-ink); }
.alert-anpe--success { background: var(--anpe-green-light); border-color: var(--anpe-green-line); color: var(--anpe-green-ink); }
.alert-anpe--info { background: var(--anpe-sun-light); border-color: var(--anpe-sun-line); color: var(--anpe-sun-ink); }
.alert-anpe--info svg { color: #7A5600; }

/* ----- Panneau de marque ----- */
.auth__brand {
    position: relative;
    background: var(--anpe-blue-deep);
    color: #fff;
    overflow: hidden;
    padding: 96px 64px 64px;
}
.auth__brand-copy { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 22px; max-width: 620px; }
.auth__kicker { font-size: 14px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--anpe-sun); }
.auth__brand h2 {
    margin: 0;
    font-family: var(--anpe-font-display);
    font-weight: 700;
    font-size: clamp(34px, 3.6vw, 52px);
    line-height: 1.06;
    letter-spacing: -0.025em;
    text-wrap: balance;
}
.auth__brand-copy p { margin: 0; font-size: 19px; line-height: 1.55; color: #C7D0F5; max-width: 540px; }

.auth__rays { position: absolute; left: 0; bottom: 0; width: 62%; max-width: 620px; height: auto; pointer-events: none; }

.auth__features {
    position: absolute; right: 48px; bottom: 48px; z-index: 1;
    width: min(280px, 32%);
    margin: 0; padding: 0; list-style: none;
    display: flex; flex-direction: column; gap: 18px;
}
.auth__features li { display: flex; align-items: center; gap: 12px; font-size: 15px; font-weight: 500; line-height: 1.3; }
.auth__features .chip {
    flex-shrink: 0; width: 36px; height: 36px; border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    display: flex; align-items: center; justify-content: center;
    color: var(--anpe-sun);
}
.auth__features .chip svg { width: 18px; height: 18px; }

.auth__logo-mobile {
    display: none;
    position: absolute; top: 24px; left: 24px; z-index: 2;
    width: 64px; height: 46px; background: #fff; border-radius: 12px;
    align-items: center; justify-content: center; overflow: hidden;
}
.auth__logo-mobile img { width: 52px; height: auto; display: block; }

@media (max-width: 1200px) {
    .auth__features { display: none; }
    .auth__form { padding-left: 40px; padding-right: 40px; }
    .auth__brand { padding-left: 40px; padding-right: 40px; }
}

/* ----- Téléphone / tablette : bandeau de marque en haut, formulaire en feuille ----- */
@media (max-width: 960px) {
    .auth { grid-template-columns: 1fr; }
    .auth__brand { order: -1; min-height: 340px; padding: 96px 24px 56px; }
    .auth__brand h2 { font-size: 30px; }
    .auth__brand-copy { gap: 10px; }
    .auth__brand-copy p, .auth__features { display: none; }
    .auth__rays { width: 60%; max-width: 210px; }
    .auth__logo-mobile { display: flex; }

    .auth__form {
        position: relative; z-index: 1;
        margin-top: -28px;
        padding: 32px 24px 24px;
        border-radius: 28px 28px 0 0;
        gap: 24px;
    }
    .auth__brand-row { display: none; }
    .auth__main { max-width: none; }
}

@media (prefers-reduced-motion: no-preference) {
    .btn-anpe, .input, .input-toggle { transition: background-color 0.15s, border-color 0.15s, color 0.15s; }
}

/* Mode sombre : le logo (PNG transparent à texte sombre) est posé sur une tuile blanche */
[data-theme=dark] .auth__logo { background: #fff; padding: 6px 8px; border-radius: 12px; box-sizing: content-box; }
