@inherits LayoutComponentBase
<MudThemeProvider />
<MudDialogProvider />
<MudSnackbarProvider />
<MudPopoverProvider />

<MudLayout>
	<MudAppBar Elevation="0" Class="rounded-xl" Style="background-color: transparent; border:none">
		<MudBreakpointProvider>
			<MudHidden Breakpoint="Breakpoint.SmAndDown" Invert=true>
				<MudIconButton Icon="@Icons.Material.Filled.Menu" Color="Color.Primary" Edge="Edge.Start" OnClick="@((e) => DrawerToggle())" />
			</MudHidden>
			<MudHidden Breakpoint="Breakpoint.SmAndDown">
				<SearchBar></SearchBar>
				<MudButton Class="mt-1">application</MudButton>
			</MudHidden>
		</MudBreakpointProvider>
		<MudSpacer />
		<MudIconButton Icon="@Icons.Material.Filled.MoreVert" Color="Color.Primary" Edge="Edge.End" />
	</MudAppBar>
	<MudDrawer @bind-Open="_drawerOpen" Height="100%" Elevation="0" Style="background-color:#f5f6fb">
		<MudDrawerHeader Class="h-100 d-flex flex-grow-1" Style="background-color:#f5f6fb">
			<MudPaper Width="250px" Class="d-flex py-3 flex-column justify-content-between rounded-xl" Elevation="3">
				<MudNavMenu Bordered="true" Dense="true" Rounded="true" Color="Color.Error" Margin="Margin.Dense">
					<ApplicationMainIconCard></ApplicationMainIconCard>
					<MudDivider Class="my-2" />
					<MudNavLink Href="/">Home</MudNavLink>
					<MudNavLink Href="/exam">Exam</MudNavLink>
					<MudNavLink Href="/students">Students</MudNavLink>

					<MudSpacer />
					<MudNavLink Class="align-content-end" Href="/about">About</MudNavLink>
				</MudNavMenu>
				<MudSpacer />
				<MudNavMenu Class="align-content-end " Bordered="true" Dense="true" Rounded="true" Margin="Margin.Dense">
					<TechHelper.Client.Pages.Global.LoginInOut.LoginInOut></TechHelper.Client.Pages.Global.LoginInOut.LoginInOut>
					<MudNavLink Class="align-content-end" Href="/Account/Manage">Setting</MudNavLink>
				</MudNavMenu>
			</MudPaper>
		</MudDrawerHeader>
	</MudDrawer>
	<MudMainContent Style="background: #f5f6fb">
		<SnackErrorBoundary @ref="errorBoundary">
			<MudPaper Height="calc(100vh - 64px)" Style="background-color:transparent" Class="overflow-hidden px-1 py-2" Elevation="0">
				<MudPaper Style="background-color:transparent" Elevation="0" Class="d-flex w-100 h-100 overflow-hidden pa-2 rounded-xl">
					@Body
				</MudPaper>
			</MudPaper>
		</SnackErrorBoundary>
	</MudMainContent>
</MudLayout>
@code {
	ErrorBoundary? errorBoundary;

	protected override void OnParametersSet()
	{
		errorBoundary?.Recover();
	}

	bool _drawerOpen = true;

	void DrawerToggle()
	{
		_drawerOpen = !_drawerOpen;
	}
}