<winex:WindowEx 
    xmlns:winex="using:WinUIEx" 
    x:Class="Clippy.SettingsWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Clippy"
    Title="Settings"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:icons="using:CubeKit.UI.Icons" 
    xmlns:settings="using:CubeKit.UI.Controls.Settings" xmlns:controls="using:Clippy.Controls"
    MinWidth="1090"
    mc:Ignorable="d">
    <winex:WindowEx.Backdrop>
        <winex:MicaSystemBackdrop  />
    </winex:WindowEx.Backdrop>
    <Grid>
        <Border x:Name="AppTitleBar"
                IsHitTestVisible="True"
                VerticalAlignment="Top"
                Height="40"
                Canvas.ZIndex="1" 
                Margin="12,0,0,0">
            <Grid>
                <StackPanel Orientation="Horizontal">
                    <Image x:Name="AppFontIcon"
                    HorizontalAlignment="Left" 
                    VerticalAlignment="Center"
                    Source="Assets/Square44x44Logo.scale-100.png"   
                    Width="24" 
                    Height="24"/>
                    <TextBlock x:Name="AppTitle"
                    Text="Clippy by FireCube"
                    VerticalAlignment="Center"
                    Margin="8, 0, 0, 0"
                    Style="{StaticResource CaptionTextBlockStyle}" />
                    <TextBlock
                    Text=" - Settings"
                    VerticalAlignment="Center"
                    Margin="2, 0, 0, 0"
                    Style="{StaticResource CaptionTextBlockStyle}"
                    Opacity="0.7"/>
                </StackPanel>
            </Grid>
        </Border>
        <ScrollViewer x:Name="SettingsPanel" Margin="0, 48, 0, 0">
            <Grid>
                <StackPanel x:Name="SettingsGrid" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="100, 50, 300, 100">
                    <StackPanel Margin="4, 4, 4, 24" Orientation="Horizontal">
                        <TextBlock FontSize="24" FontWeight="SemiBold">Clippy by FireCube</TextBlock>
                    </StackPanel>
                    <TextBlock FontSize="14" FontWeight="SemiBold" Margin="4, 4, 4, 2">API Key</TextBlock>
                    <settings:SettingsBlockControl Title="OpenAI Api" Margin="2" Description="OpenAI API key for Clippy">
                        <settings:SettingsBlockControl.Icon>
                            <icons:FluentIconElement VerticalAlignment="Center" Symbol="Key24" Foreground="LightCoral"/>
                        </settings:SettingsBlockControl.Icon>
                        <settings:SettingsBlockControl.ExpandableContent>
                            <Grid Padding="24, 0, 24, 0">
                                <controls:APIBox/>
                            </Grid>
                        </settings:SettingsBlockControl.ExpandableContent>
                    </settings:SettingsBlockControl>
                    <TextBlock FontSize="14" FontWeight="SemiBold" Margin="4, 28, 4, 2">Clippy Options</TextBlock>
                    <settings:SettingsBlockControl Title="Maximum tokens" Margin="2" Description="Maximum amount of tokens to use for Clippy input + output per prompt. (1 token = 2-3 words)">
                        <settings:SettingsBlockControl.Icon>
                            <icons:FluentIconElement VerticalAlignment="Center" Symbol="TextWordCount24"/>
                        </settings:SettingsBlockControl.Icon>
                        <NumberBox Style="{ThemeResource GlowNumberBox}" AcceptsExpression="False" Value="{x:Bind Settings.Tokens, Mode=TwoWay}" PlaceholderText="100" Maximum="2000" Minimum="50" Width="200" Margin="0, 0, 90, 0" SmallChange="10" LargeChange="100" SpinButtonPlacementMode="Inline"/>
                    </settings:SettingsBlockControl>
                    <settings:SettingsBlockControl x:Name="Keyboard" Title="Keyboard" Margin="2" Description="Note: Support for other shortcuts is not yet supported">
                        <settings:SettingsBlockControl.Icon>
                            <icons:FluentIconElement VerticalAlignment="Center" Symbol="Keyboard24"/>
                        </settings:SettingsBlockControl.Icon>
                        <ToggleSwitch IsOn="{x:Bind Settings.KeyboardEnabled, Mode=TwoWay}" Style="{ThemeResource GlowSwitch}" OnContent="Win + Shift + C" HorizontalAlignment="Right" OffContent="Off"/>
                    </settings:SettingsBlockControl>
                    <TextBlock FontSize="14" FontWeight="SemiBold" Margin="4, 28, 4, 2">Personalisation Options</TextBlock>
                    <settings:SettingsBlockControl Title="Autopin Clippy" Margin="2" Description="Always pin Clippy to the top of the screen on startup">
                        <settings:SettingsBlockControl.Icon>
                            <icons:FluentIconElement VerticalAlignment="Center" Symbol="Pin24"/>
                        </settings:SettingsBlockControl.Icon>
                        <ToggleSwitch IsOn="{x:Bind Settings.AutoPin, Mode=TwoWay}" Style="{ThemeResource GlowSwitch}" OnContent="On" HorizontalAlignment="Right" OffContent="Off"/>
                    </settings:SettingsBlockControl>
                    <settings:SettingsBlockControl Title="Translucent background" Margin="2" Description="Toggle a translucent or transparent window background. *Requires app restart">
                        <settings:SettingsBlockControl.Icon>
                            <icons:FluentIconElement VerticalAlignment="Center" Symbol="ColorBackground24"/>
                        </settings:SettingsBlockControl.Icon>
                        <ToggleSwitch IsOn="{x:Bind Settings.TranslucentBackground, Mode=TwoWay}" Style="{ThemeResource GlowSwitch}" OffContent="Transparent" HorizontalAlignment="Right" OnContent="Translucent"/>
                    </settings:SettingsBlockControl>
                    <settings:SettingsBlockControl Title="Show Clippy in Tray" Margin="2" Description="Summon Clippy from the System Tray area">
                        <settings:SettingsBlockControl.Icon>
                            <icons:FluentIconElement VerticalAlignment="Center" Symbol="Apps24"/>
                        </settings:SettingsBlockControl.Icon>
                        <ToggleSwitch IsOn="{x:Bind Settings.TrayClippy, Mode=TwoWay}" Style="{ThemeResource GlowSwitch}" OnContent="On" HorizontalAlignment="Right" OffContent="Off"/>
                    </settings:SettingsBlockControl>
                    <TextBlock FontSize="14" FontWeight="SemiBold" Margin="4, 28, 4, 2">Information</TextBlock>
                    <settings:SettingsBlockControl Title="Contact the developer, See new features, Get app support" Margin="2" Description="Jon the Windows Apps Hub">
                        <settings:SettingsBlockControl.Icon>
                            <icons:FluentIconElement VerticalAlignment="Center" Symbol="people24"/>
                        </settings:SettingsBlockControl.Icon>
                        <Button Click="Hub_Click" Margin="4,12,4,8" Width="150" Style="{ThemeResource ToolbarButton}" BorderThickness="1" BorderBrush="{ThemeResource MicaBorderBrush}">Open</Button>
                    </settings:SettingsBlockControl>
                    <settings:SettingsBlockControl Title="Submit bugs, Track updates, View code" Margin="2" Description="Visit the GitHub repository">
                        <settings:SettingsBlockControl.Icon>
                            <icons:FluentIconElement VerticalAlignment="Center" Symbol="Bug24"/>
                        </settings:SettingsBlockControl.Icon>
                        <Button Click="GitHub_Click" Margin="4,12,4,8" Width="150" Style="{ThemeResource ToolbarButton}" BorderThickness="1" BorderBrush="{ThemeResource MicaBorderBrush}">Open</Button>
                    </settings:SettingsBlockControl>
                    
                </StackPanel>

                <StackPanel Margin="80, 100, 12, 40" Width="200" x:Name="AboutPanel" HorizontalAlignment="Right" VerticalAlignment="Top">
                    <TextBlock FontSize="14" FontWeight="SemiBold" Margin="4, 4, 4, 2">About this app</TextBlock>
                    <StackPanel Margin="4, 0, 4, 0" Orientation="Horizontal">
                        <TextBlock Opacity="0.7" FontSize="14" Margin="0, 0, 0, 0">1.1</TextBlock>
                    </StackPanel>
                    <TextBlock FontSize="14" Margin="4, 0, 4, 0" TextWrapping="WrapWholeWords">Developed by FireCubeStudios</TextBlock>
                    <HyperlinkButton Margin="4" NavigateUri="https://twitter.com/FireCubeStudios">Follow me on Twitter</HyperlinkButton>
                    <HyperlinkButton Margin="4" NavigateUri="https://discord.gg/3WYcKat">Join Windows Apps Hub</HyperlinkButton>
                    <HyperlinkButton Margin="4" NavigateUri="https://github.com/FireCubeStudios/Clippy">GitHub repository</HyperlinkButton>
                    <Button Click="Exit_Click" Margin="4,12,4,8" Width="150" Style="{ThemeResource ToolbarButton}" BorderThickness="1" BorderBrush="{ThemeResource MicaBorderBrush}">Exit</Button>
                </StackPanel>
            </Grid>
        </ScrollViewer>
    </Grid>
</winex:WindowEx>
