/**
 * Modales Modernes et Professionnelles
 * MixMaster Online - Enhanced Modal System
 */

/* ========================================
   MODAL OVERLAY & BACKDROP
======================================== */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(96, 114, 172, 0.15), rgba(0, 0, 0, 0.6));
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(8px);
    }
}

/* ========================================
   MODAL CONTENT CONTAINER
======================================== */
.modal-content {
    position: relative;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    margin: 5% auto;
    padding: 0;
    border: none;
    border-radius: 16px !important;
    width: 90%;
    max-width: 450px;
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.25),
        0 10px 30px rgba(96, 114, 172, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    animation: modalSlideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

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

/* ========================================
   MODAL HEADER AVEC GRADIENT
======================================== */
.modal-header {
    background: linear-gradient(135deg, #6072AC 0%, #4a5a94 50%, #3d4b7a 100%);
    padding: 24px 30px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.modal-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    50% { left: 100%; }
    100% { left: 100%; }
}

.modal-header h2 {
    color: #ffffff;
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.5px;
    /* Gestion automatique du retour à la ligne */
    line-height: 1.3;
    word-wrap: break-word;
    margin-right: 50px; /* Espace réservé pour le bouton */
    text-align: center;
    /* Centrer le contenu dans l'espace restant */
    display: flex;
    align-items: center;
    justify-content: center;
    height: auto;
    min-height: 1.3em; /* Hauteur minimale pour une ligne */
    /* Permettre le wrap automatique sans forcer de coupure */
    white-space: normal;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* ========================================
   MODAL BODY CONTAINER
======================================== */
.modal-body {
    padding: 30px;
    background: #ffffff;
}

/* ========================================
   FORMULAIRES MODERNES
======================================== */
.form-group {
    margin-bottom: 24px;
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #5e70ae;
    font-weight: 500;
    font-size: 0.9rem;
    letter-spacing: 0.3px;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"] {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 10px !important;
    font-size: 16px;
    color: #2d3748;
    background: #ffffff;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
    font-family: inherit;
}

.form-group input:focus {
    outline: none;
    border-color: #6072AC;
    box-shadow: 
        0 0 0 3px rgba(96, 114, 172, 0.1),
        0 4px 12px rgba(96, 114, 172, 0.15);
    transform: translateY(-1px);
}

.form-group input:hover:not(:focus) {
    border-color: #cbd5e0;
    transform: translateY(-1px);
}

/* États de validation */
.form-group input.form-input-valid {
    border-color: #48bb78;
    background: #f0fff4;
}

.form-group input.form-input-error {
    border-color: #f56565;
    background: #fffafa;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Messages de validation */
.form-field-error {
    color: #f56565;
    font-size: 0.8rem;
    margin-top: 6px;
    display: flex;
    align-items: center;
    animation: slideInError 0.3s ease-out;
}

.form-field-error::before {
    content: '⚠';
    margin-right: 6px;
    font-size: 1em;
}

.form-field-success {
    color: #48bb78;
    font-size: 0.8rem;
    margin-top: 6px;
    display: flex;
    align-items: center;
    animation: slideInSuccess 0.3s ease-out;
}

.form-field-success::before {
    content: '✓';
    margin-right: 6px;
    font-size: 1em;
}

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

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

/* Styles spécifiques pour la page d'inscription */
.checkbox-group-inscription {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 20px 0;
    padding: 16px;
    background: #f7fafc;
    border-radius: 10px !important;
    border: 1px solid #e2e8f0;
    width: 100%;
    box-sizing: border-box;
}

/* ========================================
   RECAPTCHA MODERNE AVEC ADAPTATION DYNAMIQUE
======================================== */
.recaptcha-container {
    display: flex;
    justify-content: center;
    margin: 24px 0;
    padding: 16px;
    background: #f7fafc;
    border-radius: 10px !important;
    border: 2px dashed #e2e8f0;
    transition: all 0.3s ease;
    /* Adaptation dynamique aux dimensions du reCAPTCHA */
    min-height: 78px;
    width: auto;
    max-width: 100%;
    overflow: visible; /* Éviter le rogbage */
}

.recaptcha-container:hover {
    border-color: #6072AC;
    background: #edf2f7;
}

/* Container spécifique pour inscription avec adaptation */
.recaptcha-container-inscription {
    display: flex;
    justify-content: center;
    margin: 24px 0;
    padding: 16px;
    background: #f7fafc;
    border-radius: 10px !important;
    border: 2px dashed #e2e8f0;
    transition: all 0.3s ease;
    min-height: 78px;
    width: auto;
    max-width: 100%;
    overflow: visible; /* Éviter le rogbage */
    box-sizing: border-box;
}

/* Wrapper pour éviter les conflits avec les tables */
.recaptcha-wrapper {
    overflow: visible !important;
    width: 100% !important;
    max-width: none !important;
}

/* Styles spécifiques pour la page d'inscription */
.recaptcha-container-inscription .g-recaptcha {
    margin: 0 auto;
    overflow: visible;
    transform-origin: center center;
    max-width: none;
    width: auto;
}

/* Modes adaptatifs pour les containers reCAPTCHA */
.recaptcha-container-inscription.compact-mode,
.recaptcha-container.compact-mode {
    max-width: 200px;
    padding: 12px;
    margin: 15px auto;
    min-height: 78px;
}

.recaptcha-container-inscription.normal-mode,
.recaptcha-container.normal-mode {
    max-width: 320px;
    padding: 16px;
    margin: 20px auto;
    min-height: 100px;
}

/* Adaptation des modales selon le mode reCAPTCHA */
.modal-content.compact-recaptcha {
    max-width: 320px !important;
}

.modal-content.normal-recaptcha {
    max-width: 450px !important;
}

/* Corrections spécifiques pour les tables et formulaires - MÊME LARGEUR QUE LES INPUTS */
table.generic-form-table td .recaptcha-container-inscription {
    width: 100%;
    margin: 20px 0;
    display: flex;
}

table.generic-form-table td .checkbox-group-inscription {
    width: 100%;
    margin: 20px 0;
    display: flex;
}

/* S'assurer que tous les éléments du formulaire ont la même largeur */
.form-group input[type="text"],
.form-group input[type="email"], 
.form-group input[type="password"],
.recaptcha-container-inscription,
.checkbox-group-inscription {
    width: 100%;
    box-sizing: border-box;
}

/* Responsivité pour la page d'inscription */
@media (max-width: 446px) {
    .recaptcha-container-inscription {
        max-width: 200px;
        padding: 10px;
    }
    
    .recaptcha-container-inscription .g-recaptcha {
        transform: scale(0.9);
        transform-origin: center center;
    }
}

@media (max-width: 320px) {
    .recaptcha-container-inscription {
        max-width: 180px;
        padding: 8px;
    }
    
    .recaptcha-container-inscription .g-recaptcha {
        transform: scale(0.8);
        transform-origin: center center;
    }
}

/* ========================================
   BOUTONS MODAUX SPÉCIFIQUES (évite les conflits CSS)
======================================== */
.modal-btn-primary {
    background: linear-gradient(135deg, #6072AC 0%, #4a5a94 100%);
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: 10px !important;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(96, 114, 172, 0.3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    width: 100%;
    margin: 20px 0 10px 0;
}

.modal-btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(96, 114, 172, 0.4);
    background: linear-gradient(135deg, #4a5a94 0%, #3d4b7a 100%);
}

.modal-btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(96, 114, 172, 0.3);
}

.modal-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 8px rgba(96, 114, 172, 0.2);
}

/* ========================================
   MODAL FOOTER
======================================== */
.modal-footer {
    background: #f8f9fa;
    padding: 20px 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-top: 1px solid #e2e8f0;
    gap: 12px;
    flex-wrap: wrap;
}

.modal-btn-secondary {
    background: transparent;
    color: #6072AC;
    border: 2px solid #6072AC;
    padding: 12px 24px;
    border-radius: 8px !important;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
    height: 44px;
    box-sizing: border-box;
}

.modal-btn-secondary:hover {
    background: #6072AC;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(96, 114, 172, 0.3);
}

.modal-btn-link {
    background: transparent;
    border: 2px solid #cbd5e0;
    color: #718096;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    padding: 12px 24px;
    border-radius: 8px !important;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
    height: 44px;
    box-sizing: border-box;
    font-weight: 500;
}

.modal-btn-link:hover {
    background: #718096;
    color: white;
    border-color: #718096;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(113, 128, 150, 0.3);
    text-decoration: none;
}

/* ========================================
   BOUTON DE FERMETURE
======================================== */
.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50% !important;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

@keyframes loading {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* ========================================
   RESPONSIVE DESIGN
======================================== */
@media (max-width: 576px) {
    .modal-content {
        width: 95%;
        margin: 10px auto;
        border-radius: 12px;
    }
    
    .modal-header {
        padding: 20px;
    }
    
    .modal-header h2 {
        font-size: 1.3rem;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .modal-footer {
        padding: 16px 20px;
        flex-direction: column;
        gap: 10px;
    }
    
    .modal-btn-secondary,
    .modal-btn-link {
        width: 100%;
        min-width: unset;
    }
}

/* ========================================
   RESPONSIVE DESIGN POUR TITRES
======================================== */

/* Pour les écrans très petits, ajuster encore plus le titre */
@media (max-width: 320px) {
    .modal-header h2 {
        font-size: 1.3rem;
        margin-right: 45px;
        line-height: 1.2;
        /* Maintenir le centrage */
        text-align: center;
        justify-content: center;
    }
    
    .modal-close {
        width: 28px;
        height: 28px;
        font-size: 20px;
        top: 12px;
        right: 12px;
    }
}

/* Pour les écrans moyens, s'assurer que le titre reste lisible */
@media (max-width: 480px) {
    .modal-header h2 {
        font-size: 1.4rem;
        margin-right: 48px;
        /* Maintenir le centrage */
        text-align: center;
        justify-content: center;
    }
}

/* ========================================
   ANIMATIONS AVANCÉES
======================================== */
.modal.closing {
    animation: modalFadeOut 0.3s ease-in forwards;
}

.modal.closing .modal-content {
    animation: modalSlideOut 0.3s ease-in forwards;
}

@keyframes modalFadeOut {
    to {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
}

@keyframes modalSlideOut {
    to {
        transform: translateY(-50px) scale(0.9);
        opacity: 0;
    }
}

/* Focus visible pour l'accessibilité */
.modal-content:focus {
    outline: 3px solid rgba(96, 114, 172, 0.5);
    outline-offset: 2px;
}

.modal-btn-primary:focus-visible,
.modal-btn-secondary:focus-visible {
    outline: 3px solid rgba(96, 114, 172, 0.5);
    outline-offset: 2px;
}

.character-option {
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.character-option:hover {
    border-color: #6072AC;
    background: linear-gradient(135deg, #6072AC 0%, #4a5a94 100%);
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(96, 114, 172, 0.4);
}

.character-option:hover .character-level,
.character-option:hover .character-class {
    color: white;
}

.character-option.selected {
    border-color: #6072AC;
    background: linear-gradient(135deg, #6072AC 0%, #4a5a94 100%);
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    box-shadow: 0 8px 20px rgba(96, 114, 172, 0.4);
}

.character-option .character-name {
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 5px;
}

.character-option .character-level {
    font-size: 14px;
    color: #666;
}

.character-option.selected .character-level,
.character-option.selected .character-class {
    color: white;
}

.character-option .character-class {
    font-size: 12px;
    font-style: italic;
    margin-top: 5px;
    color: #888;
}
/* ========================================
   BOUTONS OAUTH (Discord / Google)
======================================== */
.oauth-separator {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 16px 0 12px;
    color: #718096;
    font-size: 0.85rem;
}
.oauth-separator::before,
.oauth-separator::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #e2e8f0;
}
.oauth-separator span {
    padding: 0 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.btn-oauth {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px 20px;
    border-radius: 10px !important;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.25s ease;
    border: none;
    cursor: pointer;
    margin-bottom: 10px;
}
.btn-oauth:last-child { margin-bottom: 0; }
.btn-discord {
    background: #5865F2;
    color: #fff !important;
    box-shadow: 0 4px 12px rgba(88,101,242,0.3);
}
.btn-discord:hover {
    background: #4752C4;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(88,101,242,0.4);
    color: #fff !important;
    text-decoration: none;
}
.btn-google {
    background: #fff;
    color: #3c4043 !important;
    border: 1.5px solid #dadce0 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.btn-google:hover {
    background: #f8f9fa;
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(0,0,0,0.14);
    color: #3c4043 !important;
    text-decoration: none;
}
/* Dans les modales */
.modal-oauth-section {
    padding: 0 30px 20px;
}
