<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login Page</title>
    <style>
        /* Center the body content */
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }

        /* Style the login container */
        .login-container {
            background-color: #fff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            width: 300px;
            text-align: center;
            display: flex;
            flex-direction: column;
            align-items: center; /* Center items horizontally */
        }

        /* Style the form elements */
        .login-container h2 {
            margin-bottom: 20px;
        }

        .login-container input {
            width: 100%;
            padding: 10px;
            margin: 10px 0;
            border: 1px solid #ccc;
            border-radius: 4px;
            max-width: 250px; /* Limit the width of inputs */
        }

        .login-container button {
            width: 100%;
            padding: 10px;
            background-color: #2d2db0;
            color: #fff;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            max-width: 250px; /* Limit the width of the button */
        }

        .login-container button:hover {
            background-color: #2d2db0;
        }

        /* Error and Success Messages */
        .error {
            color: red;
            margin-top: 10px;
        }

        .success {
            color: green;
            margin-top: 10px;
        }

        /* Link to Registration Page */
        .login-container p {
            margin-top: 20px;
        }

        .login-container a {
            color: #2d2db0;
            text-decoration: none;
        }

        .login-container a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <div class="login-container">
        <h2>Login</h2>
        <!-- Login Form -->
        <form th:action="@{/login}" method="post" class="form-group">
            <!-- Username -->
            <input type="text" name="username" placeholder="Username" required>
            <!-- Password -->
            <input type="password" name="password" placeholder="Password" required>
            <!-- Submit Button -->
            <button type="submit">Login</button>
        </form>
        <!-- Error Message -->
        <div th:if="${param.error}" class="error">
            Invalid username or password.
        </div>
        <!-- Success Message -->
        <div th:if="${param.success}" class="success">
            User registered successfully!
        </div>
        <!-- Link to Registration Page -->
        <p>Don't have an account? <a href="/register">Register here</a></p>
    </div>
</body>
</html>