<?xml version="1.0" encoding="utf-8"?>
<Window
    x:Name="_window"
    x:Class="Sonex.Client.AppWindows.LoginWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Sonex.Client.AppWindows"
    xmlns:UserControl="using:Sonex.Client.Controls"
    xmlns:helpers="using:Sonex.Client.Helpers"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Title="Sonex">

    <Window.SystemBackdrop>
        <MicaBackdrop />
    </Window.SystemBackdrop>

    <!-- ROOT: tło + UI -->
    <Grid x:Name="RootGrid">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="auto"/>
            
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="48"/>
        </Grid.RowDefinitions>
        <!-- TŁO: animacja pod UI, na całość -->
        <UserControl:ForceDirectedAnimation
            x:Name="_BackgroundAnimation"
            Grid.ColumnSpan="2"
            Grid.RowSpan="2"
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch"

            />

        <!-- Lewa kolumna (placeholder / branding / itp.) -->
        <StackPanel x:Name="_TitleBar" Grid.Column="0" Grid.Row="0" Orientation="Vertical" HorizontalAlignment="Left" Padding="32 54 32 32" Spacing="8">
            <Image  Height="32">
                <Image.Source>
                    <SvgImageSource UriSource="{x:Bind helpers:AppPaths.AssetUri('sonex_logo.svg')}"/>
                </Image.Source>
            </Image>
            <TextBlock
                Text="DESIGNED TO SUPPORT"
                FontFamily="{ThemeResource ContentControlThemeFontFamily}"
                Foreground="{ThemeResource ControlStrongFillColorDisabledBrush}"
                Margin="42 0 0 0"
                FontSize="15"
                FontWeight="SemiBold"
                CharacterSpacing="60"/>
        </StackPanel>

        <!-- Prawa kolumna: formularz -->
        <Border Grid.Column="1"
                Grid.Row="0"
                Padding="18"
                Margin="0 64 32 0"
                VerticalAlignment="Center"
                HorizontalAlignment="Center"
                CornerRadius="{ThemeResource OverlayCornerRadius}"
                Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
                Translation="0,0,32">
            <Border.Shadow>
                <ThemeShadow />
            </Border.Shadow>
            <Grid RowSpacing="12">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <!--<RowDefinition Height="Auto"/>-->
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>

                <TextBox Grid.Row="0" x:Name="_UserName" Header="User name" KeyDown="_TextBox_KeyDown" Width="200"/>

                <PasswordBox Grid.Row="1" x:Name="_Password" Header="Password" KeyDown="_TextBox_KeyDown" Width="200"/>

                <Grid Grid.Row="3" ColumnSpacing="12" Padding="0 6 0 0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>

                    <CheckBox x:Name="_KeepLogIn" Grid.Column="0" Content="Keep me logged in" VerticalAlignment="Center"/>

                    <Button x:Name="_Login" Click="_Login_Click"
                            Grid.Column="1"
                            Content="Login"
                            Style="{StaticResource AccentButtonStyle}"/>
                </Grid>
            </Grid>
        </Border>
        <TextBlock x:Name="_VersionInfo"
                Grid.Row="1"
                Grid.Column="1"
                HorizontalAlignment="Right"
                VerticalAlignment="Bottom"
                Text=""
                FontFamily="{ThemeResource ContentControlThemeFontFamily}"
                Margin="0 0 8 8"
                FontSize="13"
                FontWeight="SemiBold"
                Opacity="0.42"
                CharacterSpacing="60"/>
        <AppBarButton x:Name="_SettingButton" Icon="Setting" Grid.Row="1" Grid.Column="0" IsCompact="True" AutomationProperties.Name="Settings" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="42" Height="42">
            
            <AppBarButton.Flyout>
                <MenuFlyout Placement="TopEdgeAlignedLeft">
                    <MenuFlyoutSubItem Text="Theme"/>

                    <MenuFlyoutSubItem Text="Color mode">
                        <RadioMenuFlyoutItem Text="Auto" GroupName="ThemeLight" Click="_ThemeLight_Change"/>
                        <RadioMenuFlyoutItem Text="Dark" GroupName="ThemeLight" Click="_ThemeLight_Change"/>
                        <RadioMenuFlyoutItem Text="Light" GroupName="ThemeLight" Click="_ThemeLight_Change"/>
                    </MenuFlyoutSubItem>
                    <MenuFlyoutItem Text="About" Click="_About_Click"/>
                </MenuFlyout>

            </AppBarButton.Flyout>
        </AppBarButton>
    </Grid>
</Window>