<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:vm="using:SpotXInstaller.ViewModels"
        x:Class="SpotXInstaller.Views.MainWindow"
        x:DataType="vm:MainViewModel"
        Icon="/Assets/avalonia-logo.ico"
        Title="SpotX Installer"
        Width="700"
        Height="500"
        CanResize="False"
        Background="#050505"
        Foreground="White"
        WindowStartupLocation="CenterScreen">

    <Design.DataContext>
        <vm:MainViewModel />
    </Design.DataContext>

    <Grid>
        <!-- ================================================= -->
        <!-- 1. LOADING SCREEN                                 -->
        <!-- ================================================= -->
        <Grid IsVisible="{Binding IsStepLoading}" Background="#050507" ZIndex="10">
            <Grid Width="500" Height="260" HorizontalAlignment="Center" VerticalAlignment="Center">

                <!-- Glow (Свечение на фоне) -->
                <Border Width="390" Height="110" CornerRadius="55" Background="#8B5CF6" Opacity="0.08"
                        HorizontalAlignment="Center" VerticalAlignment="Center">
                    <Border.Styles>
                        <Style Selector="Border">
                            <Style.Animations>
                                <Animation Duration="0:0:2" IterationCount="Infinite">
                                    <KeyFrame Cue="0%"><Setter Property="Opacity" Value="0.05" /></KeyFrame>
                                    <KeyFrame Cue="50%"><Setter Property="Opacity" Value="0.15" /></KeyFrame>
                                    <KeyFrame Cue="100%"><Setter Property="Opacity" Value="0.05" /></KeyFrame>
                                </Animation>
                            </Style.Animations>
                        </Style>
                    </Border.Styles>
                </Border>

                <!-- ========================================================== -->
                <!-- ИДЕАЛЬНОЕ НАЛОЖЕНИЕ ТЕКСТА (БЕЗ МАРДЖИНОВ И СМЕЩЕНИЙ)      -->
                <!-- ========================================================== -->
                <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
                    <!-- Background text (Темный) -->
                    <TextBlock Text="KIRIESKA" FontSize="60" FontWeight="Black" Foreground="#18181D" />

                    <!-- Animated text (Фиолетовый) -->
                    <!-- Он лежит в том же Grid, поэтому координаты букв совпадут на 100% -->
                    <Border HorizontalAlignment="Left" ClipToBounds="True">
                        <Border.Styles>
                            <Style Selector="Border">
                                <Style.Animations>
                                    <Animation Duration="0:0:2.5" FillMode="Forward">
                                        <KeyFrame Cue="0%"><Setter Property="Width" Value="0" /></KeyFrame>
                                        <!-- Ставлю 400, чтобы ширины анимации точно хватило на всё слово на любом шрифте -->
                                        <KeyFrame Cue="100%"><Setter Property="Width" Value="400" /></KeyFrame>
                                    </Animation>
                                </Style.Animations>
                            </Style>
                        </Border.Styles>
                        <TextBlock Text="KIRIESKA" FontSize="60" FontWeight="Black" Foreground="#A78BFA" />
                    </Border>
                </Grid>

                <!-- Status -->
                <TextBlock Text="INITIALIZING SYSTEM" FontSize="10" FontWeight="SemiBold" Foreground="#666670"
                           HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,48" />

                <!-- Progress background -->
                <Border Width="280" Height="2" Background="#18181D" CornerRadius="1"
                        HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,30">
                    <!-- Progress -->
                    <Border Height="2" Background="#8B5CF6" CornerRadius="1" HorizontalAlignment="Left">
                        <Border.Styles>
                            <Style Selector="Border">
                                <Style.Animations>
                                    <Animation Duration="0:0:2.5" FillMode="Forward">
                                        <KeyFrame Cue="0%"><Setter Property="Width" Value="0" /></KeyFrame>
                                        <KeyFrame Cue="100%"><Setter Property="Width" Value="280" /></KeyFrame>
                                    </Animation>
                                </Style.Animations>
                            </Style>
                        </Border.Styles>
                    </Border>
                </Border>

                <!-- Loading dot -->
                <Ellipse Width="5" Height="5" Fill="#8B5CF6" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,18">
                    <Ellipse.Styles>
                        <Style Selector="Ellipse">
                            <Style.Animations>
                                <Animation Duration="0:0:1" IterationCount="Infinite">
                                    <KeyFrame Cue="0%"><Setter Property="Opacity" Value="0.2" /></KeyFrame>
                                    <KeyFrame Cue="50%"><Setter Property="Opacity" Value="1" /></KeyFrame>
                                    <KeyFrame Cue="100%"><Setter Property="Opacity" Value="0.2" /></KeyFrame>
                                </Animation>
                            </Style.Animations>
                        </Style>
                    </Ellipse.Styles>
                </Ellipse>
            </Grid>
        </Grid>


        <!-- ================================================= -->
        <!-- 2. HOME                                           -->
        <!-- ================================================= -->
        <Grid IsVisible="{Binding IsStepHome}" Margin="40">
            <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Width="320" Spacing="12">
                <TextBlock Text="SpotX Installer" FontSize="36" FontWeight="Black" HorizontalAlignment="Center" />
                <TextBlock Text="Продвинутый патч для десктопного Spotify." FontSize="14" Foreground="#666666"
                           HorizontalAlignment="Center" Margin="0,0,0,30" />

                <Button Content="НАЧАТЬ УСТАНОВКУ" Command="{Binding GoToSettingsCommand}"
                        HorizontalAlignment="Stretch" HorizontalContentAlignment="Center"
                        Background="#8B5CF6" Foreground="White" FontWeight="Bold" FontSize="14" Padding="15" />

                <Button Content="УДАЛИТЬ / ВОССТАНОВИТЬ" Command="{Binding StartUninstallCommand}"
                        HorizontalAlignment="Stretch" HorizontalContentAlignment="Center"
                        Background="Transparent" Foreground="#A0A0A0" BorderBrush="#333333" BorderThickness="1"
                        FontWeight="Bold" FontSize="12" Padding="12" />
            </StackPanel>
        </Grid>


        <!-- ================================================= -->
        <!-- 3. SETTINGS                                       -->
        <!-- ================================================= -->
        <Grid IsVisible="{Binding IsStepSettings}" Margin="40">
            <Button Content="← Назад" Command="{Binding GoBackToHomeCommand}" Background="Transparent"
                    Foreground="#777777" HorizontalAlignment="Left" VerticalAlignment="Top" />

            <TextBlock Text="Параметры" FontSize="28" FontWeight="Bold" Margin="0,45,0,0" />

            <StackPanel Spacing="15" Margin="0,105,0,0">
                <CheckBox Content="Блокировать автоматические обновления Spotify" IsChecked="{Binding BlockUpdates}" FontSize="14" />
                <CheckBox Content="Скрыть раздел с подкастами" IsChecked="{Binding HidePodcasts}" FontSize="14" />
                <CheckBox Content="Удалить кнопки покупки Premium" IsChecked="{Binding HidePremium}" FontSize="14" />
                <CheckBox Content="Очистить кэш перед установкой" IsChecked="{Binding ClearCache}" FontSize="14" />
            </StackPanel>

            <Button Content="УСТАНОВИТЬ" Command="{Binding StartInstallCommand}" HorizontalAlignment="Right"
                    VerticalAlignment="Bottom" Background="White" Foreground="Black" FontWeight="Black"
                    FontSize="14" Padding="30,15" />
        </Grid>


        <!-- ================================================= -->
        <!-- 4. INSTALLATION PROGRESS                          -->
        <!-- ================================================= -->
        <Grid IsVisible="{Binding IsStepProgress}" Background="#050505" ZIndex="5">
            <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Spacing="20">
                <ProgressBar Width="200" Height="4" IsIndeterminate="True" Foreground="#8B5CF6" Background="#18181D"/>
                <TextBlock Text="Выполнение скриптов..." Foreground="#888888" FontSize="14" HorizontalAlignment="Center" />
            </StackPanel>
        </Grid>


        <!-- ================================================= -->
        <!-- 5. POPUP NOTIFICATION                             -->
        <!-- ================================================= -->
        <Grid IsVisible="{Binding ShowPopup}" Background="#D9000000" ZIndex="20">
            <Border Width="400" Padding="30" Background="#111111" BorderBrush="#2A2A2A" BorderThickness="1"
                    CornerRadius="12" HorizontalAlignment="Center" VerticalAlignment="Center">
                <StackPanel>
                    <TextBlock Text="{Binding PopupTitle}" Foreground="{Binding PopupColor}" FontSize="18"
                               FontWeight="Black" Margin="0,0,0,10" />

                    <TextBlock Text="{Binding PopupMessage}" Foreground="#CCCCCC" FontSize="14"
                               TextWrapping="Wrap" Margin="0,0,0,25" />

                    <Button Content="ОК" Command="{Binding ClosePopupCommand}" HorizontalAlignment="Right"
                            Background="#333333" Foreground="White" FontWeight="Bold" Padding="25,10" />
                </StackPanel>
            </Border>
        </Grid>

    </Grid>
</Window>
