/* =====================================================================
   Habillage moderne — page de login + pages 2FA (setup / verify).
   Feuille PARTAGEE par les trois pages (spec : 2fa-otp-admin.md §8,
   palette adaptee au bleu CRM26 #37a7d3).
   Les pages gardent le template commun (jQuery, validate, FontAwesome) :
   ce fichier est charge APRES main.css et s'impose dessus.
   ===================================================================== */

:root {
    --lg-c1: #1a5276;   /* bleu profond (fond) */
    --lg-c2: #2e86c1;   /* bleu moyen */
    --lg-c3: #37a7d3;   /* bleu marque CRM26 */
    --lg-c4: #48c9e8;   /* bleu clair (accent) */
    --lg-grad: linear-gradient(135deg, #2e86c1 0%, #37a7d3 55%, #48c9e8 100%);
}

body.page-login {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    background: var(--lg-c1);
}

/* Le template commun n'a rien a afficher ici (header/menu absents des
   pages $ispagelogin, mais on neutralise tout residu de mise en page). */
body.page-login #page-container,
body.page-login #main-container {
    background: transparent;
}

/* ---- Fond degrade anime + formes flottantes ------------------------- */
.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(26, 82, 118, 0.97) 0%,
        rgba(31, 97, 141, 0.95) 30%,
        rgba(46, 134, 193, 0.93) 60%,
        rgba(55, 167, 211, 0.90) 85%,
        rgba(72, 201, 232, 0.88) 100%);
    background-size: 400% 400%;
    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.08);
    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;
}
.login-card {
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 50px 40px;
    width: 100%;
    max-width: 450px;
    max-height: 96vh;
    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);
}
.login-card--large {
    max-width: 560px;
}
@keyframes cardSlideUp {
    from { opacity: 0; transform: translateY(50px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---- En-tete de carte : logo + titres ------------------------------- */
.login-header {
    text-align: center;
    margin-bottom: 34px;
}
.logo-wrapper {
    display: inline-block;
    margin-bottom: 20px;
    padding: 16px 26px;
    background: var(--lg-grad);
    border-radius: 20px;
    box-shadow: 0 8px 24px rgba(55, 167, 211, 0.35);
}
.logo-image {
    width: 170px;
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
}
.login-title {
    font-size: 28px;
    font-weight: 700;
    color: #2d3748;
    margin: 0 0 10px 0;
}
.login-subtitle {
    font-size: 14px;
    color: #718096;
    margin: 0;
    line-height: 1.6;
}

/* Icone bouclier (page verification 2FA) */
.security-icon {
    width: 72px;
    height: 72px;
    margin: 18px auto 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--lg-grad);
    border-radius: 50%;
    box-shadow: 0 8px 24px rgba(55, 167, 211, 0.35);
    animation: iconPulse 2s ease-in-out infinite;
}
.security-icon i {
    font-size: 32px;
    color: white;
}
@keyframes iconPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* ---- Champs ---------------------------------------------------------- */
.modern-form-group {
    margin-bottom: 26px;
}
.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(--lg-c3);
    font-size: 15px;
}
.modern-input-wrapper {
    position: relative;
}
.login-card .modern-input {
    width: 100%;
    height: auto;
    padding: 14px 16px;
    font-size: 15px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: #ffffff;
    color: #2d3748;
    box-shadow: none;
    transition: all 0.3s ease;
    outline: none;
}
.login-card .modern-input:focus {
    border-color: var(--lg-c3);
    box-shadow: 0 0 0 4px rgba(55, 167, 211, 0.12);
    transform: translateY(-2px);
}
.login-card .modern-input::placeholder {
    color: #cbd5e0;
}

/* Saisie du code OTP : gros chiffres espaces */
.login-card .code-input {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: 12px;
    text-align: center;
    font-family: 'Courier New', monospace;
}

/* Bouton "oeil" afficher/masquer le mot de passe */
.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #a0aec0;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.3s ease;
}
.toggle-password:hover {
    color: var(--lg-c3);
    background: rgba(55, 167, 211, 0.1);
}

/* Case "Se souvenir de moi" */
.modern-form-options {
    margin-bottom: 26px;
}
.modern-checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    margin: 0;
    font-weight: normal;
}
.modern-checkbox input[type="checkbox"] {
    display: none;
}
.checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    margin-right: 10px;
    position: relative;
    transition: all 0.3s ease;
    flex-shrink: 0;
}
.modern-checkbox input:checked + .checkbox-custom {
    background: var(--lg-grad);
    border-color: var(--lg-c3);
}
.modern-checkbox input:checked + .checkbox-custom::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
}
.checkbox-label {
    font-size: 14px;
    color: #4a5568;
}

/* ---- Bouton principal ------------------------------------------------ */
.login-card .modern-btn-submit {
    width: 100%;
    padding: 15px 24px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    background: var(--lg-grad);
    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(55, 167, 211, 0.4);
    margin-bottom: 18px;
}
.login-card .modern-btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(55, 167, 211, 0.5);
    color: #fff;
}
.login-card .modern-btn-submit:active {
    transform: translateY(0);
}
.login-card .modern-btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Lien retour (pages 2FA) */
.back-link {
    text-align: center;
}
.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(--lg-c3);
    background: rgba(55, 167, 211, 0.1);
    text-decoration: none;
}

/* ---- Setup 2FA : QR + cle secrete + etapes --------------------------- */
.qr-frame {
    display: inline-block;
    padding: 10px;
    background: #fff;
    border: 2px solid var(--lg-c3);
    border-radius: 12px;
    margin: 10px 0;
}
.qr-frame .qr-holder {
    display: block;
    width: 210px;
    height: 210px;
}
.secret-code {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 12px;
    font-family: monospace;
    font-size: 13px;
    word-break: break-all;
    color: var(--lg-c1);
}
.setup-steps {
    text-align: left;
    font-size: 14px;
    color: #4a5568;
    margin: 0 0 18px;
    padding-left: 20px;
    line-height: 1.7;
}

/* ---- Erreurs (jQuery Validate) --------------------------------------- */
.login-card .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); }
}
.login-card .help-block {
    color: #f56565;
    font-size: 13px;
    margin-top: 6px;
}

/* ---- Responsive ------------------------------------------------------ */
@media (max-width: 576px) {
    .login-card { padding: 40px 26px; }
    .login-title { font-size: 24px; }
    .logo-image { width: 130px; }
    .login-card .code-input { font-size: 26px; letter-spacing: 8px; }
    .qr-frame .qr-holder { width: 180px; height: 180px; }
}

/* ── Bandeaux d'information des ecrans d'authentification ──
   Utilises par login.php (?reset=1), reinitialisemdp.php et
   reinitialiseusermdp.php. Meme rayon et meme graisse que .back-link. */
.auth-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 15px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 20px;
    border: 1px solid transparent;
}
.auth-alert i {
    flex: none;
    margin-top: 2px;
    font-size: 15px;
}
.auth-alert-success {
    background: #e8f6ef;
    border-color: #a8ddc5;
    color: #1b6b4a;
}
.auth-alert-warning {
    background: #fdf3e2;
    border-color: #f0d29a;
    color: #8a5b12;
}
.auth-alert-info {
    background: #e9f3fb;
    border-color: #a9cfe9;
    color: #245f8a;
}

/* Lien « Mot de passe oublie ? » aligne a droite du bloc d'options */
.modern-form-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.forgot-link {
    color: #2e86c1;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.3s ease;
}
.forgot-link:hover {
    color: #1b5f8e;
    text-decoration: underline;
}
