<UserControl x:Class="ClaudeDo.Installer.Checks.CheckListView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:ClaudeDo.Installer.Checks"
             xmlns:loc="clr-namespace:ClaudeDo.Installer.Localization"
             d:DataContext="{d:DesignInstance local:CheckListViewModel}"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <!-- Check list -->
        <ScrollViewer Grid.Row="0" VerticalScrollBarVisibility="Auto">
            <ItemsControl ItemsSource="{Binding Rows}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate DataType="{x:Type local:CheckRowViewModel}">
                        <Border Margin="0,0,0,6" Padding="10,8"
                                Background="{StaticResource IslandBgBrush}"
                                BorderBrush="{StaticResource BorderSubtleBrush}"
                                BorderThickness="1" CornerRadius="4">
                            <StackPanel>
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>

                                    <Ellipse Grid.Column="0" Width="10" Height="10" Margin="0,0,10,0"
                                             VerticalAlignment="Top"
                                             Fill="{Binding StatusBrush}"/>

                                    <StackPanel Grid.Column="1">
                                        <TextBlock Text="{Binding Title}" FontSize="13" FontWeight="SemiBold"/>
                                        <TextBlock Text="{Binding Message}" FontSize="12"
                                                   Foreground="{StaticResource TextSecondaryBrush}"
                                                   TextWrapping="Wrap" Margin="0,2,0,0"/>

                                        <TextBlock Text="{Binding Hint}" FontSize="11"
                                                   Foreground="{StaticResource TextMutedBrush}"
                                                   TextWrapping="Wrap" Margin="0,4,0,0"
                                                   Visibility="{Binding Hint, Converter={StaticResource NullToCollapsedConverter}}"/>

                                        <Button Content="{Binding HelpUrl}"
                                                HorizontalAlignment="Left" Margin="-16,4,0,0"
                                                Background="Transparent" BorderThickness="0"
                                                Foreground="{StaticResource AccentLightBrush}"
                                                Cursor="Hand"
                                                Command="{Binding DataContext.OpenHelpUrlCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}"
                                                CommandParameter="{Binding HelpUrl}"
                                                Visibility="{Binding HelpUrl, Converter={StaticResource NullToCollapsedConverter}}"/>
                                    </StackPanel>
                                </Grid>
                            </StackPanel>
                        </Border>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </ScrollViewer>

        <!-- Progress + summary -->
        <StackPanel Grid.Row="1" Margin="0,8,0,0">
            <ProgressBar IsIndeterminate="True" Margin="0,0,0,8"
                         Visibility="{Binding IsRunning, Converter={StaticResource BoolToVisConverter}}"/>
            <TextBlock Text="{Binding Summary}" FontSize="12" TextWrapping="Wrap"
                       Foreground="{StaticResource TextSecondaryBrush}">
                <TextBlock.Style>
                    <Style TargetType="TextBlock">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding HasBlockingError}" Value="True">
                                <Setter Property="Foreground" Value="{StaticResource ErrorBrush}"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </TextBlock.Style>
            </TextBlock>
        </StackPanel>

        <!-- Footer -->
        <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,12,0,0">
            <Button Content="{loc:Tr installer.systemCheck.recheck}"
                    Command="{Binding RunChecksCommand}"/>
        </StackPanel>
    </Grid>
</UserControl>
