<Window x:Class="NexusShell.Views.UpdateInfoWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Nexus Updates"
        Width="900" Height="700"
        MinWidth="760" MinHeight="560"
        WindowStartupLocation="CenterOwner"
        Background="{StaticResource NexusNavyBrush}"
        WindowStyle="None"
        ResizeMode="CanResize">
    <Grid Margin="24">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <StackPanel>
            <TextBlock Text="Nexus OS Update Channel" FontSize="24" FontWeight="SemiBold"
                       Foreground="{StaticResource NexusTextPrimaryBrush}"/>
            <TextBlock Text="{Binding StatusLabel}" FontSize="14" Margin="0,6,0,0"
                       TextWrapping="Wrap"
                       Foreground="{StaticResource NexusAccentCyanBrush}"/>
            <TextBlock Text="{Binding ProgressLabel}" FontSize="12" Margin="0,4,0,0"
                       Foreground="{StaticResource NexusTextMutedBrush}"
                       Visibility="{Binding HasProgress, Converter={StaticResource BoolToVisibility}}"/>
        </StackPanel>

        <ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" Margin="0,16,0,16">
            <StackPanel>
                <Border Style="{StaticResource NexusGlassPanelStyle}" Padding="16" Margin="0,0,0,12">
                    <StackPanel>
                        <Grid Margin="0,0,0,8">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="Current version" Foreground="{StaticResource NexusTextMutedBrush}"/>
                            <TextBlock Grid.Column="1" Text="{Binding CurrentVersion}" Foreground="{StaticResource NexusTextPrimaryBrush}"/>
                        </Grid>
                        <Grid Margin="0,0,0,8">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="Current build" Foreground="{StaticResource NexusTextMutedBrush}"/>
                            <TextBlock Grid.Column="1" Text="{Binding CurrentBuild}" Foreground="{StaticResource NexusTextPrimaryBrush}"/>
                        </Grid>
                        <Grid Margin="0,0,0,8">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="Latest version" Foreground="{StaticResource NexusTextMutedBrush}"/>
                            <TextBlock Grid.Column="1" Text="{Binding LatestVersion}" Foreground="{StaticResource NexusTextPrimaryBrush}"/>
                        </Grid>
                        <Grid Margin="0,0,0,8">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="Latest build" Foreground="{StaticResource NexusTextMutedBrush}"/>
                            <TextBlock Grid.Column="1" Text="{Binding LatestBuild}" Foreground="{StaticResource NexusTextPrimaryBrush}"/>
                        </Grid>
                        <Grid Margin="0,0,0,8">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="Package size" Foreground="{StaticResource NexusTextMutedBrush}"/>
                            <TextBlock Grid.Column="1" Text="{Binding PackageSizeLabel}" Foreground="{StaticResource NexusTextPrimaryBrush}"/>
                        </Grid>
                        <Grid Margin="0,0,0,8">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="Channel" Foreground="{StaticResource NexusTextMutedBrush}"/>
                            <TextBlock Grid.Column="1" Text="{Binding Channel}" Foreground="{StaticResource NexusTextPrimaryBrush}"/>
                        </Grid>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="SHA256 preview" Foreground="{StaticResource NexusTextMutedBrush}"/>
                            <TextBlock Grid.Column="1" Text="{Binding Sha256Preview}" Foreground="{StaticResource NexusTextPrimaryBrush}"/>
                        </Grid>
                    </StackPanel>
                </Border>

                <TextBlock Text="Release notes" FontWeight="SemiBold" Foreground="{StaticResource NexusTextPrimaryBrush}" Margin="0,0,0,8"/>
                <ItemsControl ItemsSource="{Binding ReleaseNotes}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding StringFormat=• {0}}" TextWrapping="Wrap" Margin="0,0,0,4"
                                       Foreground="{StaticResource NexusTextMutedBrush}"/>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>

                <TextBlock Text="{Binding InstallNotice}" TextWrapping="Wrap" FontStyle="Italic" Margin="0,16,0,0"
                           Foreground="{StaticResource NexusAccentCyanBrush}" FontSize="12"/>
            </StackPanel>
        </ScrollViewer>

        <Border Grid.Row="2" BorderBrush="#33FFFFFF" BorderThickness="0,1,0,0" Padding="0,12,0,0">
            <StackPanel>
                <WrapPanel Orientation="Horizontal" Margin="0,0,0,8">
                    <Button Content="Download og installér" Command="{Binding DownloadAndInstallCommand}" Margin="0,0,8,8"
                            IsEnabled="{Binding CanDownloadAndInstall}" Style="{StaticResource NexusGlassButtonStyle}"/>
                    <Button Content="Download" Command="{Binding DownloadCommand}" Margin="0,0,8,8"
                            IsEnabled="{Binding CanDownload}" Style="{StaticResource NexusGlassButtonStyle}"/>
                    <Button Content="Installér" Command="{Binding InstallCommand}" Margin="0,0,8,8"
                            IsEnabled="{Binding CanInstall}" Style="{StaticResource NexusGlassButtonStyle}"/>
                    <Button Content="Prøv igen" Command="{Binding RetryCommand}" Margin="0,0,8,8"
                            IsEnabled="{Binding CanRetry}" Style="{StaticResource NexusGlassButtonStyle}"/>
                </WrapPanel>
                <WrapPanel Orientation="Horizontal">
                    <Button Content="Åbn logs" Command="{Binding OpenLogsCommand}" Margin="0,0,8,8"
                            Style="{StaticResource NexusGlassButtonStyle}"/>
                    <Button Content="Annuller" Command="{Binding CancelCommand}" Margin="0,0,8,8"
                            IsEnabled="{Binding CanCancel}" Style="{StaticResource NexusGlassButtonStyle}"/>
                    <Button Content="Ryd fastlåst" Command="{Binding ClearStuckCommand}" Margin="0,0,8,8"
                            IsEnabled="{Binding CanClearStuck}" Style="{StaticResource NexusGlassButtonStyle}"/>
                    <Button Content="Check igen" Command="{Binding RefreshCommand}" Margin="0,0,8,8"
                            IsEnabled="{Binding IsNotBusy}" Style="{StaticResource NexusGlassButtonStyle}"/>
                    <Button Content="Luk" Command="{Binding CloseCommand}" Margin="0,0,0,8"
                            Style="{StaticResource NexusGlassButtonStyle}"/>
                </WrapPanel>
            </StackPanel>
        </Border>
    </Grid>
</Window>
