/* ==========================================================================
   login.css — écran de connexion (refonte interface, 17/08/2026)
   Consomme les tokens du système de design (--accent, --surface, --border,
   --text, --radius-*, --space-*, --shadow-*, ...) : aucune couleur en dur,
   thème clair/sombre et palettes intacts.
   Chargé uniquement par shared/php/login.php — aucun autre gabarit n'inclut
   ce fichier (page.php / mfa/verify.php gardent leur propre <style> inline
   et ne sont pas concernés par cette refonte).
   ========================================================================== */

/* ==========================================================================
   SOCLE DE SECOURS — ne jamais servir une page de connexion NUE
   --------------------------------------------------------------------------
   login.php charge `/assets/css/style.css`, un chemin relatif à la RACINE WEB
   DU SITE : il ne se résout que sous le DocumentRoot du dashboard
   (html/public). Or cette page de connexion est la porte d'entrée des NEUF
   sites et de tout aperçu local : dès que ce fichier ne se résout pas, la
   page perdait d'un coup sa police, son fond, ses espacements, ses rayons et
   ses ombres — champs en rendu natif du navigateur, texte en serif.

   On redéclare donc ici les tokens indispensables, dans une @layer de
   PRIORITÉ BASSE : en CSS, les règles hors couche l'emportent toujours sur
   les règles en couche. Quand style.css se charge (cas normal en production),
   ses valeurs gagnent et rien ne change ; quand il manque, la page reste
   présentable au lieu de s'effondrer.
   ========================================================================== */
@layer abrt-socle {
    :root {
        --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

        --space-1: 4px;   --space-2: 8px;   --space-3: 12px;  --space-4: 16px;
        --space-5: 20px;  --space-6: 24px;  --space-8: 32px;  --space-10: 40px;

        --radius-sm: 6px; --radius-md: 8px; --radius-lg: 12px;
        --radius-xl: 16px; --radius-full: 9999px;

        --t-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
        --t-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);

        /* Ambiance sombre par défaut (préférence du projet) */
        --bg: #08090b;          --bg-grad: none;
        --surface: #0f1115;     --surface-hover: #1f242c;
        --border: #1f232b;      --border-strong: #2a2f38;
        --text: #f4f4f5;        --text-muted: #a1a1aa;   --text-subtle: #71717a;
        --danger: #ef4444;      --success: #10b981;
        --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
        --shadow-md: 0 4px 12px rgba(0,0,0,0.45);
        --shadow-lg: 0 12px 32px rgba(0,0,0,0.55);
        --accent: #b45309;
        --accent-bg: color-mix(in srgb, var(--accent) 14%, transparent);
        --accent-border: color-mix(in srgb, var(--accent) 35%, transparent);
    }

    :root[data-theme="light"] {
        --bg: #fafafa;          --bg-grad: none;
        --surface: #ffffff;     --surface-hover: #f9fafb;
        --border: #e4e4e7;      --border-strong: #d4d4d8;
        --text: #09090b;        --text-muted: #52525b;   --text-subtle: #71717a;
        --danger: #dc2626;      --success: #059669;
        --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
        --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
        --shadow-lg: 0 12px 32px rgba(0,0,0,0.10);
    }

    /* Reset minimal repris de style.css (police, fond, boîte, formulaires) */
    *, *::before, *::after { box-sizing: border-box; }
    html { -webkit-text-size-adjust: 100%; }
    body {
        margin: 0;
        min-height: 100vh;
        font-family: var(--font-sans);
        background: var(--bg);
        color: var(--text);
        -webkit-font-smoothing: antialiased;
    }
    button, input { font: inherit; color: inherit; }
    a { color: inherit; }
}

body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
    /* Le dégradé de fond vient de --bg-grad (déjà posé par style.css) :
       pas de dégradé supplémentaire ici, pour rester sobre. */
}

/* ---------- Bascule de thème ----------
   Bouton indépendant de la carte (avant : coincé dans son coin). Masqué par
   palette.js dès que le FAB de personnalisation est injecté — comportement
   normal, cohérent avec le reste de l'écosystème ; ce bouton reste un repli
   si palette.js ne s'exécute pas. */
.theme-toggle.login-toggle {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: 40;
    width: 44px;
    height: 44px;
}
.login-toggle svg { pointer-events: none; } /* iOS/Safari : le tap doit cibler le bouton, pas le svg */

/* ---------- Structure ---------- */
.login-wrap {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.login-card {
    position: relative;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--space-10) var(--space-8) var(--space-8);
    box-shadow: var(--shadow-lg);
}

.login-brand {
    display: flex;
    justify-content: center;
    margin-bottom: var(--space-5);
}
.login-mark {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    background: var(--accent-bg);
    border: 1px solid var(--accent-border);
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-mark img { width: 26px; height: 26px; }

.login-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.25;
    text-align: center;
    color: var(--text);
}

.subtitle {
    color: var(--text-muted); /* --text-subtle est sous le seuil AA (4.5:1) sur certaines palettes */
    font-size: 0.9rem;
    line-height: 1.5;
    text-align: center;
    margin-top: 6px;
    margin-bottom: var(--space-8);
}

/* ---------- Erreur ---------- */
.login-error {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    background: color-mix(in srgb, var(--danger) 10%, transparent);
    color: var(--danger);
    border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
    border-radius: var(--radius-md);
    padding: 11px 14px;
    margin-bottom: var(--space-5);
    font-size: 0.85rem;
    line-height: 1.45;
}
.login-error svg { flex: 0 0 auto; margin-top: 1px; }
.login-error:focus { outline: none; } /* reçoit le focus par script, pas par le clavier */

/* ---------- Champs ---------- */
.field { margin-bottom: var(--space-5); }
.field label {
    display: block;
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 7px;
}
.field-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-2);
}
.field-head label { margin-bottom: 0; }
.field-link {
    font-size: 0.79rem;
    font-weight: 500;
    color: var(--text-muted); /* idem : lisibilité AA avant nuance */
    transition: color var(--t-fast);
}
.field-link:hover, .field-link:focus-visible { color: var(--accent); }

.login-card .input {
    width: 100%;
    box-sizing: border-box;
    font-size: 16px;   /* jamais < 16px : Safari iOS zoome au focus sinon */
    line-height: 1.3;
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-family: inherit;
    transition: border-color var(--t-fast), box-shadow var(--t-fast), background-color var(--t-fast);
}
.login-card .input::placeholder { color: var(--text-faint); }
.login-card .input:hover { border-color: var(--border-strong); }
.login-card .input:focus {
    outline: none;
    background: var(--surface);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}

.password-wrap { position: relative; }
.password-wrap .input { padding-right: 44px; }
.pw-toggle {
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-faint);
    cursor: pointer;
    font-family: inherit;
    transition: color var(--t-fast);
}
.pw-toggle:hover, .pw-toggle:focus-visible { color: var(--text-muted); }
.pw-toggle svg { width: 18px; height: 18px; pointer-events: none; }
.pw-toggle .icon-eye-off { display: none; }
.pw-toggle[aria-pressed="true"] .icon-eye { display: none; }
.pw-toggle[aria-pressed="true"] .icon-eye-off { display: block; }

/* ---------- Bouton principal (avec état de chargement) ---------- */
.login-submit {
    position: relative;
    width: 100%;
    min-height: 46px;
    margin-top: var(--space-2);
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    font-size: 0.95rem;
    font-weight: 700;
    font-family: inherit;
    color: var(--accent-fg, #fff);
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: filter var(--t-fast), opacity var(--t-fast);
}
.login-submit:hover { filter: brightness(1.08); }
.login-submit:active { filter: brightness(0.96); }
.login-submit:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.login-submit:disabled { cursor: default; opacity: 0.85; }

.btn-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid color-mix(in srgb, var(--accent-fg, #fff) 35%, transparent);
    border-top-color: var(--accent-fg, #fff);
    animation: login-spin 0.7s linear infinite;
}
.login-submit.is-loading .btn-spinner { display: inline-block; }
.login-submit.is-loading .btn-label { opacity: 0.85; }

@keyframes login-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .btn-spinner { animation-duration: 1.6s; }
}

/* ---------- Retour ---------- */
.back-dash {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    margin-top: var(--space-6);
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: color var(--t-fast);
}
.back-dash:hover, .back-dash:focus-visible { color: var(--accent); }

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
    .login-card { padding: var(--space-8) var(--space-5); border-radius: var(--radius-lg); }
    .login-toggle { top: var(--space-3); right: var(--space-3); }
}
