<Window x:Class="XFEToolBox.Client.Views.Windows.CommandPaletteWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:controls="clr-namespace:XFEToolBox.WpfCore.Controls;assembly=XFEToolBox.WpfCore"
        Width="620" Height="440" WindowStyle="None" AllowsTransparency="True"
        Background="Transparent" ShowInTaskbar="False" Topmost="True"
        ResizeMode="NoResize" WindowStartupLocation="Manual"
        PreviewKeyDown="Window_PreviewKeyDown">
    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
    </Window.Resources>
    <Border Background="#FAFAFF" BorderBrush="#8F8FD4" BorderThickness="1" CornerRadius="18" Padding="13">
        <Border.Effect>
            <DropShadowEffect BlurRadius="28" ShadowDepth="8" Opacity="0.35" Color="#27274C"/>
        </Border.Effect>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="42"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Border Width="36" Height="36" Background="#EEEEFB" CornerRadius="11">
                    <TextBlock Text="⌕" Foreground="#6666BC" FontSize="21" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                </Border>
                <TextBox x:Name="SearchBox" Grid.Column="1" Height="42" Margin="8,0" Padding="8,0"
                         Background="Transparent" BorderThickness="0" FontSize="17" Foreground="#3F3F54"
                         VerticalContentAlignment="Center" TextChanged="SearchBox_TextChanged"/>
                <Border Grid.Column="2" Padding="9,4" Background="#ECECF5" CornerRadius="7" VerticalAlignment="Center">
                    <TextBlock Text="ESC" Foreground="#858597" FontSize="9"/>
                </Border>
            </Grid>

            <Border Grid.Row="1" Margin="0,11,0,7" Background="#F4F4FA" CornerRadius="13" Padding="5">
                <Grid>
                    <ListBox x:Name="ResultList" Background="Transparent" BorderThickness="0"
                             ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                             MouseDoubleClick="ResultList_MouseDoubleClick">
                        <ListBox.ItemContainerStyle>
                            <Style TargetType="ListBoxItem">
                                <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                                <Setter Property="Padding" Value="0"/>
                                <Setter Property="Margin" Value="0,1"/>
                                <Setter Property="Background" Value="Transparent"/>
                                <Setter Property="BorderThickness" Value="0"/>
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="ListBoxItem">
                                            <Border x:Name="Surface" Background="{TemplateBinding Background}" CornerRadius="10" Padding="9,7">
                                                <ContentPresenter/>
                                            </Border>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsSelected" Value="True"><Setter TargetName="Surface" Property="Background" Value="#E4E4F6"/></Trigger>
                                                <Trigger Property="IsMouseOver" Value="True"><Setter TargetName="Surface" Property="Background" Value="#EBEBF8"/></Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </ListBox.ItemContainerStyle>
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <Grid IsEnabled="{Binding IsEnabled}">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="42"/>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <Border Width="34" Height="34" Background="White" CornerRadius="10">
                                        <Image Source="{Binding IconSource}" Width="22" Height="22" Stretch="Uniform"/>
                                    </Border>
                                    <StackPanel Grid.Column="1" Margin="9,0" VerticalAlignment="Center">
                                        <TextBlock Text="{Binding Title}" Foreground="#414156" FontSize="12" FontWeight="SemiBold"/>
                                        <TextBlock Text="{Binding Subtitle}" Foreground="#8B8B9D" FontSize="9.3" Margin="0,3,0,0" TextTrimming="CharacterEllipsis"/>
                                    </StackPanel>
                                    <StackPanel Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Center">
                                        <TextBlock Text="★" Foreground="#7777C9" FontSize="11" Margin="0,0,8,0" Visibility="{Binding IsPinned, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                                        <Border Padding="7,3" Background="#E8E8F4" CornerRadius="7">
                                            <TextBlock Text="{Binding KindText}" Foreground="#727289" FontSize="8.5"/>
                                        </Border>
                                    </StackPanel>
                                    <Grid.ContextMenu>
                                        <ContextMenu DataContext="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource Self}}">
                                            <MenuItem Header="{Binding PinText}" Click="PinMenuItem_Click"/>
                                        </ContextMenu>
                                    </Grid.ContextMenu>
                                </Grid>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                    <StackPanel x:Name="EmptyState" Visibility="Collapsed" HorizontalAlignment="Center" VerticalAlignment="Center">
                        <TextBlock Text="没有找到匹配项" Foreground="#626278" FontSize="12" FontWeight="SemiBold" HorizontalAlignment="Center"/>
                        <TextBlock Text="可搜索工具、软件、页面、项目和命令" Foreground="#9999A9" FontSize="9.5" Margin="0,5,0,0"/>
                    </StackPanel>
                </Grid>
            </Border>

            <Grid Grid.Row="2" Margin="5,0">
                <TextBlock x:Name="StatusText" Text="输入名称或关键词开始搜索" Foreground="#9292A4" FontSize="9"/>
                <TextBlock Text="↑↓ 选择  ·  Enter 打开  ·  右键固定" Foreground="#9292A4" FontSize="9" HorizontalAlignment="Right"/>
            </Grid>
        </Grid>
    </Border>
</Window>
