<UserControl x:Class="MainShell.AlgorithmCalib.View.RotateMatixFormCalibView"
             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:mw="http://www.maxwell-gp.com/"
             xmlns:customControl="clr-namespace:MainShell.Resources.CustomControl"
             mc:Ignorable="d"
             d:DesignHeight="800"
             d:DesignWidth="1200">

    <UserControl.Resources>

        <BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter"/>

        <Style x:Key="ModuleCardStyle" TargetType="Border">
            <Setter Property="Background" Value="White"/>
            <Setter Property="BorderBrush" Value="#E0E4EA"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="CornerRadius" Value="6"/>
            <Setter Property="Margin" Value="0,0,0,12"/>
            <Setter Property="Effect">
                <Setter.Value>
                    <DropShadowEffect Color="#000000" Opacity="0.06" BlurRadius="8" ShadowDepth="2" Direction="270"/>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="AvoidanceAxisNameStyle" TargetType="TextBlock">
            <Setter Property="Foreground" Value="#E8821A"/>
            <Setter Property="FontSize" Value="12"/>
            <Setter Property="FontWeight" Value="SemiBold"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
        </Style>

        <Style x:Key="TableHeaderStyle" TargetType="TextBlock">
            <Setter Property="FontSize" Value="11"/>
            <Setter Property="Foreground" Value="#8892A0"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="FontWeight" Value="SemiBold"/>
        </Style>

        <Style x:Key="CalibAxisNameStyle" TargetType="TextBlock">
            <Setter Property="FontSize" Value="12"/>
            <Setter Property="Foreground" Value="#2D3748"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
        </Style>

        <Style x:Key="TargetValueStyle" TargetType="mw:NumberBox">
            <Setter Property="Width" Value="85"/>
            <Setter Property="Height" Value="28"/>
            <Setter Property="Margin" Value="0,1"/>
            <Setter Property="mw:NumericKeypadAttach.IsEnabled" Value="True"/>
            <Setter Property="Minimum" Value="-99999"/>
            <Setter Property="Maximum" Value="99999"/>
            <Setter Property="DecimalPlaces" Value="3"/>
            <Setter Property="Foreground" Value="#1568D5"/>
        </Style>

        <Style x:Key="SmallIconButtonStyle" TargetType="Button">
            <Setter Property="Width" Value="28"/>
            <Setter Property="Height" Value="24"/>
            <Setter Property="Padding" Value="0"/>
            <Setter Property="Margin" Value="1,0"/>
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="BorderBrush" Value="Transparent"/>
            <Setter Property="Cursor" Value="Hand"/>
            <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Border x:Name="bd"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="1"
                                CornerRadius="4">
                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter TargetName="bd" Property="Background" Value="#F0F4F8"/>
                                <Setter TargetName="bd" Property="BorderBrush" Value="#CBD5E0"/>
                            </Trigger>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter TargetName="bd" Property="Background" Value="#E2E8F0"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="AddAxisButtonStyle" TargetType="Button" BasedOn="{StaticResource SmallIconButtonStyle}">
            <Setter Property="Width" Value="24"/>
            <Setter Property="Height" Value="24"/>
            <Setter Property="Foreground" Value="#28A745"/>
            <Setter Property="FontSize" Value="15"/>
            <Setter Property="FontWeight" Value="Bold"/>
        </Style>

        <Style x:Key="ModuleActionButtonStyle" TargetType="Button" BasedOn="{StaticResource BaseRoundedButtonStyle}">
            <Setter Property="Width" Value="110"/>
            <Setter Property="Height" Value="32"/>
            <Setter Property="FontSize" Value="12"/>
            <Setter Property="Margin" Value="4,0"/>
        </Style>

        <Style x:Key="CalibStartButtonStyle" TargetType="Button" BasedOn="{StaticResource ModuleActionButtonStyle}">
            <Setter Property="Background" Value="#1A202C"/>
            <Setter Property="BorderBrush" Value="#1A202C"/>
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background" Value="#2D3748"/>
                    <Setter Property="BorderBrush" Value="#2D3748"/>
                </Trigger>
                <Trigger Property="IsPressed" Value="True">
                    <Setter Property="Background" Value="#0F141B"/>
                    <Setter Property="BorderBrush" Value="#0F141B"/>
                </Trigger>
                <Trigger Property="IsEnabled" Value="False">
                    <Setter Property="Background" Value="{StaticResource DisabledBackground}"/>
                    <Setter Property="BorderBrush" Value="{StaticResource DisabledBackground}"/>
                    <Setter Property="Foreground" Value="{StaticResource DisabledForeground}"/>
                    <Setter Property="Cursor" Value="Arrow"/>
                </Trigger>
            </Style.Triggers>
        </Style>

        <Style x:Key="ModuleWriteButtonStyle" TargetType="Button" BasedOn="{StaticResource ModuleActionButtonStyle}">
            <Setter Property="Background" Value="{StaticResource TeachOrange}"/>
            <Setter Property="BorderBrush" Value="{StaticResource TeachOrange}"/>
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background" Value="{StaticResource TeachOrangeHover}"/>
                    <Setter Property="BorderBrush" Value="{StaticResource TeachOrangeHover}"/>
                </Trigger>
                <Trigger Property="IsPressed" Value="True">
                    <Setter Property="Background" Value="{StaticResource TeachOrangePressed}"/>
                    <Setter Property="BorderBrush" Value="{StaticResource TeachOrangePressed}"/>
                </Trigger>
                <Trigger Property="IsEnabled" Value="False">
                    <Setter Property="Background" Value="{StaticResource DisabledBackground}"/>
                    <Setter Property="BorderBrush" Value="{StaticResource DisabledBackground}"/>
                    <Setter Property="Foreground" Value="{StaticResource DisabledForeground}"/>
                    <Setter Property="Cursor" Value="Arrow"/>
                </Trigger>
            </Style.Triggers>
        </Style>

        <Style x:Key="BadgeStyle" TargetType="Border">
            <Setter Property="CornerRadius" Value="3"/>
            <Setter Property="Padding" Value="5,1"/>
            <Setter Property="Margin" Value="3,0"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
        </Style>
        <Style x:Key="SectionHeaderTextStyle" TargetType="TextBlock">
            <Setter Property="FontWeight" Value="SemiBold"/>
            <Setter Property="FontSize" Value="12"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
        </Style>

        <Style x:Key="ParamLabelStyle" TargetType="TextBlock">
            <Setter Property="Foreground" Value="#4A5568"/>
            <Setter Property="FontSize" Value="12"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="HorizontalAlignment" Value="Right"/>
        </Style>

        <Style x:Key="ParamNumberBoxStyle" TargetType="mw:NumberBox">
            <Setter Property="Width" Value="100"/>
            <Setter Property="Height" Value="28"/>
            <Setter Property="Margin" Value="6,2"/>
            <Setter Property="mw:NumericKeypadAttach.IsEnabled" Value="True"/>
            <Setter Property="Minimum" Value="-99999"/>
            <Setter Property="Maximum" Value="99999"/>
            <Setter Property="DecimalPlaces" Value="3"/>
            <Setter Property="Foreground" Value="#1568D5"/>
        </Style>

        <Style x:Key="ReadOnlyNumberBoxStyle" TargetType="mw:NumberBox" BasedOn="{StaticResource ParamNumberBoxStyle}">
            <Setter Property="IsReadOnly" Value="True"/>
            <Setter Property="Background" Value="#F0F4F8"/>
            <Setter Property="Foreground" Value="#4A5568"/>
        </Style>

        <Style x:Key="IntParamNumberBoxStyle" TargetType="mw:IntNumberBox">
            <Setter Property="Width" Value="100"/>
            <Setter Property="Height" Value="28"/>
            <Setter Property="Margin" Value="6,2"/>
            <Setter Property="mw:NumericKeypadAttach.IsEnabled" Value="True"/>
            <Setter Property="Minimum" Value="0"/>
            <Setter Property="Maximum" Value="1000"/>
        </Style>

        <Style x:Key="SmallActionButtonStyle" TargetType="Button">
            <Setter Property="Height" Value="28"/>
            <Setter Property="Padding" Value="10,0"/>
            <Setter Property="Margin" Value="4,2"/>
            <Setter Property="FontSize" Value="11"/>
            <Setter Property="Cursor" Value="Hand"/>
            <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Border x:Name="bd" Background="#EDF2F7" BorderBrush="#CBD5E0"
                        BorderThickness="1" CornerRadius="4"
                        Padding="{TemplateBinding Padding}">
                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter TargetName="bd" Property="Background" Value="#E2E8F0"/>
                            </Trigger>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter TargetName="bd" Property="Background" Value="#CBD5E0"/>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter TargetName="bd" Property="Background" Value="#F7FAFC"/>
                                <Setter TargetName="bd" Property="BorderBrush" Value="#E2E8F0"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="StartCalibButtonStyle" TargetType="Button" BasedOn="{StaticResource BaseRoundedButtonStyle}">
            <Setter Property="Width" Value="110"/>
            <Setter Property="Height" Value="32"/>
            <Setter Property="FontSize" Value="12"/>
            <Setter Property="Margin" Value="0,0,6,0"/>
            <Setter Property="Background" Value="#1A202C"/>
            <Setter Property="BorderBrush" Value="#1A202C"/>
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background" Value="#2D3748"/>
                </Trigger>
                <Trigger Property="IsPressed" Value="True">
                    <Setter Property="Background" Value="#0F141B"/>
                </Trigger>
                <Trigger Property="IsEnabled" Value="False">
                    <Setter Property="Background" Value="{StaticResource DisabledBackground}"/>
                    <Setter Property="BorderBrush" Value="{StaticResource DisabledBackground}"/>
                    <Setter Property="Foreground" Value="{StaticResource DisabledForeground}"/>
                </Trigger>
            </Style.Triggers>
        </Style>

        <Style x:Key="VerifyButtonStyle" TargetType="Button" BasedOn="{StaticResource BaseRoundedButtonStyle}">
            <Setter Property="Width" Value="110"/>
            <Setter Property="Height" Value="32"/>
            <Setter Property="FontSize" Value="12"/>
            <Setter Property="Margin" Value="0,0,6,0"/>
            <Setter Property="Background" Value="#2B6CB0"/>
            <Setter Property="BorderBrush" Value="#2B6CB0"/>
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background" Value="#2C5282"/>
                </Trigger>
                <Trigger Property="IsPressed" Value="True">
                    <Setter Property="Background" Value="#1A365D"/>
                </Trigger>
                <Trigger Property="IsEnabled" Value="False">
                    <Setter Property="Background" Value="{StaticResource DisabledBackground}"/>
                    <Setter Property="Foreground" Value="{StaticResource DisabledForeground}"/>
                </Trigger>
            </Style.Triggers>
        </Style>

        <Style x:Key="StopButtonStyle" TargetType="Button" BasedOn="{StaticResource BaseRoundedButtonStyle}">
            <Setter Property="Width" Value="110"/>
            <Setter Property="Height" Value="32"/>
            <Setter Property="FontSize" Value="12"/>
            <Setter Property="Margin" Value="0,0,6,0"/>
            <Setter Property="Background" Value="#E53E3E"/>
            <Setter Property="BorderBrush" Value="#E53E3E"/>
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background" Value="#C53030"/>
                </Trigger>
                <Trigger Property="IsPressed" Value="True">
                    <Setter Property="Background" Value="#9B2C2C"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <!-- ==================== 左侧：相机预览（对标原点标定） ==================== -->
        <Border Grid.Column="0" Margin="0,0,4,0">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="32"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

                <Border Grid.Row="0" Padding="10,0">
                    <Grid>
                        <TextBlock Text="相机预览"
                                   Foreground="#7A8FA6"
                                   FontSize="11"
                                   FontWeight="SemiBold"
                                   VerticalAlignment="Center"/>
                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center">
                            <Ellipse Width="7" Height="7" Fill="#28A745" Margin="0,0,4,0"/>
                            <TextBlock Text="LIVE" Foreground="#28A745" FontSize="10" FontWeight="Bold"/>
                        </StackPanel>
                    </Grid>
                </Border>

                <ContentControl Grid.Row="1" Content="{Binding CameraAxisViewModel}"/>
            </Grid>
        </Border>

        <!-- ==================== 右侧：工具栏 + 模块卡片 ==================== -->
        <Grid Grid.Column="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="50"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <!-- 顶部工具栏（对标原点标定） -->
            <Border Grid.Row="0" Background="White" BorderBrush="#E0E4EA"
                    BorderThickness="0,0,0,1" Padding="8,0">
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center">
                    <Button Content="保存配置"
                            Click="{mw:Action SaveConfig}"
                            Style="{StaticResource SaveButtonStyle}"
                            Width="130"
                            Height="34"
                            Margin="5,0"/>
                    <Button Content="全部复位"
                            Click="{mw:Action ResetAll}"
                            Style="{StaticResource ResetButtonStyle}"
                            Width="130"
                            Height="34"
                            Margin="5,0"/>
                </StackPanel>
            </Border>

            <!-- 单模块卡片（对标原点标定的卡片，但不用 ItemsControl） -->
            <ScrollViewer Grid.Row="1"
                          VerticalScrollBarVisibility="Auto"
                          HorizontalScrollBarVisibility="Disabled"
                          CanContentScroll="False"
                          PanningMode="VerticalOnly"
                          Padding="8,8,8,0">

                <!-- 直接绑定单个 Module，不再用 ItemsControl -->
                <Border Style="{StaticResource ModuleCardStyle}" DataContext="{Binding Module}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="36"/>
                            <!-- Header -->
                            <RowDefinition Height="Auto"/>
                            <!-- 避让/位置 -->
                            <RowDefinition Height="Auto"/>
                            <!-- 标定参数 -->
                            <RowDefinition Height="Auto"/>
                            <!-- 验证参数 -->
                            <RowDefinition Height="Auto"/>
                            <!-- 进度条 -->
                            <RowDefinition Height="46"/>
                            <!-- Footer -->
                        </Grid.RowDefinitions>

                        <!-- ====== 卡片 Header（对标原点标定） ====== -->
                        <Border Grid.Row="0"
                                Background="#F7F9FC"
                                BorderBrush="#E0E4EA"
                                BorderThickness="0,0,0,1"
                                CornerRadius="6,6,0,0"
                                Padding="10,0">
                            <Grid>
                                <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                                    <TextBlock Text="[] " Foreground="#8892A0" FontSize="14" VerticalAlignment="Center"/>
                                    <TextBlock FontWeight="SemiBold" FontSize="13" Foreground="#2D3748" VerticalAlignment="Center">
                                        <Run Text="模块"/>
                                        <Run Text=" 01: "/>
                                        <Run Text="{Binding ModuleName}"/>
                                    </TextBlock>
                                </StackPanel>
                                <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center">
                                    <Border Style="{StaticResource BadgeStyle}"
                                            Background="#EDF2F7"
                                            Visibility="{Binding ShowIndependentBadge}">
                                        <TextBlock Text="独立" FontSize="10" Foreground="#718096"/>
                                    </Border>
                                </StackPanel>
                            </Grid>
                        </Border>

                        <!-- ====== Section 1：WS旋转表标定位置（对标避让区域） ====== -->
                        <Border Grid.Row="1"
                                BorderBrush="#E0E4EA"
                                BorderThickness="0,0,0,1"
                                Padding="10,8">
                            <StackPanel>
                                <!-- 区域标题 -->
                                <Grid Margin="0,0,0,6">
                                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                                        <Ellipse Width="8" Height="8" Fill="#E8821A" VerticalAlignment="Center" Margin="0,0,5,0"/>
                                        <TextBlock Text="WS旋转表标定位置"
                                                   Foreground="#E8821A"
                                                   Style="{StaticResource SectionHeaderTextStyle}"/>
                                    </StackPanel>
                                </Grid>

                                <!-- X1避让位 -->
                                <Grid Margin="0,2">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="120"/>
                                        <ColumnDefinition Width="90"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Grid.Column="0"
                                               Text="X1避让位(mm)："
                                               Style="{StaticResource ParamLabelStyle}"
                                               Margin="6,0"/>
                                    <mw:NumberBox Grid.Column="1"
                                                  Value="{Binding X1AvoidancePosition, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                                  Width="80"  mw:NumericKeypadAttach.IsEnabled="True"
                                                  IsEnabled="{Binding CanStartCalib}"/>
                                    <Button Grid.Column="2"
                                            Content="移到此位置"
                                            Style="{StaticResource SmallActionButtonStyle}"
                                            Click="{mw:Action MoveToPosition}"
                                            mw:View.ActionTarget="{Binding}"
                                            IsEnabled="{Binding CanStartCalib}"/>
                                </Grid>

                                <!-- 起始位置 X2 / Y1 -->
                                <Grid Margin="0,2">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="120"/>
                                        <ColumnDefinition Width="90"/>
                                        <ColumnDefinition Width="40"/>
                                        <ColumnDefinition Width="90"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Grid.Column="0"
                                               Text="X2："
                                               Style="{StaticResource ParamLabelStyle}"
                                               Margin="6,0"/>
                                    <mw:NumberBox Grid.Column="1"
                                                  Value="{Binding StartX, Mode=TwoWay}" Width="80" mw:NumericKeypadAttach.IsEnabled="True"/>
                                    <TextBlock Grid.Column="2"
                                               Text="Y1："
                                               Style="{StaticResource ParamLabelStyle}"/>
                                    <mw:NumberBox Grid.Column="3"
                                                  Value="{Binding StartY, Mode=TwoWay}" Width="80" mw:NumericKeypadAttach.IsEnabled="True"/>
                                    <Button Grid.Column="4"
                                            Content="中心对齐"
                                            Style="{StaticResource SmallActionButtonStyle}"
                                            Click="{mw:Action MoveToCenterPoint}"
                                            mw:View.ActionTarget="{Binding}"
                                            IsEnabled="{Binding CanStartCalib}"/>
                                </Grid>
                            </StackPanel>
                        </Border>

                        <!-- ====== Section 2：标定参数 ====== -->
                        <Border Grid.Row="2"
                                BorderBrush="#E0E4EA"
                                BorderThickness="0,0,0,1"
                                Padding="10,8">
                            <StackPanel>
                                <!-- 区域标题 -->
                                <Grid Margin="0,0,0,6">
                                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                                        <Ellipse Width="8" Height="8" Fill="#2D3748" VerticalAlignment="Center" Margin="0,0,5,0"/>
                                        <TextBlock Text="标定参数"
                                                   Style="{StaticResource SectionHeaderTextStyle}"/>
                                    </StackPanel>
                                </Grid>

                                <!-- 行列数 / 旋转步进 -->
                                <Grid Margin="0,2">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="120"/>
                                        <ColumnDefinition Width="90"/>
                                        <ColumnDefinition Width="100"/>
                                        <ColumnDefinition Width="90"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Grid.Column="0"
                                               Text="行列数："
                                               Style="{StaticResource ParamLabelStyle}"
                                               Margin="6,0"/>
                                    <mw:IntNumberBox Grid.Column="1"
                                                     Value="{Binding RowCol, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                                     IsEnabled="{Binding CanStartCalib}" Width="80"
                                                     mw:NumericKeypadAttach.IsEnabled="True"/>
                                    <TextBlock Grid.Column="2"
                                               Text="旋转步进(°)："
                                               Style="{StaticResource ParamLabelStyle}"/>
                                    <mw:NumberBox Grid.Column="3"
                                                  Value="{Binding RotateStep, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                                  IsEnabled="{Binding CanStartCalib}" Width="80"
                                                  mw:NumericKeypadAttach.IsEnabled="True"/>
                                </Grid>

                                <!-- Wafer间距 -->
                                <Grid Margin="0,2">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="120"/>
                                        <ColumnDefinition Width="90"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Grid.Column="0"
                                               Text="Wafer间距(mm)："
                                               Style="{StaticResource ParamLabelStyle}"
                                               Margin="6,0"/>
                                    <mw:NumberBox Grid.Column="1"
                                                  Value="{Binding WaferStep, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                                  IsEnabled="{Binding CanStartCalib}" Width="80"
                                                  mw:NumericKeypadAttach.IsEnabled="True"/>
                                </Grid>
                            </StackPanel>
                        </Border>

                        <!-- ====== Section 3：验证参数 ====== -->
                        <Border Grid.Row="3"
                                BorderBrush="#E0E4EA"
                                BorderThickness="0,0,0,1"
                                Padding="10,8">
                            <StackPanel>
                                <!-- 区域标题 -->
                                <Grid Margin="0,0,0,6">
                                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                                        <Ellipse Width="8" Height="8" Fill="#2B6CB0" VerticalAlignment="Center" Margin="0,0,5,0"/>
                                        <TextBlock Text="验证参数"
                                                   Foreground="#2B6CB0"
                                                   Style="{StaticResource SectionHeaderTextStyle}"/>
                                    </StackPanel>
                                </Grid>

                                <!-- 验证起点 X / Y -->
                                <Grid Margin="0,2">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="120"/>
                                        <ColumnDefinition Width="90"/>
                                        <ColumnDefinition Width="100"/>
                                        <ColumnDefinition Width="90"/>
                                        <ColumnDefinition Width="85"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Grid.Column="0"
                                               Text="起点X(mm)："
                                               Style="{StaticResource ParamLabelStyle}"
                                               Margin="6,0"/>
                                    <mw:NumberBox Grid.Column="1"
                                                  Value="{Binding VerifyStartX, Mode=TwoWay}" Width="80"
                                                  mw:NumericKeypadAttach.IsEnabled="True"/>
                                    <TextBlock Grid.Column="2"
                                               Text="起点Y(mm)："
                                               Style="{StaticResource ParamLabelStyle}"/>
                                    <mw:NumberBox Grid.Column="3"
                                                  Value="{Binding VerifyStartY, Mode=TwoWay}" Width="80"
                                                  mw:NumericKeypadAttach.IsEnabled="True"/>
                                    <Button Grid.Column="4"
                                            Content="中心对齐"
                                            Style="{StaticResource SmallActionButtonStyle}"
                                            Click="{mw:Action VerifyApproachCenter}"
                                            mw:View.ActionTarget="{Binding}"
                                            IsEnabled="{Binding CanStartCalib}"/>

                                </Grid>

                                <!-- 验证行列数 / Wafer间距 -->
                                <Grid Margin="0,2">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="120"/>
                                        <ColumnDefinition Width="90"/>
                                        <ColumnDefinition Width="100"/>
                                        <ColumnDefinition Width="90"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Grid.Column="0"
                                               Text="行列数："
                                               Style="{StaticResource ParamLabelStyle}"
                                               Margin="6,0"/>
                                    <mw:IntNumberBox Grid.Column="1"
                                                     Value="{Binding VerifyRowCol, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                                     IsEnabled="{Binding CanStartCalib}" Width="80"
                                                     mw:NumericKeypadAttach.IsEnabled="True"/>
                                    <TextBlock Grid.Column="2"
                                               Text="Wafer间距(mm)："
                                               Style="{StaticResource ParamLabelStyle}"/>
                                    <mw:NumberBox Grid.Column="3"
                                                  Value="{Binding VerifyWaferStep, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                                  IsEnabled="{Binding CanStartCalib}" Width="80"
                                                  mw:NumericKeypadAttach.IsEnabled="True"/>
                                    <!--<Button Grid.Column="4"
                                            Content="设为起点"
                                            Style="{StaticResource SmallActionButtonStyle}"
                                            Click="{mw:Action SetVerifyStart}"
                                            mw:View.ActionTarget="{Binding}"
                                            IsEnabled="{Binding CanStartCalib}"/>-->
                                </Grid>

                                <!-- 旋转角度 -->
                                <Grid Margin="0,2">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="120"/>
                                        <ColumnDefinition Width="90"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Grid.Column="0"
                                               Text="旋转角度(°)："
                                               Style="{StaticResource ParamLabelStyle}"
                                               Margin="6,0"/>
                                    <mw:NumberBox Grid.Column="1"
                                                  Value="{Binding VerifyRotateRange, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                                  IsEnabled="{Binding CanStartCalib}" Width="80"
                                                  mw:NumericKeypadAttach.IsEnabled="True"/>
                                </Grid>
                            </StackPanel>
                        </Border>

                        <!-- ====== Section 4: 标定验证进度条 ====== -->
                        <Border Grid.Row="4"
                          BorderBrush="#E0E4EA"
                          BorderThickness="0,1,0,0"
                          Background="#F0F7FF"
                          Padding="10,8"
                          Visibility="{Binding IsProgressVisible, Converter={StaticResource
                  BoolToVisibilityConverter}}">
                            <StackPanel>
                                <!-- 进度文本 -->
                                <Grid Margin="0,0,0,6">
                                    <TextBlock Text="{Binding ProgressMessage}"
                         FontSize="12"
                         Foreground="#2B6CB0"
                         VerticalAlignment="Center"/>
                                    <TextBlock Text="{Binding ProgressText, Mode=OneWay}"
                                 FontSize="11"
                                 Foreground="#718096"
                                 HorizontalAlignment="Right"
                                 VerticalAlignment="Center"/>
                                </Grid>

                                <!-- 进度条 -->
                                <ProgressBar Height="6"
                                   Minimum="0"
                                   Maximum="100"
                                   Value="{Binding ProgressPercentage, Mode=OneWay}"
                                   Background="#E2E8F0"
                                   Foreground="#2B6CB0"
                                   BorderThickness="0"/>
                            </StackPanel>
                        </Border>

                        <!-- ====== 卡片 Footer（对标原点标定） ====== -->
                        <Border Grid.Row="5"
                                BorderBrush="#E0E4EA"
                                BorderThickness="0,1,0,0"
                                Background="#FAFBFC"
                                CornerRadius="0,0,6,6"
                                Padding="10,0">
                            <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                                <Button Content="开始标定"
                                        Click="{mw:Action StartCalib}"
                                        mw:View.ActionTarget="{Binding}"
                                        Style="{StaticResource StartCalibButtonStyle}"
                                        IsEnabled="{Binding CanStartCalib}"
                                        Margin="0,0,25,0"/>
                                <Button Content="开始验证"
                                        Click="{mw:Action StartVerify}"
                                        mw:View.ActionTarget="{Binding}"
                                        Style="{StaticResource VerifyButtonStyle}"
                                        IsEnabled="{Binding CanStartCalib}"
                                         Margin="0,0,25,0"/>
                                <Button Content="停止"
                                        Click="{mw:Action Stop}"
                                        mw:View.ActionTarget="{Binding}"
                                        Style="{StaticResource StopButtonStyle}"/>
                                <!--<Button Content="写入控制器"
                                        Click="{mw:Action WriteToController}"
                                        mw:View.ActionTarget="{Binding}"
                                        Style="{StaticResource ModuleWriteButtonStyle}"
                                        IsEnabled="{Binding CanWriteToController}"/>-->
                            </StackPanel>
                        </Border>
                    </Grid>
                </Border>
            </ScrollViewer>
        </Grid>

        <!-- 全局 Loading 遮罩（对标原点标定） -->
        <customControl:LoadingWaitView Grid.ColumnSpan="2" Panel.ZIndex="1000"/>
    </Grid>
</UserControl>
