/* Animation panneau debug (gauche/droite) */
@keyframes slideInFromRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

.side-message-panel.debug-right {
    animation: slideInFromRight 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.side-message-panel.debug-left {
    animation: slideInFromLeft 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* PANNEAU LATÉRAL MESSAGE CONFIRMATION */
.side-message-panel {
    position: absolute;
    top: 0;
    width: 600px;
    height: 100%;
    min-height: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(34,34,34,0.97);
    box-shadow: none;
    z-index: 21;
    padding: 0;
    margin: 0;
    border-radius: 0;
    overflow: hidden;
}

/* Correction : positionnement latéral du panneau debug */
.side-message-panel.debug-right { right: 0; left: auto; }
.side-message-panel.debug-left { left: 0; right: auto; }

.side-message-content {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    min-height: 100%;
    min-width: 100%;
    padding: 40px 30px;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    text-align: left;
    font-size: 18px;
    color: #fff;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    word-break: break-word;
    display: flex;
    flex-direction: column;
}

/* Photo visible derrière le panneau debug (desktop only) */
.side-photo {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    /* photo fixe : le gabarit reste en place sous les formulaires */
    z-index: 0;
}

.side-message-content * { z-index: 2; }
    .side-message-panel {
    justify-content: center;
}

.side-message-content .close-btn {
    position: absolute;
    top: 18px;
    right: 18px;
    background: none;
    border: none;
    font-size: 22px;
    color: #888;
    cursor: pointer;
}

.side-message-content .icon {
    font-size: 38px;
        transition: right 1s cubic-bezier(.4,2,.6,1), left 1s cubic-bezier(.4,2,.6,1), opacity 1s;
    margin-bottom: 18px;
}

/* RESET ET BASE */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    height: 100vh;
    margin: 0;
    padding: 0;
    position: relative;
    /* Gradient animé par-dessus l'image */
    background: linear-gradient(270deg, rgba(52, 152, 219, 0.7), rgba(109, 213, 250, 0.7), rgba(30, 60, 114, 0.7), rgba(42, 82, 152, 0.7));
    background-size: 800% 800%;
    animation: gradientMove 18s ease-in-out infinite;
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Image de fond derrière le gradient */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../img/login.jpeg');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    z-index: -1;
}

/* Animation du fond dégradé */
@keyframes gradientMove {
    0% { background-position: 0% 50%; }
    25% { background-position: 50% 100%; }
    50% { background-position: 100% 50%; }
    75% { background-position: 50% 0%; }
    100% { background-position: 0% 50%; }
}

/* CONTENEUR PRINCIPAL AVEC PHOTO FIXE */
.auth-container {
    position: relative;
    width: 1200px;
    height: 700px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
}

/* PANNEAU DES FORMULAIRES QUI SE DÉPLACE */
.form-panel {
    position: absolute;
    left: 0;
    top: 0;
    width: 600px;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px 0 0 20px;
    transform: translateX(0);
    transition: transform 1.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
}

/* POSITIONNEMENT DU PANNEAU SELON LA VUE */
.auth-container.register-view .form-panel,
.auth-container.forgot-view .form-panel { 
    transform: translateX(600px); 
}

/* FORMULAIRES INDIVIDUELS */
.auth-form {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 60px 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    opacity: 0;
    transform: translateX(-30px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

/* FORMULAIRE ACTIF */
.auth-form.active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

/* TITRES */
.brand-title {
    font-size: 32px;
    font-weight: 800;
    color: #333;
    margin-bottom: 10px;
    text-align: center;
}

.form-title {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    text-align: center;
}

/* CHAMPS DE FORMULAIRE */
.field-group {
    margin-bottom: 25px;
}

.field-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #555;
    margin-bottom: 8px;
}

.field-label i {
    margin-right: 8px;
    color: #667eea;
}

.field-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 16px;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.9);
}

.field-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    background: #fff;
}

.field-input::placeholder {
    color: #a0aec0;
}

/* BOUTON DE SOUMISSION */
.submit-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}

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

.submit-btn i {
    margin-right: 8px;
}

/* BOUTON SECONDAIRE */
.secondary-btn {
    width: 100%;
    padding: 14px 20px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #667eea;
    border-radius: 10px;
    color: #667eea;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 15px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.secondary-btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

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

.secondary-btn i {
    margin-right: 8px;
}

/* FLÈCHE RETOUR VERS CONNEXION */
.back-to-login {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #667eea;
    border-radius: 50%;
    color: #667eea;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    z-index: 10;
}

.back-to-login:hover {
    background: #667eea;
    color: white;
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.back-to-login:active {
    transform: scale(0.95);
}

/* LIENS DE NAVIGATION */
.nav-links {
    text-align: center;
    margin-top: 25px;
}

.nav-link {
    color: #667eea;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-block;
    margin: 5px 0;
}

.nav-link:hover {
    color: #764ba2;
    transform: translateY(-1px);
}

/* MESSAGES D'ALERTE */
.alert-message {
    padding: 14px 18px;
    border-radius: 10px;
    margin-bottom: 25px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-message.success {
    background: #d1f2eb;
    color: #0e6245;
    border: 1px solid #a3d9c9;
}

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

/* ERREURS DE CHAMP */
.field-error {
    color: #e53e3e;
    font-size: 12px;
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.field-error i {
    font-size: 11px;
}

/* INDICATEUR DE CONNEXION DB intégré en bas du formulaire */
.db-indicator-info {
    width: 100%;
    text-align: center;
    margin-top: 18px;
    margin-bottom: 8px;
}

.db-indicator {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    background: none;
    color: #666;
    border-radius: 6px;
    padding: 0 10px;
}

.db-indicator.connected {
    color: #38a169;
}

.db-indicator.disconnected {
    color: #e53e3e;
}

/* RESPONSIVE - MOBILE/TABLETTE */
@media (max-width: 900px) {
    /* Container plein écran sans overflow */
    .auth-container {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        overflow-x: hidden; /* Empêche le débordement horizontal */
    }

    /* IMPORTANT : Désactiver le système de slide sur mobile */
    .form-panel {
        width: 100%;
        border-radius: 0;
        /* Annuler toutes les transformations de slide */
        transform: translateX(0) !important;
        transition: none !important;
        position: relative; /* Devient relatif au lieu d'absolu */
        left: auto;
        top: auto;
    }

    /* Sur mobile, les formulaires restent en place - pas de slide */
    .auth-container.register-view .form-panel,
    .auth-container.forgot-view .form-panel { 
        transform: translateX(0) !important; /* Force à rester en place */
    }

    /* Formulaires individuels - mode morph sur mobile */
    .auth-form {
        padding: 40px 30px;
        /* Transition douce pour le morph */
        transition: opacity 0.5s ease-in-out, transform 0.3s ease;
        transform: translateX(0) !important; /* Pas de slide */
    }

    /* Formulaire non actif : caché complètement */
    .auth-form:not(.active) {
        display: none !important;
        opacity: 0 !important;
        transform: scale(0.95) !important;
        pointer-events: none !important;
    }

    /* Formulaire actif : visible avec effet fade/scale */
    .auth-form.active {
        display: flex !important;
        opacity: 1 !important;
        transform: scale(1) !important;
        pointer-events: auto !important;
        animation: mobileFormMorph 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    /* Photo fixe cachée sur mobile */
    .side-photo { 
        display: none !important; 
    }

    /* Le panneau debug devient plein écran / overlay sur mobile */
    .side-message-panel {
        width: 100vw;
        min-width: 0;
        height: 100vh;
        right: 0;
        left: 0;
        border-radius: 0;
    }

    /* Ajustement des tailles de texte */
    .form-title {
        font-size: 24px;
    }

    .brand-title {
        font-size: 32px;
    }

    /* Champs de formulaire plus compacts */
    .field-input {
        padding: 12px 14px;
        font-size: 15px;
    }

    /* Boutons plus compacts */
    .submit-btn, .secondary-btn {
        padding: 14px 18px;
        font-size: 15px;
    }
}

/* Extra small devices (phones < 480px) */
@media (max-width: 480px) {
    .auth-form {
        padding: 30px 20px;
    }

    .form-title {
        font-size: 22px;
    }

    .brand-title {
        font-size: 28px;
    }

    .field-input {
        padding: 10px 12px;
        font-size: 14px;
    }

    .submit-btn, .secondary-btn {
        padding: 12px 16px;
        font-size: 14px;
    }

    .back-to-login {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }
}

/* ANIMATION MORPH pour mobile - effet fade + légère mise à l'échelle */
@keyframes mobileFormMorph {
    0% {
        opacity: 0;
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ANIMATIONS pour desktop - slide classique */
@keyframes slideInFromLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Animation slide uniquement sur desktop (> 900px) */
@media (min-width: 901px) {
    .auth-form.active {
        animation: slideInFromLeft 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    }
}