<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login Page</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f2f2f2;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }

        .login-container {
            background-color: white;
            padding: 30px;
            border-radius: 8px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            width: 350px;
            text-align: center;
        }

        h2 {
            color: #333;
            margin-bottom: 20px;
        }

        .input-field {
            width: 100%;
            padding: 10px;
            margin: 10px 0;
            border: 1px solid #ccc;
            border-radius: 4px;
            font-size: 16px;
        }

        .input-field:focus {
            outline: none;
            border-color: #4CAF50;
        }

        .login-btn {
            width: 100%;
            padding: 10px;
            background-color: #4CAF50;
            border: none;
            color: white;
            font-size: 16px;
            border-radius: 4px;
            cursor: pointer;
        }

        .login-btn:hover {
            background-color: #45a049;
        }

        .error-message {
            color: red;
            font-size: 14px;
            display: none;
        }
    </style>
</head>
<body>

    <div class="login-container">
        <h2>Login</h2>

        <!-- Login Form -->
        <form id="loginForm">
            <div class="error-message" id="errorMessage">Please enter both username and password.</div>

            <input type="text" id="username" class="input-field" placeholder="Username" required><br>
            <input type="password" id="password" class="input-field" placeholder="Password" required><br>

            <button type="submit" class="login-btn">Login</button>
        </form>
    </div>

    <script>
        // Validate the login form
        document.getElementById('loginForm').addEventListener('submit', function(event) {
            event.preventDefault(); // Prevent form from submitting

            // Get values from input fields
            const username = document.getElementById('username').value;
            const password = document.getElementById('password').value;

            // Check if both fields are filled
            if (username === '' || password === '') {
                document.getElementById('errorMessage').style.display = 'block';
            } else {
                document.getElementById('errorMessage').style.display = 'none';
                // Simulate a successful login (redirect or other action)
                alert('Login successful!');
                // You could redirect here or trigger actual authentication logic
                // window.location.href = "dashboard.html"; // Example redirect
            }
        });
    </script>

</body>
</html>
