<Window x:Class="WPFBeginner.Views.RegistWindow"
        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"
        xmlns:controls="clr-namespace:WPFBeginner.Controls"
        mc:Ignorable="d"
        Title="{DynamicResource Regist_Title}"
        Height="450" Width="400"
        WindowStartupLocation="CenterScreen"
        WindowStyle="None"
        AllowsTransparency="True"
        Background="Transparent"
        ResizeMode="CanResize">

    <Border Background="{DynamicResource WindowBackgroundBrush}"
            CornerRadius="8"
            BorderBrush="{DynamicResource BorderBrush}"
            BorderThickness="1">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <!-- Custom Title Bar -->
            <Grid Grid.Row="0" Background="{DynamicResource SecondaryBrush}" MouseLeftButtonDown="TitleBar_MouseLeftButtonDown">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>

                <TextBlock Text="{DynamicResource Regist_Title}"
                           Foreground="{DynamicResource TextBrush}"
                           VerticalAlignment="Center"
                           Margin="15,10"
                           FontSize="14"
                           FontWeight="SemiBold"/>

                <!-- Minimize Button -->
                <Button Grid.Column="1"
                        Content="─"
                        Width="40" Height="35"
                        Background="Transparent"
                        Foreground="{DynamicResource TextBrush}"
                        BorderThickness="0"
                        FontSize="12"
                        Command="{Binding MinimizeCommand}"
                        CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=Window}}">
                    <Button.Style>
                        <Style TargetType="Button">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="Button">
                                        <Border Background="{TemplateBinding Background}">
                                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                        </Border>
                                        <ControlTemplate.Triggers>
                                            <Trigger Property="IsMouseOver" Value="True">
                                                <Setter Property="Background" Value="#4E4E52"/>
                                            </Trigger>
                                        </ControlTemplate.Triggers>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </Button.Style>
                </Button>

                <!-- Maximize Button -->
                <Button Grid.Column="2"
                        Content="☐"
                        Width="40" Height="35"
                        Background="Transparent"
                        Foreground="{DynamicResource TextBrush}"
                        BorderThickness="0"
                        FontSize="12"
                        Command="{Binding MaximizeCommand}"
                        CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=Window}}">
                    <Button.Style>
                        <Style TargetType="Button">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="Button">
                                        <Border Background="{TemplateBinding Background}">
                                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                        </Border>
                                        <ControlTemplate.Triggers>
                                            <Trigger Property="IsMouseOver" Value="True">
                                                <Setter Property="Background" Value="#4E4E52"/>
                                            </Trigger>
                                        </ControlTemplate.Triggers>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </Button.Style>
                </Button>

                <!-- Close Button -->
                <Button Grid.Column="3"
                        Content="✕"
                        Width="40" Height="35"
                        Background="Transparent"
                        Foreground="{DynamicResource TextBrush}"
                        BorderThickness="0"
                        FontSize="14"
                        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}">
                                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                        </Border>
                                        <ControlTemplate.Triggers>
                                            <Trigger Property="IsMouseOver" Value="True">
                                                <Setter Property="Background" Value="#E81123"/>
                                            </Trigger>
                                        </ControlTemplate.Triggers>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </Button.Style>
                </Button>
            </Grid>

            <!-- Content -->
            <StackPanel Grid.Row="1" Margin="25,20">
                <!-- Name Input -->
                <controls:InputPanel LabelText="{DynamicResource Regist_Name}"
                                     Text="{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                     IsRequired="True"
                                     Margin="0,0,0,15"/>

                <!-- Phone Input -->
                <controls:InputPanel LabelText="{DynamicResource Regist_Call}"
                                     Text="{Binding Call, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                     Margin="0,0,0,15"/>

                <!-- Email Input -->
                <controls:InputPanel LabelText="{DynamicResource Regist_Email}"
                                     Text="{Binding EMail, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                     IsRequired="True"
                                     Margin="0,0,0,15"/>

                <!-- Employee No Input -->
                <controls:InputPanel LabelText="{DynamicResource Regist_No}"
                                     Text="{Binding No, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                     Margin="0,0,0,10"/>

                <!-- Error Message -->
                <TextBlock Text="{Binding ErrorMessage}"
                           Foreground="{DynamicResource ErrorBrush}"
                           Visibility="{Binding HasError, Converter={StaticResource BoolToVisibilityConverter}}"
                           HorizontalAlignment="Center"
                           Margin="0,10,0,0"
                           FontSize="12"/>
            </StackPanel>

            <!-- Buttons -->
            <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="25,0,25,20">
                <Button Content="{DynamicResource Regist_Cancel}"
                        Style="{DynamicResource SecondaryButtonStyle}"
                        Command="{Binding CancelCommand}"
                        CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=Window}}"
                        Width="80"
                        Margin="0,0,10,0"/>
                <Button Content="{DynamicResource Regist_Register}"
                        Style="{DynamicResource PrimaryButtonStyle}"
                        Command="{Binding RegisterCommand}"
                        CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=Window}}"
                        Width="80"/>
            </StackPanel>
        </Grid>
    </Border>
</Window>
