<Window x:Class="codelanguage.LanguageReferenceWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Craft++ Language Reference — F1" Height="800" Width="1200" MinHeight="560" MinWidth="820" WindowStartupLocation="CenterOwner" Background="#1A1B1E" TextOptions.TextFormattingMode="Display" TextOptions.TextRenderingMode="ClearType" ResizeMode="CanResize">
  <Window.Resources>
    <!-- Refined Color Palette -->
    <SolidColorBrush x:Key="WindowBrush" Color="#1A1B1E"/>
    <SolidColorBrush x:Key="PaneBrush" Color="#25262B"/>
    <SolidColorBrush x:Key="BorderBrush" Color="#3C3E44"/>
    <SolidColorBrush x:Key="MutedBrush" Color="#9EA2A8"/>
    <SolidColorBrush x:Key="TextBrush" Color="#E2E4E7"/>
    <SolidColorBrush x:Key="AccentBrush" Color="#4D90FE"/>
    <SolidColorBrush x:Key="SelectionBrush" Color="#2D435E"/>
    <SolidColorBrush x:Key="CodeBgBrush" Color="#121212"/>
    <SolidColorBrush x:Key="KeywordBrush" Color="#C586C0"/>

    <!-- Search Box Style -->
    <Style TargetType="TextBox" x:Key="SearchBoxStyle">
      <Setter Property="Background" Value="#121212"/>
      <Setter Property="Foreground" Value="{StaticResource TextBrush}"/>
      <Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
      <Setter Property="BorderThickness" Value="1"/>
      <Setter Property="Padding" Value="12,8"/>
      <Setter Property="FontSize" Value="13"/>
      <Setter Property="FontFamily" Value="Segoe UI"/>
      <Style.Resources>
        <Style TargetType="Border">
          <Setter Property="CornerRadius" Value="6"/>
        </Style>
      </Style.Resources>
    </Style>

    <!-- Navigation List Styles -->
    <Style TargetType="ListBox" x:Key="NavListStyle">
      <Setter Property="Background" Value="Transparent"/>
      <Setter Property="Foreground" Value="{StaticResource TextBrush}"/>
      <Setter Property="BorderThickness" Value="0"/>
      <Setter Property="FontSize" Value="13"/>
      <Setter Property="FontFamily" Value="Segoe UI"/>
      <Setter Property="Padding" Value="0"/>
      <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="ListBox">
            <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
              <ScrollViewer Focusable="False">
                <ItemsPresenter />
              </ScrollViewer>
            </Border>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>

    <Style TargetType="ListBoxItem" x:Key="NavItemStyle">
      <Setter Property="Background" Value="Transparent"/>
      <Setter Property="Foreground" Value="{StaticResource TextBrush}"/>
      <Setter Property="Padding" Value="12,8"/>
      <Setter Property="Margin" Value="8,2"/>
      <Setter Property="HorizontalContentAlignment" Value="Left"/>
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="ListBoxItem">
            <Border x:Name="Border" Background="{TemplateBinding Background}" CornerRadius="4" Padding="{TemplateBinding Padding}">
              <ContentPresenter />
            </Border>
            <ControlTemplate.Triggers>
              <Trigger Property="IsSelected" Value="True">
                <Setter TargetName="Border" Property="Background" Value="{StaticResource SelectionBrush}"/>
                <Setter Property="Foreground" Value="White"/>
              </Trigger>
              <Trigger Property="IsMouseOver" Value="True">
                <Setter TargetName="Border" Property="Background" Value="#35383D"/>
              </Trigger>
            </ControlTemplate.Triggers>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>

    <!-- Typography -->
    <Style TargetType="TextBlock" x:Key="Heading1Style">
      <Setter Property="Foreground" Value="#FFFFFF"/>
      <Setter Property="FontSize" Value="28"/>
      <Setter Property="FontWeight" Value="Bold"/>
      <Setter Property="Margin" Value="0,0,0,12"/>
      <Setter Property="FontFamily" Value="Segoe UI Semibold"/>
    </Style>
    <Style TargetType="TextBlock" x:Key="Heading2Style">
      <Setter Property="Foreground" Value="{StaticResource AccentBrush}"/>
      <Setter Property="FontSize" Value="18"/>
      <Setter Property="FontWeight" Value="SemiBold"/>
      <Setter Property="Margin" Value="0,24,0,8"/>
      <Setter Property="FontFamily" Value="Segoe UI"/>
    </Style>
    <Style TargetType="TextBlock" x:Key="BodyStyle">
      <Setter Property="Foreground" Value="{StaticResource TextBrush}"/>
      <Setter Property="FontSize" Value="14"/>
      <Setter Property="FontFamily" Value="Segoe UI"/>
      <Setter Property="Margin" Value="0,4,0,4"/>
      <Setter Property="TextWrapping" Value="Wrap"/>
    </Style>
  </Window.Resources>

  <Grid Background="{StaticResource WindowBrush}">
    <Grid.RowDefinitions>
      <RowDefinition Height="60"/>
      <RowDefinition Height="*"/>
      <RowDefinition Height="32"/>
    </Grid.RowDefinitions>

    <!-- Title Bar -->
    <Border Grid.Row="0" Background="#25262B" BorderBrush="{StaticResource BorderBrush}" BorderThickness="0,0,0,1">
      <Grid Margin="20,0">
        <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
          <Border Width="32" Height="32" Background="{StaticResource AccentBrush}" CornerRadius="6" Margin="0,0,12,0">
            <TextBlock Text="C++" Foreground="White" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="12"/>
          </Border>
          <StackPanel VerticalAlignment="Center">
            <TextBlock Text="CRAFT++" Foreground="{StaticResource MutedBrush}" FontSize="10" FontWeight="Bold" Margin="0,0,0,2"/>
            <TextBlock Text="Language Reference" Foreground="White" FontSize="18" FontWeight="SemiBold"/>
          </StackPanel>
        </StackPanel>
        <Border HorizontalAlignment="Right" VerticalAlignment="Center" Background="#121212" BorderBrush="{StaticResource BorderBrush}" BorderThickness="1" CornerRadius="6" Padding="12,4">
          <TextBlock Text="F1 HELP" Foreground="{StaticResource MutedBrush}" FontSize="11" FontWeight="Bold" VerticalAlignment="Center"/>
        </Border>
      </Grid>
    </Border>

    <Grid Grid.Row="1">
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="320" MinWidth="260" MaxWidth="450"/>
        <ColumnDefinition Width="1"/>
        <ColumnDefinition Width="*"/>
      </Grid.ColumnDefinitions>

      <!-- Sidebar Navigation -->
      <Border Grid.Column="0" Background="{StaticResource PaneBrush}" BorderBrush="{StaticResource BorderBrush}" BorderThickness="0,0,1,0">
        <Grid Margin="0">
          <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
          </Grid.RowDefinitions>

          <StackPanel Grid.Row="0" Margin="16,20,16,16">
            <TextBlock Text="Quick Search" Foreground="{StaticResource MutedBrush}" FontSize="11" FontWeight="SemiBold" Margin="0,0,0,8"/>
            <TextBox x:Name="SearchBox" Style="{StaticResource SearchBoxStyle}" Height="38" TextChanged="SearchBox_TextChanged" ToolTip="Search the language reference"/>
          </StackPanel>

          <Grid Grid.Row="1">
            <Grid.RowDefinitions>
              <RowDefinition Height="Auto"/>
              <RowDefinition Height="*"/>
              <RowDefinition Height="Auto"/>
              <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            
            <TextBlock Grid.Row="0" Text="CHAPTERS" Foreground="#60636a" FontSize="10" FontWeight="Bold" Margin="20,15,20,8"/>
            <ListBox x:Name="CategoryList" Grid.Row="1" Style="{StaticResource NavListStyle}" ItemContainerStyle="{StaticResource NavItemStyle}" SelectionChanged="CategoryList_SelectionChanged">
              <ListBoxItem Tag="all" IsSelected="True"><TextBlock Text="▦  All Topics"/></ListBoxItem>
              <ListBoxItem Tag="syntax"><TextBlock Text="⌘  Syntax"/></ListBoxItem>
              <ListBoxItem Tag="keywords"><TextBlock Text="◇  Keywords"/></ListBoxItem>
              <ListBoxItem Tag="variables"><TextBlock Text="▣  Variables"/></ListBoxItem>
              <ListBoxItem Tag="typevars"><TextBlock Text="▣  Type Variables"/></ListBoxItem>
              <ListBoxItem Tag="procs"><TextBlock Text="λ  Procedures"/></ListBoxItem>
              <ListBoxItem Tag="typeprocs"><TextBlock Text="λ  Type Procedures"/></ListBoxItem>
              <ListBoxItem Tag="verbs"><TextBlock Text="◆  Verbs"/></ListBoxItem>
              <ListBoxItem Tag="builtins"><TextBlock Text="ƒ  Built-ins"/></ListBoxItem>
              <ListBoxItem Tag="operators"><TextBlock Text="⊕  Operators"/></ListBoxItem>
              <ListBoxItem Tag="controlflow"><TextBlock Text="↪  Control Flow"/></ListBoxItem>
              <ListBoxItem Tag="types"><TextBlock Text="◇  Types"/></ListBoxItem>
              <ListBoxItem Tag="lists"><TextBlock Text="☷  Lists"/></ListBoxItem>
              <ListBoxItem Tag="preprocessor"><TextBlock Text="#  Preprocessor"/></ListBoxItem>
            </ListBox>

            <TextBlock Grid.Row="2" Text="TOPICS" Foreground="#60636a" FontSize="10" FontWeight="Bold" Margin="20,15,20,8"/>
            <ListBox x:Name="TopicList" Grid.Row="3" Style="{StaticResource NavListStyle}" ItemContainerStyle="{StaticResource NavItemStyle}" SelectionChanged="TopicList_SelectionChanged"/>
          </Grid>
        </Grid>
      </Border>

        <GridSplitter Grid.Column="1" Width="1" HorizontalAlignment="Stretch" Background="{StaticResource BorderBrush}"/>

        <!-- Main Content Area -->
        <Border Grid.Column="2" Background="{StaticResource WindowBrush}">
          <ScrollViewer x:Name="ContentScrollViewer" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
            <StackPanel Margin="60,40,60,60" x:Name="ContentPanel">
              <!-- Breadcrumb Area -->
              <StackPanel Orientation="Horizontal" Margin="0,0,0,20">
                <TextBlock Text="Reference" Foreground="{StaticResource MutedBrush}" FontSize="12" VerticalAlignment="Center"/>
                <TextBlock Text=" / " Foreground="#44474D" FontSize="12" VerticalAlignment="Center" Margin="4,0"/>
                <TextBlock x:Name="BreadcrumbPath" Text="Welcome" Foreground="{StaticResource AccentBrush}" FontSize="12" FontWeight="SemiBold" VerticalAlignment="Center"/>
              </StackPanel>
              
              <TextBlock x:Name="WelcomeText" Text="Craft++ Language Reference" Style="{StaticResource Heading1Style}"/>
              <TextBlock Text="Select a chapter or topic from the contents pane. Press F1 from the editor to return here at any time." Foreground="{StaticResource MutedBrush}" FontSize="14" TextWrapping="Wrap" Margin="0,0,0,24"/>
              <Separator Background="{StaticResource BorderBrush}" Height="1" Margin="0,0,0,24"/>
              <TextBlock Text="IMPLEMENTATION STATUS" Style="{StaticResource Heading2Style}"/>
              <ItemsControl ItemsSource="{Binding ImplementedSummary}">
                <ItemsControl.ItemTemplate>
                  <DataTemplate>
                    <StackPanel Orientation="Horizontal" Margin="0,6">
                      <TextBlock Text="•" Foreground="{StaticResource AccentBrush}" Margin="0,0,12,0" FontWeight="Bold"/>
                      <TextBlock Text="{Binding}" Foreground="{StaticResource TextBrush}" FontSize="14" TextWrapping="Wrap"/>
                    </StackPanel>
                  </DataTemplate>
                </ItemsControl.ItemTemplate>
              </ItemsControl>
            </StackPanel>
          </ScrollViewer>
        </Border>
      </Grid>

    <!-- Footer Bar -->
    <Border Grid.Row="2" Background="#121212" BorderBrush="{StaticResource BorderBrush}" BorderThickness="0,1,0,0">
      <DockPanel Margin="20,0">
        <TextBlock Text="{Binding TopicCountLabel}" Foreground="{StaticResource MutedBrush}" FontSize="11" VerticalAlignment="Center"/>
        <TextBlock DockPanel.Dock="Right" Text="Ctrl+F  •  Search all topics  •  Select a topic" Foreground="#60636a" FontSize="11" VerticalAlignment="Center"/>
      </DockPanel>
    </Border>
  </Grid>
</Window>

