/* ========================================
   AUTH INTERFACE - MOBILE FIRST (CORRIGÉ)
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ✅ CORRECTION : Fond neutre par défaut */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f8f9fa; /* Fond neutre au lieu du violet */
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0; /* Caché initialement */
    transition: all 0.3s ease; /* Transition fluide */
}

/* ✅ NOUVEAU : Fond violet appliqué seulement quand nécessaire */
body.show-auth-interface {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    opacity: 1; /* Visible */
}

/* ✅ NOUVEAU : Classe pour affichage fluide */
body.show-content {
    opacity: 1;
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
    opacity: 0; /* Caché initialement */
    transform: translateY(20px); /* Légèrement décalé */
    transition: all 0.4s ease;
}

/* ✅ NOUVEAU : Animation d'apparition */
.auth-container.visible {
    opacity: 1;
    transform: translateY(0);
}

.auth-card {
    background: white;
    border-radius: 16px;
    padding: 32px 24px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    text-align: center;
}

.auth-header {
    margin-bottom: 32px;
}

.auth-logo {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-size: 24px;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.auth-header h1 {
    font-size: 24px;
    color: #333;
    margin-bottom: 8px;
}

.auth-header p {
    color: #666;
    font-size: 14px;
}

.auth-form {
    text-align: left;
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.2s;
}

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

.btn-primary, .btn-secondary {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: transparent;
    color: #667eea;
    border: 2px solid #667eea;
    margin-top: 12px;
}

.auth-footer {
    border-top: 1px solid #e1e5e9;
    padding-top: 24px;
    text-align: center;
}

.auth-footer p {
    margin-bottom: 12px;
    color: #666;
    font-size: 14px;
}

/* ✅ NOUVEAU : Spinner de redirection */
.redirect-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    color: #667eea;
}

.redirect-spinner .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e3f2fd;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.redirect-spinner p {
    font-size: 16px;
    font-weight: 500;
    color: #666;
}

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

/* Modal demande accès */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 9999;
    backdrop-filter: blur(2px);
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 32px 24px;
    width: 100%;
    max-width: 450px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Close button */
.modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
    transition: color 0.2s;
    z-index: 10;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(0,0,0,0.05);
}

.modal-close:hover {
    color: #333;
    background: rgba(0,0,0,0.1);
}

/* Titre modal */
.modal-content h3 {
    margin-bottom: 24px;
    margin-top: 8px;
    color: #333;
    font-size: 20px;
    text-align: center;
}

/* Champs du modal */
.modal-content input,
.modal-content select,
.modal-content textarea {
    width: 100%;
    padding: 14px 16px;
    margin-bottom: 16px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.2s;
}

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

/* Select personnalisé */
.modal-content select {
    background: white;
    appearance: none;
    cursor: pointer;
    background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iOCIgdmlld0JveD0iMCAwIDEyIDgiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGQ9Ik0xIDFMNiA2TDExIDEiIHN0cm9rZT0iIzY2NiIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPC9zdmc+');
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 12px;
    padding-right: 48px;
}

.modal-content select option {
    padding: 12px;
    font-size: 16px;
    background: white;
    color: #333;
}

.modal-content select option:disabled {
    color: #999;
    font-style: italic;
    background: #f8f9fa;
}

.modal-content textarea {
    min-height: 100px;
    resize: vertical;
    font-family: inherit;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal-buttons button {
    flex: 1;
    padding: 14px 20px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-buttons button[type="button"] {
    background: #f1f3f4;
    color: #5f6368;
}

.modal-buttons button[type="button"]:hover {
    background: #e8eaed;
}

.modal-buttons button[type="submit"] {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.modal-buttons button[type="submit"]:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
}

.modal-buttons button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Messages d'état */
.auth-message {
    padding: 12px 16px;
    border-radius: 8px;
    margin: 16px 0;
    font-weight: 500;
    font-size: 14px;
    animation: slideIn 0.3s ease-out;
}

.auth-message.success {
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    color: #155724;
    border-left: 4px solid #28a745;
}

.auth-message.error {
    background: linear-gradient(135deg, #f8d7da, #f5c6cb);
    color: #721c24;
    border-left: 4px solid #dc3545;
}

.auth-message.warning {
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
    color: #856404;
    border-left: 4px solid #ffc107;
}

/* Loading states */
.btn-spinner {
    animation: spin 1s linear infinite;
}

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

/* Body modal open */
body.modal-open {
    overflow: hidden;
}

/* Responsive */
@media (max-width: 480px) {
    .auth-container {
        padding: 12px;
    }
    
    .auth-card {
        padding: 24px 20px;
    }
    
    .modal {
        padding: 16px;
    }
    
    .modal-content {
        padding: 24px 20px;
        max-height: 90vh;
    }
    
    .modal-buttons {
        flex-direction: column;
        gap: 8px;
    }
    
    .modal-close {
        top: 12px;
        right: 16px;
    }
}