@page "/system"
@page "/system/configuration"
@page "/system/worker-control"
@page "/system/health"
@attribute [Authorize(Roles = "Administrator")]

<div>
    <MudText Typo="Typo.h5" Class="mb-3">مدیریت سیستم</MudText>

    <MudTabs Elevation="0" Rounded="true" Border="true" ApplyEffectsToContainer="true"
             PanelClass="pt-4" @bind-ActivePanelIndex="_activeTab">
        <MudTabPanel Text="تنظیمات" Icon="@Icons.Material.Filled.Tune">
            <Configuration />
        </MudTabPanel>
        <MudTabPanel Text="مدیریت Worker" Icon="@Icons.Material.Filled.Engineering">
            <WorkerControl />
        </MudTabPanel>
        <MudTabPanel Text="سلامت سیستم" Icon="@Icons.Material.Filled.MonitorHeart">
            <HealthDashboard />
        </MudTabPanel>
    </MudTabs>
</div>

@code {
    private int _activeTab;

    protected override void OnInitialized()
    {
        var uri = Navigation.ToBaseRelativePath(Navigation.Uri).ToLowerInvariant().TrimEnd('/');
        _activeTab = uri switch
        {
            "system/worker-control" => 1,
            "system/health" => 2,
            _ => 0
        };
    }
}
