/* ==========================================================================
   Écrans d'authentification (login.php, setup_2fa.php, verify_2fa.php)
   Design "modern" repris de demoreno.jddev.com
   Chargé par inc/template_start.php quand $uiLoginCss = true
   ========================================================================== */

/* Palette : logo ECO HABITAT CONSTRUCTION (sites/prod)
   vert #88C270 -> teal #7BC39E -> ciel #62C4DC, teal profond #1B6E86 pour le contraste */
:root {
    --ehc-green: #88C270;
    --ehc-teal: #7BC39E;
    --ehc-sky: #62C4DC;
    --ehc-deep: #1B6E86;
    --ehc-deeper: #14556A;
    --ehc-ink: #16262B;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
}

/* --------------------------------------------------------------------------
   Fond animé
   -------------------------------------------------------------------------- */
.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%;
    background:
        linear-gradient(135deg,
            rgba(136, 194, 112, 0.88) 0%,
            rgba(123, 195, 158, 0.88) 30%,
            rgba(98, 196, 220, 0.88) 60%,
            rgba(27, 110, 134, 0.90) 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); }
}

/* --------------------------------------------------------------------------
   Conteneur / carte
   -------------------------------------------------------------------------- */
#modern-login-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1;
    overflow-y: auto;
    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;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    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;
}

.login-card.login-card-wide {
    max-width: 520px;
}

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

/* --------------------------------------------------------------------------
   En-tête
   -------------------------------------------------------------------------- */
.login-header {
    text-align: center;
    margin-bottom: 36px;
}

.logo-wrapper {
    margin-bottom: 20px;
    animation: logoFloat 3s ease-in-out infinite;
    position: relative;
    display: inline-block;
    padding: 16px 26px;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 8px 24px rgba(27, 110, 134, 0.3);
}

.logo-wrapper::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, var(--ehc-green), var(--ehc-teal), var(--ehc-sky), var(--ehc-deep));
    border-radius: 22px;
    z-index: -1;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.logo-wrapper:hover::before {
    opacity: 1;
    animation: rotateBorder 3s linear infinite;
}

@keyframes rotateBorder {
    0% { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}

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

.logo-image {
    width: 200px;
    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, var(--ehc-teal) 0%, var(--ehc-deep) 100%);
    border-radius: 50%;
    box-shadow: 0 8px 24px rgba(27, 110, 134, 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(27, 110, 134, 0.3); }
    50% { transform: scale(1.05); box-shadow: 0 12px 32px rgba(27, 110, 134, 0.5); }
}

.login-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--ehc-ink);
    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;
}

/* --------------------------------------------------------------------------
   Formulaire
   -------------------------------------------------------------------------- */
.modern-form-group {
    margin-bottom: 26px;
    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: var(--ehc-deep);
    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: var(--ehc-ink);
    transition: all 0.3s ease;
    outline: none;
    height: auto;
    box-shadow: none;
}

.modern-input:focus {
    border-color: var(--ehc-deep);
    box-shadow: 0 0 0 4px rgba(27, 110, 134, 0.1);
    transform: translateY(-2px);
}

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

/* Bouton afficher / masquer le mot de passe */
.toggle-password {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: #a0aec0;
    padding: 6px 8px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    line-height: 1;
}

.toggle-password:hover {
    color: var(--ehc-deep);
    background: rgba(27, 110, 134, 0.1);
}

#show_hide_password .modern-input {
    padding-right: 48px;
}

/* Champ code à 6 chiffres */
.code-input {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 12px;
    text-align: center;
    font-family: 'Courier New', monospace;
}

/* Options (se souvenir de moi) */
.modern-form-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 26px;
    animation: formGroupSlide 0.6s ease 0.45s both;
}

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

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

.modern-checkbox .checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid #cbd5e0;
    border-radius: 6px;
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.modern-checkbox .checkbox-custom::after {
    content: '';
    width: 6px;
    height: 11px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0);
    transition: transform 0.2s ease;
    margin-top: -2px;
}

.modern-checkbox input:checked + .checkbox-custom {
    background: linear-gradient(135deg, var(--ehc-teal) 0%, var(--ehc-deep) 100%);
    border-color: var(--ehc-deep);
}

.modern-checkbox input:checked + .checkbox-custom::after {
    transform: rotate(45deg) scale(1);
}

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

/* Bouton principal */
.modern-btn-submit {
    width: 100%;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--ehc-teal) 0%, var(--ehc-deep) 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(27, 110, 134, 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(27, 110, 134, 0.5);
    color: white;
}

.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);
}

/* Lien retour */
.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: var(--ehc-deep);
    background: rgba(27, 110, 134, 0.1);
    text-decoration: none;
}

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

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

/* --------------------------------------------------------------------------
   Messages
   -------------------------------------------------------------------------- */
.auth-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 20px;
    animation: errorSlide 0.3s ease;
}

.auth-alert i {
    margin-top: 2px;
    flex-shrink: 0;
}

.auth-alert-error {
    background: #fff5f5;
    color: #c53030;
    border: 1px solid #feb2b2;
}

.auth-alert-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.auth-alert-info {
    background: #ebf4ff;
    color: #2c5282;
    border: 1px solid #bee3f8;
}

.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); }
}

/* --------------------------------------------------------------------------
   Configuration 2FA (setup_2fa.php)
   -------------------------------------------------------------------------- */
.setup-steps {
    list-style: none;
    padding: 0;
    margin: 0 0 24px;
    counter-reset: step;
    animation: formGroupSlide 0.6s ease 0.35s both;
}

.setup-steps li {
    position: relative;
    padding: 10px 12px 10px 46px;
    margin-bottom: 8px;
    background: #f7fafc;
    border-left: 3px solid var(--ehc-deep);
    border-radius: 8px;
    font-size: 13px;
    color: #4a5568;
    line-height: 1.5;
}

.setup-steps li::before {
    counter-increment: step;
    content: counter(step);
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    background: linear-gradient(135deg, var(--ehc-teal) 0%, var(--ehc-deep) 100%);
    color: #fff;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
}

.setup-steps .app-links {
    margin-top: 4px;
}

.setup-steps .app-links a {
    color: var(--ehc-deep);
    margin-right: 12px;
    text-decoration: none;
    font-weight: 600;
}

.setup-steps .app-links a:hover {
    text-decoration: underline;
}

.qr-wrapper {
    display: flex;
    justify-content: center;
    margin: 0 auto 16px;
    animation: formGroupSlide 0.6s ease 0.4s both;
}

.qr-wrapper svg {
    width: 220px;
    height: 220px;
    padding: 10px;
    background: #fff;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(27, 110, 134, 0.15);
}

.secret-box {
    text-align: center;
    margin-bottom: 20px;
    animation: formGroupSlide 0.6s ease 0.45s both;
}

.secret-box code {
    display: inline-block;
    background: #edf2f7;
    color: var(--ehc-ink);
    padding: 8px 14px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    letter-spacing: 1px;
    word-break: break-all;
}

.secret-box p {
    font-size: 12px;
    color: #718096;
    margin: 8px 0 0;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 576px) {
    .login-card {
        padding: 40px 24px;
    }

    .login-title {
        font-size: 24px;
    }

    .logo-image {
        width: 150px;
    }

    .security-icon {
        width: 70px;
        height: 70px;
    }

    .security-icon i {
        font-size: 30px;
    }

    .code-input {
        font-size: 28px;
        letter-spacing: 8px;
    }

    .qr-wrapper svg {
        width: 180px;
        height: 180px;
    }
}
