<Window xmlns="https://github.com/avaloniaui"
        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:views="using:OF_DL.Gui.Views"
        x:Class="OF_DL.Gui.Views.FaqWindow"
        x:DataType="views:FaqWindow"
        Width="760"
        Height="640"
        MinWidth="600"
        MinHeight="500"
        Title="FAQ"
        Background="{DynamicResource WindowBackgroundBrush}"
        mc:Ignorable="d">
    <Window.Styles>
        <Style Selector="Border.faqCard">
            <Setter Property="Background" Value="{DynamicResource SurfaceBackgroundBrush}" />
            <Setter Property="BorderBrush" Value="{DynamicResource SurfaceBorderBrush}" />
            <Setter Property="BorderThickness" Value="1" />
            <Setter Property="CornerRadius" Value="10" />
            <Setter Property="Padding" Value="14" />
            <Setter Property="Margin" Value="0,0,0,10" />
        </Style>
    </Window.Styles>

    <Border Margin="14"
            Padding="16"
            Background="{DynamicResource SurfaceBackgroundBrush}"
            BorderBrush="{DynamicResource SurfaceBorderBrush}"
            BorderThickness="1"
            CornerRadius="12">
        <Grid RowDefinitions="Auto,Auto,*,Auto">
            <TextBlock Grid.Row="0"
                       FontSize="24"
                       FontWeight="SemiBold"
                       Foreground="{DynamicResource TextPrimaryBrush}"
                       Text="Frequently Asked Questions" />

            <ScrollViewer Grid.Row="2"
                          Margin="0,14,0,0">
                <ItemsControl ItemsSource="{Binding Entries}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate x:DataType="views:FaqEntry">
                            <Border Classes="faqCard">
                                <StackPanel Spacing="8">
                                    <TextBlock FontSize="18"
                                               FontWeight="SemiBold"
                                               Foreground="{DynamicResource TextPrimaryBrush}"
                                               Text="{Binding Question}"
                                               TextWrapping="Wrap" />

                                    <ItemsControl ItemsSource="{Binding Paragraphs}">
                                        <ItemsControl.ItemTemplate>
                                            <DataTemplate x:DataType="x:String">
                                                <TextBlock Foreground="{DynamicResource TextSecondaryBrush}"
                                                           Text="{Binding .}"
                                                           TextWrapping="Wrap" />
                                            </DataTemplate>
                                        </ItemsControl.ItemTemplate>
                                    </ItemsControl>

                                    <ItemsControl IsVisible="{Binding HasLinks}"
                                                  ItemsSource="{Binding Links}">
                                        <ItemsControl.ItemTemplate>
                                            <DataTemplate x:DataType="views:FaqLink">
                                                <Button HorizontalAlignment="Left"
                                                        Background="Transparent"
                                                        BorderThickness="0"
                                                        Padding="0"
                                                        Foreground="{DynamicResource PrimaryButtonBackgroundBrush}"
                                                        FontWeight="SemiBold"
                                                        Content="{Binding Label}"
                                                        ToolTip.Tip="{Binding Url}"
                                                        CommandParameter="{Binding Url}"
                                                        Click="OnLinkClick" />
                                            </DataTemplate>
                                        </ItemsControl.ItemTemplate>
                                    </ItemsControl>

                                    <Border IsVisible="{Binding HasCodeSnippet}"
                                            Margin="0,2,0,0"
                                            Padding="10"
                                            CornerRadius="8"
                                            Background="{DynamicResource PreviewBackgroundBrush}"
                                            BorderBrush="{DynamicResource PreviewBorderBrush}"
                                            BorderThickness="1">
                                        <TextBlock Text="{Binding CodeSnippet}"
                                                   FontFamily="Consolas"
                                                   FontSize="12"
                                                   Foreground="{DynamicResource TextPrimaryBrush}"
                                                   TextWrapping="Wrap" />
                                    </Border>
                                </StackPanel>
                            </Border>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </ScrollViewer>

            <Button Grid.Row="3"
                    Margin="0,18,0,0"
                    HorizontalAlignment="Right"
                    Content="Close"
                    Click="OnCloseClick" />
        </Grid>
    </Border>
</Window>
