<UserControl
    d:DesignHeight="450"
    d:DesignWidth="800"
    mc:Ignorable="d"
    x:Class="Nebula.Launcher.Views.Pages.AccountInfoView"
    x:DataType="pages:AccountInfoViewModel"
    xmlns="https://github.com/avaloniaui"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:pages="clr-namespace:Nebula.Launcher.ViewModels.Pages"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Design.DataContext>
        <pages:AccountInfoViewModel />
    </Design.DataContext>
    <Grid
        ColumnDefinitions="3*,2*"
        Margin="15"
        RowDefinitions="*">
        <StackPanel Grid.Column="1" Grid.Row="0">
            <Border
                BoxShadow="0 -1 15 -2 #121212"
                CornerRadius="10,10,0,0"
                Margin="5,5,5,0"
                Padding="5">
                <Border.Background>
                    <LinearGradientBrush EndPoint="50%,100%" StartPoint="50%,0%">
                        <GradientStop Color="#222222" Offset="0.0" />
                        <GradientStop Color="#292222" Offset="1.0" />
                    </LinearGradientBrush>
                </Border.Background>
                <Label HorizontalAlignment="Center">Profiles:</Label>
            </Border>
            <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
                <ItemsControl
                    Background="#00000000"
                    ItemsSource="{Binding Accounts}"
                    Padding="0">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate DataType="{x:Type pages:ProfileAuthCredentials}">
                            <Border
                                BoxShadow="0 1 15 -2 #121212"
                                CornerRadius="0,10,0,10"
                                Margin="5,5,5,0"
                                VerticalAlignment="Center">
                                <Border.Background>
                                    <LinearGradientBrush EndPoint="50%,100%" StartPoint="50%,0%">
                                        <GradientStop Color="#292222" Offset="0.0" />
                                        <GradientStop Color="#222222" Offset="1.0" />
                                    </LinearGradientBrush>
                                </Border.Background>
                                <Panel>
                                    <StackPanel Margin="10,5,5,5" Orientation="Horizontal">
                                        <Label>
                                            <TextBlock Text="{Binding Login}" />
                                        </Label>
                                    </StackPanel>
                                    <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
                                        <Button
                                            Command="{Binding OnSelect}"
                                            CornerRadius="0,0,0,10"
                                            Padding="5">
                                            <Label>
                                                Select
                                            </Label>
                                        </Button>
                                        <Button
                                            Command="{Binding OnDelete}"
                                            CornerRadius="0,10,0,0"
                                            Padding="5">
                                            <Label>
                                                Delete
                                            </Label>
                                        </Button>
                                    </StackPanel>
                                </Panel>
                            </Border>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </ScrollViewer>
        </StackPanel>

        <StackPanel
            Grid.Column="0"
            Grid.ColumnSpan="{Binding AuthViewSpan}"
            Grid.Row="0">
            <Border
                BoxShadow="{StaticResource DefaultShadow}"
                CornerRadius="10"
                Margin="5"
                Padding="15">
                <Border.Background>
                    <LinearGradientBrush EndPoint="50%,100%" StartPoint="50%,0%">
                        <GradientStop Color="#292222" Offset="0.0" />
                        <GradientStop Color="#222222" Offset="1.0" />
                    </LinearGradientBrush>
                </Border.Background>
                <Panel>
                    <StackPanel IsVisible="{Binding !IsLogged}" Spacing="15">
                        <Svg
                            Height="100"
                            Margin="0,0,0,20"
                            Path="/Assets/svg/user.svg" />
                        <StackPanel HorizontalAlignment="Center">
                            <StackPanel Orientation="Horizontal">
                                <Label VerticalAlignment="Center">
                                    Login:
                                </Label>
                                <TextBox Text="{Binding CurrentLogin}" MinWidth="200" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <Label HorizontalAlignment="Left" VerticalAlignment="Center">
                                    Password:
                                </Label>
                                <TextBox PasswordChar="#" MinWidth="200" Text="{Binding CurrentPassword}" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <Label VerticalAlignment="Center">
                                    Auth server:
                                </Label>
                                <Button Command="{Binding ExpandAuthUrlCommand}" VerticalAlignment="Stretch">
                                    <Label>+</Label>
                                </Button>
                            </StackPanel>
                        </StackPanel>

                        <Border
                            BoxShadow="{StaticResource DefaultShadow}"
                            CornerRadius="10"
                            IsVisible="{Binding AuthUrlConfigExpand}">
                            <ScrollViewer Height="80">
                                <ListBox
                                    Background="#00000000"
                                    ItemsSource="{Binding AuthUrls}"
                                    Margin="5"
                                    SelectedItem="{Binding AuthItemSelect}"
                                    SelectionMode="Single">
                                    <ListBox.ItemTemplate>
                                        <DataTemplate>
                                            <Label>
                                                <TextBlock Text="{Binding Name}" />
                                            </Label>
                                        </DataTemplate>
                                    </ListBox.ItemTemplate>
                                </ListBox>
                            </ScrollViewer>
                        </Border>
                        <Border Background="{StaticResource DefaultSelected}" BoxShadow="{StaticResource DefaultShadow}">
                            <Button
                                Command="{Binding DoAuth}"
                                HorizontalAlignment="Stretch"
                                HorizontalContentAlignment="Center">
                                <Label>Auth</Label>
                            </Button>
                        </Border>
                        <Border BoxShadow="{StaticResource DefaultShadow}">
                            <Button 
                                Command="{Binding SaveProfileCommand}" 
                                HorizontalAlignment="Stretch"
                                HorizontalContentAlignment="Center">
                                <Label>Save profile</Label>
                            </Button>
                        </Border>
                        <Button Command="{Binding ExpandAuthViewCommand}" HorizontalAlignment="Right">
                            <Label>
                                >
                            </Label>
                        </Button>
                    </StackPanel>

                    <StackPanel IsVisible="{Binding IsLogged}">
                        <Svg
                            Height="100"
                            Margin="0,0,0,20"
                            Path="/Assets/svg/user.svg" />
                        <Label>
                            <StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
                                <TextBlock>Hello,</TextBlock>
                                <TextBlock Text="{Binding CurrentLogin}" />
                            </StackPanel>
                        </Label>
                        <StackPanel
                            HorizontalAlignment="Center"
                            Margin="5,20,5,5"
                            Orientation="Horizontal"
                            Spacing="5">
                            <Border BoxShadow="{StaticResource DefaultShadow}">
                                <Button Command="{Binding Logout}">
                                    <Label>Logout</Label>
                                </Button>
                            </Border>
                            <Border BoxShadow="{StaticResource DefaultShadow}">
                                <Button Command="{Binding SaveProfileCommand}">
                                    <Label>Save profile</Label>
                                </Button>
                            </Border>
                        </StackPanel>
                    </StackPanel>
                </Panel>
            </Border>
        </StackPanel>
    </Grid>
</UserControl>