<Window x:Class="ych.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Учёт оценок студентов" Height="650" Width="1100"
        Background="#F4F6FA" WindowStartupLocation="CenterScreen">

    <Window.Resources>
        <Style x:Key="SideBtn" TargetType="Button">
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="Foreground" Value="#2C3E50"/>
            <Setter Property="FontSize" Value="14"/>
            <Setter Property="FontFamily" Value="Segoe UI"/>
            <Setter Property="Height" Value="42"/>
            <Setter Property="Cursor" Value="Hand"/>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="HorizontalContentAlignment" Value="Left"/>
            <Setter Property="Padding" Value="20,0,0,0"/>
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background" Value="#E3EAF6"/>
                </Trigger>
            </Style.Triggers>
        </Style>

        <Style x:Key="ActionBtn" TargetType="Button">
            <Setter Property="Height" Value="34"/>
            <Setter Property="Padding" Value="16,0"/>
            <Setter Property="FontSize" Value="13"/>
            <Setter Property="FontFamily" Value="Segoe UI"/>
            <Setter Property="Cursor" Value="Hand"/>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="Foreground" Value="White"/>
        </Style>
    </Window.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="200"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <!-- Боковая панель -->
        <Border Grid.Column="0" Background="White"
                BorderBrush="#E0E6EF" BorderThickness="0,0,1,0">
            <StackPanel>

                <Border Background="#1F4E79" Height="60">
                    <TextBlock Text="Учёт оценок"
                               Foreground="White" FontSize="15"
                               FontWeight="Bold" FontFamily="Segoe UI"
                               VerticalAlignment="Center"
                               HorizontalAlignment="Center"/>
                </Border>

                <Border Background="#EBF3FB" Height="36">
                    <TextBlock x:Name="RoleLabel"
                               FontFamily="Segoe UI" FontSize="12"
                               Foreground="#1F4E79" FontWeight="SemiBold"
                               HorizontalAlignment="Center"
                               VerticalAlignment="Center"/>
                </Border>

                <TextBlock Text="ТАБЛИЦЫ" Foreground="#999"
                           FontSize="11" FontFamily="Segoe UI"
                           Margin="20,14,0,4"/>

                <Button x:Name="BtnStudents"
                        Content="  Студенты"
                        Style="{StaticResource SideBtn}"
                        Click="ShowStudents"/>
                <Button x:Name="BtnSubjects"
                        Content="  Предметы"
                        Style="{StaticResource SideBtn}"
                        Click="ShowSubjects"/>
                <Button x:Name="BtnTeachers"
                        Content="  Преподаватели"
                        Style="{StaticResource SideBtn}"
                        Click="ShowTeachers"/>
                <Button x:Name="BtnGroups"
                        Content="  Группы"
                        Style="{StaticResource SideBtn}"
                        Click="ShowGroups"/>
                <Button x:Name="BtnGrades"
                        Content="  Оценки"
                        Style="{StaticResource SideBtn}"
                        Click="ShowGrades"/>

                <Separator Margin="16,10" Background="#E0E6EF"/>

                <TextBlock Text="ЗАПРОСЫ" Foreground="#999"
                           FontSize="11" FontFamily="Segoe UI"
                           Margin="20,0,0,4"/>

                <Button Content="  Неуспевающие"
                        Style="{StaticResource SideBtn}"
                        Click="ShowFailing"/>
                <Button Content="  Средний балл"
                        Style="{StaticResource SideBtn}"
                        Click="ShowAvg"/>

                <Separator Margin="16,10" Background="#E0E6EF"/>

                <Button Content="  Выйти"
                        Style="{StaticResource SideBtn}"
                        Foreground="#E74C3C"
                        Click="Logout_Click"/>
            </StackPanel>
        </Border>

        <!-- Основная область -->
        <Grid Grid.Column="1" Margin="24,20,24,20">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <TextBlock x:Name="TitleText" Grid.Row="0"
                       Text="Выберите таблицу"
                       FontSize="22" FontWeight="Bold"
                       FontFamily="Segoe UI"
                       Foreground="#1F4E79"
                       Margin="0,0,0,14"/>

            <StackPanel x:Name="ActionPanel" Grid.Row="1"
                        Orientation="Horizontal"
                        Margin="0,0,0,12"
                        Visibility="Collapsed">

                <Button x:Name="BtnAdd"
                        Content="  Добавить"
                        Style="{StaticResource ActionBtn}"
                        Background="#27AE60"
                        Click="AddRow"
                        Margin="0,0,8,0"/>

                <Button Content="  Сохранить"
                        Style="{StaticResource ActionBtn}"
                        Background="#2980B9"
                        Click="SaveRow"
                        Margin="0,0,8,0"/>

                <Button x:Name="BtnDelete"
                        Content="  Удалить"
                        Style="{StaticResource ActionBtn}"
                        Background="#E74C3C"
                        Click="DeleteRow"/>
            </StackPanel>

            <DataGrid x:Name="MainGrid" Grid.Row="2"
                      AutoGenerateColumns="True"
                      CanUserAddRows="False"
                      RowBackground="White"
                      AlternatingRowBackground="#F8FAFE"
                      BorderBrush="#D0DBE8" BorderThickness="1"
                      GridLinesVisibility="Horizontal"
                      HorizontalGridLinesBrush="#EDF0F5"
                      FontFamily="Segoe UI" FontSize="13"
                      SelectionMode="Single"
                      ColumnHeaderHeight="38">
                <DataGrid.ColumnHeaderStyle>
                    <Style TargetType="DataGridColumnHeader">
                        <Setter Property="Background" Value="#1F4E79"/>
                        <Setter Property="Foreground" Value="White"/>
                        <Setter Property="FontWeight" Value="SemiBold"/>
                        <Setter Property="FontSize" Value="13"/>
                        <Setter Property="Padding" Value="10,0"/>
                        <Setter Property="Height" Value="38"/>
                    </Style>
                </DataGrid.ColumnHeaderStyle>
            </DataGrid>

            <TextBlock x:Name="StatusText" Grid.Row="3"
                       Margin="0,10,0,0"
                       FontFamily="Segoe UI" FontSize="12"
                       Foreground="#666"/>
        </Grid>
    </Grid>
</Window>