<Page x:Class="SkyTeam.AdminDashboard"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
      xmlns:properties="clr-namespace:SkyTeam"
      Title="AdminDashboard"
      Background="{DynamicResource PageBackground}">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="200"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <Border Grid.Row="0" Grid.ColumnSpan="2" Background="#D32F2F" Padding="15">
            <StackPanel Orientation="Horizontal">
                <iconPacks:PackIconMaterial Kind="ShieldAccount" Width="36" Height="36" Foreground="White" Margin="0,0,10,0"/>
                <StackPanel>
                    <TextBlock Text="{x:Static properties:Resources.AdminHeaderTitle}" FontSize="20" FontWeight="Bold" Foreground="White"/>
                    <TextBlock Text="{x:Static properties:Resources.AdminHeaderSubtitle}" FontSize="12" Foreground="White"/>
                </StackPanel>
            </StackPanel>
        </Border>

        <StackPanel Grid.Row="1" Grid.Column="0" Background="{DynamicResource SidebarBackground}">
            <Button Height="50" Margin="5" Click="ShowUsers_Click">
                <StackPanel Orientation="Horizontal">
                    <iconPacks:PackIconMaterial Kind="AccountGroup" Width="20" Margin="0,0,10,0"/>
                    <TextBlock Text="{x:Static properties:Resources.AdminSidebarManageUsers}"/>
                </StackPanel>
            </Button>
            <Button Height="50" Margin="5" Click="ShowFlights_Click">
                <StackPanel Orientation="Horizontal">
                    <iconPacks:PackIconMaterial Kind="Airplane" Width="20" Margin="0,0,10,0"/>
                    <TextBlock Text="{x:Static properties:Resources.AdminSidebarManageFlights}"/>
                </StackPanel>
            </Button>
            <Button Height="50" Margin="5" Background="#FFEBEB" BorderBrush="#FFB71C1C" Foreground="#D32F2F" FontWeight="Bold" Click="Logout_Click">
                <StackPanel Orientation="Horizontal">
                    <iconPacks:PackIconMaterial Kind="Logout" Width="20" Margin="0,0,10,0"/>
                    <TextBlock Text="{x:Static properties:Resources.AdminSidebarLogout}"/>
                </StackPanel>
            </Button>
        </StackPanel>

        <Grid Grid.Row="1" Grid.Column="1" Margin="20">

            <Grid x:Name="UserManagementGrid" Visibility="Visible">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

                <TextBlock Text="{x:Static properties:Resources.AdminUsersTitle}" FontSize="24" FontWeight="Bold" Foreground="{DynamicResource PrimaryText}"/>

                <DataGrid x:Name="AllUsersGrid" Grid.Row="1" Margin="0,10,0,20" AutoGenerateColumns="False" IsReadOnly="True" SelectionMode="Single" SelectionChanged="AllUsersGrid_SelectionChanged">
                    <DataGrid.Columns>
                        <DataGridTextColumn Header="ID" Binding="{Binding Id}" Width="50"/>
                        <DataGridTextColumn Header="Vorname" Binding="{Binding Vorname}" Width="*"/>
                        <DataGridTextColumn Header="Nachname" Binding="{Binding Nachname}" Width="*"/>
                        <DataGridTextColumn Header="Email" Binding="{Binding Email}" Width="150"/>
                        <DataGridTextColumn Header="Rolle" Binding="{Binding Rolle}" Width="80"/>
                    </DataGrid.Columns>
                </DataGrid>

                <StackPanel Grid.Row="2" Orientation="Horizontal" Margin="0,0,0,10">
                    <TextBlock Text="{x:Static properties:Resources.AdminUserBookingsTitle}" FontSize="18" FontWeight="Bold" Foreground="{DynamicResource PrimaryText}" VerticalAlignment="Center"/>
                    <Button Content="{x:Static properties:Resources.AdminDeleteUserButton}" Background="#D32F2F" Foreground="White" FontWeight="Bold" Margin="20,0,0,0" Padding="10,5" Click="DeleteUser_Click"/>
                </StackPanel>

                <DataGrid x:Name="UserBookingsGrid" Grid.Row="3" AutoGenerateColumns="False" IsReadOnly="True" Background="{DynamicResource CardBackground}">
                    <DataGrid.Columns>
                        <DataGridTextColumn Header="Buchung ID" Binding="{Binding BuchungId}"/>
                        <DataGridTextColumn Header="Flug Nr." Binding="{Binding Flugnummer}"/>
                        <DataGridTextColumn Header="Von" Binding="{Binding Abflugort}"/>
                        <DataGridTextColumn Header="Nach" Binding="{Binding Zielort}"/>
                        <DataGridTextColumn Header="Datum" Binding="{Binding Abflugdatum}"/>
                    </DataGrid.Columns>
                </DataGrid>
            </Grid>

            <Grid x:Name="FlightManagementGrid" Visibility="Collapsed">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>

                <TextBlock Text="{x:Static properties:Resources.AdminFlightsTitle}" FontSize="24" FontWeight="Bold" Foreground="{DynamicResource PrimaryText}" Margin="0,0,0,10"/>

                <DataGrid x:Name="AllFlightsGrid" Grid.Row="1" Margin="0,0,0,20" AutoGenerateColumns="False" IsReadOnly="True">
                    <DataGrid.Columns>
                        <DataGridTextColumn Header="ID" Binding="{Binding Id}" Width="40"/>
                        <DataGridTextColumn Header="Nummer" Binding="{Binding Flugnummer}" FontWeight="Bold" Width="80"/>
                        <DataGridTextColumn Header="Von" Binding="{Binding Abflugort}" Width="*"/>
                        <DataGridTextColumn Header="Nach" Binding="{Binding Zielort}" Width="*"/>
                        <DataGridTextColumn Header="Datum" Binding="{Binding Abflugdatum}" Width="120"/>
                        <DataGridTextColumn Header="Preis" Binding="{Binding Preis}" Width="60"/>
                        <DataGridTextColumn Header="Flugzeug" Binding="{Binding Plane}" Width="100"/>
                        <DataGridTextColumn Header="Pilot" Binding="{Binding Pilot}" Width="100"/>
                    </DataGrid.Columns>
                </DataGrid>

                <Button Grid.Row="1" VerticalAlignment="Top" HorizontalAlignment="Right" Content="Flug Löschen" Background="#D32F2F" Foreground="White" Margin="0,-40,0,0" Padding="10,5" Click="DeleteFlight_Click"/>

                <Border Grid.Row="2" Background="{DynamicResource CardBackground}" CornerRadius="8" Padding="15" BorderBrush="#DDD" BorderThickness="1">
                    <StackPanel>
                        <TextBlock Text="{x:Static properties:Resources.AdminAddFlightTitle}" FontWeight="Bold" Margin="0,0,0,10"/>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>

                            <StackPanel Margin="5">
                                <Label Content="{Binding Source={x:Static properties:Resources.PrepositionVon}, StringFormat='{}{0}:'}"/>

                                <ComboBox x:Name="AddFromCombo" IsEditable="True">
                                    <ComboBoxItem Content="Berlin"/>
                                    <ComboBoxItem Content="München"/>
                                    <ComboBoxItem Content="Frankfurt"/>
                                    <ComboBoxItem Content="Hamburg"/>
                                    <ComboBoxItem Content="Paris"/>
                                    <ComboBoxItem Content="London"/>
                                    <ComboBoxItem Content="Madrid"/>
                                    <ComboBoxItem Content="Rom"/>
                                    <ComboBoxItem Content="Lissabon"/>
                                    <ComboBoxItem Content="Wien"/>
                                    <ComboBoxItem Content="Zürich"/>
                                    <ComboBoxItem Content="Amsterdam"/>
                                    <ComboBoxItem Content="Prag"/>
                                    <ComboBoxItem Content="Budapest"/>
                                    <ComboBoxItem Content="Warschau"/>
                                    <ComboBoxItem Content="Paderborn"/>
                                </ComboBox>
                            </StackPanel>

                            <StackPanel Grid.Column="1" Margin="5">
                                <Label Content="{Binding Source={x:Static properties:Resources.To}, StringFormat='{}{0}:'}"/>
                                <ComboBox x:Name="AddToCombo" IsEditable="True">
                                    <ComboBoxItem Content="Mallorca"/>
                                    <ComboBoxItem Content="Berlin"/>
                                    <ComboBoxItem Content="München"/>
                                    <ComboBoxItem Content="Frankfurt"/>
                                    <ComboBoxItem Content="Hamburg"/>
                                    <ComboBoxItem Content="Paris"/>
                                    <ComboBoxItem Content="London"/>
                                    <ComboBoxItem Content="Madrid"/>
                                    <ComboBoxItem Content="Rom"/>
                                    <ComboBoxItem Content="Lissabon"/>
                                    <ComboBoxItem Content="Wien"/>
                                    <ComboBoxItem Content="Zürich"/>
                                    <ComboBoxItem Content="Amsterdam"/>
                                    <ComboBoxItem Content="Prag"/>
                                    <ComboBoxItem Content="Budapest"/>
                                    <ComboBoxItem Content="Tokio"/>
                                    <ComboBoxItem Content="New York"/>
                                    <ComboBoxItem Content="Dubai"/>
                                </ComboBox>
                            </StackPanel>

                            <StackPanel Grid.Column="2" Margin="5">
                                <Label Content="{Binding Source={x:Static properties:Resources.DateLabel}, StringFormat='{}{0}:'}"/>
                                <DatePicker x:Name="AddDatePick"/>
                            </StackPanel>
                            <StackPanel Grid.Column="3" Margin="5">
                                <Label Content="{Binding Source={x:Static properties:Resources.PriceLabel}, StringFormat='{}{0}:'}"/>
                                <TextBox x:Name="AddPriceTxt"/>
                            </StackPanel>

                            <StackPanel Grid.Row="1" Grid.Column="0" Margin="5">
                                <Label Content="{Binding Source={x:Static properties:Resources.PlaneLabel}, StringFormat='{}{0}:'}"/>
                                <ComboBox x:Name="PlaneCombo" DisplayMemberPath="Modell" SelectedValuePath="Id"/>
                            </StackPanel>
                            <StackPanel Grid.Row="1" Grid.Column="1" Margin="5">
                                <Label Content="{Binding Source={x:Static properties:Resources.PilotLabel}, StringFormat='{}{0}:'}"/>
                                <ComboBox x:Name="PilotCombo" DisplayMemberPath="FullName" SelectedValuePath="Id"/>
                            </StackPanel>

                            <Button Grid.Row="1" Grid.Column="3" Content="{x:Static properties:Resources.AdminCreateFlightButton}" Background="#1E88E5" Foreground="White" FontWeight="Bold" VerticalAlignment="Bottom" Height="30" Margin="5" Click="AddFlight_Click"/>
                        </Grid>
                    </StackPanel>
                </Border>
            </Grid>

        </Grid>
    </Grid>
</Page>