<UserControl 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:vm="using:ClawdDotNet.Desktop.ViewModels"
             xmlns:ctrl="using:ClawdDotNet.Desktop.Controls"
             mc:Ignorable="d" d:DesignWidth="1100" d:DesignHeight="700"
             x:Class="ClawdDotNet.Desktop.Views.InfoPageView"
             x:DataType="vm:InfoPageViewModel">

  <ScrollViewer VerticalScrollBarVisibility="Auto">
    <!-- Etwas Luft nach aussen: Die Eckmarken des BlueprintFrame ragen ueber den
         Rahmen hinaus und wuerden sonst am Rand des Bereichs abgeschnitten. -->
    <StackPanel Spacing="26" Margin="8" MaxWidth="820" HorizontalAlignment="Left">

      <!-- Die einzige Karte des Entwurfs mit Eckmarken -->
      <ctrl:BlueprintFrame MaxWidth="420" HorizontalAlignment="Left">
        <StackPanel Spacing="6">
          <TextBlock Classes="h2" Text="ClawdDotNet" />
          <TextBlock Classes="muted" FontSize="13">
            <Run Text="Version" /><Run Text=" " /><Run Text="{Binding AppVersion}" /><Run Text=" · Avalonia UI · net10.0" />
          </TextBlock>
        </StackPanel>
      </ctrl:BlueprintFrame>

      <!-- Anwendung -->
      <StackPanel Spacing="10">
        <TextBlock Classes="kicker" Text="ANWENDUNG" />
        <TextBlock Classes="h2" Text="Build" />

        <Grid ColumnDefinitions="170,*" RowDefinitions="Auto,Auto" >
          <TextBlock Grid.Row="0" Grid.Column="0" Classes="label" Text="Version" />
          <TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding AppVersion}" />

          <TextBlock Grid.Row="1" Grid.Column="0" Classes="label" Text="Build-Zusammenfassung"
                     Margin="0,6,0,0" />
          <TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding BuildSummary}"
                     TextWrapping="Wrap" Margin="0,6,0,0" />
        </Grid>
      </StackPanel>

      <Border Classes="hr" />

      <!-- Instanz -->
      <StackPanel Spacing="10">
        <TextBlock Classes="kicker" Text="INSTANZ" />

        <DockPanel>
          <TextBlock Classes="h2" Text="Aktuelle Instanz" VerticalAlignment="Center" />
          <Button DockPanel.Dock="Right" HorizontalAlignment="Right" Classes="toolbar"
                  Command="{Binding OpenInstanceFolderCommand}">
            <StackPanel Orientation="Horizontal" Spacing="6">
              <ctrl:StrokeIcon Data="{StaticResource IconFolder}" Width="14" Height="14" />
              <TextBlock Text="Instanz-Ordner öffnen" />
            </StackPanel>
          </Button>
        </DockPanel>

        <Grid ColumnDefinitions="170,*" RowDefinitions="Auto,Auto,Auto,Auto,Auto">
          <TextBlock Grid.Row="0" Grid.Column="0" Classes="label" Text="Name" />
          <TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding InstanceName}" />

          <TextBlock Grid.Row="1" Grid.Column="0" Classes="label" Text="ID" Margin="0,6,0,0" />
          <TextBlock Grid.Row="1" Grid.Column="1" Classes="mono" Text="{Binding InstanceId}"
                     Margin="0,6,0,0" />

          <TextBlock Grid.Row="2" Grid.Column="0" Classes="label" Text="Pfad" Margin="0,6,0,0" />
          <SelectableTextBlock Grid.Row="2" Grid.Column="1" Text="{Binding InstancePath}"
                               TextWrapping="Wrap" Margin="0,6,0,0" />

          <TextBlock Grid.Row="3" Grid.Column="0" Classes="label" Text="Log-Ordner" Margin="0,6,0,0" />
          <SelectableTextBlock Grid.Row="3" Grid.Column="1" Text="{Binding LogDirectory}"
                               TextWrapping="Wrap" Margin="0,6,0,0" />

          <TextBlock Grid.Row="4" Grid.Column="0" Classes="label" Text="OpenRouter" Margin="0,6,0,0" />
          <TextBlock Grid.Row="4" Grid.Column="1" Text="{Binding OpenRouterStatus}" Margin="0,6,0,0" />
        </Grid>
      </StackPanel>

      <Border Classes="hr" />

      <!-- Baugruppen -->
      <StackPanel Spacing="10">
        <TextBlock Classes="kicker" Text="MODULE" />
        <TextBlock Classes="h2" Text="Baugruppen" />

        <Border Classes="thead">
          <Grid ColumnDefinitions="1.6*,0.6*,1.4*,3*">
            <TextBlock Grid.Column="0" Classes="th" Text="MODUL" />
            <TextBlock Grid.Column="1" Classes="th" Text="BUILD" />
            <TextBlock Grid.Column="2" Classes="th" Text="BUILD-DATUM" />
            <TextBlock Grid.Column="3" Classes="th" Text="ÄNDERUNGEN" />
          </Grid>
        </Border>

        <ItemsControl ItemsSource="{Binding Assemblies}" Margin="0,-10,0,0">
          <ItemsControl.ItemTemplate>
            <DataTemplate DataType="vm:AssemblyInfoItem">
              <Border Classes="tr" Padding="7">
                <Grid ColumnDefinitions="1.6*,0.6*,1.4*,3*">
                  <TextBlock Grid.Column="0" Classes="td" FontWeight="SemiBold" Text="{Binding ShortName}" />
                  <TextBlock Grid.Column="1" Classes="td" Text="{Binding BuildNumber}" />
                  <TextBlock Grid.Column="2" Classes="td dim" Text="{Binding BuildDate}" />
                  <TextBlock Grid.Column="3" Classes="td dim" Text="{Binding Changes}" />
                </Grid>
              </Border>
            </DataTemplate>
          </ItemsControl.ItemTemplate>
        </ItemsControl>
      </StackPanel>

    </StackPanel>
  </ScrollViewer>

</UserControl>
