<UserControl x:Class="Ink_Canvas.Windows.SettingsViews.Pages.PluginMarketSourcesWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
    xmlns:props="clr-namespace:Ink_Canvas.Properties"
    mc:Ignorable="d"
    d:DesignWidth="760" d:DesignHeight="360"
    Width="760" Height="360">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="200"/>
            <ColumnDefinition Width="16"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <!-- 左侧：插件源列表 -->
        <Grid Grid.Column="0">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <TextBlock Grid.Row="0"
                Text="{x:Static props:PluginStrings.Market_ManageSources}"
                FontWeight="SemiBold" FontSize="14" Margin="0,0,0,8"/>

            <ListBox x:Name="SourcesList" Grid.Row="1"
                SelectionChanged="SourcesList_SelectionChanged"
                BorderThickness="0"
                HorizontalContentAlignment="Stretch"
                ScrollViewer.HorizontalScrollBarVisibility="Disabled">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal" Margin="4,6">
                            <ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Globe}"
                                FontSize="14" Margin="0,0,8,0"
                                VerticalAlignment="Center"
                                Foreground="{DynamicResource TextFillColorSecondaryBrush}"/>
                            <TextBlock Text="{Binding Display}"
                                FontSize="13" VerticalAlignment="Center"
                                TextTrimming="CharacterEllipsis"/>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

            <Button Grid.Row="2" Click="AddButton_Click"
                HorizontalAlignment="Left" Margin="0,12,0,0" Padding="10,6">
                <StackPanel Orientation="Horizontal">
                    <ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Add}" FontSize="13" Margin="0,0,6,0"/>
                    <TextBlock Text="{x:Static props:PluginStrings.Market_AddSource}" VerticalAlignment="Center"/>
                </StackPanel>
            </Button>
        </Grid>

        <Border Grid.Column="2"
            Background="{DynamicResource CardBackgroundFillColorDefaultBrush}"
            BorderBrush="{DynamicResource CardStrokeColorDefaultBrush}"
            BorderThickness="1" CornerRadius="8" Padding="16">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>

                <TextBlock Grid.Row="0" Text="{x:Static props:PluginStrings.Market_EditSource}"
                    FontWeight="SemiBold" FontSize="14" Margin="0,0,0,14"/>

                <StackPanel Grid.Row="1">
                    <TextBlock Text="{x:Static props:PluginStrings.Market_SourceIdLabel}"
                        FontSize="12" Margin="0,0,0,4"
                        Foreground="{DynamicResource TextFillColorSecondaryBrush}"/>
                    <TextBox x:Name="IdBox" Padding="8,6" Margin="0,0,0,12"/>
                </StackPanel>

                <StackPanel Grid.Row="2">
                    <TextBlock Text="{x:Static props:PluginStrings.Market_SourceUrlLabel}"
                        FontSize="12" Margin="0,0,0,4"
                        Foreground="{DynamicResource TextFillColorSecondaryBrush}"/>
                    <TextBox x:Name="UrlBox" Padding="8,6" Margin="0,0,0,8"/>
                </StackPanel>

                <TextBlock x:Name="HintText" Grid.Row="3"
                    TextWrapping="Wrap" MinHeight="20"
                    Foreground="{DynamicResource SystemFillColorCriticalBrush}"/>

                <StackPanel Grid.Row="5" Orientation="Horizontal" HorizontalAlignment="Right">
                    <Button Click="RemoveButton_Click" x:Name="RemoveBtn" Padding="12,7" Margin="0,0,8,0">
                        <StackPanel Orientation="Horizontal">
                            <ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Delete}" FontSize="13" Margin="0,0,6,0"/>
                            <TextBlock Text="{x:Static props:PluginStrings.Market_RemoveSource}" VerticalAlignment="Center"/>
                        </StackPanel>
                    </Button>
                    <Button x:Name="SaveBtn" Click="SaveButton_Click" Padding="14,7" IsDefault="True">
                        <StackPanel Orientation="Horizontal">
                            <ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Save}" FontSize="13" Margin="0,0,6,0"/>
                            <TextBlock Text="{x:Static props:PluginStrings.Market_SaveSource}" VerticalAlignment="Center"/>
                        </StackPanel>
                    </Button>
                </StackPanel>
            </Grid>
        </Border>
    </Grid>
</UserControl>
