<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions"
    xmlns:sys="clr-namespace:System;assembly=mscorlib">

    <!-- BUTTON DEFAULT TEMPLATE -->
    <!--////////////////////////////////////////////////////////////////////-->
    <!-- Template.Button.Default defines the base of our buttons. It consists of an outer and inner border, a background, and content -->
    <ControlTemplate x:Key="Template.Button.Default" TargetType="Button">
        <Border
            x:Name="TemplateRoot"
            BorderThickness="2"
            CornerRadius="4"
            Background="{TemplateBinding Background}"
            BorderBrush="{TemplateBinding BorderBrush}"
            Height="{TemplateBinding Height}">

            <Border
                x:Name="ButtonBase"
                BorderThickness="2"
                CornerRadius="2"
                Background="Transparent"
                BorderBrush="#66000000">

                <ContentPresenter
                    x:Name="PART_ContentPresenter"
                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                    Margin="{TemplateBinding Padding}"/>
            </Border>
        </Border>
    </ControlTemplate>

    <!-- DEFAULT BUTTON STYLE -->
    <!--////////////////////////////////////////////////////////////////////-->
    <!-- Style.Button.Default is used as a base for creating other button styles. It sets a number of properties that will remain consistent across the styles based on it -->
    <Style x:Key="Style.Button.Default" TargetType="Button" BasedOn="{StaticResource {x:Type ContentControl}}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Focusable" Value="True"/>
        <Setter Property="FocusVisualStyle" Value="{DynamicResource Style.Focus}"/>
        <Setter Property="FontFamily" Value="{DynamicResource Font.CoreSansBold}"/>
        <Setter Property="FontSize" Value="{DynamicResource Font.Size.Default}"/>
        <Setter Property="Height" Value="48"/>
        <Setter Property="Padding" Value="24,0"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template" Value="{StaticResource Template.Button.Default}"/>
    </Style>

    <!-- SECONDARY BUTTON STYLE -->
    <!--////////////////////////////////////////////////////////////////////-->
    <!-- Styles Template.Button.Default to look like the Secondary Button from the Figma Design System -->
    <Style x:Key="Style.Button.Secondary" TargetType="Button" BasedOn="{StaticResource Style.Button.Default}">
        <Setter Property="Background" Value="{DynamicResource Color.BackgroundSecondary}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource Color.BorderOutSecondary}"/>
        <Setter Property="Foreground" Value="{DynamicResource Color.Text}"/>

        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value ="True">
                <Setter Property="Background" Value="{DynamicResource Color.BackgroundSecondaryHover}"/>
                <Setter Property="BorderBrush" Value="{DynamicResource Color.BorderHover}"/>
            </Trigger>

            <Trigger Property="IsPressed" Value ="True">
                <Setter Property="Background" Value="{DynamicResource Color.BackgroundSecondaryPress}"/>
                <Setter Property="BorderBrush" Value="{DynamicResource Color.BorderHover}"/>
            </Trigger>

            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Background" Value="{DynamicResource Color.BackgroundDisable}"/>
                <Setter Property="BorderBrush" Value="{DynamicResource Color.BorderOutDisable}"/>
                <Setter Property="Foreground" Value="{DynamicResource Color.TextDisable}"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <!-- DANGER BUTTON STYLE -->
    <!--////////////////////////////////////////////////////////////////////-->
    <!-- Styles the Template.Button.Default to look like the Danger Button from the Figma Design System -->
    <Style x:Key="Style.Button.Danger" TargetType="Button" BasedOn="{StaticResource Style.Button.Default}">
        <Setter Property="Background" Value="{DynamicResource Color.BackgroundDanger}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource Color.BorderOutDanger}"/>
        <Setter Property="Foreground" Value="{DynamicResource Color.Text}"/>

        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value ="True">
                <Setter Property="Background" Value="{DynamicResource Color.BackgroundDangerHover}"/>
                <Setter Property="BorderBrush" Value="{DynamicResource Color.BorderHover}"/>
            </Trigger>

            <Trigger Property="IsPressed" Value ="True">
                <Setter Property="Background" Value="{DynamicResource Color.BackgroundDangerPress}"/>
                <Setter Property="BorderBrush" Value="{DynamicResource Color.BorderHover}"/>
            </Trigger>

            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Background" Value="{DynamicResource Color.BackgroundDisable}"/>
                <Setter Property="BorderBrush" Value="{DynamicResource Color.BorderOutDisable}"/>
                <Setter Property="Foreground" Value="{DynamicResource Color.TextDisable}"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <!-- BUTTON PRIMARY TEMPLATE -->
    <!--////////////////////////////////////////////////////////////////////-->
    <!-- The Primary Button design uses a separate template as it has a unique decorative border which we don't want to have to turn off every time for other styles -->
    <ControlTemplate x:Key="Template.Button.Primary" TargetType="Button">
        <Border
            x:Name="TemplateRoot"
            BorderThickness="2"
            CornerRadius="4"
            Background="{TemplateBinding Background}"
            BorderBrush="{TemplateBinding BorderBrush}"
            Height="{TemplateBinding Height}"
            Padding="0">

            <Border
                x:Name="ButtonBase"
                BorderThickness="2"
                CornerRadius="2"
                Background="Transparent"
                BorderBrush="{DynamicResource Color.BorderInPrimary}"
                Padding="0">

                <Grid>
                    <Grid x:Name="ButtonDecor" Opacity="0.25">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="24"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="24"/>
                        </Grid.ColumnDefinitions>

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

                    <ContentPresenter
                        x:Name="PART_ContentPresenter"
                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                        VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                        Margin="{TemplateBinding Padding}"/>
                </Grid>
            </Border>
        </Border>
    </ControlTemplate>

    <!-- BUTTON PRIMARY STYLE -->
    <!--////////////////////////////////////////////////////////////////////-->
    <Style x:Key="Style.Button.Primary" TargetType="Button" BasedOn="{StaticResource {x:Type ContentControl}}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Focusable" Value="True"/>
        <Setter Property="FocusVisualStyle" Value="{DynamicResource Style.Focus}"/>
        <Setter Property="Background" Value="{DynamicResource Color.BackgroundPrimary}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource Color.BorderOutPrimary}"/>
        <Setter Property="Foreground" Value="{DynamicResource Color.Text}"/>
        <Setter Property="FontFamily" Value="{DynamicResource Font.CoreSansBold}"/>
        <Setter Property="FontSize" Value="{DynamicResource Font.Size.Default}"/>
        <Setter Property="Height" Value="48"/>
        <Setter Property="Padding" Value="24,0"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template" Value="{StaticResource Template.Button.Primary}"/>

        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value ="True">
                <Setter Property="Background" Value="{DynamicResource Color.BackgroundPrimaryHover}"/>
                <Setter Property="BorderBrush" Value="{DynamicResource Color.BorderHover}"/>
            </Trigger>

            <Trigger Property="IsPressed" Value ="True">
                <Setter Property="Background" Value="{DynamicResource Color.BackgroundPrimaryPress}"/>
                <Setter Property="BorderBrush" Value="{DynamicResource Color.BorderHover}"/>
            </Trigger>

            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Background" Value="{DynamicResource Color.BackgroundDisable}"/>
                <Setter Property="BorderBrush" Value="{DynamicResource Color.BorderOutDisable}"/>
                <Setter Property="Foreground" Value="{DynamicResource Color.TextDisable}"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <!-- BUTTON GHOST TEMPLATE -->
    <!--////////////////////////////////////////////////////////////////////-->
    <!-- Template.Button.Ghost design uses a separate template as it has no need for the internal border -->
    <ControlTemplate x:Key="Template.Button.Ghost" TargetType="Button">
        <Border
            x:Name="TemplateRoot"
            BorderThickness="2"
            CornerRadius="4"
            Background="{TemplateBinding Background}"
            BorderBrush="{TemplateBinding BorderBrush}"
            Height="{TemplateBinding Height}">

            <ContentPresenter
                    x:Name="PART_ContentPresenter"
                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                    Margin="{TemplateBinding Padding}"/>
        </Border>
    </ControlTemplate>

    <!-- GHOST BUTTON STYLE -->
    <!--////////////////////////////////////////////////////////////////////-->
    <Style x:Key="Style.Button.Ghost" TargetType="Button" BasedOn="{StaticResource {x:Type ContentControl}}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Focusable" Value="True"/>
        <Setter Property="FocusVisualStyle" Value="{DynamicResource Style.Focus}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderBrush" Value="{DynamicResource Color.BorderGhost}"/>
        <Setter Property="Foreground" Value="{DynamicResource Color.Text}"/>
        <Setter Property="FontFamily" Value="{DynamicResource Font.CoreSansBold}"/>
        <Setter Property="FontSize" Value="{DynamicResource Font.Size.Default}"/>
        <Setter Property="Height" Value="48"/>
        <Setter Property="Padding" Value="24,0"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template" Value="{StaticResource Template.Button.Ghost}"/>

        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value ="True">
                <Setter Property="Background" Value="{DynamicResource Color.BackgroundGhostHover}"/>
                <Setter Property="BorderBrush" Value="{DynamicResource Color.BorderGhostHover}"/>
            </Trigger>

            <Trigger Property="IsPressed" Value ="True">
                <Setter Property="Background" Value="{DynamicResource Color.BackgroundGhostPress}"/>
                <Setter Property="BorderBrush" Value="{DynamicResource Color.BorderGhostHover}"/>
            </Trigger>

            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Background" Value="Transparent"/>
                <Setter Property="BorderBrush" Value="{DynamicResource Color.BorderOutDisable}"/>
                <Setter Property="Foreground" Value="{DynamicResource Color.TextDisable}"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <!-- HINT BUTTON STYLE -->
    <!--////////////////////////////////////////////////////////////////////-->
    <Style x:Key="Style.Button.Hint" TargetType="Button" BasedOn="{StaticResource {x:Type ContentControl}}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Focusable" Value="True"/>
        <Setter Property="FocusVisualStyle" Value="{DynamicResource Style.Focus}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="Foreground" Value="{DynamicResource Color.Text}"/>
        <Setter Property="FontFamily" Value="{DynamicResource Font.CoreSansBold}"/>
        <Setter Property="FontSize" Value="{DynamicResource Font.Size.Default}"/>
        <Setter Property="Height" Value="48"/>
        <Setter Property="Padding" Value="12,0"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="TextBlock.CharacterSpacing" Value="40"/>
        <Setter Property="Template" Value="{StaticResource Template.Button.Ghost}"/>

        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value ="True">
                <Setter Property="Background" Value="{DynamicResource Color.BackgroundGhostHover}"/>
                <Setter Property="BorderBrush" Value="{DynamicResource Color.BorderGhost}"/>
            </Trigger>

            <Trigger Property="IsPressed" Value ="True">
                <Setter Property="Background" Value="{DynamicResource Color.BackgroundGhostPress}"/>
                <Setter Property="BorderBrush" Value="{DynamicResource Color.BorderGhost}"/>
            </Trigger>

            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Background" Value="Transparent"/>
                <Setter Property="BorderBrush" Value="{DynamicResource Color.BorderOutDisable}"/>
                <Setter Property="Foreground" Value="{DynamicResource Color.TextDisable}"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <!-- BUTTON MAIN MENU TEMPLATE -->
    <!--////////////////////////////////////////////////////////////////////-->
    <!-- Template.Button.MainMenu design uses a separate template as it does not have an internal border and uses background images -->
    <ControlTemplate x:Key="Template.Button.MainMenu" TargetType="Button">
        <Border
            x:Name="TemplateRoot"
            BorderThickness="2"
            CornerRadius="8"
            Background="{TemplateBinding Background}"
            BorderBrush="{TemplateBinding BorderBrush}"
            Width="{TemplateBinding Width}"
            Height="{TemplateBinding Height}">

            <ContentPresenter
                x:Name="PART_ContentPresenter"
                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                Margin="{TemplateBinding Padding}"/>
        </Border>
    </ControlTemplate>

    <!-- BUTTON MAIN MENU ISLAND STYLE -->
    <!--////////////////////////////////////////////////////////////////////-->
    <Style x:Key="Style.Button.MainMenu" TargetType="Button" BasedOn="{StaticResource {x:Type ContentControl}}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Focusable" Value="True"/>
        <Setter Property="FocusVisualStyle" Value="{DynamicResource Style.Focus}"/>
        <Setter Property="Foreground" Value="{DynamicResource Color.Text}"/>
        <Setter Property="FontFamily" Value="{DynamicResource Font.LexendBold}"/>
        <Setter Property="FontSize" Value="{DynamicResource Font.Size.Heading}"/>
        <Setter Property="Padding" Value="32,0"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template" Value="{StaticResource Template.Button.MainMenu}"/>
    </Style>

    <!-- BUTTON MAIN MENU DEFAULT STYLE -->
    <!--////////////////////////////////////////////////////////////////////-->
    <Style x:Key="Style.Button.MainMenu.Default" TargetType="Button" BasedOn="{StaticResource Style.Button.MainMenu}">
        <Setter Property="Height" Value="64"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="Background" Value="Transparent"/>

        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="BorderBrush" Value="{DynamicResource Color.BorderHover}"/>
                <Setter Property="Foreground" Value="{DynamicResource Color.TextSelected}"/>
            </Trigger>

            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="BorderBrush" Value="{DynamicResource Color.BorderOutDisable}"/>
                <Setter Property="Foreground" Value="{DynamicResource Color.TextDisable}"/>
            </Trigger>
        </Style.Triggers>
    </Style>
</ResourceDictionary>
