{% load static %}
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>WFM - Login</title>

    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
    <link rel="stylesheet" href="{% static 'css/login.css' %}">
</head>

<body>
    <div class="container">
                {% if messages %}
            <div id="django-toasts" class="toast-container position-fixed top-0 end-0 p-3" style="z-index: 1080; width: 400px;">
                {% for message in messages %}
                    <div class="toast align-items-center text-white bg-{{ message.tags }} border-0 fade" role="alert" aria-live="assertive" aria-atomic="true" data-bs-delay="5000">
                        <div class="d-flex">
                            <div class="toast-body">
                                {{ message }}
                            </div>
                            <button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
                        </div>
                    </div>
                {% endfor %}
            </div>

            <script>
                document.addEventListener('DOMContentLoaded', function() {
                    const toastElements = document.querySelectorAll('.toast');
                    toastElements.forEach(function(toastEl) {
                        const toast = new bootstrap.Toast(toastEl, {
                            autohide: true,
                            delay: 3000  // 3 seconds
                        });
                        toast.show();
                    });
                });
            </script>
        {% endif %}
        <div class="login">
            <div class="login-container">
                <div class="login-left">
                    <div class="lbox">
                       
                        <h2 class="clogo">Content Quality Tool</h2>
                        <img src="{% static './images/logo.png' %}" alt="Lumina Datamatics" class="llogo">
                        <!-- <p>© 2022 Lumina Datamatics Ltd. All Rights Reserved.</p> -->
                    </div>
                </div>
                <div class="login-right">
                    <form action="{% url 'login' %}" method="POST" class="form-signin" >
                        {% csrf_token %}
                        <h2 class="form-signin-heading">Login</h2>
                        <div class="group">
                            <input type="text" name="username" id="username">
                            <label>Email address</label>
                        </div>

                        <div class="group">
                            <input type="password" name="password" id="password">
                            <label>Password</label>
                        </div>
                        <div class="group" style="margin-bottom: 30px;">
                            <button class="btn btn-lg btn-outline-dark btn-block" type="submit" >Sign in</button>
                        </div>
                       
                    </form>
                </div>
            </div>
        </div>
    </div>


    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <!-- Latest compiled and minified JavaScript -->
    <!-- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script> -->

        <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
        <!-- Bootstrap Bundle JS (includes Toast component JS) -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>


    <script>
        function validateLogin() {
            if ($("#username").val() == "" || $("#password").val() == "") {
                $("#missing").fadeTo(2000, 500).slideUp(500, function () {
                    $("#missing").slideUp(500);
                });
                return false;
            } else if ($("#username").val() != "admin" && $("#password").val() != "admin") {
                $("#wrong").fadeTo(2000, 500).slideUp(500, function () {
                    $("#wrong").slideUp(500);
                });
                return false;
            } else if ($("#username").val() == "admin" && $("#password").val() == "admin") {
                $("#success").fadeTo(2000, 500).slideUp(500, function () {
                    $("#success").slideUp(500);
                });
                return true;
            }
        }
    </script>

</body>

</html>