<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Apply Changes" 
        Width="500"
        SizeToContent="Height"
        ResizeMode="NoResize"
        WindowStartupLocation="CenterOwner"
        WindowStyle="None"
        AllowsTransparency="True"
        Background="Transparent"
        Topmost="True"
        ShowInTaskbar="False">

    <Border BorderBrush="{DynamicResource BorderColor}" 
            BorderThickness="1" 
            CornerRadius="8"
            Background="{DynamicResource CardBgColor}"
            Margin="25">
        <Border.Effect>
            <DropShadowEffect Color="Black" 
                            Opacity="0.15" 
                            BlurRadius="20" 
                            ShadowDepth="0" 
                            Direction="0"/>
        </Border.Effect>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <!-- Close/Cancel button (top right) -->
            <Button x:Name="ApplyCancelBtn" Grid.Row="0"
                    HorizontalAlignment="Right" VerticalAlignment="Top"
                    Width="36" Height="32"
                    BorderThickness="0"
                    Cursor="Hand"
                    ToolTip="Cancel"
                    AutomationProperties.Name="Cancel">
                <Button.Template>
                    <ControlTemplate TargetType="Button">
                        <Border Background="{TemplateBinding Background}" BorderThickness="0" CornerRadius="0,8,0,0">
                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Border>
                    </ControlTemplate>
                </Button.Template>
                <Button.Style>
                    <Style TargetType="Button">
                        <Setter Property="Background" Value="Transparent"/>
                        <Setter Property="Foreground" Value="{DynamicResource FgColor}"/>
                        <Style.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Background" Value="{DynamicResource CloseHover}"/>
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </Button.Style>
                <TextBlock Text="&#xE8BB;" FontFamily="Segoe Fluent Icons" FontSize="10"/>
            </Button>

            <StackPanel Grid.Row="0" Grid.RowSpan="2">
            <!-- In-progress content -->
            <StackPanel x:Name="ApplyInProgressPanel">
                <StackPanel Margin="32,24">
                    <!-- Loading icon (spinning) -->
                    <TextBlock x:Name="ApplySpinnerIcon"
                            Text="&#xE895;" 
                            FontFamily="Segoe Fluent Icons" 
                            FontSize="36" 
                            Foreground="{DynamicResource ButtonBg}" 
                            HorizontalAlignment="Center" 
                            Margin="0,0,0,16"
                            RenderTransformOrigin="0.5,0.5">
                        <TextBlock.RenderTransform>
                            <RotateTransform x:Name="SpinnerRotation" Angle="0"/>
                        </TextBlock.RenderTransform>
                        <TextBlock.Triggers>
                            <EventTrigger RoutedEvent="Loaded">
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="SpinnerRotation"
                                                        Storyboard.TargetProperty="Angle"
                                                        From="0" To="360"
                                                        Duration="0:0:1.5"
                                                        RepeatBehavior="Forever"/>
                                    </Storyboard>
                                </BeginStoryboard>
                            </EventTrigger>
                        </TextBlock.Triggers>
                    </TextBlock>
                    
                    <TextBlock Text="Applying Changes" 
                            Style="{DynamicResource ModalTitleStyle}"/>

                    <!-- Current step name -->
                    <TextBlock x:Name="ApplyStepName" 
                                Text="Preparing..." 
                                Style="{DynamicResource ModalSubtextStyle}"
                                TextTrimming="CharacterEllipsis"
                                MaxWidth="430"/>
                </StackPanel>
                
                <Border Background="{DynamicResource BgColor}"
                        BorderBrush="{DynamicResource BorderColor}"
                        BorderThickness="0,1,0,0"
                        Padding="16,12"
                        CornerRadius="0,0,8,8">
                    <StackPanel>
                    
                    <!-- Progress bar -->
                    <ProgressBar x:Name="ApplyProgressBar" 
                                    Style="{DynamicResource ApplyProgressBarStyle}"
                                    Minimum="0" Maximum="100" Value="0" 
                                    Margin="0,2,0,8"/>
                    
                    <!-- Step counter -->
                    <TextBlock x:Name="ApplyStepCounter" 
                            Text="Step 0 of 0" 
                            FontSize="12" 
                            Foreground="{DynamicResource FgColor}" 
                            HorizontalAlignment="Right" 
                            Opacity="0.8"/>
                    </StackPanel>
                </Border>
            </StackPanel>
            
            <!-- Completion content -->
            <StackPanel x:Name="ApplyCompletionPanel" Visibility="Collapsed">
                <StackPanel Margin="32,24">
                    <!-- Success icon -->
                    <TextBlock x:Name="ApplyCompletionIcon" 
                            Text="&#xE73E;" 
                            FontFamily="Segoe Fluent Icons" 
                            FontSize="40"
                            Foreground="{DynamicResource ButtonBg}" 
                            HorizontalAlignment="Center" 
                            Margin="0,0,0,12"/>
                    
                    <TextBlock x:Name="ApplyCompletionTitle" 
                            Text="Changes Applied" 
                            Style="{DynamicResource ModalTitleStyle}"/>
                    
                    <TextBlock x:Name="ApplyCompletionMessage" 
                            Text="Please note that some changes will only take effect after a reboot. Thanks for using Win11Debloat!"
                            TextWrapping="Wrap"
                            Style="{DynamicResource ModalSubtextStyle}"/>
                </StackPanel>

                <!-- Reboot required section -->
                <Border x:Name="ApplyRebootPanel"
                        Visibility="Collapsed"
                        BorderBrush="{DynamicResource BorderColor}"
                        HorizontalAlignment="Center"
                        BorderThickness="0,1,0,1"
                        Padding="24,12,24,14">
                    <StackPanel>
                        <StackPanel Orientation="Horizontal" Margin="0,0,0,6">
                            <TextBlock Text="&#xE7BA;"
                                       FontFamily="Segoe Fluent Icons"
                                       FontSize="14"
                                       Foreground="#e8912d"
                                       VerticalAlignment="Center"
                                       Margin="0,0,8,0"/>
                            <TextBlock Text="A reboot is required for these changes to take effect:"
                                       FontSize="13"
                                       FontWeight="SemiBold"
                                       Foreground="{DynamicResource FgColor}"
                                       VerticalAlignment="Center"/>
                        </StackPanel>
                        <StackPanel x:Name="ApplyRebootList" Margin="22,0,0,0"/>
                    </StackPanel>
                </Border>

                <!-- Button Panel -->
                <Border Background="{DynamicResource BgColor}"
                        BorderBrush="{DynamicResource BorderColor}"
                        BorderThickness="0,1,0,0"
                        Padding="16,12"
                        CornerRadius="0,0,8,8">
                    <StackPanel x:Name="ButtonPanel"
                                Orientation="Horizontal"
                                HorizontalAlignment="Center">
                        <Button x:Name="ApplyKofiBtn" Width="210" Height="32" 
                                Style="{DynamicResource SecondaryButtonStyle}" 
                                Margin="0,0,12,0"
                                AutomationProperties.Name="Support the creator">
                            <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                                <TextBlock Text="&#xEB52;" FontFamily="Segoe Fluent Icons" FontSize="14" VerticalAlignment="Center" Margin="0,0,8,-1"/>
                                <TextBlock Text="Support the creator" VerticalAlignment="Center" FontSize="14" Margin="0,0,0,1"/>
                            </StackPanel>
                        </Button>
                        <Button x:Name="ApplyCloseBtn" Width="100" Height="32" 
                                Style="{DynamicResource PrimaryButtonStyle}"
                                AutomationProperties.Name="Close">
                            <TextBlock Text="Close" VerticalAlignment="Center" FontSize="14" Margin="0,0,0,1"/>
                        </Button>
                    </StackPanel>
                </Border>
            </StackPanel>
        </StackPanel>
        </Grid>
    </Border>
</Window>
