/* ============================================================
   AUTHENTIFICATION - STYLE TYPE FREEPIK (FINAL CORRIGÉ ET OPTIMISÉ)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');

:root {
    --primary: #1f2352;
    --secondary: #1c8480;
    --accent: #ff8c00;
    --bg-light: #f8fafc;
    --text-muted: #64748b;
    --error: #ff4757;
    --warning: #ffa502;
    --success: #2ed573;
}

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

/* ============================================
   CORRECTIONS CRITIQUES POUR TOUS NAVIGATEURS
   ============================================ */
html, body {
    overflow-x: hidden;
}

body {
    background-color: var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

/* --- CONTENEUR PRINCIPAL --- */
.auth-container {
    display: flex;
    width: 100%;
    max-width: 1200px;
    height: auto;
    min-height: 600px;
    max-height: 90vh;
    background: #fff;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    margin: auto;
}

/* --- SECTION VISUELLE (GAUCHE) --- */
.auth-visual {
    flex: 1.2;
    position: relative;
    background: url('Assets/homme\ en\ vert.jpg') no-repeat center center/cover;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: white;
}

.auth-visual .overlay {
    position: absolute;
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background: linear-gradient(135deg, rgba(31, 35, 82, 0.9) 2%, rgba(28, 132, 128, 0.8) 100%);
}

.visual-content {
    position: relative;
    z-index: 2;
    max-width: 450px;
    text-align: center;
}

.auth-logo {
    width: 150px;
    margin-bottom: 30px;
}

.visual-content h1 {
    font-size: 2rem;
    line-height: 1.2;
    margin-bottom: 15px;
    font-weight: 700;
}

.visual-content p {
    font-size: 1rem;
    opacity: 0.9;
    line-height: 1.5;
}

/* --- SECTION FORMULAIRE (DROITE) - CORRECTION CENTRAGE --- */
.auth-form-section {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 70px 35px 35px 35px;
    position: relative;
    background-color: #fff;
    overflow-y: auto;
    min-height: 100%;
}



.form-box {
    width: 100%;
    max-width: 400px;
    display: none;
    animation: fadeIn 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

.form-box.active {
    display: block;
}

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

/* --- TITRES --- */
h2 {
    color: var(--primary);
    font-size: 1.6rem;
    margin-bottom: 6px;
}

#registerTitle {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.subtext {
    color: var(--text-muted);
    margin-bottom: 20px;
    font-size: 0.85rem;
    line-height: 1.4;
}

/* --- INPUTS & CHAMPS --- */
.input-group {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    width: 100%;
    position: relative;
}

.input-group label {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--primary);
}

.input-group input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    outline: none;
}

.input-group input:focus {
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(28, 132, 128, 0.1);
}

/* Validation Styles */
.input-group input.invalid {
    border-color: var(--error);
    background-color: rgba(255, 71, 87, 0.02);
}

.input-group input.valid {
    border-color: var(--success);
}

/* --- MESSAGES D'ERREUR & ANIMATIONS --- */
.error-text, 
#strength-text {
    font-size: 0.7rem;
    font-weight: 600;
    max-height: 0;
    opacity: 0;
    transform: translateY(-5px);
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin-top: 0;
}

.error-text { 
    color: var(--error); 
}

.error-text.visible,
#strength-text.visible {
    max-height: 25px;
    opacity: 1;
    transform: translateY(0);
    margin-top: 4px;
}

/* --- PASSWORD WRAPPER --- */
.password-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.password-wrapper input {
    padding-right: 40px;
}

.toggle-password {
    position: absolute;
    right: 12px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1rem;
    transition: 0.3s;
    z-index: 5;
}

.toggle-password:hover { 
    color: var(--secondary); 
}

/* --- JAUGE DE SÉCURITÉ --- */
.strength-meter {
    width: 100%;
    height: 5px;
    background-color: #f1f2f6;
    border-radius: 10px;
    margin-top: 8px;
    overflow: hidden;
    display: none;
}

.strength-bar {
    height: 100%;
    width: 0%;
    border-radius: 10px;
    transition: width 0.4s ease, background-color 0.4s ease;
}

/* --- RÔLES & BOUTONS (DESIGN COMPACT) --- */
.forgot-link {
    font-size: 0.75rem;
    color: var(--secondary);
    text-decoration: none;
    margin-top: 4px;
    align-self: flex-end;
    font-weight: 500;
}

.forgot-link:hover { 
    text-decoration: underline; 
}

/*  Rôles en ligne (compact) */
.role-selector {
    display: flex;
    width: 100%;
    gap: 6px;
    margin-bottom: 20px;
    background-color: #f1f5f9;
    padding: 4px;
    border-radius: 8px;
}

.role-card {
    flex: 1;
    position: relative;
    cursor: pointer;
}

.role-card input {
    display: none;
}

.role-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 0;
    border-radius: 6px;
    transition: all 0.3s ease;
    color: var(--text-muted);
    border: 1px solid transparent;
}

.role-content i {
    font-size: 0.9rem;
    transition: 0.3s;
}

.role-content span {
    font-size: 0.85rem;
    font-weight: 600;
}

/* État Sélectionné */
.role-card input:checked + .role-content {
    background-color: #fff;
    color: var(--secondary);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border-color: #e2e8f0;
}

/* État Hover */
.role-card:hover .role-content {
    color: var(--primary);
}

/* --- BOUTON D'ACTION --- */
.btn-auth {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 12px;
}

.btn-auth:hover {
    background: var(--secondary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(28, 132, 128, 0.2);
}

/* Animation "Shake" en cas d'erreur */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.switch-text {
    text-align: center;
    margin-top: 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.switch-text span {
    color: var(--secondary);
    font-weight: 700;
    cursor: pointer;
    transition: 0.3s;
}

.switch-text span:hover { 
    color: var(--primary); 
    text-decoration: underline; 
}

/* Bouton Back  */
.back-btn {
    position: absolute;
    top: 25px;
    left: 25px;
    text-decoration: none;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: 0.3s;
    z-index: 10;
}

.back-btn:hover {
    color: var(--secondary);
    transform: translateX(-3px);
}

/* ============================================
   VÉRIFICATION HYBRIDE - ÉLÉMENTS PLUS COMPACTS
   ============================================ */

/* Indicateur d'étape */
.step-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    gap: 6px;
}

.step {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: #e2e8f0;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.step.active {
    background-color: var(--secondary);
    color: white;
}

.step-line {
    width: 35px;
    height: 2px;
    background-color: #e2e8f0;
}

/* Boutons pour formulaire à plusieurs étapes */
.form-buttons {
    display: flex;
    gap: 12px;
    margin-top: 15px;
}

.btn-back {
    flex: 1;
    padding: 10px;
    background: #f8fafc;
    color: var(--primary);
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

   #loginBox{
    margin-top: 3rem;
    }

.btn-back:hover {
    background: #e2e8f0;
    transform: translateY(-2px);
}

/* Sections par rôle - PLUS COMPACT */
.role-section {
    background: #f8fafc;
    border-radius: 10px;
    padding: 18px;
    margin-bottom: 18px;
    border: 1px solid #e2e8f0;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
}

.section-header i {
    font-size: 1.2rem;
    color: var(--secondary);
    background: white;
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.section-header h3 {
    color: var(--primary);
    font-size: 1.1rem;
    margin: 0;
}

/* Options de vérification - ULTRA COMPACT */
.verification-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.verif-option {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.verif-option input[type="radio"] {
    display: none;
}

.verif-option input[type="radio"]:checked + .option-label {
    background: rgba(28, 132, 128, 0.08);
    border-color: var(--secondary);
}

.verif-option input[type="radio"]:checked + .option-label .option-icon {
    background: var(--secondary);
    color: white;
}

.verif-option input[type="radio"]:checked + .option-label + .option-content {
    display: block;
}

.option-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.option-label:hover {
    background: #f8fafc;
}

.option-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    background: #f1f5f9;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    color: var(--primary);
    transition: all 0.3s ease;
}

.option-text h4 {
    margin: 0 0 2px 0;
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 600;
}

.option-text p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.75rem;
    line-height: 1.3;
}

.option-content {
    display: none;
    padding: 0 12px 12px 12px;
    animation: slideDown 0.3s ease;
}

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

/* Champs spécifiques - PLUS COMPACT */
select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    outline: none;
    font-family: 'Poppins', sans-serif;
}

select:focus, textarea:focus {
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(28, 132, 128, 0.1);
}

textarea {
    resize: vertical;
    min-height: 80px;
    font-size: 0.85rem;
}

/* Message d'information */
.info-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 11px;
    display: flex;
    align-items: flex-start;
    gap: 4px;
    line-height: 1.3;
}

.info-text i {
    color: var(--secondary);
    font-size: 0.8rem;
    margin-top: 1px;
}

/* Liens d'aide */
.help-links {
    margin-top: 8px;
    font-size: 0.75rem;
}

.help-links a {
    color: var(--secondary);
    text-decoration: none;
    transition: 0.3s;
}

.help-links a:hover {
    text-decoration: underline;
    color: var(--primary);
}

/* Info box - PLUS COMPACT */
.info-box {
    background: rgba(28, 132, 128, 0.08);
    border: 1px solid rgba(28, 132, 128, 0.15);
    border-radius: 8px;
    padding: 12px;
    margin-top: 15px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.info-box i {
    color: var(--secondary);
    font-size: 1rem;
    margin-top: 2px;
}

.info-box p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.4;
}

/* Message de succès */
.success-icon {
    font-size: 3rem;
    color: var(--success);
    margin-bottom: 15px;
}

.loading-spinner {
    width: 30px;
    height: 30px;
    border: 2px solid #e2e8f0;
    border-top: 2px solid var(--secondary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Message en attente pour enseignants */
.pending-icon {
    font-size: 3rem;
    color: var(--warning);
    margin-bottom: 15px;
}

.pending-details {
    background: #fff8e1;
    border: 1px solid #ffecb3;
    border-radius: 8px;
    padding: 15px;
    margin: 18px 0;
    text-align: left;
}

.pending-details p {
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.pending-details ul {
    margin: 0;
    padding-left: 18px;
    color: var(--text-muted);
}

.pending-details li {
    margin-bottom: 6px;
    font-size: 0.8rem;
    line-height: 1.3;
}

/* Indicateur requis */
.required {
    color: var(--error);
    font-weight: bold;
    font-size: 0.9rem;
}

/* Ajustements pour le texte de bascule */
#switchLoginText {
    margin-top: 20px;
}

/* Animations pour le changement d'étape */
@keyframes slideOutLeft {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-40px);
    }
}

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

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

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

/* ============================================
   CORRECTIONS SPÉCIFIQUES POUR TOUS NAVIGATEURS
   ============================================ */

/* Garantir le centrage sur Edge/IE */
@supports (-ms-ime-align: auto) {
    body {
        display: flex !important;
        height: 100vh !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .auth-form-section {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
}

/* Support pour Opera */
@media all and (-webkit-min-device-pixel-ratio:0) and (min-resolution: .001dpcm) {
    .auth-container {
        margin: auto;
        position: relative;
    }
}

/* Support pour Firefox */
@-moz-document url-prefix() {
    .auth-container {
        margin-top: auto;
        margin-bottom: auto;
    }
}

/* ============================================
   RESPONSIVE DESIGN - CORRECTION CENTRAGE
   ============================================ */

@media (max-width: 1024px) {
    .auth-visual { 
        flex: 1; 
        padding: 30px; 
    }
    .visual-content h1 { 
        font-size: 1.8rem; 
    }
    .visual-content p {
        font-size: 0.95rem;
    }

    .login-box h2  {
        text-align: center;
    }

    /* CORRECTION CENTRAGE */
    .auth-form-section {
        padding: 70px 20px 20px 20px;
        align-items: center;
    }

    .back-btn {
        top: 20px;
        left: 20px;
        font-size: 0.85rem;
    }

    .form-box { 
        max-height: calc(100vh - 140px);
        overflow-y: auto;
    }
}

@media (max-width: 900px) {
    .auth-container {
        flex-direction: column;
        max-height: 100vh;
        min-height: 100vh;
        border-radius: 0;
        box-shadow: none;
        margin: 0;
        padding: 0;
    }

       #loginBox{
    margin-top: 0rem;
    }
    
    .auth-visual { 
        flex: none;
        height: 200px;
        width: 100%;
        padding: 20px;
    }
    
    .auth-form-section { 
        flex: 1;
        padding: 60px 20px 20px 20px;
        align-items: flex-start;
        justify-content: flex-start;
        min-height: calc(100vh - 200px);
    }
    
    .visual-content {
        max-width: 100%;
    }
    
    .auth-logo {
        width: 120px;
        margin-bottom: 15px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 0;
    }
    
    .auth-container {
        width: 100%;
        height: auto;
        min-height: 100vh;
    }
    
    .auth-visual {
        height: 180px;
    }
    
    .auth-form-section {
        padding: 60px 15px 15px 15px;
        min-height: calc(100vh - 180px);
    }
    
    .form-box {
        max-width: 100%;
    }
}

@media (max-height: 700px) {
    .auth-form-section {
        padding: 60px 20px 15px 20px;
        align-items: flex-start;
    }
    
    .form-box {
        max-height: calc(100vh - 80px);
        overflow-y: auto;
        padding-right: 5px;
    }
    
    .form-box::-webkit-scrollbar {
        width: 4px;
    }
    
    .form-box::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 10px;
    }
    
    .form-box::-webkit-scrollbar-thumb {
        background: #c1c1c1;
        border-radius: 10px;
    }
    
    #registerTitle {
        font-size: 1.4rem;
        margin-bottom: 3px;
    }
    
    .subtext {
        margin-bottom: 15px;
        font-size: 0.8rem;
    }
    
    .role-section {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .option-label {
        padding: 12px;
    }
    
    .input-group {
        margin-bottom: 12px;
    }
}

/* Version ultra compacte pour très petits écrans */
@media (max-width: 480px), (max-height: 600px) {
    body {
        padding: 0;
    }
    
    .auth-container {
        width: 100%;
        height: 100vh;
        border-radius: 0;
        box-shadow: none;
        margin: 0;
    }
    
    .auth-visual {
        height: 160px;
        padding: 15px;
    }
    
    .visual-content h1 {
        font-size: 1.5rem;
        margin-bottom: 10px;
    }
    
    .visual-content p {
        font-size: 0.9rem;
    }
    
    .auth-logo {
        width: 100px;
        margin-bottom: 10px;
    }
    
    .auth-form-section {
        padding: 60px 15px 15px 15px;
        min-height: calc(100vh - 160px);
    }
    
    .role-section {
        padding: 12px;
    }
    
    .section-header {
        margin-bottom: 12px;
        padding-bottom: 10px;
    }
    
    .option-label {
        padding: 10px;
        gap: 8px;
    }
    
    .option-icon {
        width: 35px;
        height: 35px;
        font-size: 0.9rem;
    }
    
    .option-text h4 {
        font-size: 0.9rem;
    }
    
    .option-content {
        padding: 0 10px 10px 10px;
    }
    
    .input-group input,
    select, textarea {
        padding: 8px 10px;
        font-size: 0.85rem;
    }
    
    .btn-auth, .btn-back {
        padding: 10px;
        font-size: 0.85rem;
    }
    
    .info-box {
        padding: 10px;
    }

    #registerTitle {
        text-align: center;
    }

    .subtext {
        text-align: center;
        margin-bottom: 1rem;
    }
}

/* Support pour les très petits téléphones */
@media (max-width: 360px) {
    .role-selector {
        flex-direction: column;
        gap: 4px;
    }
    
    .role-content {
        padding: 6px 0;
    }
    
    .step-indicator {
        gap: 4px;
    }
    
    .step {
        width: 24px;
        height: 24px;
        font-size: 0.7rem;
    }
    
    .step-line {
        width: 25px;
    }
}

/* ============================================
   CORRECTION FINALE POUR LE CENTRAGE ABSOLU
   ============================================ */

/* Fallback pour les navigateurs anciens */
@media all and (max-width: 900px) {
    html, body {
        height: auto !important;
        min-height: 100vh !important;
    }
    
    body {
        display: block !important;
        padding: 0 !important;
    }
    
    .auth-container {
        display: block !important;
        height: auto !important;
        min-height: 100vh !important;
    }
    
    .auth-visual {
        position: relative !important;
        height: 200px !important;
    }
    
    .auth-form-section {
        position: relative !important;
        height: auto !important;
        min-height: calc(100vh - 200px) !important;
        display: flex !important;
        align-items: flex-start !important;
        justify-content: center !
    }
}