<UserControl x:Class="Noctalk_client.Admin.Admin_panel"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:uiButton="clr-namespace:Noctalk.UI.Components.Button"
             xmlns:uiInput="clr-namespace:Noctalk.UI.Components.Input"
             xmlns:uiLabel="clr-namespace:Noctalk.UI.Components.Label"
             Background="#050912" Foreground="#49D9FF">
    <UserControl.Resources>
        <Style x:Key="SectionContent" TargetType="Grid">
            <Setter Property="Margin" Value="14,12,14,12" />
        </Style>
        <Style x:Key="SectionSeparator" TargetType="Border">
            <Setter Property="Height" Value="1" />
            <Setter Property="Background" Value="#123E5D" />
            <Setter Property="HorizontalAlignment" Value="Stretch" />
        </Style>
        <Style TargetType="DataGrid">
            <Setter Property="Background" Value="#070D18" />
            <Setter Property="Foreground" Value="#B9F3FF" />
            <Setter Property="RowBackground" Value="#08101D" />
            <Setter Property="AlternatingRowBackground" Value="#0A1828" />
            <Setter Property="BorderBrush" Value="#146B93" />
            <Setter Property="GridLinesVisibility" Value="Horizontal" />
            <Setter Property="HeadersVisibility" Value="Column" />
            <Setter Property="HorizontalGridLinesBrush" Value="#123E5D" />
            <Setter Property="RowHeight" Value="40" />
        </Style>
        <Style TargetType="DataGridColumnHeader">
            <Setter Property="Background" Value="#0E2A3D" />
            <Setter Property="Foreground" Value="#D8F8FF" />
            <Setter Property="BorderBrush" Value="#146B93" />
            <Setter Property="FontWeight" Value="Bold" />
            <Setter Property="Padding" Value="8,6" />
        </Style>
        <Style TargetType="DataGridCell">
            <Setter Property="Padding" Value="8,0" />
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="DataGridCell">
                        <Border Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}">
                            <ContentPresenter VerticalAlignment="Center" />
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>

    <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
        <StackPanel Margin="0">
            <Grid Style="{StaticResource SectionContent}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="260" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <uiLabel:Noctalk_label Grid.Row="0" Grid.Column="0" Text="Server" Size="medium" Color="standard" />
                    <uiInput:Noctalk_dropdown x:Name="Admin_server_combobox" Grid.Row="0" Grid.Column="1" SelectionChanged="Admin_server_combobox__selection_changed" />
            </Grid>

            <Border Style="{StaticResource SectionSeparator}" />

            <Grid Style="{StaticResource SectionContent}">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <uiLabel:Noctalk_label Grid.Row="0" Text="Create conversation pair" Size="large" Margin="0,0,0,10" />

                    <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,0,0,12">
                        <uiInput:Noctalk_radiobutton x:Name="Create_config_files_radio" GroupName="Create_mode" Content="Conversation pair config files" Margin="0,0,18,0" Checked="Create_mode_radio__checked" />
                        <uiInput:Noctalk_radiobutton x:Name="Create_full_clients_radio" GroupName="Create_mode" Content="Full clients - ready for delivery" IsChecked="True" Checked="Create_mode_radio__checked" />
                    </StackPanel>

                    <Grid Grid.Row="2">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="22" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <Border Grid.Column="0" BorderBrush="#146B93" BorderThickness="1" Background="#06101D">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="34" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>

                                <Border Grid.Row="0" Background="#0C1E32" Padding="10,0">
                                    <uiLabel:Noctalk_label Text="Client A" Size="medium" />
                                </Border>

                                <Grid Grid.Row="1" Margin="10">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="150" />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>

                                    <uiLabel:Noctalk_label Grid.Row="0" Grid.Column="0" Text="Client name" Size="medium" Color="standard" />
                                    <uiInput:Noctalk_textbox x:Name="Client_A__nickname_textbox" Grid.Row="0" Grid.Column="1" />

                                    <uiLabel:Noctalk_label x:Name="Client_A__local_tor_port_label" Grid.Row="1" Grid.Column="0" Text="Local Tor port" Size="medium" Color="standard" Margin="0,6,0,0" />
                                    <uiInput:Noctalk_numeric_up_down x:Name="Client_A__local_tor_port_numeric" Grid.Row="1" Grid.Column="1" Width="140" HorizontalAlignment="Left" Margin="4,6,0,0" Minimum="1" Maximum="65535" Value="65191" />

                                    <uiLabel:Noctalk_label Grid.Row="2" Grid.Column="0" Text="Admin rights" Size="medium" Color="standard" Margin="0,6,0,0" />
                                    <uiInput:Noctalk_checkbox x:Name="Client_A__admin_rights_checkbox" Grid.Row="2" Grid.Column="1" Content="" IsChecked="False" Margin="4,6,0,0" />
                                </Grid>
                            </Grid>
                        </Border>

                        <Border Grid.Column="2" BorderBrush="#146B93" BorderThickness="1" Background="#06101D">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="34" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>

                                <Border Grid.Row="0" Background="#0C1E32" Padding="10,0">
                                    <uiLabel:Noctalk_label Text="Client B" Size="medium" />
                                </Border>

                                <Grid Grid.Row="1" Margin="10">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="150" />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>

                                    <uiLabel:Noctalk_label Grid.Row="0" Grid.Column="0" Text="Client name" Size="medium" Color="standard" />
                                    <uiInput:Noctalk_textbox x:Name="Client_B__nickname_textbox" Grid.Row="0" Grid.Column="1" />

                                    <uiLabel:Noctalk_label x:Name="Client_B__local_tor_port_label" Grid.Row="1" Grid.Column="0" Text="Local Tor port" Size="medium" Color="standard" Margin="0,6,0,0" />
                                    <uiInput:Noctalk_numeric_up_down x:Name="Client_B__local_tor_port_numeric" Grid.Row="1" Grid.Column="1" Width="140" HorizontalAlignment="Left" Margin="4,6,0,0" Minimum="1" Maximum="65535" Value="65192" />

                                    <uiLabel:Noctalk_label Grid.Row="2" Grid.Column="0" Text="Admin rights" Size="medium" Color="standard" Margin="0,6,0,0" />
                                    <uiInput:Noctalk_checkbox x:Name="Client_B__admin_rights_checkbox" Grid.Row="2" Grid.Column="1" Content="" IsChecked="False" Margin="4,6,0,0" />
                                </Grid>
                            </Grid>
                        </Border>
                    </Grid>

                    <Border x:Name="Create_new_server_box" Grid.Row="3" BorderBrush="#146B93" BorderThickness="1" Background="#06101D" Margin="0,12,0,0">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="34" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>

                            <Border Grid.Row="0" Background="#0C1E32" Padding="10,0">
                                <uiLabel:Noctalk_label Text="Create new server" Size="medium" />
                            </Border>

                            <Grid Grid.Row="1" Margin="10">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="55" />
                                    <ColumnDefinition Width="360" />
                                    <ColumnDefinition Width="18" />
                                    <ColumnDefinition Width="130" />
                                    <ColumnDefinition Width="140" />
                                </Grid.ColumnDefinitions>
                                <uiInput:Noctalk_checkbox x:Name="Create_new_server_checkbox" Grid.Column="0" Content="" IsChecked="False" Checked="Create_new_server_checkbox__checked_changed" Unchecked="Create_new_server_checkbox__checked_changed" />
                                <uiLabel:Noctalk_label x:Name="New_server_name_label" Grid.Column="1" Text="Name" Size="medium" Color="standard" Visibility="Collapsed" />
                                <uiInput:Noctalk_textbox x:Name="New_server_name_textbox" Grid.Column="2" Text="My private chat server" Visibility="Collapsed" />
                                <uiLabel:Noctalk_label x:Name="New_server_local_relay_port_label" Grid.Column="4" Text="Local relay port" Size="medium" Color="standard" Visibility="Collapsed" />
                                <uiInput:Noctalk_numeric_up_down x:Name="New_server_local_relay_port_numeric" Grid.Column="5" Width="130" HorizontalAlignment="Left" Margin="4,0,0,0" Minimum="1" Maximum="65535" Value="65190" Visibility="Collapsed" />
                            </Grid>
                        </Grid>
                    </Border>

                    <uiButton:Noctalk_button x:Name="button__create" Grid.Row="5" Content="Create" WidthMode="Content" Color="Blue_O__Blue_O" HorizontalAlignment="Right" Margin="0,12,0,0" Click="Create_button__click" />
            </Grid>

            <Border Style="{StaticResource SectionSeparator}" />

            <Grid Style="{StaticResource SectionContent}">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <Grid Grid.Row="0" Margin="0,0,0,10">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="34" />
                        </Grid.ColumnDefinitions>
                        <uiLabel:Noctalk_label Text="Conversation list" Size="large" />
                        <uiButton:Noctalk_button x:Name="button__refresh_list" Grid.Column="1" Width="34" Height="34" Padding="0" Margin="0" Icon="Refresh" Color="Blue_O__Blue_O" Click="Refresh_list_button__click" />
                    </Grid>

                    <DataGrid x:Name="Conversation_metadata_grid" Grid.Row="1" MinHeight="110" AutoGenerateColumns="False" IsReadOnly="True" PreviewMouseWheel="Conversation_metadata_grid__preview_mouse_wheel">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="Conversation guid" Binding="{Binding Conversation_guid}" Width="310" />
                            <DataGridTextColumn Header="Created" Binding="{Binding Conversation__metadata__date__created__local}" Width="150" />
                            <DataGridTextColumn Header="Pending messages" Binding="{Binding Pending_messages__display}" Width="130" />
                            <DataGridTextColumn Header="Last sent A" Binding="{Binding Client_A__last_sent__date__local}" Width="150" />
                            <DataGridTemplateColumn Header="Last sent B" Width="170">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Grid>
                                            <Grid.Style>
                                                <Style TargetType="Grid">
                                                    <Setter Property="ClipToBounds" Value="False" />
                                                </Style>
                                            </Grid.Style>
                                            <TextBlock Text="{Binding Client_B__last_sent__date__local}" VerticalAlignment="Center" Foreground="#B9F3FF" />
                                            <Grid HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,2,0,2">
                                                <Grid.Style>
                                                    <Style TargetType="Grid">
                                                        <Setter Property="Visibility" Value="Collapsed" />
                                                        <Style.Triggers>
                                                            <DataTrigger Binding="{Binding IsMouseOver, RelativeSource={RelativeSource AncestorType=DataGridRow}}" Value="True">
                                                                <Setter Property="Visibility" Value="Visible" />
                                                            </DataTrigger>
                                                        </Style.Triggers>
                                                    </Style>
                                                </Grid.Style>
                                                <uiButton:Noctalk_button Size="Grid" Margin="0" Icon="Trash" Color="Red_R__Red_R" Click="Delete_conversation_row_button__click" />
                                            </Grid>
                                        </Grid>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                        </DataGrid.Columns>
                    </DataGrid>

            </Grid>
        </StackPanel>
    </ScrollViewer>
</UserControl>
