/* Authentification LSF Energie — login, 2FA, reinitialisation.
   Base : design fourni dans tmp2fa/2fa_auth/verify_2fa.php.
   Servi depuis /css/, les chemins d'images sont donc en ../ */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    /* Pas d'overflow:hidden : l'ecran de configuration 2FA (etapes + QR code +
       cle de secours + formulaire) depasse la hauteur d'un petit ecran et doit
       rester defilable. Le fond reste fixe, seul le contenu defile. */
    overflow-x: hidden;
    overflow-y: auto;
}

/* Modern Animated Background */
.modern-bg-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
}

.modern-bg-gradient {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Charte LSF Foyer : petrole #123B3A → terracotta #C7623D */
    background:
        linear-gradient(135deg,
            rgba(10, 39, 38, 0.92) 0%,
            rgba(18, 59, 58, 0.90) 30%,
            rgba(31, 86, 84, 0.88) 60%,
            rgba(199, 98, 61, 0.86) 100%),
        url('../img/placeholders/backgrounds/login_full_bg.jpg');
    background-size: 400% 400%, cover;
    background-position: 0% 50%, center;
    animation: gradientShift 15s ease infinite;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.modern-bg-shapes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.shape {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.shape-1 {
    width: 300px;
    height: 300px;
    top: -100px;
    left: -100px;
    animation: float 20s ease-in-out infinite;
}

.shape-2 {
    width: 200px;
    height: 200px;
    top: 60%;
    right: -50px;
    animation: float 15s ease-in-out infinite reverse;
}

.shape-3 {
    width: 150px;
    height: 150px;
    bottom: 10%;
    left: 10%;
    animation: float 18s ease-in-out infinite;
}

.shape-4 {
    width: 250px;
    height: 250px;
    top: 20%;
    right: 15%;
    animation: float 22s ease-in-out infinite reverse;
}

@keyframes float {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    33% {
        transform: translate(30px, -30px) scale(1.1);
    }
    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }
}

/* Modern Login Container */
/* En flux normal (et non fixed) : la carte peut depasser la hauteur de la
   fenetre et la page defile. Centre verticalement tant que ca tient. */
#modern-login-container {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
    z-index: 1;
    animation: containerFadeIn 0.8s ease;
}

@keyframes containerFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 50px 40px;
    width: 100%;
    max-width: 450px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: cardSlideUp 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s;
}

.login-card:hover::before {
    left: 100%;
}

@keyframes cardSlideUp {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Login Header */
.login-header {
    text-align: center;
    margin-bottom: 40px;
}

/* Logo posé directement sur la carte : ni fond, ni cadre, ni effet au survol. */
.logo-wrapper {
    margin-bottom: 20px;
    animation: logoFloat 3s ease-in-out infinite;
    position: relative;
    display: inline-block;
    padding: 0;
    background: none;
    box-shadow: none;
}

@keyframes logoFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.logo-image {
    width: 180px;
    max-width: 100%;
    height: auto;
    display: block;
    position: relative;
    z-index: 1;
}

.security-icon {
    width: 80px;
    height: 80px;
    margin: 20px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #123B3A 0%, #C7623D 100%);
    border-radius: 50%;
    box-shadow: 0 8px 24px rgba(18, 59, 58, 0.3);
    animation: iconPulse 2s ease-in-out infinite;
}

.security-icon i {
    font-size: 36px;
    color: white;
}

@keyframes iconPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 8px 24px rgba(18, 59, 58, 0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 12px 32px rgba(18, 59, 58, 0.5);
    }
}

.login-title {
    font-size: 28px;
    font-weight: 700;
    color: #2d3748;
    margin: 0 0 10px 0;
    animation: titleSlide 0.8s ease 0.2s both;
}

@keyframes titleSlide {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.login-subtitle {
    font-size: 14px;
    color: #718096;
    margin: 0;
    line-height: 1.6;
    animation: titleSlide 0.8s ease 0.3s both;
}

/* Modern Form Groups */
.modern-form-group {
    margin-bottom: 30px;
    animation: formGroupSlide 0.6s ease 0.4s both;
}

@keyframes formGroupSlide {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.modern-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 8px;
}

.modern-label i {
    color: #123B3A;
    font-size: 16px;
}

.modern-input-wrapper {
    position: relative;
}

.modern-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 15px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: #ffffff;
    color: #2d3748;
    transition: all 0.3s ease;
    outline: none;
}

.modern-input:focus {
    border-color: #123B3A;
    box-shadow: 0 0 0 4px rgba(18, 59, 58, 0.1);
    transform: translateY(-2px);
}

.modern-input::placeholder {
    color: #cbd5e0;
}

/* Code Input Special Styling */
.code-input {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 12px;
    text-align: center;
    font-family: 'Courier New', monospace;
}

/* Modern Submit Button */
.modern-btn-submit {
    width: 100%;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #123B3A 0%, #C7623D 100%);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(18, 59, 58, 0.4);
    position: relative;
    overflow: hidden;
    animation: formGroupSlide 0.6s ease 0.5s both;
    margin-bottom: 20px;
}

.modern-btn-submit::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.modern-btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(18, 59, 58, 0.5);
}

.modern-btn-submit:hover::before {
    left: 100%;
}

.modern-btn-submit:active {
    transform: translateY(0);
}

.modern-btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-icon {
    transition: transform 0.3s ease;
}

.modern-btn-submit:hover .btn-icon {
    transform: translateX(4px);
}

/* Back Link */
.back-link {
    text-align: center;
    animation: formGroupSlide 0.6s ease 0.6s both;
}

.back-link a {
    color: #718096;
    text-decoration: none;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.back-link a:hover {
    color: #123B3A;
    background: rgba(18, 59, 58, 0.1);
}

.back-link a i {
    transition: transform 0.3s ease;
}

.back-link a:hover i {
    transform: translateX(-4px);
}

/* Error States */
.has-error .modern-input {
    border-color: #f56565;
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.help-block {
    color: #f56565;
    font-size: 13px;
    margin-top: 6px;
    animation: errorSlide 0.3s ease;
}

@keyframes errorSlide {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 576px) {
    .login-card {
        padding: 40px 30px;
    }
    
    .login-title {
        font-size: 24px;
    }
    
    .logo-image {
        width: 140px;
    }
    
    .security-icon {
        width: 70px;
        height: 70px;
    }
    
    .security-icon i {
        font-size: 30px;
    }
    
    .code-input {
        font-size: 28px;
        letter-spacing: 8px;
    }
}

/* ─────────────────────────────────────────────────────────────
   Complements : login, mot de passe oublie, configuration 2FA
   ───────────────────────────────────────────────────────────── */

/* Options du formulaire (case a cocher + lien) */
.modern-form-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    animation: formGroupSlide 0.6s ease 0.45s both;
}

.modern-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    margin: 0;
    font-weight: 500;
}

.modern-checkbox input { position: absolute; opacity: 0; width: 0; height: 0; }

.checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
    transition: all 0.25s ease;
    position: relative;
    flex: 0 0 auto;
}

.modern-checkbox input:checked + .checkbox-custom {
    background: linear-gradient(135deg, #123B3A 0%, #C7623D 100%);
    border-color: #123B3A;
}

.modern-checkbox input:checked + .checkbox-custom::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.modern-checkbox input:focus-visible + .checkbox-custom {
    box-shadow: 0 0 0 4px rgba(18, 59, 58, 0.2);
}

.checkbox-label { font-size: 14px; color: #4a5568; }

/* Lien secondaire (mot de passe oublie, retour) */
.auth-link {
    font-size: 14px;
    color: #123B3A;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}
.auth-link:hover { color: #00a768; text-decoration: underline; }

/* Bouton oeil dans le champ mot de passe */
.modern-input-wrapper .toggle-password {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #a0aec0;
    cursor: pointer;
    padding: 6px 8px;
    font-size: 15px;
    line-height: 1;
    transition: color 0.2s ease;
}
.modern-input-wrapper .toggle-password:hover { color: #123B3A; }
.modern-input-wrapper .toggle-password:focus-visible {
    outline: 2px solid #123B3A;
    border-radius: 6px;
}
.modern-input-wrapper:has(.toggle-password) .modern-input { padding-right: 44px; }

/* Bandeaux de message */
.auth-alert {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.5;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: errorSlide 0.3s ease;
}
.auth-alert i { margin-top: 2px; }
.auth-alert-info    { background: #ebf4ff; color: #2c5282; border: 1px solid #bee3f8; }
.auth-alert-success { background: #f0fff4; color: #22543d; border: 1px solid #c6f6d5; }
.auth-alert-error   { background: #fff5f5; color: #822727; border: 1px solid #fed7d7; }
.auth-alert-warning { background: #fffaf0; color: #7b341e; border: 1px solid #feebc8; }

/* Configuration 2FA : QR code + secret de secours */
.qr-wrapper {
    display: flex;
    justify-content: center;
    margin: 0 auto 20px;
    padding: 16px;
    background: #fff;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    width: fit-content;
    max-width: 100%;
}
.qr-wrapper svg { display: block; width: 220px; height: 220px; max-width: 100%; }

.setup-steps {
    counter-reset: step;
    list-style: none;
    padding: 0;
    margin: 0 0 24px;
}
.setup-steps li {
    counter-increment: step;
    position: relative;
    padding-left: 38px;
    margin-bottom: 12px;
    font-size: 14px;
    color: #4a5568;
    line-height: 1.5;
}
.setup-steps li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: -1px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, #123B3A 0%, #C7623D 100%);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.secret-box {
    text-align: center;
    margin-bottom: 24px;
}
.secret-box code {
    display: inline-block;
    font-family: 'Courier New', monospace;
    font-size: 15px;
    letter-spacing: 2px;
    background: #f7fafc;
    border: 1px dashed #cbd5e0;
    border-radius: 10px;
    padding: 10px 14px;
    color: #2d3748;
    word-break: break-all;
}
.secret-box p { font-size: 12.5px; color: #718096; margin: 8px 0 0; }

/* ── Petits ecrans : l'ecran de configuration 2FA est le plus haut ── */
@media (max-width: 576px) {
    #modern-login-container { padding: 16px 12px; }

    .login-card { padding: 28px 20px; border-radius: 18px; }

    /* Le logo flottant consomme de la hauteur pour rien sur mobile */
    .logo-wrapper { animation: none; margin-bottom: 14px; }
    .logo-image   { width: 140px; }

    .login-header  { margin-bottom: 24px; }
    .security-icon { width: 58px; height: 58px; margin: 14px auto; }
    .security-icon i { font-size: 26px; }

    .modern-form-group { margin-bottom: 20px; }

    /* QR code : doit rester scannable, mais sans pousser la page */
    .qr-wrapper     { padding: 10px; border-radius: 12px; }
    .qr-wrapper svg { width: 180px; height: 180px; }

    .setup-steps li { margin-bottom: 9px; font-size: 13.5px; }
    .secret-box code { font-size: 13px; letter-spacing: 1px; }
}

/* Fenetre basse (mobile en paysage, petit portable) : on ne centre plus
   verticalement, sinon le haut de la carte devient inaccessible. */
@media (max-height: 720px) {
    #modern-login-container { align-items: flex-start; }
}
