@using System.Security.Claims

<!DOCTYPE html>
<html lang="pt-br">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@ViewData["Title"] - SumaTube</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="~/css/custom.css" asp-append-version="true" />
    <link rel="stylesheet" href="~/SumaTube.styles.css" asp-append-version="true" />
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap" rel="stylesheet">
    @await RenderSectionAsync("Styles", required: false)
</head>
<body class="d-flex flex-column min-vh-100 hide-body">
    <partial name="_Busy" />

    <header>
        <nav id="nav-bar" class="navbar navbar-expand-lg navbar-dark">
            <div class="container">
                <a class="navbar-brand d-flex align-items-center" asp-area="" asp-controller="Home" asp-action="Index">
                    <i class="bi bi-play-btn-fill mr-2"></i> SumaTube
                </a>
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                </button>

                <!-- Campo de busca central -->
                <div class="d-none d-md-block mx-auto">
                    <form class="form-inline my-2 my-lg-0">
                        <div class="input-group">
                            <input class="form-control search-input" type="search" placeholder="Buscar vídeos..." aria-label="Buscar">
                            <div class="input-group-append">
                                <button class="btn btn-light" type="submit">
                                    <i class="bi bi-search"></i>
                                </button>
                            </div>
                        </div>
                    </form>
                </div>

                <div class="navbar-collapse collapse" id="navbarNav">
                    <ul class="navbar-nav">
                        <li class="nav-item">
                            <a class="nav-link text-white" asp-area="" asp-controller="Home" asp-action="Index">
                                <i class="bi bi-house-door"></i> Home
                            </a>
                        </li>
                         @*                      
                            Exibir apenas são não estiver logado.
                         *@
                        <li class="nav-item">
                            <a class="nav-link text-white" asp-area="" asp-controller="Plans" asp-action="Index">
                                <i class="bi bi-star"></i> Planos
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link text-white" asp-area="" asp-controller="Video" asp-action="MySummary">
                                <i class="bi bi-file-text"></i> Meus resumos
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link text-white" asp-area="" asp-controller="Video" asp-action="Extract">
                                <i class="bi bi-magic"></i> Extract
                            </a>
                        </li>
                        <partial name="_Language" />
                    </ul>

                    @if (User != null && User.Identity != null && !User.Identity.IsAuthenticated)
                    {
                        <ul class="navbar-nav ml-auto">
                            <li class="nav-item">
                                <a class="nav-link text-white" asp-area="" asp-controller="Login" asp-action="Index">
                                    <i class="bi bi-box-arrow-in-right"></i> Login
                                </a>
                            </li>
                        </ul>
                    }
                    else
                    {
                        <ul class="navbar-nav ml-auto">
                            @*                      
                            Criar uma tela que permita alterar o plano.
                            *@
                            <li class="nav-item dropdown">
                                <a class="nav-link dropdown-toggle text-white" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                    <i class="bi bi-person-circle"></i> @(User.FindFirst("FullName") != null ? User.FindFirst("FullName").Value : "N/A")
                                </a>
                                <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
                                    <a class="dropdown-item" asp-controller="Account" asp-action="Profile">
                                        <i class="bi bi-person"></i> Meu Perfil
                                    </a>
                                    <a class="dropdown-item" asp-controller="Videos" asp-action="History">
                                        <i class="bi bi-clock-history"></i> Histórico
                                    </a>
                                    <div class="dropdown-divider"></div>
                                    <a class="dropdown-item" asp-area="" asp-controller="Login" asp-action="Logout">
                                        <i class="bi bi-box-arrow-right"></i> Sair
                                    </a>
                                </div>
                            </li>
                        </ul>
                    }
                </div>
            </div>
        </nav>

        <!-- Campo de busca para dispositivos móveis -->
        <div class="container d-md-none mt-3 mb-3">
            <form class="form-inline">
                <div class="input-group w-100">
                    <input class="form-control" type="search" placeholder="Buscar vídeos..." aria-label="Buscar">
                    <div class="input-group-append">
                        <button class="btn btn-light" type="submit">
                            <i class="bi bi-search"></i>
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </header>

    <!-- Conteúdo principal -->
    <main class="flex-grow-1">
        <div class="container py-4">
            @RenderBody()
        </div>
    </main>

    <!-- Footer -->
    <footer class="footer mt-auto py-3">
        <div class="container">
            <div class="row align-items-center">
                <div class="col-md-4 mb-3 mb-md-0">
                    <div class="d-flex align-items-center">
                        <i class="bi bi-play-btn-fill mr-2" style="color: var(--suma-red); font-size: 1.2rem;"></i>
                        <span class="font-weight-bold">SumaTube</span>
                        <span class="mx-2">|</span>
                        <small>Resumos inteligentes de vídeos</small>
                    </div>
                </div>
                <div class="col-md-4 mb-3 mb-md-0 text-center">
                    <div class="d-flex justify-content-center">
                        <a href="#" class="text-muted mx-2"><i class="bi bi-facebook"></i></a>
                        <a href="#" class="text-muted mx-2"><i class="bi bi-twitter"></i></a>
                        <a href="#" class="text-muted mx-2"><i class="bi bi-instagram"></i></a>
                        <a href="#" class="text-muted mx-2"><i class="bi bi-youtube"></i></a>
                    </div>
                </div>
                <div class="col-md-4 text-md-right">
                    <div class="text-center text-md-right">
                        <small class="text-muted">&copy; 2024 - Todos os direitos reservados</small>
                    </div>
                </div>
            </div>
        </div>
    </footer>

    <!-- Scripts -->
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></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 src="~/js/wait.js" asp-append-version="true"></script>
    <script type="text/javascript">
        $(function () {
            $(document).ready(function () {
                $('.loading').hide();
                $('body').fadeIn(800);
            });

            // Animação para links do menu
            $('.navbar-nav .nav-link').hover(
                function() { $(this).addClass('pulse'); },
                function() { $(this).removeClass('pulse'); }
            );

            // Ativar o item de menu atual
            $(document).ready(function () {
                setActiveByLocation();
            });

            // Controle de carregamento de página
            $(window).on('beforeunload', function () {
                displayBusyIndicator();
            });

            $(document).on('submit', 'form', function () {
                displayBusyIndicator();
            });

            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-black');
            }

            function displayBusyIndicator() {
                $('body').fadeOut(300);
            }
        });
    </script>
    @await RenderSectionAsync("Scripts", required: false)
</body>
</html>