<Window x:Class="WPFBeginner.Views.LoginWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        Title="{DynamicResource Login_Title}"
        Height="540" Width="440"
        WindowStartupLocation="CenterScreen"
        WindowStyle="None"
        AllowsTransparency="True"
        Background="Transparent"
        ResizeMode="NoResize">

    <Border Margin="15" CornerRadius="12">
        <Border.Effect>
            <DropShadowEffect BlurRadius="15" ShadowDepth="0" Opacity="0.5"/>
        </Border.Effect>
        <Border.Background>
            <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                <GradientStop Color="#1a1a2e" Offset="0"/>
                <GradientStop Color="#16213e" Offset="1"/>
            </LinearGradientBrush>
        </Border.Background>

        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <!-- Title Bar -->
            <Grid Grid.Row="0" Background="Transparent" MouseLeftButtonDown="TitleBar_MouseLeftButtonDown">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>

                <Button Grid.Column="1"
                        Content="✕"
                        Width="45" Height="35"
                        Background="Transparent"
                        Foreground="#808080"
                        BorderThickness="0"
                        FontSize="14"
                        Cursor="Hand"
                        Command="{Binding CloseCommand}"
                        CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=Window}}">
                    <Button.Style>
                        <Style TargetType="Button">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="Button">
                                        <Border Background="{TemplateBinding Background}" CornerRadius="0,12,0,0">
                                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                        </Border>
                                        <ControlTemplate.Triggers>
                                            <Trigger Property="IsMouseOver" Value="True">
                                                <Setter Property="Background" Value="#E81123"/>
                                                <Setter Property="Foreground" Value="White"/>
                                            </Trigger>
                                        </ControlTemplate.Triggers>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </Button.Style>
                </Button>
            </Grid>

            <!-- Content -->
            <StackPanel Grid.Row="1" Margin="40,10,40,30" VerticalAlignment="Center">

                <!-- Logo Icon -->
                <Border Width="70" Height="70"
                        CornerRadius="35"
                        Margin="0,0,0,20"
                        HorizontalAlignment="Center">
                    <Border.Background>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                            <GradientStop Color="#0f3460" Offset="0"/>
                            <GradientStop Color="#e94560" Offset="1"/>
                        </LinearGradientBrush>
                    </Border.Background>
                    <TextBlock Text="W"
                               FontSize="32"
                               FontWeight="Bold"
                               Foreground="White"
                               HorizontalAlignment="Center"
                               VerticalAlignment="Center"/>
                </Border>

                <!-- Welcome Message -->
                <TextBlock Text="{DynamicResource Login_Welcome}"
                           Foreground="White"
                           FontSize="26"
                           FontWeight="SemiBold"
                           HorizontalAlignment="Center"
                           Margin="0,0,0,5"/>

                <TextBlock Text="WPF Beginner"
                           Foreground="#808080"
                           FontSize="13"
                           HorizontalAlignment="Center"
                           Margin="0,0,0,25"/>

                <!-- User ID -->
                <TextBlock Text="{DynamicResource Login_UserId}"
                           Foreground="#a0a0a0"
                           FontSize="12"
                           Margin="5,0,0,6"/>
                <Border CornerRadius="8" Background="#0f3460" Margin="0,0,0,15">
                    <TextBox Text="{Binding UserId, UpdateSourceTrigger=PropertyChanged}"
                             Background="Transparent"
                             Foreground="White"
                             BorderThickness="0"
                             Padding="12,10"
                             FontSize="14"
                             CaretBrush="White"/>
                </Border>

                <!-- Password -->
                <TextBlock Text="{DynamicResource Login_Password}"
                           Foreground="#a0a0a0"
                           FontSize="12"
                           Margin="5,0,0,6"/>
                <Border CornerRadius="8" Background="#0f3460" Margin="0,0,0,12">
                    <PasswordBox x:Name="PasswordBox"
                                 Background="Transparent"
                                 Foreground="White"
                                 BorderThickness="0"
                                 Padding="12,10"
                                 FontSize="14"
                                 CaretBrush="White"
                                 PasswordChanged="PasswordBox_PasswordChanged"/>
                </Border>

                <!-- Error Message -->
                <Border Background="#3d1f2f"
                        CornerRadius="6"
                        Padding="10,6"
                        Margin="0,0,0,10"
                        Visibility="{Binding HasError, Converter={StaticResource BoolToVisibilityConverter}}">
                    <TextBlock Text="{Binding ErrorMessage}"
                               Foreground="#ff6b6b"
                               FontSize="12"
                               HorizontalAlignment="Center"/>
                </Border>

                <!-- Login Button -->
                <Button Command="{Binding LoginCommand}"
                        CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=Window}}"
                        Cursor="Hand"
                        Margin="0,5,0,0">
                    <Button.Template>
                        <ControlTemplate TargetType="Button">
                            <Border x:Name="ButtonBorder" CornerRadius="8" Padding="15,12">
                                <Border.Background>
                                    <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
                                        <GradientStop Color="#e94560" Offset="0"/>
                                        <GradientStop Color="#0f3460" Offset="1"/>
                                    </LinearGradientBrush>
                                </Border.Background>
                                <TextBlock Text="{DynamicResource Login_LoginButton}"
                                           Foreground="White"
                                           FontSize="15"
                                           FontWeight="SemiBold"
                                           HorizontalAlignment="Center"/>
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter TargetName="ButtonBorder" Property="Background">
                                        <Setter.Value>
                                            <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
                                                <GradientStop Color="#ff6b6b" Offset="0"/>
                                                <GradientStop Color="#1a5276" Offset="1"/>
                                            </LinearGradientBrush>
                                        </Setter.Value>
                                    </Setter>
                                </Trigger>
                                <Trigger Property="IsPressed" Value="True">
                                    <Setter TargetName="ButtonBorder" Property="Background">
                                        <Setter.Value>
                                            <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
                                                <GradientStop Color="#c0392b" Offset="0"/>
                                                <GradientStop Color="#0a3d62" Offset="1"/>
                                            </LinearGradientBrush>
                                        </Setter.Value>
                                    </Setter>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Button.Template>
                </Button>
            </StackPanel>
        </Grid>
    </Border>
</Window>
