<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login - 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">Welcome Back</h1>
                    <p class="auth-subtitle">Sign in to manage your WhatsApp sessions</p>
                </div>

                <% if (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="/login" class="auth-form">
                    <% if (typeof csrfToken !== 'undefined' && csrfToken) { %>
                    <input type="hidden" name="_csrf" value="<%= csrfToken %>">
                    <% } %>
                    
                    <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="Enter your password" 
                                required
                                autocomplete="current-password"
                            >
                            <button type="button" class="auth-input-toggle" onclick="togglePassword('password')">
                                <i class="fas fa-eye" id="password-icon"></i>
                            </button>
                        </div>
                    </div>

                    <button type="submit" class="auth-btn auth-btn-primary">
                        <span>Sign In</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 in with Google</span>
                </a>
                <% } %>

                <div class="auth-divider">
                    <span>New to Wavvy?</span>
                </div>

                <a href="/register" class="auth-btn auth-btn-secondary">
                    <i class="fas fa-user-plus"></i>
                    <span>Create Account</span>
                </a>

                <div class="auth-footer">
                    <p>
                        <i class="fas fa-shield-alt"></i>
                        Your data is secure and encrypted
                    </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');
            }
        }
    </script>
</body>
</html>
