@using DysonNetwork.Zone.Publication
@using DysonNetwork.Shared.Models
@using Microsoft.IdentityModel.Tokens
@{
    Layout = "_Layout";
    var site = Context.Items[PublicationSiteMiddleware.SiteContextKey] as SnPublicationSite;
    var siteDisplayName = site?.Name ?? "Solar Network";
}

<div class="navbar backdrop-blur-md bg-white/1 shadow-xl px-5">
    <div class="flex-1">
        <a class="btn btn-ghost text-xl" href="/">@siteDisplayName</a>
    </div>
    <div class="flex-none">
        @if (site?.Config.NavItems is null || site.Config.NavItems.Count == 0)
        {
            @*Use preset navs*@
            <ul class="menu menu-horizontal px-1">
                <li><a href="/posts">Posts</a></li>
                <li><a href="/about">About</a></li>
            </ul>
        }
        else
        {
            <ul class="menu menu-horizontal px-1">
                @foreach (var item in site.Config.NavItems)
                {
                    <li><a href="@item.Href">@item.Label</a></li>
                }
            </ul>
        }
    </div>
</div>

<main class="content-main">
    @RenderBody()
</main>

@section Scripts
{
    @await RenderSectionAsync("Scripts", required: false)
}

@section Head
{
    @await RenderSectionAsync("Head", required: false)
    
    @if (site?.Config.StyleOverride is not null)
    {
        <style>@(site.Config.StyleOverride)</style>
    }

    <style>
        .navbar {
            height: 64px;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            z-index: 1000;
        }

        .content-main {
            height: calc(100vh - 64px);
            margin-top: 64px;
        }
    </style>
}
