* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', sans-serif; }

body {
    background: #f1f5f9;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-container {
    display: flex;
    width: 900px;
    height: 600px;
    background: white;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
}

/* Côté Visuel */
.auth-visual {
    flex: 1;
    background: linear-gradient(135deg, #4f46e5 0%, #1e293b 100%);
    color: white;
    padding: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.visual-content h2 { font-size: 2.2rem; margin-bottom: 20px; }
.visual-content p { color: #cbd5e1; line-height: 1.6; }

.logo-box-auth {
    margin-top: 40px;
    width: 60px;
    height: 60px;
    background: white;
    color: #4f46e5;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-size: 1.5rem;
}

/* Côté Formulaires */
.auth-form-side { flex: 1; position: relative; padding: 50px; }

.auth-card {
    display: none;
    flex-direction: column;
    height: 100%;
}

.auth-card.active { display: flex; animation: slideIn 0.4s ease forwards; }

.auth-header h3 { font-size: 1.8rem; color: #1e293b; }
.auth-header p { color: #64748b; margin-bottom: 30px; }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 0.9rem; color: #1e293b; margin-bottom: 8px; font-weight: 600; }

.input-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon i {
    position: absolute;
    left: 15px;
    color: #94a3b8;
}

.input-icon input {
    width: 100%;
    padding: 12px 15px 12px 45px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    outline: none;
    transition: 0.3s;
}

.input-icon input:focus { border-color: #4f46e5; box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1); }

.form-footer-options {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 25px;
}

.btn-auth {
    width: 100%;
    padding: 14px;
    background: #4f46e5;
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.3s;
}

.btn-auth:hover { opacity: 0.9; transform: translateY(-2px); }

.switch-text { text-align: center; margin-top: auto; font-size: 0.9rem; color: #64748b; }
.switch-text a { color: #4f46e5; font-weight: 600; text-decoration: none; }

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

/* Grille pour mettre deux champs sur une ligne */
.form-grid-auth {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* Zone scrollable si le formulaire dépasse sur petit écran */
.form-scroll-area-auth {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
    margin-bottom: 10px;
}

/* Personnalisation du scrollbar interne */
.form-scroll-area-auth::-webkit-scrollbar {
    width: 4px;
}
.form-scroll-area-auth::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}

/* Style spécifique pour le select de la ville */
.input-icon select {
    width: 100%;
    padding: 12px 15px 12px 45px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    outline: none;
    background: white;
    cursor: pointer;
    appearance: none; /* Retire la flèche par défaut pour certains navigateurs */
}

/* --- RESPONSIVE LOGIC --- */

/* Tablettes et écrans moyens */
@media (max-width: 950px) {
    .auth-container {
        width: 95%;
        height: auto; /* Laisse le container s'adapter au contenu */
        flex-direction: column; /* On empile visuel et formulaire */
    }

    .auth-visual {
        padding: 40px;
        text-align: center;
    }

    .auth-visual .logo-box-auth {
        margin: 20px auto 0;
    }
}

/* Mobiles (Smartphones) */
@media (max-width: 480px) {
    .auth-form-side {
        padding: 30px 20px;
    }

    .form-grid-auth {
        grid-template-columns: 1fr; /* Un seul champ par ligne sur mobile */
        gap: 0;
    }

    .auth-header h3 {
        font-size: 1.5rem;
    }
}

/* --- CORRECTION DU SCROLL DU FORMULAIRE --- */

.auth-card {
    display: none;
    flex-direction: column;
    height: 100%;
    max-height: 520px; /* Limite la hauteur pour forcer le scroll */
}

.auth-card.active {
    display: flex;
}

/* Zone contenant les champs */
.form-scroll-area-auth {
    flex: 1; /* Prend l'espace disponible */
    overflow-y: auto; /* Active le scroll */
    padding-right: 8px; /* Espace pour la barre de scroll */
    margin-bottom: 15px;
}

/* Style de la barre de scroll pour qu'elle soit visible et inciter au scroll */
.form-scroll-area-auth::-webkit-scrollbar {
    width: 6px;
}

.form-scroll-area-auth::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.form-scroll-area-auth::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

/* Fixer le bouton en bas pour qu'il soit toujours accessible */
.btn-auth {
    flex-shrink: 0; /* Empêche le bouton de rétrécir */
    margin-top: auto;
}

/* --- AJUSTEMENT DU BODY --- */
body {
    background: #f1f5f9;
    min-height: 100vh; /* Utilise min-height au lieu de height */
    display: flex;
    align-items: center; /* Centre verticalement si l'écran est grand */
    justify-content: center;
    padding: 20px; /* Ajoute un espace global autour du conteneur */
}

/* --- AJUSTEMENTS RESPONSIVE MOBILE --- */
@media (max-width: 950px) {
    body {
        align-items: flex-start; /* Sur mobile, on commence en haut au lieu de centrer */
        padding-top: 40px; /* Espace de sécurité en haut de l'écran */
        padding-bottom: 40px; /* Espace en bas pour ne pas coller au bord */
    }

    .auth-container {
        width: 100%;
        max-width: 450px; /* Évite que le formulaire soit trop large sur tablette */
        height: auto;
        margin: 0 auto; /* Centre horizontalement */
        display: block; /* On repasse en bloc pour l'empilement */
    }

    .auth-visual {
        padding: 30px 20px;
        border-radius: 20px 20px 0 0; /* Arrondi seulement le haut */
    }

    .auth-form-side {
        padding: 30px 20px;
        border-radius: 0 0 20px 20px; /* Arrondi seulement le bas */
    }
}

/* Correction spécifique pour les très petits écrans (iPhone SE, etc.) */
@media (max-width: 380px) {
    body {
        padding-top: 20px;
    }

    .auth-header h3 {
        font-size: 1.3rem;
    }
}

/* Barre de navigation supérieure */
.auth-top-nav {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    z-index: 1001; /* Doit être au-dessus du reste */
}

.nav-back-link {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    color: #1e293b;
    text-decoration: none;
    padding: 8px 15px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    cursor: pointer;
    transition: 0.3s;
}

.nav-back-link:hover {
    background: #f8fafc;
    transform: translateX(-3px);
    color: #4f46e5;
}

/* Adaptation Mobile */
@media (max-width: 950px) {
    .auth-top-nav {
        top: 10px;
        left: 10px;
        right: 10px;
    }

    .nav-back-link span {
        display: none; /* On cache le texte sur petit mobile pour ne garder que l'icône */
    }

    .nav-back-link {
        padding: 10px;
        width: 40px;
        height: 40px;
        justify-content: center;
    }
}

/* Navigation interne au cadre blanc */
.auth-internal-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px; /* Espace avant le titre "Connexion" */
}

.btn-inline-nav {
    background: transparent;
    border: none;
    color: #64748b;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 0;
    transition: 0.2s;
}

.btn-inline-nav:hover {
    color: #4f46e5;
}

/* Sur mobile, on s'assure que les boutons ne sont pas collés aux bords du cadre */
@media (max-width: 950px) {
    .auth-internal-nav {
        margin-bottom: 15px;
    }
}

/* Cette classe s'applique maintenant au Login et au Register */
.form-scroll-area-auth {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 8px;
    margin-bottom: 15px;
    /* On définit une hauteur minimale pour que le scroll s'active bien sur petit écran */
    min-height: 150px;
}

/* On s'assure que le conteneur principal (auth-form-side)
   utilise Flexbox pour pousser le footer vers le bas */
.auth-form-side {
    display: flex;
    flex-direction: column;
}

.auth-card {
    display: none;
    flex-direction: column;
    flex: 1; /* Occupe tout l'espace pour que le footer soit bien en bas */
}

.auth-card.active {
    display: flex;
}

/* OPTIMISATION MOBILE :
   Si l'écran est très petit, on limite la hauteur totale pour forcer le scroll */
@media (max-height: 700px) {
    .auth-container {
        height: 95vh;
    }
    .form-scroll-area-auth {
        max-height: 250px;
    }
}

/* Pour s'assurer que le formulaire prend toute la place */
.auth-logic-form {
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Style des placeholders pour plus de clarté */
::placeholder {
    color: #cbd5e1;
    font-size: 0.85rem;
}

/* Amélioration visuelle des selects */
select {
    color: #1e293b;
    font-weight: 500;
}

/* Style personnalisé pour les liens "Mot de passe oublié" */
.forgot-link {
    color: #6366f1;
    text-decoration: none;
    font-weight: 600;
    transition: 0.2s;
}
.forgot-link:hover { text-decoration: underline; }

/* Conteneur Checkbox aligné */
.checkbox-container {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #64748b;
}

/* Focus sur les inputs pour l'accessibilité */
input:focus, select:focus {
    border-color: #4f46e5 !important;
    background-color: #f8fafc;
}

.auth-error-alert {
    background: #fef2f2;
    border-left: 4px solid #ef4444;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 8px;
    animation: shake 0.5s ease-in-out;
}

.error-alert-header {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #991b1b;
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.auth-error-alert ul {
    list-style: none;
    padding-left: 28px;
}

.auth-error-alert li {
    color: #b91c1c;
    font-size: 0.85rem;
}

/* Petite animation pour attirer l'attention sur l'erreur */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

