<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="https://www.thymeleaf.org/thymeleaf-extras-springsecurity5"
      lang="en">
    <head th:replace="fragments/loggedInNav :: head(~{::title}, ~{}, ~{})">
        <title>ITems | Login page</title>
        <meta charset="utf-8" />
	</head>
    <body>

    <div th:block sec:authorize="!isAuthenticated()" th:replace="fragments/loggedOutNav :: nav(~{::navbar})"></div>
    <div th:block sec:authorize="isAuthenticated()" th:replace="fragments/loggedInNav :: nav(~{::navbar})"></div>

    <header class="masthead bg-light mb-3 border-bottom" >
        <div class="container">
            <div class="row gx-4 gx-lg-5 justify-content-center text-center">
                <div class="col-md-10 col-lg-8 col-xl-7">
                    <div class="site-heading">
                        <h1 class="mt-5">ITems</h1>
                        <p class="mb-5">
                            <span class="subheading">An Employee Management System</span>
                        </p>
                    </div>
                </div>
            </div>
        </div>
    </header>

    <main>
    <div class="container d-flex justify-content-center align-content-center">
        <div class="border rounded-2 p-5 m-5 bg-light">
            <form th:action="@{/login}"  method="POST" class="form justify-center">
                <div class="row g-3 align-items-center">
                    <div class="col form-floating mb-3">
                        <input type="text"  placeholder="Enter Email" id="username" name="username" class="form-control form-control-sm col-2 mb-4"/>
                        <label for="username">Email</label>
                    </div>
                </div>
                <div class="row g-3 align-items-center">
                    <div class="col form-floating mb-3">
                        <input type="password" id="password" name="password" placeholder="Your Password" class="form-control form-control-sm col-2 mb-4"/>
                        <label for="password">Password</label>
                    </div>
                </div>
                <p th:if="${loginError}"  class="text-danger">Wrong user or password</p>
                <button class="btn btn-info" type="submit">Sign in</button>
            </form>
            <hr>
            <p>Demo Log in</p>
            <p>email: manager@items.com</p>
            <p>password: Password1</p>
        </div>
    </div>
    </main>
    <div th:block th:replace="fragments/loggedInNav :: footer(~{::footer})"></div>

    </body>
</html>
