<!doctype html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php include 'configs.php'; echo $nombre_pagina; ?> - Registro</title>
    
    <!-- Estilos CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap">
    <link href="https://fonts.googleapis.com/css2?family=Modern+Antiqua&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    
    <style>
        :root {
            --jade: #38b2ac;
            --jade-light: #4fd1cc;
            --jade-dark: #2c8a86;
            --bg-dark: #0a0a12;
        }
        
        body, html {
            margin: 0;
            padding: 0;
            font-family: 'Modern Antiqua', serif;
            background-color: black;
            color: #e5e5e5;
            min-height: 100vh;
            position: relative;
        }
        
        /* Estilos de cursor personalizado */
        body {
            cursor: url("assets/media/cursors/image.png"), auto !important;
        }
        
        a, 
        button,
        .btn,
        .language-button,
        .back-button,
        input,
        select {
            cursor: url("assets/media/cursors/image.png"), auto !important;
        }
        
        a:hover, 
        button:hover,
        .btn:hover,
        .language-button:hover,
        .back-button:hover,
        input:hover,
        select:hover {
            cursor: url("assets/media/cursors/image2.png"), auto !important;
        }
        
        /* Aplicar Inter a los textos normales */
        h1, h2, .form-title, .logo-container h1 {
            font-family: 'Modern Antiqua', serif;
            letter-spacing: 0.05em;
        }
        
        .form-title {
            font-size: 1.875rem;
            font-weight: 700;
            color: var(--jade);
            margin-bottom: 0.5rem;
            font-family: 'Modern Antiqua', serif;
        }
        
        .bg-image {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            object-fit: cover;
            z-index: 0;
            opacity: 0.6;
        }
        
        .bg-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.4);
            z-index: 1;
        }
        
        header, main, footer {
            position: relative;
            z-index: 10;
        }
        
        header {
            padding: 1rem 1.5rem;
        }
        
        .back-button {
            display: inline-flex;
            align-items: center;
            padding: 0.5rem 1rem;
            background-color: rgba(10, 10, 18, 0.8);
            backdrop-filter: blur(4px);
            border: 1px solid rgba(56, 178, 172, 0.2);
            border-radius: 0.375rem;
            color: var(--jade);
            font-weight: 500;
            transition: all 0.3s ease;
            text-decoration: none;
        }
        
        .back-button:hover {
            background-color: rgba(10, 10, 18, 0.95);
            border-color: rgba(56, 178, 172, 0.4);
            color: var(--jade-light);
        }
        
        .back-button i {
            margin-right: 0.5rem;
        }
        
        .header-controls {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .language-selector {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        .language-button {
            background: transparent;
            border: 1px solid rgba(56, 178, 172, 0.3);
            color: #e5e5e5;
            padding: 0.25rem 0.5rem;
            border-radius: 0.25rem;
            cursor: pointer;
            transition: all 0.2s ease;
        }
        
        .language-button:hover, .language-button.active {
            background-color: rgba(56, 178, 172, 0.2);
            border-color: rgba(56, 178, 172, 0.5);
        }
        
        .main-content {
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: calc(100vh - 180px);
            padding: 2rem 1rem;
        }
        
        .form-container {
            width: 100%;
            max-width: 460px;
            animation: fadeInUp 0.5s ease forwards;
        }
        
        .logo-container {
            text-align: center;
            margin-bottom: 2rem;
        }
        
        .logo {
            max-width: 200px;
            margin-bottom: 1.5rem;
        }
        
        .form-description {
            color: #a0aec0;
            margin-bottom: 1.5rem;
        }
        
        .form-card {
            background-color: rgba(10, 10, 18, 0.8);
            backdrop-filter: blur(8px);
            border: 1px solid rgba(56, 178, 172, 0.2);
            border-radius: 0.5rem;
            padding: 1.5rem;
            margin-bottom: 1rem;
        }
        
        .form-group {
            margin-bottom: 1.5rem;
        }
        
        .form-label {
            display: block;
            margin-bottom: 0.5rem;
            color: #d1d5db;
            font-weight: 500;
        }
        
        .form-control {
            width: 100%;
            padding: 0.75rem;
            background-color: rgba(23, 25, 35, 0.5);
            border: 1px solid rgba(75, 85, 99, 0.5);
            border-radius: 0.375rem;
            color: white;
            transition: all 0.3s ease;
        }
        
        .form-control:focus {
            outline: none;
            border-color: var(--jade);
            box-shadow: 0 0 0 2px rgba(56, 178, 172, 0.25);
            background-color: rgba(23, 25, 35, 0.7);
            color: white;
        }

        .form-control::placeholder {
            color: rgba(255, 255, 255, 0.5);
        }
        
        .password-container {
            position: relative;
        }
        
        .password-toggle {
            position: absolute;
            right: 12px;
            top: 50%;
            transform: translateY(-50%);
            background: none;
            border: none;
            color: #9ca3af;
            cursor: pointer;
        }
        
        .password-toggle:hover {
            color: #f9fafb;
        }
        
        /* Estilos simples para el checkbox */
        .form-checkbox {
            display: flex;
            align-items: center;
            margin-bottom: 1.5rem;
            gap: 10px;
        }

        /* Ocultamos visualmente el checkbox original pero lo mantenemos accesible */
        .checkbox-input {
            position: absolute;
            opacity: 0;
            cursor: pointer;
            height: 0;
            width: 0;
        }
        
        /* Creamos un checkbox personalizado */
        .checkbox-custom {
            position: relative;
            display: inline-block;
            width: 24px;
            height: 24px;
            background-color: transparent;
            border: 2px solid var(--jade);
            border-radius: 4px;
            cursor: pointer;
            flex-shrink: 0;
        }
        
        /* El check cuando está marcado */
        .checkbox-input:checked + .checkbox-custom:after {
            content: '✓';
            position: absolute;
            display: block;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            color: var(--jade);
            font-size: 16px;
            font-weight: bold;
        }
        
        .checkbox-label {
            color: #d1d5db;
            font-size: 0.9rem;
            cursor: pointer;
        }
        
        .checkbox-label a {
            color: var(--jade);
            text-decoration: none;
        }
        
        .checkbox-label a:hover {
            color: var(--jade-light);
        }
        
        .btn-primary {
            display: block;
            width: 100%;
            padding: 0.75rem 1rem;
            background-color: var(--jade);
            color: white;
            border: none;
            border-radius: 0.375rem;
            font-weight: 600;
            transition: all 0.3s ease;
            cursor: pointer;
        }
        
        .btn-primary:hover {
            background-color: var(--jade-dark);
        }
        
        .btn-primary:disabled {
            background-color: #4b5563;
            cursor: not-allowed;
            color: #d1d5db;
        }
        
        .recovery-link {
            display: block;
            text-align: center;
            margin-top: 1rem;
            color: var(--jade);
            text-decoration: none;
            border-bottom: 1px solid var(--jade);
            display: inline-block;
            padding-bottom: 2px;
            transition: all 0.3s ease;
        }
        
        .recovery-link:hover {
            color: var(--jade-light);
        }
        
        .recovery-link-container {
            text-align: center;
            padding-top: 0.5rem;
        }
        
        footer {
            text-align: center;
            padding: 1rem;
            color: #9ca3af;
            font-size: 0.875rem;
        }
        
        .success-message {
            text-align: center;
            padding: 1rem 0;
        }
        
        .success-icon {
            width: 4rem;
            height: 4rem;
            background-color: rgba(56, 178, 172, 0.2);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin: 0 auto 1rem;
        }
        
        .success-icon i {
            color: var(--jade);
            font-size: 2rem;
        }
        
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        @keyframes fadeIn {
            from {
                opacity: 0;
            }
            to {
                opacity: 1;
            }
        }
        
        .form-register {
            animation: fadeIn 0.3s ease-in-out;
        }
        
        .form-recovery {
            animation: fadeIn 0.3s ease-in-out;
        }
        
        .vote-section {
            position: fixed;
            z-index: 50;
            right: 1rem;
            top: 50%;
            transform: translateY(-50%);
        }

        .vote-container {
            padding: 1rem;
        }

        .vote-title {
            font-size: 1.25rem;
            font-weight: bold;
            color: white;
            margin-bottom: 1rem;
            text-align: center;
            text-transform: uppercase;
            letter-spacing: 0.1em;
        }

        .vote-buttons {
            display: flex;
            flex-direction: column;
            gap: 1.5rem;
            align-items: center;
        }

        .vote-button {
            position: relative;
            display: block;
            text-decoration: none;
        }

        .vote-button-glow {
            position: absolute;
            inset: 0;
            border-radius: 9999px;
            background-color: rgba(56, 178, 172, 0.2);
            opacity: 0;
            transition: opacity 0.3s, filter 0.3s;
            filter: blur(1rem);
        }

        .vote-button:hover .vote-button-glow {
            opacity: 1;
        }

        .vote-button-content {
            position: relative;
            width: 4rem;
            height: 4rem;
            display: flex;
            align-items: center;
            justify-content: center;
            background-color: rgba(10, 10, 18, 0.8);
            border-radius: 9999px;
            border: 2px solid rgba(56, 178, 172, 0.2);
            backdrop-filter: blur(4px);
            transition: border-color 0.3s, transform 0.3s;
        }

        .vote-button:hover .vote-button-content {
            border-color: rgba(56, 178, 172, 0.5);
            transform: scale(1.1);
        }

        .vote-icon {
            width: 2rem;
            height: 2rem;
            transition: transform 0.3s;
        }

        .vote-button:hover .vote-icon {
            transform: scale(1.1);
        }
        
        /* Estilos para las notificaciones */
        .custom-notification {
            position: fixed;
            top: 20px;
            right: 20px;
            z-index: 9999;
            background: rgba(0, 0, 0, 0.8);
            color: white;
            padding: 15px 25px;
            border-radius: 4px;
            max-width: 350px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            display: none;
        }

        .custom-notification.success {
            background: rgba(40, 167, 69, 0.9);
        }

        .custom-notification.error {
            background: rgba(220, 53, 69, 0.9);
        }

        .custom-notification.info {
            background: rgba(23, 162, 184, 0.9);
        }

        .custom-notification.show {
            display: block;
            animation: slideIn 0.5s ease-out;
        }

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

        @keyframes slideOut {
            from {
                transform: translateX(0);
                opacity: 1;
            }
            to {
                transform: translateX(100%);
                opacity: 0;
            }
        }
        
        /* Estilos para el modal personalizado */
        .custom-modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.5);
            z-index: 9999;
            animation: fadeIn 0.3s ease-out;
        }

        .modal-content {
            position: relative;
            background: #fff;
            width: 90%;
            max-width: 500px;
            margin: 50px auto;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            animation: slideIn 0.3s ease-out;
        }

        .modal-close {
            position: absolute;
            right: 15px;
            top: 10px;
            font-size: 24px;
            cursor: pointer;
            color: #666;
        }

        .modal-close:hover {
            color: #333;
        }

        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }

        @keyframes slideIn {
            from {
                transform: translateY(-100px);
                opacity: 0;
            }
            to {
                transform: translateY(0);
                opacity: 1;
            }
        }
    </style>
</head>
<body>
    <!-- Imagen de fondo -->
    <img src="https://hebbkx1anhila5yf.public.blob.vercel-storage.com/background%203.jpg-C7MxrAutxR9FqTKCjXcmCLXq5rHAEC.jpeg" alt="Fondo Místico" class="bg-image">
    <div class="bg-overlay"></div>
    
    <!-- Sección de votación -->
    <div class="vote-section">
        <div class="vote-container">
            <h3 class="vote-title">Votar</h3>
            <div class="vote-buttons">
                <a href="https://l2.hopzone.net/site/vote/106242/1" target="_blank" rel="noopener noreferrer" class="vote-button">
                    <div class="vote-button-glow"></div>
                    <div class="vote-button-content">
                        <img src="assets/media/hopzone.png" alt="Vote on Hopzone" class="vote-icon">
                    </div>
                </a>
                <a href="https://svtop.net/vote/618" target="_blank" rel="noopener noreferrer" class="vote-button">
                    <div class="vote-button-glow"></div>
                    <div class="vote-button-content">
                        <img src="assets/media/server-top.png" alt="Vote on Server Top" class="vote-icon">
                    </div>
                </a>
            </div>
        </div>
    </div>
    
    <!-- Cabecera con botón de volver y selector de idioma -->
    <header>
        <div class="header-controls">
            <a href="index.php" class="back-button">
                <i class="fas fa-arrow-left"></i>
                <span class="lang-back-to-panel">Volver al Panel</span>
            </a>
            
            <div class="language-selector">
                <button type="button" class="language-button active" data-lang="es">ES</button>
                <button type="button" class="language-button" data-lang="en">EN</button>
                <button type="button" class="language-button" data-lang="br">PT</button>
            </div>
        </div>
    </header>
    
    <!-- Contenido principal -->
    <main class="main-content">
        <div class="form-container">
            <div class="logo-container">
                <img src="https://hebbkx1anhila5yf.public.blob.vercel-storage.com/logo-wLBB9y6KreoxJBVQKAJj1BZ1eqO9f4.png" alt="L2JADE Logo" class="logo">
                <h1 class="form-title">
                    <span class="lang-create-account" id="register-title">Crear Cuenta</span>
                    <span class="lang-recover-account" id="recovery-title" style="display: none;">Recuperar Cuenta</span>
                </h1>
                <p class="form-description">
                    <span class="lang-description" id="register-description">Únete a nuestra comunidad y disfruta de la aventura.</span>
                    <span class="lang-recovery-description" id="recovery-description" style="display: none;">Ingresa tu correo para recuperar tu cuenta.</span>
                </p>
            </div>
            
            <!-- Formulario de registro -->
            <div id="register-form" class="form-register">
                <form class="form-card js-validation-signin uns-signup" action="account_save.php" method="post" id="form_signup" onsubmit="return false;">
                    <input type="hidden" name="module_form" value="Modules\Globals\SignUp\SignUp">
                    <input type="hidden" name="module" value="signup">
                    <input id="type_reg" name="type_reg" type="hidden" value="#r-email">
                    
                    <!-- Nombre de usuario -->
                    <div class="form-group">
                        <label for="signup-username" class="form-label lang-username">Usuario</label>
                        <input type="text" class="form-control" id="signup-username" name="username" required>
                    </div>
                    
                    <!-- Contraseña -->
                    <div class="form-group">
                        <label for="t-signup-password" class="form-label lang-password">Contraseña</label>
                        <div class="password-container">
                            <input type="password" class="form-control" id="t-signup-password" name="password" required>
                            <button type="button" class="password-toggle" id="eye">
                                <i class="fas fa-eye" id="password-toggle-icon"></i>
                            </button>
                        </div>
                    </div>
                    
                    <!-- Correo electrónico -->
                    <div class="form-group">
                        <label for="signup-email" class="form-label lang-email">Correo electrónico</label>
                        <input type="email" class="form-control" id="signup-email" name="email" required>
                    </div>
                    
                    <!-- Aceptar reglas - Implementación totalmente nueva -->
                    <div class="form-checkbox">
                        <label style="display: flex; align-items: center; cursor: pointer;">
                            <input type="checkbox" class="checkbox-input" id="signup-terms" name="terms" value="1" required>
                            <span class="checkbox-custom"></span>
                            <span class="checkbox-label" style="margin-left: 10px;">
                                <span class="lang-rules">Estoy de acuerdo con las reglas.</span>
                                <a href="https://l2jade.com.ar/info.html#reglamentos" target="_blank" class="lang-server-rules" style="display: block; margin-top: 5px;">Reglas del servidor</a>
                            </span>
                        </label>
                    </div>
                    
                    <!-- Botón de registro -->
                    <button type="submit" class="btn-primary submit-form" id="register-button">
                        <span class="lang-register-button">Registrar Cuenta</span>
                    </button>
                    
                    <!-- Enlace a recuperación de contraseña -->
                    <div class="recovery-link-container">
                        <a href="recuperar.php" class="recovery-link">
                            <span class="lang-recover-password">Recuperar contraseña</span>
                        </a>
                    </div>
                </form>
            </div>
            
            <!-- Formulario de recuperación de contraseña (inicialmente oculto) -->
            <div id="recovery-form" class="form-recovery" style="display: none;">
                <form class="form-card" action="account_save.php" method="post" id="form_recovery">
                    <input type="hidden" name="module_form" value="Modules\Globals\Reminder\Reminder">
                    <input type="hidden" name="module" value="reminder">
                    
                    <div id="recovery-not-submitted">
                        <!-- Correo electrónico para recuperación -->
                        <div class="form-group">
                            <label for="recovery-email" class="form-label lang-email">Correo electrónico</label>
                            <input type="email" class="form-control" id="recovery-email" name="email" required>
                        </div>
                        
                        <!-- Botón de recuperación -->
                        <button type="submit" class="btn-primary submit-form">
                            <span class="lang-recover">Recuperar</span>
                        </button>
                        
                    </div>
                </form>
            </div>
        </div>
    </main>
    
    <!-- Pie de página -->
    <footer>
        <p> 2023 L2JADE. <span class="lang-all-rights">Todos los derechos reservados</span></p>
    </footer>
    
    <!-- Scripts -->
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
        // Implementación personalizada de notify
        jQuery.notify = function(options, settings) {
            var message = options.message || '';
            var type = (settings && settings.type) || 'info';
            
            var notification = $('<div class="custom-notification">').addClass(type).html(message);
            
            $('body').append(notification);
            
            setTimeout(function() {
                notification.addClass('show');
            }, 100);
            
            setTimeout(function() {
                notification.css('animation', 'slideOut 0.5s ease-out forwards');
                setTimeout(function() {
                    notification.remove();
                }, 500);
            }, 5000);
        };
    </script>
    <script src="assets/js/mmoweb2954.js?v=1651936502"></script>
    <script>
        $(document).ready(function() {
            // Manejar el envío del formulario de registro
            $('.submit-form').on('click', function(e) {
                e.preventDefault();
                var form = $(this).closest('form');
                var formData = new FormData(form[0]);
                
                $.ajax({
                    url: form.attr('action'),
                    type: 'POST',
                    data: formData,
                    processData: false,
                    contentType: false,
                    success: function(response) {
                        console.log('Respuesta:', response);
                        try {
                            if (typeof response === 'string') {
                                response = JSON.parse(response);
                            }
                            jQuery.notify({
                                message: response.text || 'Cuenta creada con éxito. En unos momentos te estará llegando un email con la información de tu cuenta.'
                            }, {
                                type: response.status || 'info'
                            });
                            
                            if (response.status === 'success' && form.attr('id') === 'register-form') {
                                setTimeout(function() {
                                    window.location.href = 'index.php';
                                }, 3000);
                            }
                        } catch (e) {
                            console.error('Error al procesar respuesta:', e);
                            jQuery.notify({
                                message: 'Error al procesar la respuesta del servidor'
                            }, {
                                type: 'error'
                            });
                        }
                    },
                    error: function(xhr, status, error) {
                        console.error('Error:', error);
                        jQuery.notify({
                            message: 'Error al enviar el formulario: ' + error
                        }, {
                            type: 'error'
                        });
                    }
                });
            });
        });
    </script>
    <script>
        // Traducciones
        const translations = {
            en: {
                "lang-back-to-panel": "Back to Panel",
                "lang-create-account": "Create Account",
                "lang-recover-account": "Recover Account",
                "lang-description": "Join our community and enjoy the adventure.",
                "lang-recovery-description": "Enter your email to recover your account.",
                "lang-username": "Username",
                "lang-password": "Password",
                "lang-email": "Email",
                "lang-rules": "I agree with the rules.",
                "lang-server-rules": "Server Rules",
                "lang-register-button": "Register Account",
                "lang-recover-password": "Recover password",
                "lang-recovery-title": "Password Recovery",
                "lang-recovery-description": "Enter your email to receive password reset instructions.",
                "lang-recovery-submit": "Send Request",
                "lang-back-to-register": "Back to Register",
                "lang-recovery-success-title": "Request Sent",
                "lang-recovery-success-description": "We've sent an email with instructions to recover your password.",
                "lang-all-rights": "All rights reserved"
            },
            es: {
                "lang-back-to-panel": "Volver al Panel",
                "lang-create-account": "Crear Cuenta",
                "lang-recover-account": "Recuperar Cuenta",
                "lang-description": "Únete a nuestra comunidad y disfruta de la aventura.",
                "lang-recovery-description": "Ingresa tu correo para recuperar tu cuenta.",
                "lang-username": "Usuario",
                "lang-password": "Contraseña",
                "lang-email": "Correo electrónico",
                "lang-rules": "Estoy de acuerdo con las reglas.",
                "lang-server-rules": "Reglas del servidor",
                "lang-register-button": "Registrar Cuenta",
                "lang-recover-password": "Recuperar contraseña",
                "lang-recovery-title": "Recuperación de Contraseña",
                "lang-recovery-description": "Ingresa tu correo para recibir instrucciones de restablecimiento.",
                "lang-recovery-submit": "Enviar solicitud",
                "lang-back-to-register": "Volver al registro",
                "lang-recovery-success-title": "Solicitud enviada",
                "lang-recovery-success-description": "Hemos enviado un correo con instrucciones para recuperar tu contraseña.",
                "lang-all-rights": "Todos los derechos reservados"
            },
            br: {
                "lang-back-to-panel": "Voltar ao Painel",
                "lang-create-account": "Criar Conta",
                "lang-recover-account": "Recuperar Conta",
                "lang-description": "Junte-se à nossa comunidade e aproveite a aventura.",
                "lang-recovery-description": "Digite seu e-mail para recuperar sua conta.",
                "lang-username": "Usuário",
                "lang-password": "Senha",
                "lang-email": "E-mail",
                "lang-rules": "Estou de acordo com as regras.",
                "lang-server-rules": "Regras do servidor",
                "lang-register-button": "Registrar Conta",
                "lang-recover-password": "Recuperar senha",
                "lang-recovery-title": "Recuperação de Senha",
                "lang-recovery-description": "Digite seu e-mail para receber instruções de redefinição.",
                "lang-recovery-submit": "Enviar solicitação",
                "lang-back-to-register": "Voltar ao registro",
                "lang-recovery-success-title": "Solicitação enviada",
                "lang-recovery-success-description": "Enviamos um e-mail com instruções para recuperar sua senha.",
                "lang-all-rights": "Todos os direitos reservados"
            }
        };
        
        // Función para actualizar el idioma en la interfaz
        function updateLanguage(lang) {
            document.documentElement.lang = lang;
            
            // Actualizar todos los elementos con clases de idioma
            for (const [key, value] of Object.entries(translations[lang])) {
                const elements = document.getElementsByClassName(key);
                for (let i = 0; i < elements.length; i++) {
                    elements[i].innerHTML = value;
                }
            }
            
            // Actualizar el título del formulario de recuperación
            if (isRecoveryMode) {
                document.querySelector('.form-title').innerHTML = translations[lang]["lang-recovery-title"];
                document.querySelector('.form-description').innerHTML = translations[lang]["lang-recovery-description"];
            } else {
                document.querySelector('.form-title').innerHTML = translations[lang]["lang-create-account"];
                document.querySelector('.form-description').innerHTML = translations[lang]["lang-description"];
            }
            
            // Actualizar botones de idioma
            const langButtons = document.querySelectorAll('.language-button');
            langButtons.forEach(button => {
                button.classList.remove('active');
                if (button.getAttribute('data-lang') === lang) {
                    button.classList.add('active');
                }
            });
        }
        
        // Detectar el idioma del navegador
        function detectLanguage() {
            const userLang = navigator.language || navigator.userLanguage;
            const lang = userLang.split('-')[0].toLowerCase();
            return translations[lang] ? lang : 'es';
        }
        
        // Variables globales
        let isRecoveryMode = false;
        let recoverySubmitted = false;
        const currentLang = detectLanguage();
        
        // Función para validar el formulario de registro
        function validateRegisterForm() {
            const username = document.getElementById('signup-username').value.trim();
            const password = document.getElementById('t-signup-password').value.trim();
            const email = document.getElementById('signup-email').value.trim();
            const terms = document.getElementById('signup-terms').checked;
            
            return username !== '' && password !== '' && email !== '' && terms;
        }
        
        // Función para validar el formulario de recuperación
        function validateRecoveryForm() {
            return document.getElementById('recovery-email').value.trim() !== '';
        }
        
        // Toggle entre modo registro y recuperación
        /*document.getElementById('recovery-mode-toggle').addEventListener('click', function(e) {
            e.preventDefault();
            const registerForm = document.getElementById('register-form');
            const recoveryForm = document.getElementById('recovery-form');
            const registerTitle = document.getElementById('register-title');
            const recoveryTitle = document.getElementById('recovery-title');
            const registerDesc = document.getElementById('register-description');
            const recoveryDesc = document.getElementById('recovery-description');
            
            if (registerForm.style.display !== 'none') {
                registerForm.style.display = 'none';
                recoveryForm.style.display = 'block';
                registerTitle.style.display = 'none';
                recoveryTitle.style.display = 'block';
                registerDesc.style.display = 'none';
                recoveryDesc.style.display = 'block';
            } else {
                registerForm.style.display = 'block';
                recoveryForm.style.display = 'none';
                registerTitle.style.display = 'block';
                recoveryTitle.style.display = 'none';
                registerDesc.style.display = 'block';
                recoveryDesc.style.display = 'none';
            }
        });*/
        
        // Inicializar la página cuando el DOM esté cargado
        document.addEventListener('DOMContentLoaded', function() {
            // Configurar idioma inicial
            updateLanguage(currentLang);
            
            // Event listeners para botones de idioma
            const langButtons = document.querySelectorAll('.language-button');
            langButtons.forEach(button => {
                button.addEventListener('click', function() {
                    const lang = this.getAttribute('data-lang');
                    updateLanguage(lang);
                });
            });
            
            // Event listener para alternar visibilidad de contraseña
            const eyeButton = document.getElementById('eye');
            const passwordInput = document.getElementById('t-signup-password');
            const passwordToggleIcon = document.getElementById('password-toggle-icon');
            
            eyeButton.addEventListener('click', function() {
                if (passwordInput.type === 'password') {
                    passwordInput.type = 'text';
                    passwordToggleIcon.classList.remove('fa-eye');
                    passwordToggleIcon.classList.add('fa-eye-slash');
                } else {
                    passwordInput.type = 'password';
                    passwordToggleIcon.classList.remove('fa-eye-slash');
                    passwordToggleIcon.classList.add('fa-eye');
                }
            });
            
            // Configurar envío del formulario de registro
            document.getElementById('form_signup').addEventListener('submit', function(e) {
                e.preventDefault();
                // La función original de envío está en mmoweb.js y se activa con la clase submit-form
            });
            
            // Configurar envío del formulario de recuperación
            document.getElementById('form_recovery').addEventListener('submit', function(e) {
                e.preventDefault();
                
                // Mostrar mensaje de éxito
                const recoverySubmittedEl = document.getElementById('recovery-submitted');
                const recoveryNotSubmittedEl = document.getElementById('recovery-not-submitted');
                
                recoverySubmittedEl.style.display = 'block';
                recoveryNotSubmittedEl.style.display = 'none';
                
                // La función original de envío está en mmoweb.js y se activa con la clase submit-form
            });
            
            $(document).ready(function() {
                // Eliminamos todos los manejadores de eventos anteriores que pueden estar causando conflictos
                $('#signup-terms').off();
                $('.form-checkbox').off();
                
                // Solo mantenemos la verificación en el envío del formulario
                $('#form_signup').on('submit', function(e) {
                    console.log('Verificando formulario antes de enviar');
                    console.log('Estado del checkbox:', $('#signup-terms').is(':checked'));
                    
                    if (!$('#signup-terms').is(':checked')) {
                        console.log('Checkbox no marcado - mostrando alerta');
                        alert('Debes aceptar las reglas para continuar');
                        return false;
                    }
                    
                    console.log('Formulario enviándose correctamente');
                    return true; // Permitir que el formulario se envíe normalmente
                });
            });
        });
        
        // Asegurarnos que el documento esté completamente cargado
        $(document).ready(function() {
            // Debug para términos y condiciones
            console.log("Inicializando checkbox...");
            
            // Implementamos una solución manual para el checkbox
            // Asignar un event listener al contenedor general
            $('.form-checkbox').on('click', function(event) {
                // Prevenir comportamiento predeterminado
                event.stopPropagation();
                event.preventDefault();
                
                // No procesar si se hizo clic en el enlace
                if ($(event.target).is('a') || $(event.target).parents('a').length > 0) {
                    return true; // Permitir que el enlace funcione
                }
                
                // Encontrar el checkbox dentro del contenedor
                const checkbox = $('#signup-terms');
                
                // Cambiar estado y forzar el evento change
                checkbox.prop('checked', !checkbox.prop('checked')).change();
                
                console.log("Checkbox cambiado manualmente a:", checkbox.prop('checked'));
                
                return false; // Evitar cualquier otro comportamiento
            });
            
            // Monitorear cambios en el checkbox
            $('#signup-terms').on('change', function() {
                console.log("Estado del checkbox actualizado:", $(this).prop('checked'));
            });
            
            // Validar formulario antes de enviar
            $('#form_signup').on('submit', function(e) {
                const checkbox = $('#signup-terms');
                console.log("Enviando formulario, estado del checkbox:", checkbox.prop('checked'));
                
                if (!checkbox.prop('checked')) {
                    alert("Debes aceptar las reglas para continuar");
                    return false;
                }
                
                // Permitir envío normal si todo está bien
                return true;
            });
        });
    </script>
</body>
</html>