<UserControl xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:automation="clr-namespace:Avalonia.Automation;assembly=Avalonia.Controls"
             xmlns:vm="using:UniGetUI.Avalonia.ViewModels"
             xmlns:vmd="using:UniGetUI.Avalonia.ViewModels"
             xmlns:controls="using:UniGetUI.Avalonia.Views.Controls"
             x:Class="UniGetUI.Avalonia.Views.DialogPages.InstallOptionsControl"
             x:DataType="vm:InstallOptionsViewModel">

    <UserControl.Styles>
        <!-- WinUI-style rich tabs: roomy headers that hold an icon + two text lines. -->
        <Style Selector="TabItem">
            <Setter Property="Padding" Value="12,6"/>
            <Setter Property="MinHeight" Value="0"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
        </Style>
        <!-- WinUI tabs have no accent underline; the selected tab is shown by its background. -->
        <Style Selector="TabItem /template/ #PART_SelectedPipe" x:SetterTargetType="Control">
            <Setter Property="IsVisible" Value="False"/>
        </Style>
        <Style Selector="TabItem:selected /template/ #PART_SelectedPipe" x:SetterTargetType="Control">
            <Setter Property="IsVisible" Value="False"/>
        </Style>
    </UserControl.Styles>

    <StackPanel Spacing="12">

        <!-- ── Header: icon · title · profile selector ── -->
        <Grid ColumnDefinitions="Auto,*,Auto" ColumnSpacing="8">

            <Image Source="{Binding PackageIcon}"
                   Width="32" Height="32"
                   automation:AutomationProperties.AccessibilityView="Raw"
                   VerticalAlignment="Center"/>

            <TextBlock Grid.Column="1"
                       automation:AutomationProperties.Name="{Binding DialogTitle}"
                       Text="{Binding DialogTitle}"
                       FontSize="24" FontWeight="Bold"
                       TextWrapping="Wrap"
                       VerticalAlignment="Center"/>

            <StackPanel Grid.Column="2" Spacing="3" VerticalAlignment="Center">
                <TextBlock x:Name="ProfileLabelBlock"
                           Text="{Binding ProfileLabel}"
                           FontSize="14" Opacity="0.7"/>
                <ComboBox x:Name="ProfileSelectorComboBox"
                          ItemsSource="{Binding ProfileOptions}"
                          SelectedItem="{Binding SelectedProfile}"
                          automation:AutomationProperties.LabeledBy="{Binding #ProfileLabelBlock}"
                          MinWidth="110"/>
            </StackPanel>
        </Grid>

        <!-- ── Follow-global-options card ── -->
        <Border Background="{DynamicResource AppDialogPanelBackground}" CornerRadius="8" Padding="16,8">
            <Grid ColumnDefinitions="*,Auto" RowDefinitions="Auto,Auto" ColumnSpacing="8">
                <TextBlock x:Name="FollowGlobalLabelBlock"
                           Grid.Row="0" Grid.Column="0"
                           Text="{Binding FollowGlobalLabel}"
                           TextWrapping="Wrap"
                           VerticalAlignment="Center"/>
                <HyperlinkButton Grid.Row="1" Grid.Column="0"
                                 Content="{Binding ChangeDefaultOptionsLabel}"
                                 automation:AutomationProperties.Name="{Binding ChangeDefaultOptionsLabel}"
                                 Command="{Binding ChangeDefaultOptionsCommand}"
                                 Padding="0" Margin="0,2,0,0"
                                 HorizontalAlignment="Left"/>
                <ToggleSwitch Grid.RowSpan="2" Grid.Column="1"
                              IsChecked="{Binding FollowGlobal}"
                              automation:AutomationProperties.LabeledBy="{Binding #FollowGlobalLabelBlock}"
                              OnContent="" OffContent=""
                              VerticalAlignment="Center"/>
            </Grid>
        </Border>

        <!-- ── Options area + lock overlay ── -->
        <Grid>
          <StackPanel Spacing="12">

            <!-- Explainer (applies to every tab, like WinUI) -->
            <TextBlock Text="{Binding GeneralInfoLabel}"
                       Opacity="0.7"
                       TextWrapping="Wrap"
                       Margin="4,0"/>

            <TabControl IsEnabled="{Binding IsCustomMode}"
                        Background="Transparent">

            <!-- Tab 0: General -->
            <TabItem>
                <TabItem.Header>
                    <StackPanel Orientation="Horizontal" Spacing="8">
                        <controls:SvgIcon Path="avares://UniGetUI/Assets/Symbols/settings.svg"
                                          Width="20" Height="20" VerticalAlignment="Center"/>
                        <StackPanel VerticalAlignment="Center">
                            <TextBlock Text="{Binding TabGeneralLine1}" FontSize="14"/>
                            <TextBlock Text="{Binding TabGeneralLine2}" FontSize="12" Opacity="0.7"/>
                        </StackPanel>
                    </StackPanel>
                </TabItem.Header>
                <Border Background="{DynamicResource AppDialogPanelBackground}" CornerRadius="0,8,8,8" Padding="16">
                    <StackPanel Spacing="8">

                        <WrapPanel Orientation="Horizontal">
                            <CheckBox Content="{Binding AdminCheckBox_Content, FallbackValue='Run as admin'}"
                                      IsChecked="{Binding AdminChecked}"
                                      IsEnabled="{Binding CanRunAsAdmin}"
                                      IsVisible="{Binding CanRunAsAdmin}"
                                      automation:AutomationProperties.Name="{Binding AdminCheckBox_Content}"
                                      Margin="0,0,16,4"/>
                            <CheckBox Content="{Binding InteractiveCheckBox_Content, FallbackValue='Interactive installation'}"
                                      IsChecked="{Binding InteractiveChecked}"
                                      IsEnabled="{Binding CanRunInteractively}"
                                      automation:AutomationProperties.Name="{Binding InteractiveCheckBox_Content}"
                                      Margin="0,0,16,4"/>
                            <CheckBox Content="{Binding SkipHashCheckBox_Content, FallbackValue='Skip hash check'}"
                                      IsChecked="{Binding SkipHashChecked}"
                                      IsEnabled="{Binding SkipHashEnabled}"
                                      automation:AutomationProperties.Name="{Binding SkipHashCheckBox_Content}"
                                      Margin="0,0,16,4"/>
                            <CheckBox Content="{Binding UninstallPrevCheckBox_Content, FallbackValue='Uninstall previous versions when updated'}"
                                      IsChecked="{Binding UninstallPrevChecked}"
                                      IsEnabled="{Binding CanUninstallPrev}"
                                      IsVisible="{Binding CanUninstallPrev}"
                                      automation:AutomationProperties.Name="{Binding UninstallPrevCheckBox_Content}"
                                      Margin="0,0,16,4"/>
                        </WrapPanel>

                        <Border Height="1" Background="{DynamicResource AppBorderBrush}"
                                automation:AutomationProperties.AccessibilityView="Raw"/>

                        <Grid ColumnDefinitions="*,*" ColumnSpacing="8">
                            <TextBlock x:Name="VersionLabelBlock"
                                       Text="{Binding VersionLabel}"
                                       VerticalAlignment="Center"/>
                            <ComboBox Grid.Column="1"
                                      ItemsSource="{Binding VersionOptions}"
                                      SelectedItem="{Binding SelectedVersion}"
                                      IsEnabled="{Binding VersionEnabled}"
                                      automation:AutomationProperties.LabeledBy="{Binding #VersionLabelBlock}"
                                      HorizontalAlignment="Stretch"/>
                        </Grid>

                        <Border Height="1" Background="{DynamicResource AppBorderBrush}"
                                automation:AutomationProperties.AccessibilityView="Raw"/>

                        <StackPanel Orientation="Vertical" Spacing="4">
                            <CheckBox Content="{Binding IgnoreUpdatesCheckBox_Content, FallbackValue='Ignore future updates for this package'}"
                                      IsChecked="{Binding IgnoreUpdatesChecked}"
                                      automation:AutomationProperties.Name="{Binding IgnoreUpdatesCheckBox_Content}"/>
                            <CheckBox Content="{Binding AutoUpdateCheckBox_Content, FallbackValue='Auto-update this package'}"
                                      IsChecked="{Binding AutoUpdateChecked}"
                                      automation:AutomationProperties.Name="{Binding AutoUpdateCheckBox_Content}"/>
                            <CheckBox Content="{Binding SkipMinorCheckBox_Content, FallbackValue='Skip minor updates'}"
                                      IsChecked="{Binding SkipMinorChecked}"
                                      automation:AutomationProperties.Name="{Binding SkipMinorCheckBox_Content}"/>
                            <WrapPanel Orientation="Horizontal" Margin="28,0,0,0"
                                       IsEnabled="{Binding SkipMinorChecked}">
                                <TextBlock Text="{Binding SkipMinorLevelPrefix_Content, FallbackValue='Ignore changes after the first'}"
                                           VerticalAlignment="Center" Margin="0,0,8,0" TextWrapping="Wrap"/>
                                <ComboBox ItemsSource="{Binding SkipMinorLevelOptions}"
                                          SelectedIndex="{Binding SkipMinorLevelIndex}"
                                          automation:AutomationProperties.Name="{Binding SkipMinorLevelPrefix_Content}"
                                          VerticalAlignment="Center" MinWidth="64"/>
                                <TextBlock Text="{Binding SkipMinorLevelSuffix_Content, FallbackValue='version numbers'}"
                                           VerticalAlignment="Center" Margin="8,0,0,0" TextWrapping="Wrap"/>
                            </WrapPanel>
                        </StackPanel>

                    </StackPanel>
                </Border>
            </TabItem>

            <!-- Tab 1: Architecture, Scope & Location -->
            <TabItem>
                <TabItem.Header>
                    <StackPanel Orientation="Horizontal" Spacing="8">
                        <controls:SvgIcon Path="avares://UniGetUI/Assets/Symbols/open_folder.svg"
                                          Width="20" Height="20" VerticalAlignment="Center"/>
                        <StackPanel VerticalAlignment="Center">
                            <TextBlock Text="{Binding TabLocationLine1}" FontSize="14"/>
                            <TextBlock Text="{Binding TabLocationLine2}" FontSize="12" Opacity="0.7"/>
                        </StackPanel>
                    </StackPanel>
                </TabItem.Header>
                <Border Background="{DynamicResource AppDialogPanelBackground}" CornerRadius="0,8,8,8" Padding="16">
                    <StackPanel Spacing="8">

                        <Grid ColumnDefinitions="*,*" ColumnSpacing="8">
                            <TextBlock x:Name="ArchLabelBlock" Text="{Binding ArchLabel}" VerticalAlignment="Center"/>
                            <ComboBox Grid.Column="1"
                                      ItemsSource="{Binding ArchOptions}"
                                      SelectedItem="{Binding SelectedArch}"
                                      IsEnabled="{Binding ArchEnabled}"
                                      automation:AutomationProperties.LabeledBy="{Binding #ArchLabelBlock}"
                                      HorizontalAlignment="Stretch"/>
                        </Grid>

                        <Border Height="1" Background="{DynamicResource AppBorderBrush}"
                                automation:AutomationProperties.AccessibilityView="Raw"/>

                        <Grid ColumnDefinitions="*,*" ColumnSpacing="8">
                            <TextBlock x:Name="ScopeLabelBlock" Text="{Binding ScopeLabel}" VerticalAlignment="Center"/>
                            <ComboBox Grid.Column="1"
                                      ItemsSource="{Binding ScopeOptions}"
                                      SelectedItem="{Binding SelectedScope}"
                                      IsEnabled="{Binding ScopeEnabled}"
                                      automation:AutomationProperties.LabeledBy="{Binding #ScopeLabelBlock}"
                                      HorizontalAlignment="Stretch"/>
                        </Grid>

                        <Border Height="1" Background="{DynamicResource AppBorderBrush}"
                                automation:AutomationProperties.AccessibilityView="Raw"/>

                        <Grid ColumnDefinitions="*,Auto,Auto" ColumnSpacing="6">
                            <TextBlock x:Name="LocationLabelBlock" Text="{Binding LocationLabel}" VerticalAlignment="Center"/>
                            <Button Grid.Column="1"
                                    Content="{Binding SelectDirLabel}"
                                    automation:AutomationProperties.Name="{Binding SelectDirLabel}"
                                    automation:AutomationProperties.HelpText="{Binding LocationLabel}"
                                    IsEnabled="{Binding HasCustomLocations}"
                                    Padding="8,3" CornerRadius="4"
                                    Click="SelectDir_Click"/>
                            <Button Grid.Column="2"
                                    Content="{Binding ResetDirLabel}"
                                    automation:AutomationProperties.Name="{Binding ResetDirLabel}"
                                    automation:AutomationProperties.HelpText="{Binding LocationLabel}"
                                    IsEnabled="{Binding HasCustomLocations}"
                                    Padding="8,3" CornerRadius="4"
                                    Command="{Binding ResetLocationCommand}"/>
                        </Grid>

                        <TextBox Text="{Binding LocationText}"
                                 IsEnabled="{Binding LocationEnabled}"
                                 automation:AutomationProperties.LabeledBy="{Binding #LocationLabelBlock}"
                                 FontFamily="Consolas,Cascadia Mono,Menlo,monospace"
                                 FontSize="14"
                                 HorizontalAlignment="Stretch"/>

                        <Grid ColumnDefinitions="*,Auto" ColumnSpacing="8"
                              IsVisible="{Binding LocationEnabled}">
                            <TextBlock Text="{Binding EnvVarSyntaxHintLabel}"
                                       VerticalAlignment="Center"
                                       TextWrapping="Wrap"
                                       Opacity="0.7"
                                       FontSize="12"/>
                            <HyperlinkButton Grid.Column="1"
                                             Content="{Binding ChangeEnvVarSyntaxLabel}"
                                             Command="{Binding GoToOperationsSettingsCommand}"
                                             VerticalAlignment="Center"
                                             Padding="0" FontSize="12"/>
                        </Grid>

                    </StackPanel>
                </Border>
            </TabItem>

            <!-- Tab 2: Custom CLI arguments -->
            <TabItem>
                <TabItem.Header>
                    <StackPanel Orientation="Horizontal" Spacing="8">
                        <controls:SvgIcon Path="avares://UniGetUI/Assets/Symbols/console.svg"
                                          Width="20" Height="20" VerticalAlignment="Center"/>
                        <StackPanel VerticalAlignment="Center">
                            <TextBlock Text="{Binding TabCLILine1}" FontSize="14"/>
                            <TextBlock Text="{Binding TabCLILine2}" FontSize="12" Opacity="0.7"/>
                        </StackPanel>
                    </StackPanel>
                </TabItem.Header>
                <Border Background="{DynamicResource AppDialogPanelBackground}" CornerRadius="0,8,8,8" Padding="16">
                    <StackPanel Spacing="8">

                      <!-- Security warning shown when custom CLI arguments are disabled -->
                      <TextBlock Text="{Binding CliDisabledLabel}"
                                 IsVisible="{Binding CliDisabledWarningVisible}"
                                 Foreground="{DynamicResource StatusWarningForeground}"
                                 TextWrapping="Wrap"/>
                      <HyperlinkButton Content="{Binding GoToSecurityLabel}"
                                       IsVisible="{Binding CliDisabledWarningVisible}"
                                       Command="{Binding GoToSecuritySettingsCommand}"
                                       HorizontalAlignment="Left" Padding="0" FontWeight="SemiBold"/>

                      <TextBlock Text="{Binding CliArgsHintLabel}"
                                 IsVisible="{Binding CliEnabled}"
                                 TextWrapping="Wrap"
                                 Opacity="0.7"
                                 FontSize="12"/>

                      <Grid ColumnDefinitions="*,Auto" ColumnSpacing="8"
                            IsVisible="{Binding CliEnabled}">
                          <TextBlock Text="{Binding EnvVarSyntaxHintLabel}"
                                     VerticalAlignment="Center"
                                     TextWrapping="Wrap"
                                     Opacity="0.7"
                                     FontSize="12"/>
                          <HyperlinkButton Grid.Column="1"
                                           Content="{Binding ChangeEnvVarSyntaxLabel}"
                                           Command="{Binding GoToOperationsSettingsCommand}"
                                           VerticalAlignment="Center"
                                           Padding="0" FontSize="12"/>
                      </Grid>

                      <Grid ColumnDefinitions="*,2*"
                            RowDefinitions="Auto,Auto,Auto"
                            ColumnSpacing="8" RowSpacing="8"
                            IsEnabled="{Binding CliEnabled}">

                        <TextBlock x:Name="ParamsInstallLabelBlock" Text="{Binding ParamsInstallLabel}"
                                   VerticalAlignment="Center"/>
                        <TextBox Grid.Column="1"
                                 Text="{Binding ParamsInstall}"
                                 automation:AutomationProperties.LabeledBy="{Binding #ParamsInstallLabelBlock}"
                                 FontFamily="Consolas,Cascadia Mono,Menlo,monospace"
                                 FontSize="14"/>

                        <TextBlock x:Name="ParamsUpdateLabelBlock" Grid.Row="1"
                                   Text="{Binding ParamsUpdateLabel}"
                                   VerticalAlignment="Center"/>
                        <TextBox Grid.Row="1" Grid.Column="1"
                                 Text="{Binding ParamsUpdate}"
                                 automation:AutomationProperties.LabeledBy="{Binding #ParamsUpdateLabelBlock}"
                                 FontFamily="Consolas,Cascadia Mono,Menlo,monospace"
                                 FontSize="14"/>

                        <TextBlock x:Name="ParamsUninstallLabelBlock" Grid.Row="2"
                                   Text="{Binding ParamsUninstallLabel}"
                                   VerticalAlignment="Center"/>
                        <TextBox Grid.Row="2" Grid.Column="1"
                                 Text="{Binding ParamsUninstall}"
                                 automation:AutomationProperties.LabeledBy="{Binding #ParamsUninstallLabelBlock}"
                                 FontFamily="Consolas,Cascadia Mono,Menlo,monospace"
                                 FontSize="14"/>

                      </Grid>

                      <HyperlinkButton Content="{Binding CopyInstallArgsLabel}"
                                       IsVisible="{Binding CliEnabled}"
                                       automation:AutomationProperties.Name="{Binding CopyInstallArgsLabel}"
                                       Command="{Binding CopyInstallArgsToOthersCommand}"
                                       Padding="0"
                                       HorizontalAlignment="Left"/>
                    </StackPanel>
                </Border>
            </TabItem>

            <!-- Tab 3: Close apps before installing -->
            <TabItem>
                <TabItem.Header>
                    <StackPanel Orientation="Horizontal" Spacing="8">
                        <controls:SvgIcon Path="avares://UniGetUI/Assets/Symbols/cross.svg"
                                          Width="20" Height="20" VerticalAlignment="Center"/>
                        <StackPanel VerticalAlignment="Center">
                            <TextBlock Text="{Binding TabCloseAppsLine1}" FontSize="14"/>
                            <TextBlock Text="{Binding TabCloseAppsLine2}" FontSize="12" Opacity="0.7"/>
                        </StackPanel>
                    </StackPanel>
                </TabItem.Header>
                <Border Background="{DynamicResource AppDialogPanelBackground}" CornerRadius="0,8,8,8" Padding="16">
                    <StackPanel Spacing="8">

                        <TextBlock Text="{Binding KillProcessesDescriptionLabel}"
                                   TextWrapping="Wrap"
                                   Opacity="0.7"/>

                        <TextBox x:Name="KillProcessNewEntryBox"
                                 Text="{Binding KillProcessNewEntry}"
                                 PlaceholderText="{Binding KillProcessesPlaceholderLabel}"
                                 HorizontalAlignment="Stretch"
                                 KeyDown="KillProcessBox_KeyDown"/>

                        <ItemsControl ItemsSource="{Binding KillProcessEntries}">
                            <ItemsControl.ItemTemplate>
                                <DataTemplate x:DataType="vmd:KillProcessEntry">
                                    <Grid ColumnDefinitions="*,Auto" Margin="0,2">
                                        <TextBlock Text="{Binding Name}"
                                                   VerticalAlignment="Center"
                                                   FontFamily="Consolas,Cascadia Mono,Menlo,monospace"
                                                   FontSize="14"/>
                                        <Button Grid.Column="1"
                                                Content="✕"
                                                Command="{Binding RemoveCommand}"
                                                Padding="6,2" Margin="8,0,0,0"
                                                VerticalAlignment="Center"/>
                                    </Grid>
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                        </ItemsControl>

                        <Border Height="1" Background="{DynamicResource AppBorderBrush}"
                                automation:AutomationProperties.AccessibilityView="Raw"/>

                        <CheckBox Content="{Binding ForceKillLabelText}"
                                  IsChecked="{Binding ForceKillChecked}"
                                  automation:AutomationProperties.Name="{Binding ForceKillLabelText}"/>

                    </StackPanel>
                </Border>
            </TabItem>

            <!-- Tab 4: Pre/Post commands -->
            <TabItem>
                <TabItem.Header>
                    <StackPanel Orientation="Horizontal" Spacing="8">
                        <controls:SvgIcon Path="avares://UniGetUI/Assets/Symbols/clipboard_list.svg"
                                          Width="20" Height="20" VerticalAlignment="Center"/>
                        <StackPanel VerticalAlignment="Center">
                            <TextBlock Text="{Binding TabPrePostLine1}" FontSize="14"/>
                            <TextBlock Text="{Binding TabPrePostLine2}" FontSize="12" Opacity="0.7"/>
                        </StackPanel>
                    </StackPanel>
                </TabItem.Header>
                <Border Background="{DynamicResource AppDialogPanelBackground}" CornerRadius="0,8,8,8" Padding="16">
                    <StackPanel Spacing="10">

                        <!-- Security warning shown when pre/post scripts are disabled -->
                        <TextBlock Text="{Binding PrePostDisabledLabel}"
                                   IsVisible="{Binding PrePostDisabledWarningVisible}"
                                   Foreground="{DynamicResource StatusWarningForeground}"
                                   TextWrapping="Wrap"/>
                        <HyperlinkButton Content="{Binding GoToSecurityLabel}"
                                         IsVisible="{Binding PrePostDisabledWarningVisible}"
                                         Command="{Binding GoToSecuritySettingsCommand}"
                                         HorizontalAlignment="Left" Padding="0" FontWeight="SemiBold"/>
                        <TextBlock Text="{Binding PrePostExplainerLabel}" TextWrapping="Wrap" Opacity="0.7"/>

                        <!-- Install -->
                        <Grid ColumnDefinitions="*,*"
                              RowDefinitions="Auto,56,Auto"
                              ColumnSpacing="8" RowSpacing="4"
                              IsEnabled="{Binding PrePostEnabled}">
                            <TextBlock x:Name="PreInstallLabelBlock" Text="{Binding PreInstallLabel}" FontSize="12"/>
                            <TextBlock x:Name="PostInstallLabelBlock" Grid.Column="1"
                                       Text="{Binding PostInstallLabel}" FontSize="12"/>
                            <TextBox Grid.Row="1"
                                     Text="{Binding PreInstallText}"
                                     AcceptsReturn="True"
                                     automation:AutomationProperties.LabeledBy="{Binding #PreInstallLabelBlock}"
                                     FontFamily="Consolas,Cascadia Mono,Menlo,monospace"
                                     FontSize="14"/>
                            <TextBox Grid.Row="1" Grid.Column="1"
                                     Text="{Binding PostInstallText}"
                                     AcceptsReturn="True"
                                     automation:AutomationProperties.LabeledBy="{Binding #PostInstallLabelBlock}"
                                     FontFamily="Consolas,Cascadia Mono,Menlo,monospace"
                                     FontSize="14"/>
                            <CheckBox Grid.Row="2" Grid.ColumnSpan="2"
                                      Content="{Binding AbortInstallLabel}"
                                      automation:AutomationProperties.Name="{Binding AbortInstallLabel}"
                                      IsChecked="{Binding AbortInstall}"/>
                        </Grid>

                        <Border Height="1" Background="{DynamicResource AppBorderBrush}"
                                automation:AutomationProperties.AccessibilityView="Raw"/>

                        <!-- Update -->
                        <Grid ColumnDefinitions="*,*"
                              RowDefinitions="Auto,56,Auto"
                              ColumnSpacing="8" RowSpacing="4"
                              IsEnabled="{Binding PrePostEnabled}">
                            <TextBlock x:Name="PreUpdateLabelBlock" Text="{Binding PreUpdateLabel}" FontSize="12"/>
                            <TextBlock x:Name="PostUpdateLabelBlock" Grid.Column="1"
                                       Text="{Binding PostUpdateLabel}" FontSize="12"/>
                            <TextBox Grid.Row="1"
                                     Text="{Binding PreUpdateText}"
                                     AcceptsReturn="True"
                                     automation:AutomationProperties.LabeledBy="{Binding #PreUpdateLabelBlock}"
                                     FontFamily="Consolas,Cascadia Mono,Menlo,monospace"
                                     FontSize="14"/>
                            <TextBox Grid.Row="1" Grid.Column="1"
                                     Text="{Binding PostUpdateText}"
                                     AcceptsReturn="True"
                                     automation:AutomationProperties.LabeledBy="{Binding #PostUpdateLabelBlock}"
                                     FontFamily="Consolas,Cascadia Mono,Menlo,monospace"
                                     FontSize="14"/>
                            <CheckBox Grid.Row="2" Grid.ColumnSpan="2"
                                      Content="{Binding AbortUpdateLabel}"
                                      automation:AutomationProperties.Name="{Binding AbortUpdateLabel}"
                                      IsChecked="{Binding AbortUpdate}"/>
                        </Grid>

                        <Border Height="1" Background="{DynamicResource AppBorderBrush}"
                                automation:AutomationProperties.AccessibilityView="Raw"/>

                        <!-- Uninstall -->
                        <Grid ColumnDefinitions="*,*"
                              RowDefinitions="Auto,56,Auto"
                              ColumnSpacing="8" RowSpacing="4"
                              IsEnabled="{Binding PrePostEnabled}">
                            <TextBlock x:Name="PreUninstallLabelBlock" Text="{Binding PreUninstallLabel}" FontSize="12"/>
                            <TextBlock x:Name="PostUninstallLabelBlock" Grid.Column="1"
                                       Text="{Binding PostUninstallLabel}" FontSize="12"/>
                            <TextBox Grid.Row="1"
                                     Text="{Binding PreUninstallText}"
                                     AcceptsReturn="True"
                                     automation:AutomationProperties.LabeledBy="{Binding #PreUninstallLabelBlock}"
                                     FontFamily="Consolas,Cascadia Mono,Menlo,monospace"
                                     FontSize="14"/>
                            <TextBox Grid.Row="1" Grid.Column="1"
                                     Text="{Binding PostUninstallText}"
                                     AcceptsReturn="True"
                                     automation:AutomationProperties.LabeledBy="{Binding #PostUninstallLabelBlock}"
                                     FontFamily="Consolas,Cascadia Mono,Menlo,monospace"
                                     FontSize="14"/>
                            <CheckBox Grid.Row="2" Grid.ColumnSpan="2"
                                      Content="{Binding AbortUninstallLabel}"
                                      automation:AutomationProperties.Name="{Binding AbortUninstallLabel}"
                                      IsChecked="{Binding AbortUninstall}"/>
                        </Grid>

                    </StackPanel>
                </Border>
            </TabItem>

            </TabControl>

          </StackPanel>

          <!-- Lock overlay shown while following the default options. A translucent solid
               layer (composites over the in-app tabs so they show faintly behind); Avalonia
               has no in-app gaussian blur, so this is the closest readable equivalent. -->
          <Panel IsVisible="{Binding FollowGlobal}">
            <Border Background="{DynamicResource AppDialogBackground}" Opacity="0.7" IsHitTestVisible="True"/>
            <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"
                        Spacing="12" Margin="24" MaxWidth="420">
              <TextBlock Text="{Binding PlaceholderText}"
                         FontSize="20" FontWeight="SemiBold"
                         TextAlignment="Center" TextWrapping="Wrap"/>
              <Button Content="{Binding UnlockLabel}"
                      HorizontalAlignment="Center"
                      Padding="12,5" CornerRadius="4"
                      Command="{Binding UnlockCommand}"/>
            </StackPanel>
          </Panel>
        </Grid>

        <!-- ── Command-line preview ── -->
        <Border Background="{DynamicResource AppDialogPanelBackground}" CornerRadius="8" Padding="12">
            <StackPanel Spacing="6">
                <Grid ColumnDefinitions="*,Auto" ColumnSpacing="8">
                    <TextBlock Grid.Column="0" Text="{Binding CommandPreviewLabel}" Opacity="0.7"
                               VerticalAlignment="Center"/>
                    <Button Grid.Column="1" x:Name="ManualButton"
                            Content="{Binding ManualActionLabel}"
                            automation:AutomationProperties.Name="{Binding ManualActionLabel}"
                            Padding="10,4" CornerRadius="4"
                            Click="Manual_Click"/>
                </Grid>
                <Border Background="{DynamicResource AppDialogDarkBackground}" CornerRadius="4" Padding="8">
                    <SelectableTextBlock Text="{Binding CommandPreview}"
                               automation:AutomationProperties.Name="{Binding CommandPreviewLabel}"
                               FontFamily="Consolas,Cascadia Mono,Menlo,monospace"
                               FontSize="14"
                               TextWrapping="Wrap"/>
                </Border>
            </StackPanel>
        </Border>

    </StackPanel>
</UserControl>
