<UserControl x:Class="XplorePlane.Views.OperatorToolboxView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:prism="http://prismlibrary.com/"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             prism:ViewModelLocator.AutoWireViewModel="True"
             mc:Ignorable="d"
             d:DesignHeight="600" d:DesignWidth="200">

    <UserControl.Resources>
        <SolidColorBrush x:Key="PanelBg" Color="White"/>
        <SolidColorBrush x:Key="PanelBorder" Color="#cdcbcb"/>
        <FontFamily x:Key="CsdFont">Microsoft YaHei UI</FontFamily>
    </UserControl.Resources>

    <Border Background="{StaticResource PanelBg}"
            BorderBrush="{StaticResource PanelBorder}"
            BorderThickness="1" CornerRadius="4">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <!-- 标题 -->
            <Border Grid.Row="0" Background="#F0F0F0" BorderBrush="{StaticResource PanelBorder}"
                    BorderThickness="0,0,0,1" Padding="8,6">
                <TextBlock Text="算子工具箱" FontFamily="{StaticResource CsdFont}"
                           FontWeight="Bold" FontSize="12" Foreground="#1c1c1b"/>
            </Border>

            <!-- 搜索框 -->
            <Border Grid.Row="1" Padding="6,4" BorderBrush="{StaticResource PanelBorder}"
                    BorderThickness="0,0,0,1">
                <TextBox Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}"
                         FontFamily="{StaticResource CsdFont}" FontSize="11"
                         Padding="4,2" BorderBrush="#cdcbcb" BorderThickness="1">
                    <TextBox.Style>
                        <Style TargetType="TextBox">
                            <Style.Triggers>
                                <Trigger Property="Text" Value="">
                                    <Setter Property="Background">
                                        <Setter.Value>
                                            <VisualBrush AlignmentX="Left" AlignmentY="Center" Stretch="None">
                                                <VisualBrush.Visual>
                                                    <TextBlock Text="搜索算子..." Foreground="#aaa"
                                                               FontFamily="Microsoft YaHei UI" FontSize="11"
                                                               Margin="4,0,0,0"/>
                                                </VisualBrush.Visual>
                                            </VisualBrush>
                                        </Setter.Value>
                                    </Setter>
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </TextBox.Style>
                </TextBox>
            </Border>

            <!-- 算子列表（拖拽源） -->
            <telerik:RadListBox Grid.Row="2"
                                x:Name="ToolboxListBox"
                                ItemsSource="{Binding FilteredOperators}"
                                BorderThickness="0"
                                Background="Transparent">
                <telerik:RadListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal" Margin="4,3">
                            <Border Width="24" Height="24" Background="#E8F0FE"
                                    CornerRadius="3" Margin="0,0,6,0">
                                <TextBlock Text="⚙" HorizontalAlignment="Center"
                                           VerticalAlignment="Center" FontSize="12"/>
                            </Border>
                            <TextBlock Text="{Binding DisplayName}"
                                       FontFamily="Microsoft YaHei UI" FontSize="11"
                                       VerticalAlignment="Center"/>
                        </StackPanel>
                    </DataTemplate>
                </telerik:RadListBox.ItemTemplate>
            </telerik:RadListBox>
        </Grid>
    </Border>
</UserControl>
