<UserControl x:Class="District_3_App.LogIn.SignInPage"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:WpfTest="clr-namespace:Log_In">

    <UserControl.Resources>
        <Style x:Key="RoundedTextBoxStyle" TargetType="TextBox">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="TextBox">
                        <Border BorderBrush="#8492A6" BorderThickness="1" CornerRadius="5">
                            <TextBox Text="{TemplateBinding Text}" 
                                  BorderThickness="0" 
                                  Background="Transparent" 
                                  Padding="10,10"
                                  Foreground="#8190A5"/>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="passwordbox" TargetType="{x:Type PasswordBox}" BasedOn="{StaticResource {x:Type PasswordBox}}">
            <Setter Property="Padding"  Value="10, 10" />
            <Setter Property="WpfTest:PasswordBoxMonitor.IsMonitoring"
  Value="True"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type PasswordBox}">
                        <Border Background="{TemplateBinding Background}" 
x:Name="Bd" BorderBrush="#8492A6"
BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="5">
                            <Grid>
                                <ScrollViewer x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>

                                <TextBlock x:Name="txtPrompt" Text="{TemplateBinding Tag}" 
                                   Background="Transparent" 
                                   Visibility="Collapsed"
                                   Padding="10,10"
                                   Foreground="#8190A5" />
                            </Grid>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="WpfTest:PasswordBoxMonitor.PasswordLength" Value="0">
                                <Setter Property="Visibility" TargetName="txtPrompt" Value="Visible"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="placeHolder" TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
            <Setter Property="Padding"  Value="10, 10"/>
            <Setter Property="Foreground"  Value="Black"/>
            <Setter Property="Background"  Value="Transparent"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TextBox}">
                        <Border x:Name="border" BorderBrush="#8492A6" BorderThickness="1" CornerRadius="5" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
                            <Grid>
                                <ScrollViewer x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>

                                <TextBlock Text="{TemplateBinding Tag}" 
                             Background="Transparent" 
                             Padding="10,10"
                             Foreground="#8190A5" IsHitTestVisible="False">
                                    <TextBlock.Style>
                                        <Style TargetType="TextBlock">
                                            <Setter Property="Visibility" Value="Hidden"/>
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding Path=Text, RelativeSource={RelativeSource AncestorType=TextBox}}" 
                                              Value="">
                                                    <Setter Property="Visibility" Value="Visible"/>
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </TextBlock.Style>
                                </TextBlock>

                            </Grid>
                        </Border>
                        <ControlTemplate.Triggers>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    </UserControl.Resources>

    <Grid x:Name="SignInGrid" Background="White" Width="1000" Height="1001" Margin="120,45,0,0" VerticalAlignment="Top">
        <Border BorderBrush="#5A6978" BorderThickness="1" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="184,33,0,0" Height="576">
            <Grid Margin="60,90">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto" />
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                </Grid.RowDefinitions>
                <Image Source="\images\app_logo.png" Width="90" Height="54" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="179,-10,0,0"/>
                <TextBlock Grid.Row="1" Text="Sign in" FontSize="25" HorizontalAlignment="Center" FontWeight="Bold" Margin="0,19,0,52" Foreground="#47525E" RenderTransformOrigin="0.528,1.16"/>
                <TextBox Grid.Row="2" Tag="Username/Email" x:Name="txtUsernameAndEmail" Width="290" Margin="12,1,10,0" Height="46" VerticalAlignment="Top" FontSize="16" Style="{StaticResource placeHolder}" Foreground="#8190A5"/>
                <StackPanel Grid.Row="2" Orientation="Horizontal" VerticalAlignment="Top" Margin="42,46,0,0" Grid.RowSpan="2">
                    <PasswordBox Tag="Password" x:Name="txtPassword" Width="290" Margin="18,22,10,0" Height="46" FontSize="16" Foreground="#8190A5" PasswordChar="•" Style="{StaticResource passwordbox}"/>
                    <TextBox x:Name="txtVisiblePassword" IsEnabled="False" Visibility="Collapsed" Width="290" Margin="18,22,10,0" Height="46" FontSize="16" Foreground="#8190A5" Style="{StaticResource RoundedTextBoxStyle}"/>
                    <ToggleButton x:Name="TogglePasswordVisibility" Width="40" Height="40" Margin="0,22,10,0" HorizontalAlignment="Left" Background="Transparent" BorderBrush="Transparent" Click="TogglePasswordVisibility_Click">
                        <Image x:Name="PasswordVisibilityIcon" Width="30" Height="30" Source="\images\hidePasswordIcon.png" RenderTransformOrigin="1.786,0.428" />
                    </ToggleButton>
                </StackPanel>
                <Button Grid.Row="4" x:Name="SignInButton" Content="Sign In" Background="#FF46525E" Foreground="White" Margin="0,35,0,45" Width="220" Height="38" HorizontalAlignment="Center" FontSize="16" BorderBrush="#FF47525E" Grid.RowSpan="2" Click="SignInButton_Click">
                    <Button.Resources>
                        <Style TargetType="Border">
                            <Setter Property="CornerRadius" Value="5"/>
                        </Style>
                    </Button.Resources>
                </Button>
                <TextBlock Grid.Row="5" FontSize="14" HorizontalAlignment="Center" Margin="0,56,0,-26" Foreground="#8190A5">
                  <Hyperlink Click="ForgotPasswordLink_Click">
                      <TextBlock Text="Forgot your password?" Foreground="#8190A5"/>
                  </Hyperlink>
                </TextBlock>
            </Grid>
        </Border>
        <Grid Margin="0,-10,0,10">

            <TextBlock VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,10" FontSize="14" Foreground="#8190A5">
                <Hyperlink Click="BackToSignUp_Click">
                    <TextBlock Text="&lt;" VerticalAlignment="Center" FontSize="17" Foreground="Black"/>
                </Hyperlink>
                 <Run Text="Back" FontSize="16" Foreground="#8190A5"/>
            </TextBlock>
        </Grid>
    </Grid>
</UserControl>
