@inherits LayoutComponentBase
@using System.Security.Claims

@* Thin delegation to the shared ZB.MOM.WW.Theme side-rail chassis. ThemeShell owns
   the brand bar, the CSS-only narrow-viewport hamburger, and the responsive collapse,
   so MainLayout no longer carries its own .app-shell / hamburger wrapper. Nav sections
   are static <details> (NavRailSection) whose expand state is persisted to localStorage
   by the kit's <ThemeScripts/> (emitted in App.razor) — replacing the old interactive
   NavSidebar island + cookie/URL auto-expand. *@

<ThemeShell Product="OtOpcUa" Accent="#2f5fd0">
    <Nav>
        <NavRailSection Title="Navigation" Key="nav">
            <NavRailItem Href="/" Text="Overview" Match="NavLinkMatch.All" />
            <NavRailItem Href="/fleet" Text="Fleet status" />
            <NavRailItem Href="/hosts" Text="Host status" />
            <NavRailItem Href="/clusters" Text="Clusters" />
            <NavRailItem Href="/reservations" Text="Reservations" />
            <NavRailItem Href="/certificates" Text="Certificates" />
            <NavRailItem Href="/role-grants" Text="Role grants" />
        </NavRailSection>
        <NavRailSection Title="Scripting" Key="scripting">
            <NavRailItem Href="/virtual-tags" Text="Virtual tags" />
            <NavRailItem Href="/scripted-alarms" Text="Scripted alarms" />
            <NavRailItem Href="/scripts" Text="Scripts" />
            <NavRailItem Href="/script-log" Text="Script log" />
        </NavRailSection>
        <NavRailSection Title="Live" Key="live">
            <NavRailItem Href="/deployments" Text="Deployments" />
            <NavRailItem Href="/alerts" Text="Alerts" />
            <NavRailItem Href="/alarms-historian" Text="Alarms historian" />
        </NavRailSection>
    </Nav>
    <RailFooter>
        <AuthorizeView>
            <Authorized>
                <div class="rail-eyebrow">Session</div>
                <a class="rail-user" href="/account">@context.User.Identity?.Name</a>
                <div class="rail-roles">
                    @string.Join(", ", context.User.Claims
                        .Where(c => c.Type == ClaimTypes.Role).Select(c => c.Value))
                </div>
                <form method="post" action="/auth/logout">
                    <AntiforgeryToken />
                    <button class="rail-btn" type="submit">Sign out</button>
                </form>
            </Authorized>
            <NotAuthorized>
                <div class="rail-eyebrow">Session</div>
                <a class="rail-btn" href="/login">Sign in</a>
            </NotAuthorized>
        </AuthorizeView>
    </RailFooter>
    <ChildContent>@Body</ChildContent>
</ThemeShell>
