@using System.Security.Claims

<div class="nav-shell">
    <div class="nav-brand">
        <img class="nav-brand__logo"
             src="Content/imagenes/logo-oaaf-negativo-transparente.svg"
             alt="Logo Oficina Antifraude" />
        <div class="nav-brand__copy">
            <span class="nav-brand__eyebrow">OAAF</span>
            <strong class="nav-brand__title">Gestion de denuncias</strong>
            <span class="nav-brand__subtitle">Entrada, revision y tramitacion unificada</span>
        </div>
    </div>

    <nav class="nav-sections" aria-label="Navegacion principal">
        <div class="nav-section">
            <span class="nav-section__label">Operativa diaria</span>

            <NavLink class="menu-link" href="/Entrada" Match="NavLinkMatch.All">
                <span class="menu-link__icon bi bi-box-seam" aria-hidden="true"></span>
                <span class="menu-link__content">
                    <span class="menu-link__title">Entrada</span>
                    <span class="menu-link__meta">Importar denuncias y renovar 2FA</span>
                </span>
            </NavLink>

            <NavLink class="menu-link" href="/Pendientes" Match="NavLinkMatch.All">
                <span class="menu-link__icon bi bi-inbox" aria-hidden="true"></span>
                <span class="menu-link__content">
                    <span class="menu-link__title">Pendientes</span>
                    <span class="menu-link__meta">Expedientes nuevos listos para tramitar</span>
                </span>
            </NavLink>

            <NavLink class="menu-link" href="/Actualizaciones" Match="NavLinkMatch.All">
                <span class="menu-link__icon bi bi-arrow-repeat" aria-hidden="true"></span>
                <span class="menu-link__content">
                    <span class="menu-link__title">Actualizaciones</span>
                    <span class="menu-link__meta">Nuevos documentos sobre expedientes ya abiertos</span>
                </span>
            </NavLink>
        </div>

        <div class="nav-section">
            <span class="nav-section__label">Consulta y control</span>

            <NavLink class="menu-link" href="/Gestiona" Match="NavLinkMatch.All">
                <span class="menu-link__icon bi bi-journal-check" aria-hidden="true"></span>
                <span class="menu-link__content">
                    <span class="menu-link__title">Gestiona</span>
                    <span class="menu-link__meta">Seguimiento de expedientes enviados</span>
                </span>
            </NavLink>

            <NavLink class="menu-link" href="/Rechazados" Match="NavLinkMatch.All">
                <span class="menu-link__icon bi bi-journal-x" aria-hidden="true"></span>
                <span class="menu-link__content">
                    <span class="menu-link__title">Rechazados</span>
                    <span class="menu-link__meta">Historico de descartes y motivos</span>
                </span>
            </NavLink>

            <NavLink class="menu-link" href="/Buscador" Match="NavLinkMatch.All">
                <span class="menu-link__icon bi bi-search" aria-hidden="true"></span>
                <span class="menu-link__content">
                    <span class="menu-link__title">Buscador de terceros</span>
                    <span class="menu-link__meta">Consulta identidades y expedientes vinculados</span>
                </span>
            </NavLink>

            <AuthorizeView>
                <Authorized Context="authContext">
                    @if (IsConfigurationUser(authContext.User))
                    {
                        <NavLink class="menu-link" href="/Configuracion" Match="NavLinkMatch.All">
                            <span class="menu-link__icon bi bi-gear" aria-hidden="true"></span>
                            <span class="menu-link__content">
                                <span class="menu-link__title">Configuracion</span>
                                <span class="menu-link__meta">Fecha de corte y purga manual</span>
                            </span>
                        </NavLink>
                    }
                </Authorized>
            </AuthorizeView>
        </div>

        <div class="nav-section nav-section--footer">
            <span class="nav-section__label">Ayuda</span>

            <NavLink class="menu-link" href="/Instrucciones" Match="NavLinkMatch.All">
                <span class="menu-link__icon bi bi-book-half" aria-hidden="true"></span>
                <span class="menu-link__content">
                    <span class="menu-link__title">Instrucciones</span>
                    <span class="menu-link__meta">Guia rapida para el equipo gestor</span>
                </span>
            </NavLink>
        </div>
    </nav>
</div>

@code {
    private static readonly HashSet<string> ConfigurationUsers = new(StringComparer.OrdinalIgnoreCase)
    {
        "pcornejo",
        "Rgarciaglbk",
        "eaguilarGestor"
    };

    private static bool IsConfigurationUser(ClaimsPrincipal user)
    {
        var username = user.Identity?.Name?.Trim();
        return !string.IsNullOrWhiteSpace(username) &&
               ConfigurationUsers.Contains(username);
    }
}
