<style>
    body,
    html {
        margin: 0;
        padding: 0;
        height: 100%;
        font-family: Arial, sans-serif;
    }

    .container {
        display: flex;
        height: 100%;
    }

    .cover {
        flex: 2;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .cover img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .login-form {
        display: flex;
        flex-direction: column;
        width: auto;
        height: 100%;
        justify-content: center;
        padding: 10px;
    }

    @media (max-width: 1024px) {
        .cover img {
            height: auto;
        }

        .container {
            flex-direction: column;
        }

        .cover {
            display: none;
        }

        .login-form {
            padding: 150px;
        }
    }

    @media (max-width: 768px) {
        .login-form {
            padding: 10px;
        }
    }
</style>


<div class="page-content">

    <div class="cover">
        <!-- <img src="files/itecevo/itecevo-pub-02.jpg" alt=""> -->
        <img src="assets/images/evosys-pos-pub-dark.png" alt="evosys-pos-pub" style="width: 100%; height: auto;">
    </div>

    <div class="content-wrapper">
        <div class="content">
            <div class="login-form">

                <div class="text-center mb-4">
                    <div class="mb-3 fs-5 text-uppercase">
                        <p>Welcome to</p>
                    </div>
                    <div class="row d-inline-flex align-items-center justify-content-center mb-3">
                        <img src="assets/images/evosys-pos-logo.png" class="w-150px h-150px" alt="">
                    </div>
                </div>

                <!-- <div class="text-center mb-1 fs-5 text-white">
                    <p>Login into your account</p>
                </div> -->

                <!-- <form action="" method="POST" needs-validation novalidate> -->
                <form id="loginForm">

                    <div class="card card-body" style="width: 100%;">

                        <div class="mb-2">
                            <label class="form-label">Username</label>
                            <div class="form-control-feedback form-control-feedback-start">
                                <input type="text" name="user_name_login" class="form-control form-control-lg" required>
                                <div class="invalid-feedback">Enter your username</div>
                                <div class="form-control-feedback-icon">
                                    <i class="ph-user text-muted"></i>
                                </div>
                            </div>
                        </div>

                        <div class="mb-4">
                            <label class="form-label">Password</label>
                            <div class="form-control-feedback form-control-feedback-start">
                                <div class="input-group">
                                    <input type="password" name="user_password_login" class="form-control form-control-lg password" required autocomplete="off">
                                    <span class="input-group-text pointer" style="cursor: pointer;"><i class="ph-eye"></i></span>
                                    <div class="invalid-feedback">Enter your password</div>
                                    <div class="form-control-feedback-icon">
                                        <i class="ph-lock text-muted"></i>
                                    </div>
                                </div>
                            </div>
                            <div class="invalid-feedback">Enter your password</div>
                        </div>

                        <!-- <div class="d-flex align-items-center mb-3">
                            <label class="form-check">
                                <input type="checkbox" name="remember" class="form-check-input" checked>
                                <span class="form-check-label">Remember</span>
                            </label>

                            <a href="login_password_recover.html" class="ms-auto">Forgot password?</a>
                        </div> -->

                        <div class="mb-2 btn-group">
                            <button type="submit" class="btn btn-warning"><i class="ph-arrow-circle-right me-1"></i>LOGIN</button>
                        </div>

                        <div class="mt-4 border-top">
                            &copy; <?= date('Y') ?> <a target="_blank" href="https://www.evoqikcash.com/">ITECEVO LLC</a> All rights reserved.</p>
                        </div>

                        <!-- <div class="text-center text-muted content-divider mb-3">
                            <span class="px-2">Don't have an account?</span>
                        </div>

                        <div class="mb-3">
                            <a href="#" class="btn btn-light w-100">Sign up</a>
                        </div> -->

                        <!-- <span class="form-text text-center text-muted">By continuing, you're confirming that you've read our <a href="#">Terms &amp; Conditions</a> and <a href="#">Cookie Policy</a></span> -->
                    </div>

                    <!-- <?php
                            if (isset($_POST['user_name_login']) && isset($_POST['user_password_login'])) {
                                $loginControllerAccess->ctrSessionStartController();
                            }
                            ?> -->

                </form>

            </div>
        </div>
    </div>

    <!-- /main content -->
</div>
<!-- /page content -->


<script>
    const pswrdField = document.querySelector(".password"),
        toggleIcon = document.querySelector(".pointer");

    toggleIcon.onclick = () => {
        if (pswrdField.type === "password") {
            pswrdField.type = "text";
            pswrdField.focus();
        } else {
            pswrdField.type = "password";
        }
    }

    document.getElementById("loginForm").addEventListener("submit", function(e) {
        e.preventDefault(); // 🔥 Prevent reload

        let formData = new FormData(this);

        fetch("./ajax/login.ajax.php", {
                method: "POST",
                body: formData
            })
            .then(response => response.json())
            .then(data => {

                swalInit.fire({
                    title: data.title,
                    text: data.text,
                    icon: data.status
                });

                if (data.status === "success") {
                    window.location.href = data.page;
                }
            });
    });
</script>