/* =========================================================
   COMPLETE BLISS - LOGIN
========================================================= */

document.addEventListener(
    "DOMContentLoaded",
    function () {

        const passwordInput =
            document.getElementById(
                "password"
            );


        const togglePassword =
            document.getElementById(
                "togglePassword"
            );


        if (
            passwordInput &&
            togglePassword
        ) {

            togglePassword.addEventListener(
                "click",
                function () {

                    const isPassword =
                        passwordInput.type
                        === "password";


                    passwordInput.type =
                        isPassword
                            ? "text"
                            : "password";


                    const icon =
                        togglePassword.querySelector(
                            "i"
                        );


                    if (icon) {

                        icon.classList.toggle(
                            "fa-eye",
                            !isPassword
                        );


                        icon.classList.toggle(
                            "fa-eye-slash",
                            isPassword
                        );

                    }


                    togglePassword.setAttribute(

                        "aria-label",

                        isPassword
                            ? "Hide password"
                            : "Show password"

                    );

                }
            );

        }

    }
);