/**
 * Helios Login - Complete Redesign
 * Version: 2026-01-10
 * Design Premium & Cohérent avec l'identité visuelle Helios
 * Sobre, élégant, professionnel
 */

/* ============================================
   BRANDING TENANT (mission tenant-onboarding, P0-3)
   ============================================
   Recible LOCALEMENT --accent-cyan (utilisee par le sun-icon, les liens, les
   focus rings et la checkbox "remember me") sur --tenant-accent, emise par
   helios_tenant_branding_meta_tags() (login.phtml). Ne touche JAMAIS
   theme-global.css (theme par defaut partage par toute l'app) : cette page
   seule recoit la couleur du tenant courant.
   Repli = comportement actuel (#E63946, rouge Helios) si --tenant-accent
   n'est pas emise (page hors contexte tenant) -> 0 regression.
   ============================================ */
body {
    --accent-cyan: var(--tenant-accent, #E63946);
}

/* ============================================
   BASE & LAYOUT
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Utility class - hidden */
.hidden {
    display: none !important;
}

html, body {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: var(--h-font-family, system-ui, sans-serif);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    /* Utilise les variables CSS d'Helios */
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* Gradient de fond subtil et professionnel - DARK MODE */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    /* Fond identique à stabilis-it.ch/formations : halo rouge haut-gauche +
       halo or bas-droit sur noir profond (aucun bleu). */
    background:
        radial-gradient(circle at 18% 22%, rgba(230, 57, 70, 0.18) 0%, transparent 42%),
        radial-gradient(circle at 82% 78%, rgba(212, 175, 55, 0.10) 0%, transparent 45%),
        linear-gradient(160deg, #0A0A0A 0%, #0D0D0D 50%, #111111 100%);
    z-index: -1;
}

/* Light theme - Gradient clair et apaisant - VRAIMENT DIFFÉRENT */
body.light-theme::before {
    background: linear-gradient(137.5deg, var(--phi-gray-50) 0%, var(--bg-lighter) 30%, var(--bg-light) 70%, var(--phi-blue-200) 100%);
}

/* Texture grain subtile pour ajouter de la profondeur */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: 0.015;
    pointer-events: none;
    z-index: 0;
}

body.light-theme::after {
    opacity: 0.01;
}

/* ============================================
   LOGIN CONTAINER - Premium Glassmorphism
   ============================================ */
.login-container {
    position: relative;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    padding: var(--space-8);
    background: var(--phi-dark-800);
    backdrop-filter: blur(var(--blur-xl, 21px));
    -webkit-backdrop-filter: blur(var(--blur-xl, 21px));
    border: 1px solid var(--phi-gray-200);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-glow-md);
    z-index: 10;
    animation: fadeInUp var(--duration-slower) cubic-bezier(0.22, 1, 0.36, 1);
}

/* Light theme - Container blanc pur avec ombre douce */
body.light-theme .login-container {
    background: var(--phi-gray-950) !important;
    backdrop-filter: blur(var(--blur-xl, 21px)) !important;
    border: 1px solid var(--accent-secondary-13) !important;
    box-shadow: var(--shadow-xl) !important;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Subtle top accent border */
.login-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: var(--space-1);
    background: linear-gradient(90deg, transparent 0%, var(--accent-cyan) 50%, transparent 100%);
    border-radius: var(--radius-2xl) 24px 0 0;
}

body.light-theme .login-container::before {
    background: linear-gradient(90deg, transparent 0%, var(--accent-secondary) 50%, transparent 100%);
}

/* ============================================
   LOGO & BRANDING
   ============================================ */
.logo-container {
    text-align: center;
    margin-bottom: var(--space-7);
}

.logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--size-55, 55px);
    height: var(--size-55, 55px);
    margin: 0 auto var(--space-5);
    /* Repli legacy (parite stricte, navigateurs sans color-mix()) */
    background: linear-gradient(135deg, var(--accent-primary, #E63946) 0%, #FF5A67 100%);
    border-radius: var(--radius-xl);
    box-shadow: 0 8px 24px rgba(var(--tenant-accent-rgb, 230, 57, 70), 0.35);
}

/* Branding tenant : structure du gradient conservee, stops derives de
   --tenant-accent via color-mix(). Repli ci-dessus si non supporte. */
@supports (background: color-mix(in srgb, red, white)) {
    .logo-icon {
        background: linear-gradient(
            135deg,
            var(--tenant-accent, #E63946) 0%,
            color-mix(in srgb, var(--tenant-accent, #E63946) 82%, white 18%) 100%
        );
    }
}

body.light-theme .logo-icon {
    box-shadow: var(--shadow-lg);
}

.logo-icon.sun-logo {
    background: transparent;
    box-shadow: none;
}

/* Logo tenant (mission tenant-onboarding) : remplace l'icone soleil generique
   quand tenant_settings.logo_path est configure. Fond transparent (le logo
   uploade porte deja sa propre identite visuelle, pas de halo colore dessus). */
.logo-icon.tenant-logo-icon {
    background: transparent;
    box-shadow: none;
    padding: var(--space-1);
}

.tenant-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: var(--radius-md);
}

.sun-icon {
    width: var(--space-9);  /* 55px - Fibonacci */
    height: var(--space-9);
}

.sun-core {
    fill: var(--accent-cyan);
    filter: drop-shadow(0 0 10px var(--accent-cyan));
}

body.light-theme .sun-core {
    fill: var(--accent-secondary);
    filter: drop-shadow(0 0 10px var(--accent-secondary));
}

.sun-rays line {
    stroke: var(--accent-cyan);
    stroke-width: 2.5;
    stroke-linecap: round;
}

body.light-theme .sun-rays line {
    stroke: var(--accent-secondary);
}

.brand-name {
    font-size: var(--text-2xl);
    font-weight: 700;
    letter-spacing: -0.02em;
    /* Titre blanc comme stabilis-it.ch/formations (plus de dégradé orange) */
    color: #F4F4F5;
    background: none;
    -webkit-text-fill-color: #F4F4F5;
    margin-bottom: var(--space-2);
}

.brand-tagline {
    font-size: var(--text-sm);
    color: var(--text-muted);
    font-weight: 400;
}

/* ============================================
   FORMS - Élégant et cohérent avec Helios
   ============================================ */
.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
    letter-spacing: 0.01em;
}

.input-group {
    position: relative;
    display: flex;
    width: 100%;
    margin-bottom: var(--space-4);
}

.input-group-text {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 var(--space-4);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-right: none;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    color: var(--text-muted);
    font-size: var(--text-base);
    transition: all var(--transition-fast);
}

.input-group:focus-within .input-group-text {
    background: var(--bg-input-focus);
    border-color: var(--border-focus);
    color: var(--accent-cyan);
}

body.light-theme .input-group:focus-within .input-group-text {
    color: var(--accent-secondary);
}

.form-control {
    flex: 1;
    min-height: var(--space-7);
    padding: 0 var(--space-4);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-left: none;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: 400;
    outline: none;
    transition: all var(--transition-fast);
}

.form-control::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.form-control:focus {
    background: var(--bg-input-focus);
    border-color: var(--border-focus);
    /* Branding tenant : focus ring en teinte accent tenant (repli identique a
       var(--accent-primary-10) = rgba(230,57,70,.1) aujourd'hui). */
    box-shadow: 0 0 0 3px rgba(var(--tenant-accent-rgb, 230, 57, 70), 0.1);
}

body.light-theme .form-control:focus {
    box-shadow: 0 0 0 3px var(--accent-secondary-10);
}

/* ============================================
   CHECKBOX - Remember Me (UX UI Pro Max)
   ============================================ */
.form-check {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: 0;
    /* Touch target minimum 44px via padding */
    padding: var(--space-2) 0;
    min-height: 44px;
}

.form-check-input {
    appearance: none;
    -webkit-appearance: none;
    /* Taille Fibonacci: 18px (proche de 21 mais plus proportionné) */
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    position: relative;
    transition: all var(--duration-fast) var(--ease-golden);
    margin: 0;
    flex-shrink: 0;
}

.form-check-input:hover {
    border-color: var(--accent-cyan);
    background: var(--bg-input-focus);
    transform: scale(1.05);
}

body.light-theme .form-check-input:hover {
    border-color: var(--accent-secondary);
}

.form-check-input:checked {
    background: var(--accent-cyan);
    border-color: var(--accent-cyan);
}

body.light-theme .form-check-input:checked {
    background: var(--accent-secondary);
    border-color: var(--accent-secondary);
}

/* Checkmark SVG centré - UX UI Pro Max pattern */
.form-check-input:checked::after {
    content: '';
    position: absolute;
    /* Centrage précis dans la box 18x18 avec border 2px = 14x14 intérieur */
    left: 4px;
    top: 1px;
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2.5px 2.5px 0;
    transform: rotate(45deg);
    animation: checkmarkPop var(--duration-fast) var(--ease-golden);
}

@keyframes checkmarkPop {
    0% {
        opacity: 0;
        transform: rotate(45deg) scale(0);
    }
    50% {
        transform: rotate(45deg) scale(1.2);
    }
    100% {
        opacity: 1;
        transform: rotate(45deg) scale(1);
    }
}

.form-check-input:focus {
    outline: none;
    /* Branding tenant : repli identique a var(--accent-primary-13) = rgba(230,57,70,.13) */
    box-shadow: 0 0 0 3px rgba(var(--tenant-accent-rgb, 230, 57, 70), 0.13);
}

body.light-theme .form-check-input:focus {
    box-shadow: 0 0 0 3px var(--accent-secondary-13);
}

.form-check-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    /* Touch target: clickable area for accessibility */
    padding: var(--space-1) 0;
    transition: color var(--duration-fast);
}

.form-check-label:hover {
    color: var(--text-primary);
}

/* ============================================
   BUTTON - Primary CTA
   ============================================ */
.btn-login {
    width: 100%;
    height: var(--space-7);
    padding: 0 var(--space-5);
    /* Repli legacy (parite stricte, navigateurs sans color-mix()) : bouton rouge
       identique au rendu actuel. Sur-charge tenant ci-dessous. */
    background: linear-gradient(135deg, var(--accent-primary, #E63946) 0%, #FF5A67 100%);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: var(--text-sm);
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 16px rgba(var(--tenant-accent-rgb, 230, 57, 70), 0.32);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

/* Branding tenant (mission tenant-onboarding) : structure du gradient
   conservee (2 stops), derivee de --tenant-accent via color-mix(). Repli
   ci-dessus (#E63946/#FF5A67) si color-mix() non supporte.
   NOTE contraste : le texte du CTA reste blanc par defaut (aucun calcul de
   luminance possible en CSS pur) — le wizard d'onboarding est responsable de
   refuser un accent_color trop clair pour garder un contraste AA suffisant
   avec du texte blanc (cf. rapport de livraison). */
@supports (background: color-mix(in srgb, red, white)) {
    .btn-login {
        background: linear-gradient(
            135deg,
            var(--tenant-accent, #E63946) 0%,
            color-mix(in srgb, var(--tenant-accent, #E63946) 82%, white 18%) 100%
        );
    }
}

body.light-theme .btn-login {
    box-shadow: var(--shadow-md);
}

.btn-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 22px rgba(var(--tenant-accent-rgb, 230, 57, 70), 0.45);
}

body.light-theme .btn-login:hover {
    box-shadow: var(--shadow-md);
}

.btn-login:active {
    transform: translateY(0);
}

.btn-login:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ============================================
   LINKS
   ============================================ */
.forgot-link {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.forgot-link:hover {
    color: var(--accent-cyan);
    text-decoration: none;
}

body.light-theme .forgot-link:hover {
    color: var(--accent-secondary);
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-6);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--text-sm);
    font-weight: 500;
    border: 1px solid;
    backdrop-filter: blur(var(--blur-md, 8px));
}

.alert i {
    font-size: var(--text-lg);
}

.alert-danger,
.alert-glass.error {
    background: var(--danger-bg);
    border-color: var(--danger-30);
    color: var(--danger-light, var(--danger-light));
}

body.light-theme .alert-danger,
body.light-theme .alert-glass.error {
    background: var(--danger-bg);
    border-color: var(--danger-30);
    color: var(--danger);
}

.alert-success {
    background: var(--success-bg);
    border-color: var(--success-30);
    color: var(--success-light);
}

body.light-theme .alert-success {
    background: var(--success-bg);
    border-color: var(--success-30);
    color: var(--success);
}

/* ============================================
   THEME TOGGLE - Icône simple sans fond
   ============================================ */
.theme-toggle {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    width: var(--space-7);
    height: var(--space-7);
    background: transparent;
    border: none;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    transition: transform var(--transition-fast);
}

.theme-toggle:hover {
    transform: scale(1.1);
}

.theme-toggle i {
    font-size: var(--text-2xl);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    filter: drop-shadow(0 2px 4px var(--phi-dark-300));
}

.theme-toggle:hover i {
    color: var(--accent-cyan);
}

body.light-theme .theme-toggle:hover i {
    color: var(--accent-secondary);
}

/* ============================================
   LOADING SPINNER
   ============================================ */
.spinner-border {
    width: var(--space-5);
    height: var(--space-5);
    border: 2px solid var(--phi-gray-300);
    border-top-color: white;
    border-radius: var(--radius-full);
    animation: spin var(--duration-slower) linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   SUBTLE BACKGROUND ACCENT - DARK MODE
   ============================================ */
.bg-accent {
    position: fixed;
    width: var(--size-610, 610px);
    height: var(--size-610, 610px);
    border-radius: var(--radius-full);
    filter: blur(120px);
    opacity: 0.2;
    pointer-events: none;
    z-index: -1;
}

.bg-accent-1 {
    top: -200px;
    left: -200px;
    /* Repli legacy (parite stricte, navigateurs sans color-mix()) : halo rouge pur */
    background: radial-gradient(circle, var(--accent-primary, #E63946) 0%, var(--accent-primary-strong, #C41E3A) 100%);
}

/* Branding tenant : halo 1 suit --tenant-accent (structure gradient conservee,
   2e stop assombri via color-mix). Repli ci-dessus si color-mix() non supporte. */
@supports (background: color-mix(in srgb, red, white)) {
    .bg-accent-1 {
        background: radial-gradient(
            circle,
            var(--tenant-accent, #E63946) 0%,
            color-mix(in srgb, var(--tenant-accent, #E63946) 85%, black 15%) 100%
        );
    }
}

.bg-accent-2 {
    bottom: -200px;
    right: -200px;
    /* Halo or — flourish decoratif Helios volontairement NON tenant (aucun champ
       tenant_settings ne correspond a une couleur "or secondaire" ; recolorer ce
       halo en derive de --tenant-accent produirait un halo rouge/vert la ou il
       est gold aujourd'hui, une regression visuelle pour le tenant courant.
       Documente dans le rapport de livraison. */
    background: radial-gradient(circle, #D4AF37 0%, #B8962E 100%);
}

/* Light theme - Accents pastel doux */
body.light-theme .bg-accent {
    opacity: 0.15;
}

body.light-theme .bg-accent-1 {
    background: linear-gradient(137.5deg, var(--bg-lighter), var(--accent-primary-30));
}

body.light-theme .bg-accent-2 {
    background: linear-gradient(137.5deg, var(--accent-primary-30), var(--phi-red-200));
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Tablet */
@media (max-width: 768px) {
    .login-container {
        max-width: var(--size-377, 377px);
        padding: var(--space-7) var(--space-6);
        border-radius: var(--radius-2xl);
    }

    .logo-icon {
        width: var(--space-8);
        height: var(--space-8);
    }

    .sun-icon {
        width: 42px;
        height: 42px;
    }

    .brand-name {
        font-size: var(--text-2xl);
    }

    .brand-tagline {
        font-size: var(--text-xs);
    }
}

/* Mobile */
@media (max-width: 576px) {
    body {
        padding: var(--space-4);
    }

    .login-container {
        max-width: 100%;
        padding: var(--space-6) var(--space-5);
        border-radius: var(--radius-2xl);
    }

    .logo-container {
        margin-bottom: var(--space-6);
    }

    .logo-icon {
        width: 52px;
        height: 52px;
        border-radius: var(--radius-xl);
    }

    .sun-icon {
        width: 38px;
        height: 38px;
    }

    .brand-name {
        font-size: var(--text-xl);
    }

    .brand-tagline {
        font-size: var(--text-xs);
    }

    .form-control,
    .input-group-text {
        /* min-height et non height : le champ peut grandir (cible tactile
           44 px) et l'icone doit le suivre, sinon elle decroche visuellement. */
        min-height: var(--space-7);
        font-size: var(--text-sm);
    }

    .btn-login {
        height: var(--space-7);
        font-size: var(--text-sm);
    }

    .form-label {
        font-size: var(--text-xs);
    }

    .form-check-label,
    .forgot-link {
        font-size: var(--text-xs);
    }

    .mb-4 {
        flex-wrap: wrap;
        gap: var(--space-3);
    }

    .form-check {
        width: 100%;
    }

    .forgot-link {
        width: 100%;
        text-align: center;
    }

    .theme-toggle {
        top: 1rem;
        right: 1rem;
        width: var(--space-7);
        height: var(--space-7);
    }

    .theme-toggle i {
        font-size: var(--text-xl);
    }

    .bg-accent {
        width: var(--size-377, 377px);
        height: var(--size-377, 377px);
    }
}

/* Small mobile 377px */
@media (max-width: 377px) {
    .login-container {
        padding: var(--space-6) var(--space-5);
        border-radius: var(--radius-xl);
    }

    .logo-icon {
        width: var(--space-7);
        height: var(--space-7);
        border-radius: var(--radius-lg);
    }

    .sun-icon {
        width: var(--size-34, 34px);
        height: var(--size-34, 34px);
    }

    .brand-name {
        font-size: var(--text-xl);
    }
}

/* Extreme mobile 320px */
@media (max-width: 320px) {
    body {
        padding: var(--space-2);
    }

    .login-container {
        padding: var(--space-5) var(--space-4);
        border-radius: var(--radius-lg);
        max-width: 100%;
    }

    .logo-container {
        margin-bottom: var(--space-4);
    }

    .logo-icon {
        width: var(--space-6);
        height: var(--space-6);
        margin-bottom: var(--space-3);
    }

    .sun-icon {
        width: 28px;
        height: 28px;
    }

    .brand-name {
        font-size: var(--text-lg);
    }

    .brand-tagline {
        font-size: var(--text-2xs);
    }

    .form-label {
        font-size: var(--text-2xs);
    }

    .form-control,
    .input-group-text {
        min-height: var(--space-6);
        font-size: var(--text-xs);
        padding: 0 var(--space-3);
    }

    .input-group {
        margin-bottom: var(--space-3);
    }

    .btn-login {
        height: var(--space-6);
        font-size: var(--text-xs);
        padding: 0 var(--space-4);
    }

    .form-check-label,
    .forgot-link {
        font-size: var(--text-2xs);
    }

    .alert {
        padding: var(--space-3) var(--space-4);
        font-size: var(--text-xs);
    }

    .theme-toggle {
        top: var(--space-2);
        right: var(--space-2);
        width: var(--space-6);
        height: var(--space-6);
    }

    .theme-toggle i {
        font-size: var(--text-lg);
    }

    .bg-accent {
        display: none;
    }
}

/* Landscape mode */
@media (max-height: 610px) and (orientation: landscape) {
    .login-container {
        padding: var(--space-5) var(--space-5);
        margin: var(--space-2) auto;
    }

    .logo-container {
        margin-bottom: var(--space-4);
    }

    .logo-icon {
        width: var(--space-7);
        height: var(--space-7);
        margin-bottom: var(--space-3);
    }

    .sun-icon {
        width: var(--space-6);
        height: var(--space-6);
    }

    .brand-name {
        font-size: var(--text-lg);
    }

    .brand-tagline {
        display: none;
    }

    .input-group {
        margin-bottom: var(--space-3);
    }

    .mb-4 {
        margin-bottom: var(--space-3) !important;
    }

    .bg-accent {
        display: none;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.mb-3 {
    margin-bottom: var(--space-4);
}

.mb-4 {
    margin-bottom: var(--space-6);
}

.d-flex {
    display: flex;
}

.justify-content-between {
    justify-content: space-between;
}

.align-items-center {
    align-items: center;
}

.w-100 {
    width: 100%;
}

.me-2 {
    margin-right: var(--space-2);
}

.text-danger {
    color: var(--danger) !important;
}

/* ==================== Bascule mot de passe (a11y) — arch/phase-D ==================== */
.input-group .toggle-password {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: var(--space-7);
    padding: 0 var(--space-4);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    z-index: 5;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    transition: color var(--transition-fast);
}

.input-group .toggle-password:hover {
    color: var(--accent-cyan);
}

.input-group .toggle-password:focus-visible {
    outline: 2px solid var(--focus-ring, #1677C8);
    outline-offset: -2px;
    color: var(--accent-cyan);
}

/* Réserver l'espace pour le bouton dans le champ mot de passe */
#password {
    padding-right: var(--space-7);
}

@media (prefers-reduced-motion: reduce) {
    .input-group .toggle-password {
        transition: none;
    }
}

/* =========================================================================
   EXCELLENCE PASS (2026-07-25) — a11y focus-visible, cibles tactiles φ,
   prefers-reduced-motion global. Bloc autoritaire : garantit un focus
   clavier visible (WCAG 2.4.7) quelle que soit la cascade Bootstrap/thème,
   et des cibles ≥ var(--space-8) (42px, φ-conforme, ≥ plancher WCAG 2.5.8).
   ========================================================================= */

/* Focus clavier visible sur TOUS les éléments interactifs de la page login.
   :focus-visible = clavier uniquement (pas de halo au clic souris). */
.login-container .form-control:focus-visible,
.login-container .btn-login:focus-visible,
.login-container .form-check-input:focus-visible,
.login-container .forgot-link:focus-visible,
.theme-toggle:focus-visible {
    outline: 3px solid var(--focus-ring, #1677C8) !important;
    outline-offset: 2px !important;
    border-radius: var(--radius-md);
}
body.light-theme .login-container .form-control:focus-visible,
body.light-theme .login-container .btn-login:focus-visible,
body.light-theme .login-container .form-check-input:focus-visible,
body.light-theme .login-container .forgot-link:focus-visible,
body.light-theme .theme-toggle:focus-visible {
    outline-color: var(--focus-ring, #1677C8) !important;
}

/* Cibles tactiles : champs + bouton principal ≥ 42px (var(--space-8)) */
.login-container .form-control {
    min-height: var(--space-8);
}
.login-container .btn-login {
    min-height: var(--space-8);
}
.input-group .toggle-password {
    min-width: var(--space-8);
    min-height: var(--space-8);
}
/* Zone de tap confortable autour du lien "mot de passe oublié" et du toggle thème */
.login-container .forgot-link {
    display: inline-flex;
    align-items: center;
    min-height: var(--space-8);
}
.theme-toggle {
    min-width: var(--space-8);
    min-height: var(--space-8);
}

/* Réduction de mouvement : neutralise toutes les animations décoratives */
@media (prefers-reduced-motion: reduce) {
    .login-container,
    .login-container *,
    .bg-accent,
    .sun-rays,
    .sun-core,
    .btn-login,
    .theme-toggle {
        animation: none !important;
        transition: none !important;
    }
}

/* ═══════════════════════════════════════════════════════════════
   SPLIT-SCREEN MODERNE 2026 — panneau marque immersif + formulaire
   Desktop ≥838px : 2 colonnes (marque | formulaire).
   Mobile : marque compacte au-dessus de la carte.
   Tokens φ uniquement — durées/espacements/rayons via variables.
   ═══════════════════════════════════════════════════════════════ */

.login-shell {
    --lb-drift-slow: 21s;   /* dérive aurora — Fibonacci s */
    --lb-drift-fast: 13s;
    --lb-red-rgb: 230, 57, 70;    /* accent Helios (soleil) */
    --lb-gold-rgb: 212, 175, 55;  /* or vitrine stabilis-it.ch */
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-y: auto;
    z-index: 1;
    /* La banniere RGPD est `position: fixed; bottom` et recouvrait le bouton
       « Se connecter » sur mobile (mesure : elementFromPoint au centre du
       bouton retournait la banniere a 320 ET 375 px). C'est CE conteneur qui
       defile, pas le document : le padding pose sur <body> restait hors de
       lui. gdpr-banner.js publie la hauteur reelle sur <html>. */
    padding-block-end: var(--gdpr-banner-space, 0px);
}

.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 auto;
    padding: var(--space-5) var(--space-4) var(--space-8);
}

/* ---- Panneau marque : compact en mobile ---- */
.login-brand {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-6) var(--space-4) var(--space-2);
}

.login-brand-inner {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-5);
    max-width: 420px;
}

/* Points de valeur : cachés en mobile (la carte doit rester au-dessus du pli) */
.login-values {
    display: none;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-direction: column;
    gap: var(--space-4);
}

.login-value {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.5;
}

.login-value-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: var(--space-7);
    height: var(--space-7);
    border-radius: var(--radius-full);
    background: rgba(230, 57, 70, 0.12);
    border: 1px solid rgba(230, 57, 70, 0.22);
    color: var(--accent-primary, #e63946);
    font-size: var(--text-base);
}

body.light-theme .login-value {
    color: var(--phi-gray-700);
}

/* ---- Desktop ≥838px : vrai split 2 colonnes ---- */
@media (min-width: 838px) {
    .login-shell {
        flex-direction: row;
        /* La reservation de hauteur pour la banniere RGPD ne vaut qu'en dessous
           de ce breakpoint : au-dela, la banniere occupe le coin bas-gauche et
           ne couvre plus le bouton. Le padding y volait sa hauteur au
           `min-height: 100dvh` — le contenu se centrait dans un espace ampute et
           remontait, laissant un tiers de page vide sous le pli (mesure a
           1355 px : panneau a -61 px, carte finie a 573 px sur 900). */
        padding-block-end: 0;
    }

    .login-brand {
        flex: 1 1 50%;
        padding: var(--space-8);
        overflow: hidden;
    }

    .login-panel {
        flex: 1 1 50%;
        padding: var(--space-8);
    }

    .login-brand-inner {
        align-items: flex-start;
        gap: var(--space-7);
    }

    .login-brand .logo-container {
        text-align: left;
        margin-block-end: 0;
    }

    .login-brand .brand-name {
        font-size: var(--text-4xl);
    }

    .login-brand .brand-tagline {
        font-size: var(--text-base);
    }

    .login-values {
        display: flex;
        animation: fadeInUp var(--duration-slower) cubic-bezier(0.22, 1, 0.36, 1);
    }

    /* Aurora immersive : 2 halos qui dérivent lentement (marque = soleil Helios) */
    .login-brand::before,
    .login-brand::after {
        content: '';
        position: absolute;
        inset: auto;
        width: 55vmin;
        height: 55vmin;
        border-radius: var(--radius-full);
        filter: blur(89px);
        pointer-events: none;
        z-index: 1;
    }

    .login-brand::before {
        top: -13%;
        left: -8%;
        background: radial-gradient(circle, rgba(var(--lb-red-rgb), 0.28) 0%, transparent 62%);
        animation: lb-drift-a var(--lb-drift-slow) ease-in-out infinite alternate;
    }

    .login-brand::after {
        bottom: -18%;
        right: -5%;
        background: radial-gradient(circle, rgba(var(--lb-gold-rgb), 0.20) 0%, transparent 62%);
        animation: lb-drift-b var(--lb-drift-fast) ease-in-out infinite alternate;
    }

    body.light-theme .login-brand::before {
        background: radial-gradient(circle, rgba(var(--lb-red-rgb), 0.14) 0%, transparent 62%);
    }

    body.light-theme .login-brand::after {
        background: radial-gradient(circle, rgba(var(--lb-gold-rgb), 0.12) 0%, transparent 62%);
    }

    /* Séparation subtile entre les 2 volets */
    .login-panel {
        border-inline-start: 1px solid var(--phi-gray-200);
        background: rgba(255, 255, 255, 0.015);
    }

    body.light-theme .login-panel {
        border-inline-start-color: rgba(15, 23, 42, 0.08);
        background: rgba(255, 255, 255, 0.35);
    }
}

@keyframes lb-drift-a {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to   { transform: translate3d(8%, 6%, 0) scale(1.13); }
}

@keyframes lb-drift-b {
    from { transform: translate3d(0, 0, 0) scale(1.08); }
    to   { transform: translate3d(-6%, -8%, 0) scale(1); }
}

/* Entrance décalée : marque puis carte (φ : décalage duration-normal) */
@media (min-width: 838px) {
    .login-brand-inner {
        animation: fadeInUp var(--duration-slower) cubic-bezier(0.22, 1, 0.36, 1);
    }

    .login-container {
        animation-delay: var(--duration-normal);
        animation-fill-mode: backwards;
    }
}

@media (prefers-reduced-motion: reduce) {
    .login-brand::before,
    .login-brand::after,
    .login-brand-inner,
    .login-values,
    .login-container {
        animation: none;
    }
}

/* ---- Correctifs & en-tête de carte (refonte 2026) ---- */

/* Bootstrap tire la checkbox hors de la carte (.form-check .form-check-input
   { float:left; margin-left:-1.5em } gagne en spécificité) — on neutralise. */
.form-check .form-check-input {
    float: none;
    margin-left: 0;
}

/* Ligne "se souvenir / mot de passe oublié" : wrap propre en étroit */
#loginForm .d-flex.justify-content-between {
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-4);
}

/* En-tête de la carte : la carte retrouve une tête depuis que le logo vit
   dans le panneau marque. */
.login-form-head {
    margin-block-end: var(--space-5);
}

.login-form-title {
    margin: 0 0 var(--space-2);
    font-size: var(--text-2xl);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    /* « Bon retour parmi nous » se coupait en laissant « nous » seul sur la
       deuxieme ligne. Un mot orphelin dans le titre d accueil est la premiere
       chose que voit un prospect : le navigateur repartit desormais les lignes. */
    text-wrap: balance;
}

.login-form-hint {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

body.light-theme .login-form-hint {
    color: var(--phi-gray-600);
}

/* Mobile : pas de trou — l'ensemble marque+carte est centré, la carte suit
   directement la marque compacte. (837px : exclusif avec le min-width 838 du split) */
@media (max-width: 837px) {
    .login-shell {
        justify-content: center;
    }

    .login-brand {
        flex: 0 0 auto;
    }

    .login-panel {
        flex: 0 0 auto;
        align-items: flex-start;
        padding-block-start: var(--space-4);
    }

    .login-form-title {
        font-size: var(--text-xl);
    }
}

/* Thème clair : le nom de marque redevient lisible (le -webkit-text-fill-color
   blanc forcé du thème sombre le rendait invisible sur fond clair — AA). */
body.light-theme .brand-name {
    color: #0f172a;
    -webkit-text-fill-color: #0f172a;
}
