<Window x:Class="AxCopilot.Views.MacroEditorWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="AX Commander — 매크로 편집"
        Width="560" Height="520"
        MinWidth="460" MinHeight="420"
        WindowStyle="None" AllowsTransparency="True"
        Background="Transparent"
        WindowStartupLocation="CenterScreen"
        ResizeMode="NoResize"
        ShowInTaskbar="False">

    <Border Background="{DynamicResource LauncherBackground}" CornerRadius="12"
            BorderBrush="{DynamicResource BorderColor}" BorderThickness="1"
            Margin="6">
        <Border.Effect>
            <DropShadowEffect BlurRadius="22" ShadowDepth="4" Opacity="0.32" Color="Black" Direction="270"/>
        </Border.Effect>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="44"/>   <!-- 타이틀바 -->
                <RowDefinition Height="Auto"/> <!-- 이름/설명 -->
                <RowDefinition Height="*"/>    <!-- 단계 목록 -->
                <RowDefinition Height="Auto"/> <!-- 하단 버튼 -->
            </Grid.RowDefinitions>

            <!-- ─── 타이틀바 ─────────────────────────────────────────────── -->
            <Border Grid.Row="0" CornerRadius="12,12,0,0"
                    Background="{DynamicResource ItemBackground}"
                    MouseLeftButtonDown="TitleBar_MouseDown">
                <Grid Margin="14,0,8,0">
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                        <TextBlock Text="&#xE768;"
                                   FontFamily="Segoe MDL2 Assets" FontSize="15"
                                   Foreground="{DynamicResource AccentColor}"
                                   VerticalAlignment="Center" Margin="0,1,10,0"/>
                        <TextBlock Text="매크로 편집"
                                   FontSize="13" FontWeight="SemiBold"
                                   Foreground="{DynamicResource PrimaryText}"
                                   VerticalAlignment="Center"/>
                    </StackPanel>
                    <Border HorizontalAlignment="Right" VerticalAlignment="Center"
                            CornerRadius="4" Padding="8,4" Cursor="Hand"
                            MouseLeftButtonUp="BtnClose_Click">
                        <Border.Style>
                            <Style TargetType="Border">
                                <Setter Property="Background" Value="Transparent"/>
                                <Style.Triggers>
                                    <Trigger Property="IsMouseOver" Value="True">
                                        <Setter Property="Background" Value="#40C05050"/>
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </Border.Style>
                        <TextBlock Text="&#xE711;" FontFamily="Segoe MDL2 Assets" FontSize="13"
                                   Foreground="{DynamicResource SecondaryText}"/>
                    </Border>
                </Grid>
            </Border>

            <!-- ─── 이름/설명 ─────────────────────────────────────────────── -->
            <StackPanel Grid.Row="1" Margin="18,14,18,8">
                <TextBlock Text="매크로 이름" FontSize="10" FontWeight="Medium"
                           Foreground="{DynamicResource SecondaryText}" Margin="0,0,0,4"/>
                <TextBox x:Name="NameBox"
                         FontSize="13" FontWeight="SemiBold"
                         Foreground="{DynamicResource PrimaryText}"
                         Background="{DynamicResource LauncherBackground}"
                         BorderBrush="{DynamicResource BorderColor}" BorderThickness="1"
                         Padding="8,6" Margin="0,0,0,10"/>

                <TextBlock Text="설명 (선택)" FontSize="10" FontWeight="Medium"
                           Foreground="{DynamicResource SecondaryText}" Margin="0,0,0,4"/>
                <TextBox x:Name="DescBox"
                         FontSize="11"
                         Foreground="{DynamicResource SecondaryText}"
                         Background="{DynamicResource LauncherBackground}"
                         BorderBrush="{DynamicResource BorderColor}" BorderThickness="1"
                         Padding="8,5" Margin="0,0,0,10"/>

                <!-- 열 헤더 -->
                <Border Height="1" Background="{DynamicResource BorderColor}" Margin="0,0,0,6"/>
                <Grid Margin="0,0,0,4">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="90"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="80"/>
                        <ColumnDefinition Width="70"/>
                        <ColumnDefinition Width="28"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Grid.Column="0" Text="유형" FontSize="10" FontWeight="Medium"
                               Foreground="{DynamicResource SecondaryText}"/>
                    <TextBlock Grid.Column="1" Text="대상 (경로/URL/명령)" FontSize="10" FontWeight="Medium"
                               Foreground="{DynamicResource SecondaryText}" Margin="4,0,0,0"/>
                    <TextBlock Grid.Column="2" Text="표시 이름" FontSize="10" FontWeight="Medium"
                               Foreground="{DynamicResource SecondaryText}" Margin="4,0,0,0"/>
                    <TextBlock Grid.Column="3" Text="딜레이(ms)" FontSize="10" FontWeight="Medium"
                               Foreground="{DynamicResource SecondaryText}" Margin="4,0,0,0"/>
                </Grid>
            </StackPanel>

            <!-- ─── 단계 목록 ─────────────────────────────────────────────── -->
            <ScrollViewer Grid.Row="2" Margin="18,0,18,0"
                          VerticalScrollBarVisibility="Auto"
                          HorizontalScrollBarVisibility="Disabled">
                <StackPanel x:Name="StepsPanel"/>
            </ScrollViewer>

            <!-- ─── 하단 버튼 바 ─────────────────────────────────────────── -->
            <Border Grid.Row="3" CornerRadius="0,0,12,12"
                    Background="{DynamicResource ItemBackground}"
                    BorderBrush="{DynamicResource BorderColor}" BorderThickness="0,1,0,0"
                    Padding="12,8">
                <Grid>
                    <!-- 단계 추가 -->
                    <Border CornerRadius="4" Padding="12,5" Cursor="Hand"
                            HorizontalAlignment="Left"
                            MouseLeftButtonUp="BtnAddStep_Click">
                        <Border.Style>
                            <Style TargetType="Border">
                                <Setter Property="Background" Value="#18FFFFFF"/>
                                <Style.Triggers>
                                    <Trigger Property="IsMouseOver" Value="True">
                                        <Setter Property="Background" Value="#28FFFFFF"/>
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </Border.Style>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="&#xE710;" FontFamily="Segoe MDL2 Assets" FontSize="12"
                                       Foreground="{DynamicResource AccentColor}"
                                       VerticalAlignment="Center" Margin="0,0,6,0"/>
                            <TextBlock Text="단계 추가" FontSize="11"
                                       Foreground="{DynamicResource SecondaryText}"/>
                        </StackPanel>
                    </Border>

                    <!-- 취소·저장 -->
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center">
                        <Border CornerRadius="4" Padding="14,5" Cursor="Hand" Margin="0,0,8,0"
                                MouseLeftButtonUp="BtnCancel_Click">
                            <Border.Style>
                                <Style TargetType="Border">
                                    <Setter Property="Background" Value="#18FFFFFF"/>
                                    <Style.Triggers>
                                        <Trigger Property="IsMouseOver" Value="True">
                                            <Setter Property="Background" Value="#28FFFFFF"/>
                                        </Trigger>
                                    </Style.Triggers>
                                </Style>
                            </Border.Style>
                            <TextBlock Text="취소" FontSize="12"
                                       Foreground="{DynamicResource SecondaryText}"/>
                        </Border>

                        <Border CornerRadius="4" Padding="16,5" Cursor="Hand"
                                MouseLeftButtonUp="BtnSave_Click">
                            <Border.Style>
                                <Style TargetType="Border">
                                    <Setter Property="Background" Value="{DynamicResource AccentColor}"/>
                                    <Style.Triggers>
                                        <Trigger Property="IsMouseOver" Value="True">
                                            <Setter Property="Opacity" Value="0.85"/>
                                        </Trigger>
                                    </Style.Triggers>
                                </Style>
                            </Border.Style>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="&#xE74E;" FontFamily="Segoe MDL2 Assets" FontSize="12"
                                           Foreground="White" VerticalAlignment="Center" Margin="0,0,6,0"/>
                                <TextBlock Text="저장" FontSize="12" FontWeight="SemiBold" Foreground="White"/>
                            </StackPanel>
                        </Border>
                    </StackPanel>
                </Grid>
            </Border>
        </Grid>
    </Border>
</Window>
