<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Register - Wavvy</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <link href="/css/style.css" rel="stylesheet">
</head>
<body>
    <div class="auth-container">
        <div class="auth-background">
            <div class="auth-shape auth-shape-1"></div>
            <div class="auth-shape auth-shape-2"></div>
            <div class="auth-shape auth-shape-3"></div>
        </div>
        
        <div class="auth-content">
            <div class="auth-card">
                <div class="auth-card-header">
                    <div class="auth-logo">
                        <i class="fab fa-whatsapp"></i>
                    </div>
                    <h1 class="auth-title">Create Account</h1>
                    <p class="auth-subtitle">Start managing your WhatsApp sessions today</p>
                </div>

                <% if (typeof error !== 'undefined' && error) { %>
                <div class="auth-alert auth-alert-danger">
                    <i class="fas fa-exclamation-circle"></i>
                    <span><%= error %></span>
                </div>
                <% } %>

                <% if (typeof success !== 'undefined' && success) { %>
                <div class="auth-alert auth-alert-success">
                    <i class="fas fa-check-circle"></i>
                    <span><%= success %></span>
                </div>
                <% } %>

                <form method="POST" action="/register" class="auth-form" id="registerForm">
                    <% if (typeof csrfToken !== 'undefined' && csrfToken) { %>
                    <input type="hidden" name="_csrf" value="<%= csrfToken %>">
                    <% } %>
                    
                    <div class="auth-input-group">
                        <label for="fullname" class="auth-label">
                            <i class="fas fa-user"></i>
                            Full Name
                        </label>
                        <input 
                            type="text" 
                            class="auth-input" 
                            id="fullname" 
                            name="fullname" 
                            placeholder="John Doe" 
                            required
                            autocomplete="name"
                            minlength="2"
                        >
                    </div>

                    <div class="auth-input-group">
                        <label for="email" class="auth-label">
                            <i class="fas fa-envelope"></i>
                            Email Address
                        </label>
                        <input 
                            type="email" 
                            class="auth-input" 
                            id="email" 
                            name="email" 
                            placeholder="your@email.com" 
                            required
                            autocomplete="email"
                        >
                    </div>

                    <div class="auth-input-group">
                        <label for="password" class="auth-label">
                            <i class="fas fa-lock"></i>
                            Password
                        </label>
                        <div class="auth-input-wrapper">
                            <input 
                                type="password" 
                                class="auth-input" 
                                id="password" 
                                name="password" 
                                placeholder="Create a strong password" 
                                required
                                autocomplete="new-password"
                                minlength="6"
                            >
                            <button type="button" class="auth-input-toggle" onclick="togglePassword('password')">
                                <i class="fas fa-eye" id="password-icon"></i>
                            </button>
                        </div>
                        <small class="auth-hint">Minimum 6 characters</small>
                    </div>

                    <div class="auth-input-group">
                        <label for="confirmPassword" class="auth-label">
                            <i class="fas fa-lock"></i>
                            Confirm Password
                        </label>
                        <div class="auth-input-wrapper">
                            <input 
                                type="password" 
                                class="auth-input" 
                                id="confirmPassword" 
                                name="confirmPassword" 
                                placeholder="Re-enter your password" 
                                required
                                autocomplete="new-password"
                                minlength="6"
                            >
                            <button type="button" class="auth-input-toggle" onclick="togglePassword('confirmPassword')">
                                <i class="fas fa-eye" id="confirmPassword-icon"></i>
                            </button>
                        </div>
                    </div>

                    <button type="submit" class="auth-btn auth-btn-primary">
                        <span>Create Account</span>
                        <i class="fas fa-arrow-right"></i>
                    </button>
                </form>

                <% if (typeof googleAuthEnabled !== 'undefined' && googleAuthEnabled) { %>
                <div class="auth-divider">
                    <span>Or continue with</span>
                </div>

                <a href="/auth/google" class="auth-btn auth-btn-google">
                    <i class="fab fa-google"></i>
                    <span>Sign up with Google</span>
                </a>
                <% } %>

                <div class="auth-divider">
                    <span>Already have an account?</span>
                </div>

                <a href="/login" class="auth-btn auth-btn-secondary">
                    <i class="fas fa-sign-in-alt"></i>
                    <span>Sign In</span>
                </a>

                <div class="auth-footer">
                    <p>
                        <i class="fas fa-shield-alt"></i>
                        By signing up, you agree to our Terms of Service
                    </p>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <script>
        function togglePassword(inputId) {
            const input = document.getElementById(inputId);
            const icon = document.getElementById(inputId + '-icon');
            
            if (input.type === 'password') {
                input.type = 'text';
                icon.classList.remove('fa-eye');
                icon.classList.add('fa-eye-slash');
            } else {
                input.type = 'password';
                icon.classList.remove('fa-eye-slash');
                icon.classList.add('fa-eye');
            }
        }

        // Client-side password validation
        document.getElementById('registerForm').addEventListener('submit', function(e) {
            const password = document.getElementById('password').value;
            const confirmPassword = document.getElementById('confirmPassword').value;
            
            if (password !== confirmPassword) {
                e.preventDefault();
                alert('Passwords do not match!');
                return false;
            }
            
            if (password.length < 6) {
                e.preventDefault();
                alert('Password must be at least 6 characters long!');
                return false;
            }
        });
    </script>
</body>
</html>
