<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login - MHA Flow v3.0</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <style>
        @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Inter', sans-serif;
        }
        
        body {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            overflow: hidden;
        }
        
        body::before {
            content: '';
            position: absolute;
            width: 500px;
            height: 500px;
            background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
            border-radius: 50%;
            top: -100px;
            right: -100px;
            animation: float 6s ease-in-out infinite;
        }
        
        body::after {
            content: '';
            position: absolute;
            width: 400px;
            height: 400px;
            background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
            border-radius: 50%;
            bottom: -80px;
            left: -80px;
            animation: float 8s ease-in-out infinite reverse;
        }
        
        @keyframes float {
            0%, 100% {
                transform: translateY(0) rotate(0deg);
            }
            50% {
                transform: translateY(-20px) rotate(5deg);
            }
        }
        
        .login-wrapper {
            position: relative;
            z-index: 1;
            width: 100%;
            max-width: 1100px;
            padding: 20px;
        }
        
        .login-container {
            background: white;
            border-radius: 25px;
            box-shadow: 0 30px 80px rgba(0,0,0,0.25);
            overflow: hidden;
            display: flex;
            flex-direction: row;
            animation: slideIn 0.6s ease-out;
        }
        
        @keyframes slideIn {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        .login-left {
            flex: 1;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 60px 50px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            position: relative;
            overflow: hidden;
        }
        
        .login-left::before {
            content: '';
            position: absolute;
            width: 300px;
            height: 300px;
            background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
            border-radius: 50%;
            top: -50px;
            right: -50px;
        }
        
        .brand-section {
            position: relative;
            z-index: 1;
        }
        
        .brand-logo {
            font-size: 4.5rem;
            margin-bottom: 1.5rem;
            animation: pulse 2s ease-in-out infinite;
        }
        
        @keyframes pulse {
            0%, 100% {
                transform: scale(1);
            }
            50% {
                transform: scale(1.05);
            }
        }
        
        .brand-title {
            font-size: 2.8rem;
            font-weight: 900;
            margin-bottom: 1rem;
            line-height: 1.2;
        }
        
        .brand-subtitle {
            font-size: 1.15rem;
            opacity: 0.95;
            margin-bottom: 2rem;
            line-height: 1.6;
        }
        
        .features-list {
            list-style: none;
            padding: 0;
            margin: 2rem 0 0 0;
        }
        
        .features-list li {
            padding: 12px 0;
            font-size: 1rem;
            opacity: 0.9;
            display: flex;
            align-items: center;
            gap: 12px;
        }
        
        .features-list i {
            font-size: 1.3rem;
        }
        
        .login-right {
            flex: 1;
            padding: 60px 50px;
            display: flex;
            flex-direction: column;
            justify-content: center;
        }
        
        .form-header {
            margin-bottom: 2.5rem;
        }
        
        .form-header h2 {
            font-size: 2rem;
            font-weight: 800;
            color: #2d3748;
            margin-bottom: 0.5rem;
        }
        
        .form-header p {
            color: #718096;
            font-size: 1rem;
        }
        
        .form-group {
            margin-bottom: 1.8rem;
        }
        
        .form-label {
            font-weight: 600;
            color: #2d3748;
            margin-bottom: 0.7rem;
            font-size: 0.95rem;
            display: block;
        }
        
        .form-control {
            border: 2px solid #e2e8f0;
            border-radius: 12px;
            padding: 14px 18px;
            font-size: 1rem;
            transition: all 0.3s ease;
            width: 100%;
        }
        
        .form-control:focus {
            border-color: #667eea;
            box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
            outline: none;
        }
        
        .input-group {
            position: relative;
        }
        
        .input-group i {
            position: absolute;
            left: 18px;
            top: 50%;
            transform: translateY(-50%);
            color: #a0aec0;
            font-size: 1.1rem;
        }
        
        .input-group .form-control {
            padding-left: 50px;
        }
        
        .btn-login {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border: none;
            border-radius: 12px;
            padding: 14px 28px;
            font-size: 1.05rem;
            font-weight: 700;
            color: white;
            width: 100%;
            transition: all 0.3s ease;
            cursor: pointer;
            box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
        }
        
        .btn-login:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
        }
        
        .btn-login:active {
            transform: translateY(0);
        }
        
        .divider {
            text-align: center;
            color: #a0aec0;
            margin: 2rem 0;
            position: relative;
            font-size: 0.9rem;
            font-weight: 500;
        }
        
        .divider::before,
        .divider::after {
            content: '';
            position: absolute;
            top: 50%;
            width: 42%;
            height: 1px;
            background: #e2e8f0;
        }
        
        .divider::before {
            left: 0;
        }
        
        .divider::after {
            right: 0;
        }
        
        .demo-accounts {
            background: #f7fafc;
            border-radius: 12px;
            padding: 20px;
            margin-top: 1.5rem;
            border: 2px solid #e2e8f0;
        }
        
        .demo-accounts h6 {
            font-weight: 700;
            color: #2d3748;
            margin-bottom: 1rem;
            font-size: 0.95rem;
        }
        
        .demo-item {
            display: flex;
            justify-content: space-between;
            padding: 8px 0;
            font-size: 0.9rem;
            color: #4a5568;
        }
        
        .demo-item strong {
            color: #2d3748;
        }
        
        .quick-login-btn {
            background: #edf2f7;
            border: 2px solid #e2e8f0;
            border-radius: 8px;
            padding: 8px 16px;
            font-size: 0.85rem;
            font-weight: 600;
            color: #667eea;
            cursor: pointer;
            transition: all 0.2s ease;
        }
        
        .quick-login-btn:hover {
            background: #667eea;
            color: white;
            border-color: #667eea;
        }
        
        .alert {
            border-radius: 12px;
            padding: 14px 18px;
            margin-bottom: 1.5rem;
            border: none;
            font-size: 0.95rem;
        }
        
        .footer-text {
            text-align: center;
            margin-top: 2rem;
            color: #a0aec0;
            font-size: 0.85rem;
        }
        
        @media (max-width: 768px) {
            .login-container {
                flex-direction: column;
            }
            
            .login-left {
                padding: 40px 30px;
            }
            
            .login-right {
                padding: 40px 30px;
            }
            
            .brand-title {
                font-size: 2rem;
            }
        }
    </style>
</head>
<body>
    <div class="login-wrapper">
        <div class="login-container">
            <!-- Left Side - Branding -->
            <div class="login-left">
                <div class="brand-section">
                    <div class="brand-logo">
                        <i class="fas fa-brain"></i>
                    </div>
                    <h1 class="brand-title">MHA Flow v3.0</h1>
                    <p class="brand-subtitle">
                        Professional Meta-Heuristic Algorithm Optimization Framework
                    </p>
                    
                    <ul class="features-list">
                        <li>
                            <i class="fas fa-check-circle"></i>
                            <span>145+ Advanced Algorithms</span>
                        </li>
                        <li>
                            <i class="fas fa-check-circle"></i>
                            <span>Real-time Visualization</span>
                        </li>
                        <li>
                            <i class="fas fa-check-circle"></i>
                            <span>Comprehensive Analytics</span>
                        </li>
                        <li>
                            <i class="fas fa-check-circle"></i>
                            <span>Export & History Management</span>
                        </li>
                    </ul>
                </div>
            </div>
            
            <!-- Right Side - Login Form -->
            <div class="login-right">
                <div class="form-header">
                    <h2>Welcome Back</h2>
                    <p>Sign in to continue your optimization journey</p>
                </div>
                
                {% with messages = get_flashed_messages(with_categories=true) %}
                    {% if messages %}
                        {% for category, message in messages %}
                            <div class="alert alert-{{ category }}">
                                <i class="fas fa-{{ 'check-circle' if category == 'success' else 'exclamation-triangle' }}"></i>
                                {{ message }}
                            </div>
                        {% endfor %}
                    {% endif %}
                {% endwith %}
                
                <form method="POST" action="{{ url_for('login') }}">
                    <div class="form-group">
                        <label class="form-label">Username</label>
                        <div class="input-group">
                            <i class="fas fa-user"></i>
                            <input type="text" class="form-control" name="username" 
                                   placeholder="Enter your username" required autofocus>
                        </div>
                    </div>
                    
                    <div class="form-group">
                        <label class="form-label">Password</label>
                        <div class="input-group">
                            <i class="fas fa-lock"></i>
                            <input type="password" class="form-control" name="password" 
                                   placeholder="Enter your password" required>
                        </div>
                    </div>
                    
                    <button type="submit" class="btn-login">
                        <i class="fas fa-sign-in-alt"></i> Sign In
                    </button>
                </form>
                
                <div class="divider">OR</div>
                
                <div class="demo-accounts">
                    <h6><i class="fas fa-rocket"></i> Quick Demo Access</h6>
                    <div class="demo-item">
                        <div>
                            <strong>Admin:</strong> admin / admin123
                        </div>
                        <button class="quick-login-btn" onclick="quickLogin('admin', 'admin123')">
                            Quick Login
                        </button>
                    </div>
                    <div class="demo-item">
                        <div>
                            <strong>Demo:</strong> demo / demo123
                        </div>
                        <button class="quick-login-btn" onclick="quickLogin('demo', 'demo123')">
                            Quick Login
                        </button>
                    </div>
                </div>
                
                <div class="register-link" style="text-align: center; margin-top: 1.5rem; padding: 1rem; background: #f7fafc; border-radius: 12px;">
                    <p style="color: #4a5568; margin: 0;">
                        Don't have an account? 
                        <a href="{{ url_for('register') }}" style="color: #667eea; font-weight: 600; text-decoration: none;">
                            Create Account <i class="fas fa-arrow-right"></i>
                        </a>
                    </p>
                </div>
                
                <div class="footer-text">
                    &copy; 2025 MHA Flow v3.0 - Professional Optimization Framework
                </div>
            </div>
        </div>
    </div>
    
    <script>
        function quickLogin(username, password) {
            document.querySelector('input[name="username"]').value = username;
            document.querySelector('input[name="password"]').value = password;
            document.querySelector('form').submit();
        }
    </script>
</body>
</html>
