<?xml version="1.0" encoding="UTF-8" ?>
<Shell
    x:Class="LSFE.MobApp.AppShell"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:auth="clr-namespace:LSFE.MobApp.Pages.Authentication"
    xmlns:admin="clr-namespace:LSFE.MobApp.Pages.Admin"
    xmlns:attendanceViews="clr-namespace:LSFE.MobApp.Pages.Attendance"
    xmlns:coverageViews="clr-namespace:LSFE.MobApp.Pages.CoveragePlan"
    xmlns:utilitiesViews="clr-namespace:LSFE.MobApp.Pages.Utilities"
    Shell.BackgroundColor="{AppThemeBinding Light=#f9f9f9, Dark=#121212}"
    Shell.NavBarHasShadow="False"
    Shell.TabBarBackgroundColor="{AppThemeBinding Light=#ffffff, Dark=#1E1E1E}"
    Shell.TabBarTitleColor="{AppThemeBinding Light=#4a4a4a, Dark=#dddddd}"
    Shell.TabBarUnselectedColor="{AppThemeBinding Light=#9e9e9e, Dark=#666666}"
    Shell.TabBarForegroundColor="{AppThemeBinding Light=#2196F3, Dark=#64B5F6}"
    Title="LSFE.MobApp"
    FlyoutBackgroundColor="#1DB9A6">

    <!-- Flyout Header -->
    <Shell.FlyoutHeader>
        <Grid BackgroundColor="#1DB9A6" 
              Padding="20"
              HeightRequest="180">
            <VerticalStackLayout VerticalOptions="Center" Spacing="8">
                <Border StrokeShape="RoundRectangle 40"
                        BackgroundColor="White"
                        WidthRequest="80"
                        HeightRequest="80"
                        HorizontalOptions="Center">
                    <Label Text="&#xf505;"
                           FontFamily="FontAwesome"
                           FontSize="40"
                           TextColor="#1DB9A6"
                           HorizontalOptions="Center"
                           VerticalOptions="Center"/>
                </Border>
                <Label Text="Admin Panel"
                       FontSize="20"
                       FontAttributes="Bold"
                       TextColor="White"
                       HorizontalOptions="Center"/>
                <Label Text="Secure Device Management"
                       FontSize="14"
                       TextColor="White"
                       Opacity="0.9"
                       HorizontalOptions="Center"/>
            </VerticalStackLayout>
        </Grid>
    </Shell.FlyoutHeader>

    <!-- Login Page (Initial Page - No TabBar, Flyout accessible via swipe only) -->
    <ShellContent 
        Route="LoginPage"
        Shell.TabBarIsVisible="False"
        Shell.FlyoutBehavior="Flyout"
        Shell.NavBarIsVisible="False"
        ContentTemplate="{DataTemplate auth:LoginPage}" />

    <!-- Main App Tabs (Hidden by default, shown after login - No NavBar) -->
    <TabBar Route="MainTabs">
        <Tab Title="Coverage"
             Icon="actual_coverage.png">
            <ShellContent 
                Route="DoctorsPage"
                ContentTemplate="{DataTemplate coverageViews:DoctorsPage}" />
        </Tab>
        <Tab Title="Attendance"
             Icon="attendance.png">
            <ShellContent 
                Route="AttendancePage"
                ContentTemplate="{DataTemplate attendanceViews:AttendancePage}" />
        </Tab>
        <Tab Title="Utilities"
             Icon="utilities.png">
            <ShellContent 
                Route="UtilitiesPage"
                ContentTemplate="{DataTemplate utilitiesViews:UtilitiesPage}" />
        </Tab>
    </TabBar>

    <!-- Flyout Menu Items (Protected by authentication inside the page) -->
    <FlyoutItem Title="Device Registration"
                Icon="device_icon.png"
                FlyoutDisplayOptions="AsMultipleItems"
                Shell.NavBarIsVisible="False">
        <ShellContent 
            Title="Register Device"
            ContentTemplate="{DataTemplate admin:DeviceRegistrationPage}"
            Route="DeviceRegistrationPage">
            <ShellContent.Icon>
                <FontImageSource FontFamily="FontAwesome"
                                Glyph="&#xf3cd;"
                                Color="#1DB9A6"/>
            </ShellContent.Icon>
        </ShellContent>
    </FlyoutItem>

    <MenuItem Text="Close Admin Panel"
              Clicked="OnCloseFlyout">
        <MenuItem.IconImageSource>
            <FontImageSource FontFamily="FontAwesome"
                            Glyph="&#xf00d;"
                            Color="White"/>
        </MenuItem.IconImageSource>
    </MenuItem>

</Shell>