<UserControl xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:vm="using:ClaudeDo.Ui.ViewModels.Modals"
             x:Class="ClaudeDo.Ui.Views.Controls.DiffLinesView"
             x:Name="Root">

  <UserControl.Styles>
    <!-- diff line row tints via Tag selector (compiled-binding-friendly) -->
    <Style Selector="Border.diff-line[Tag=add]">
      <Setter Property="Background" Value="{StaticResource RunningTintBrush}"/>
    </Style>
    <Style Selector="Border.diff-line[Tag=del]">
      <Setter Property="Background" Value="{StaticResource ErrorTintBrush}"/>
    </Style>
    <Style Selector="Border.diff-line[Tag=ctx]">
      <Setter Property="Background" Value="Transparent"/>
    </Style>
    <Style Selector="Border.diff-line[Tag=file]">
      <Setter Property="Background" Value="{StaticResource Surface3Brush}"/>
    </Style>
    <Style Selector="Border.diff-line[Tag=add] TextBlock.diff-sign">
      <Setter Property="Foreground" Value="{StaticResource MossBrightBrush}"/>
    </Style>
    <Style Selector="Border.diff-line[Tag=del] TextBlock.diff-sign">
      <Setter Property="Foreground" Value="{StaticResource BloodBrush}"/>
    </Style>
    <Style Selector="Border.diff-line[Tag=ctx] TextBlock.diff-sign">
      <Setter Property="Foreground" Value="{StaticResource TextFaintBrush}"/>
    </Style>
    <Style Selector="Border.diff-line[Tag=add] TextBlock.diff-text">
      <Setter Property="Foreground" Value="{StaticResource MossBrightBrush}"/>
    </Style>
    <Style Selector="Border.diff-line[Tag=del] TextBlock.diff-text">
      <Setter Property="Foreground" Value="{StaticResource BloodBrush}"/>
    </Style>
    <Style Selector="Border.diff-line[Tag=ctx] TextBlock.diff-text">
      <Setter Property="Foreground" Value="{StaticResource TextDimBrush}"/>
    </Style>
    <Style Selector="Border.diff-line[Tag=file] TextBlock.diff-text">
      <Setter Property="Foreground" Value="{StaticResource TextBrush}"/>
      <Setter Property="FontWeight" Value="SemiBold"/>
    </Style>
  </UserControl.Styles>

  <ItemsControl ItemsSource="{Binding #Root.Lines}">
    <ItemsControl.ItemTemplate>
      <DataTemplate x:DataType="vm:DiffLineViewModel">
        <Border Classes="diff-line"
                Tag="{Binding ClassName}"
                Padding="4,1">
          <Grid ColumnDefinitions="48,48,16,*">
            <!-- Old line number -->
            <TextBlock Grid.Column="0"
                       Text="{Binding OldNo}"
                       Classes="diff-lineno"
                       HorizontalAlignment="Right"
                       Margin="0,0,8,0"/>
            <!-- New line number -->
            <TextBlock Grid.Column="1"
                       Text="{Binding NewNo}"
                       Classes="diff-lineno"
                       HorizontalAlignment="Right"
                       Margin="0,0,8,0"/>
            <!-- Sign -->
            <TextBlock Grid.Column="2"
                       Classes="diff-sign"
                       Text="{Binding Sign}"
                       FontFamily="{DynamicResource MonoFont}"
                       FontSize="{StaticResource FontSizeMono}"/>
            <!-- Line text -->
            <TextBlock Grid.Column="3"
                       Classes="diff-text"
                       Text="{Binding Text}"
                       FontFamily="{DynamicResource MonoFont}"
                       FontSize="{StaticResource FontSizeMono}"
                       TextWrapping="NoWrap"/>
          </Grid>
        </Border>
      </DataTemplate>
    </ItemsControl.ItemTemplate>
  </ItemsControl>
</UserControl>
