@using System.Security.Claims
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@ViewData["Title"] - VCart</title>

    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
    <link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
    <link rel="stylesheet" href="~/VCart.styles.css" asp-append-version="true" />

    @await RenderSectionAsync("Style", required: false)
</head>
<body>
    <div id="wrapper">
        <header>
            <nav id="nav-bar" class="navbar navbar-expand-sm navbar-toggleable-sm navbar-dark">
                <div class="container-fluid">
                    <a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">VCart</a>
                    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
                            aria-expanded="false" aria-label="Toggle navigation">
                        <span class="navbar-toggler-icon"></span>
                    </button>
                    <div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
                        <ul class="navbar-nav flex-grow-1">
                            <li class="nav-item">
                                <a class="nav-link text-white" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link text-white" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
                            </li>
                        </ul>
                    </div>
                @if (!User.Identity.IsAuthenticated)
                {
                    <div class="navbar-collapse collapse">
                            <ul class="navbar-nav ml-auto">
                                <li class="nav-item" style="margin-right: 10px">
                                <a class="nav-link text-white" asp-area="" asp-controller="Login" asp-action="Index">Login</a>
                            </li>
                        </ul>
                    </div>
                }
                else
                {
                    <div class="navbar-collapse collapse">
                            <ul class="navbar-nav ml-auto">
                                <li class="nav-item dropdown" style="margin-right: 10px">
                                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                        @User.FindFirst("FullName").Value
                                    </a>
                                    <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                                        <a class="dropdown-item" asp-area="" asp-controller="Login" asp-action="Logout">Sair</a>
@*                                         <a class="dropdown-item" href="#">Action</a>
                                        <a class="dropdown-item" href="#">Another action</a>
                                        <div class="dropdown-divider"></div>
                                        <a class="dropdown-item" href="#">Something else here</a>
 *@
                                    </div>
                                </li>
@* 
                                <li class="nav-item">
                                    <a class="nav-link text-white" asp-area="" asp-controller="Login" asp-action="Logout">@User.FindFirst("FullName").Value
                                    </a>
                                </li>
 *@                        
                            </ul>
                    </div>
                }
                </div>
            </nav>
        </header>
        <div class="container">
            @RenderBody()
    @*         <main role="main" class="pb-3">
            </main>
     *@ 
        </div>

        <footer class="border-top footer text-muted">
            <div class="container">
                &copy; 2024 - VCart - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
            </div>
        </footer>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-Fy6S3B9q64WdZWQUiU+q4/2Lc9npb8tCaSX9FK7E8HnRr0Jz8D6OP9dO5Vg3Q9ct" crossorigin="anonymous"></script>
    <script src="~/js/site.js" asp-append-version="true"></script>
    <script type="text/javascript" >
        $(function () {
            $('a[href="#search"]').on('click', function (event) {
                event.preventDefault();
                $('#search').addClass('open');
                $('#search > form > input[type="search"]').focus();
                inactivateActiveOption();
                searchActive();
            });

            $('#search, #search button.close').on('click keyup', function (event) {
                if (event.target == this || event.target.className == 'close' || event.keyCode == 27) {
                    $(this).removeClass('open');
                    setActiveByLocation();
                    searchInactive();
                }
            });

            //Do not include! This prevents the form from submitting for DEMO purposes only!
            $('form').submit(function (event) {
                event.preventDefault();
                return false;
            })

            $(document).ready(function () {
                $('#wrapper').fadeIn('slow');

                $('a.nav-link').click(function () {
                    $('#wrapper').fadeOut('slow');
                });
                setActiveByLocation();
            });



            function setActiveByLocation() {
                $('ul.navbar-nav').find('a[href="' + location.pathname + '"]')
                    .closest('li')
                    .addClass("active")

                $('ul.navbar-nav').find('a[href="' + location.pathname + '"]')
                    .closest('a')
                    .removeClass('text-white')
                    .addClass('text-red');
            }

            function searchActive() {
                $('#searchLi').addClass("active");
                $('#searchLi > a')
                    .removeClass('text-white')
                    .addClass('text-red');
            }

            function searchInactive() {
                $('#searchLi').removeClass("active");
                $('#searchLi > a')
                    .removeClass('text-red')
                    .addClass('text-white');
            }

            function inactivateActiveOption() {
                $('ul.navbar-nav li.active')
                    .closest('li')
                    .removeClass("active")

                $('ul.navbar-nav').find('a[href="' + location.pathname + '"]')
                    .closest('a')
                    .removeClass('text-red')
                    .addClass('text-white');
            }
        });
    </script>
    @await RenderSectionAsync("Scripts", required: false)
</body>
</html>
