/*********************************************
 * LOGIN & AUTHENTICATION - CSS OPTIMISÉ
 * Version refactorisée - Décembre 2025
 *********************************************
 * Structure:
 * 1. BASE & RESET
 * 2. VARIABLES CSS
 * 3. LAYOUT & TYPOGRAPHIE
 * 4. FORMULAIRE LOGIN
 * 5. ALERTES & STATUTS
 * 6. MODALES
 * 7. ÉTATS CONFIRMATION
 * 8. RESPONSIVE
 *********************************************/

/*********************************************
 * 1. BASE & RESET
 *********************************************/
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #FF6600 0%, #FF8800 100%);
    position: relative;
}

/* Fond avec opacité 30% */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../img/fond.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    opacity: 0.2;
    z-index: -1;
}

/*********************************************
 * 2. VARIABLES CSS (Thème centralisé)
 *********************************************/
:root {
    /* Couleurs principales */
    --primary: #FF6600;
    --primary-dark: #E55A00;
    --secondary: #95a5a6;
    
    /* Neutres */
    --text: #333;
    --text-muted: #666;
    --bg: rgba(255, 255, 255, 0.95);
    --border: #ddd;
    --border-light: #eee;
    --bg-light: transparent;
    
    /* États */
    --success-bg: #d4edda;
    --success-text: #155724;
    --success-border: #c3e6cb;
    --error-bg: #f8d7da;
    --error-text: #721c24;
    --error-border: #f5c6cb;
    --neutral-bg: #e8e8e8;
    
    /* Ombres */
    --shadow-sm: 0 4px 20px rgba(0,0,0,0.3);
    --shadow-md: 0 10px 25px rgba(0,0,0,0.2);
    
    /* Spacings */
    --spacing-xs: 8px;
    --spacing-sm: 10px;
    --spacing-md: 12px;
    --spacing-lg: 15px;
    --spacing-xl: 20px;
    --spacing-2xl: 25px;
    --spacing-3xl: 30px;
    --spacing-4xl: 40px;
    
    /* Bordures */
    --border-radius: 5px;
    --border-radius-lg: 10px;
    --border-radius-pill: 20px;
}

/*********************************************
 * 3. LAYOUT & TYPOGRAPHIE
 *********************************************/
/* Styles communs pour le conteneur de connexion et la modale */
.login-container,
.modal-content {
    background: var(--bg) !important;
    padding: var(--spacing-4xl);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 400px;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.login-container h1 {
    color: var(--primary);
    margin-bottom: var(--spacing-sm);
    font-size: 28px;
}

.login-container p {
    color: var(--text-muted);
    margin-bottom: var(--spacing-3xl);
    font-size: 14px;
}

/*********************************************
 * 4. FORMULAIRE LOGIN & INSCRIPTION
 *********************************************/
.form-group {
    margin-bottom: var(--spacing-xl);
}

.form-group label {
    display: block;
    color: var(--text);
    margin-bottom: var(--spacing-xs);
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: var(--spacing-md);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: all 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 5px rgba(255, 102, 0, 0.3);
}

.button-group {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-xl);
}

.input-hint {
    font-size: 12px;
    color: var(--text-muted); /* Gris discret */
    margin-top: 6px; /* Espace entre le champ et le texte */
    margin-bottom: 0;
    line-height: 1.4;
}
/*********************************************
 * 5. BOUTONS
 *********************************************/
.btn {
    flex: 1;
    padding: var(--spacing-md);
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-login {
    background: var(--primary);
    color: white;
}

.btn-login:hover { background: var(--primary-dark); }

.btn-register {
    background: #f0f0f0;
    color: var(--text);
}

.btn-register:hover { background: #e0e0e0; }

.btn-primary {
    padding: var(--spacing-sm) var(--spacing-2xl);
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
    padding: var(--spacing-sm) var(--spacing-2xl);
    background: var(--secondary);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
}

/*********************************************
 * 6. ALERTES & STATUTS
 *********************************************/
.alert,
.modal-alert {
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-xl);
    display: none;
}

.alert.success,
.modal-alert.success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success-border);
}

.alert.error,
.modal-alert.error {
    background: var(--error-bg);
    color: var(--error-text);
    border: 1px solid var(--error-border);
}

.alert.active,
.modal-alert.active {
    display: block;
}

.status-container { text-align: center; }

.status-icon { 
    font-size: 50px; 
    margin-bottom: var(--spacing-lg); 
}

.status-title {
    font-size: 18px;
    color: var(--text);
    margin-bottom: var(--spacing-sm);
    font-weight: 600;
}

.status-message {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: var(--spacing-xl);
    line-height: 1.6;
}

.status-badge {
    display: inline-block;
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--border-radius-pill);
    font-weight: 600;
    margin-bottom: var(--spacing-xl);
}

.status-badge.pending,
.status-badge.rejected {
    background: var(--neutral-bg);
    color: var(--text-muted);
}

.status-badge.approved {
    background: var(--success-bg);
    color: var(--success-text);
}

#statusResultContainer {
    display: none;
}

/*********************************************
 * 7. MODALES (Corrigé pour correspondre au style du login)
 *********************************************/
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    /* On retire le background: rgba(255,255,255,0.95) !important qui cachait tout */
    background-color: rgba(0, 0, 0, 0); 
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* .modal-content est déjà stylisé plus haut avec .login-container pour le glassmorphism */
.modal-content {
    margin: 20px; /* Ajout d'une petite marge pour que ça ne touche pas les bords sur mobile */
}

.modal-header {
    padding: 0 0 var(--spacing-xl) 0;
    border-bottom: none;
    background: transparent;
}

.modal-header h2 {
    color: var(--primary);
    font-size: 28px; /* Même taille que le h1 du login */
    margin: 0;
}

.modal-body { 
    padding: 0; 
}

.modal-footer {
    padding: var(--spacing-xl) 0 0 0;
    border-top: none;
    display: flex;
    gap: var(--spacing-sm);
}

.modal-footer button {
    flex: 1; /* Pour que les boutons Annuler et S'inscrire aient la même taille, comme Se connecter et S'inscrire */
    padding: var(--spacing-md);
    font-size: 14px;
}

/* --- GESTION DES MOTS DE PASSE (INSCRIPTION UNIQUEMENT) --- */
.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.password-input-wrapper input {
    padding-right: 40px;
    width: 100%;
}
.password-toggle {
    position: absolute;
    right: 12px;
    cursor: pointer;
    font-size: 16px;
    user-select: none;
}
.input-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    margin-bottom: 0;
    line-height: 1.4;
}
input.valid-match {
    border-color: #28a745 !important;
    background-color: rgba(40, 167, 69, 0.05);
}
input.invalid-match {
    border-color: #dc3545 !important;
    background-color: rgba(220, 53, 69, 0.05);
}
.hint-error   { color: #dc3545; }
.hint-success { color: #28a745; }

/*********************************************
 * 8. ÉTATS CONFIRMATION
 *********************************************/
.confirmation-icon {
    text-align: center;
    margin-bottom: var(--spacing-2xl);
}

.confirmation-icon .icon-large {
    font-size: 60px;
    margin-bottom: var(--spacing-lg);
}

.confirmation-text {
    text-align: center;
    color: var(--text);
    line-height: 1.6;
}

.confirmation-text h3 {
    font-size: 18px;
    margin-bottom: var(--spacing-sm);
}

.confirmation-text p {
    color: var(--text-muted);
    font-size: 14px;
}

.confirmation-text p + p {
    margin-top: 10px;
    font-weight: 600;
}

/*********************************************
 * 9. LIENS & UTILITAIRES
 *********************************************/
.login-link {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    margin-top: var(--spacing-lg);
}

.login-link a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

.login-link a:hover { 
    text-decoration: underline; 
}

/*********************************************
 * 10. RESPONSIVE
 *********************************************/
@media (max-width: 480px) {
    body { padding: 10px; }
    
    .login-container, .modal-content {
        padding: var(--spacing-2xl);
        margin: 10px;
    }
    
    .button-group, .modal-footer {
        flex-direction: column;
        gap: var(--spacing-md);
    }
    
    .modal-content {
        width: 95%;
    }
}