<Window x:Class="AxCopilot.Views.ClipboardImagePreviewWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="AX Copilot — 이미지 미리보기"
        Width="820" Height="640"
        WindowStyle="None" AllowsTransparency="True"
        Background="Transparent"
        WindowStartupLocation="CenterScreen"
        ResizeMode="CanResizeWithGrip"
        MinWidth="320" MinHeight="260">

    <!-- Phase L2-3: 클립보드 이미지 미리보기 창 -->

    <Border Background="{DynamicResource LauncherBackground}" CornerRadius="12"
            BorderBrush="{DynamicResource BorderColor}" BorderThickness="1"
            Margin="6">
        <Border.Effect>
            <DropShadowEffect BlurRadius="20" ShadowDepth="4" Opacity="0.3" Color="Black" Direction="270"/>
        </Border.Effect>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="44"/>   <!-- 타이틀바 -->
                <RowDefinition Height="*"/>    <!-- 이미지 영역 -->
                <RowDefinition Height="46"/>   <!-- 하단 툴바 -->
            </Grid.RowDefinitions>

            <!-- ─── 타이틀바 ─────────────────────────────────────────────── -->
            <Border Grid.Row="0" CornerRadius="12,12,0,0"
                    Background="{DynamicResource ItemBackground}"
                    MouseLeftButtonDown="TitleBar_MouseDown">
                <Grid Margin="16,0,8,0">
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                        <!-- 이미지 아이콘 -->
                        <TextBlock Text="&#xEB9F;" 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"/>
                        <TextBlock x:Name="SizeLabel" Text=""
                                   FontSize="11" Foreground="{DynamicResource SecondaryText}"
                                   VerticalAlignment="Center" Margin="12,0,0,0"/>
                    </StackPanel>

                    <!-- 닫기 버튼 -->
                    <Border x:Name="BtnClose" 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>

            <!-- ─── 이미지 영역 ────────────────────────────────────────────── -->
            <ScrollViewer Grid.Row="1" x:Name="ImageScroll"
                          HorizontalScrollBarVisibility="Auto"
                          VerticalScrollBarVisibility="Auto"
                          Background="{DynamicResource LauncherBackground}"
                          PreviewMouseWheel="ImageScroll_PreviewMouseWheel">
                <Grid HorizontalAlignment="Center" VerticalAlignment="Center" Margin="8">
                    <Image x:Name="PreviewImage"
                           RenderOptions.BitmapScalingMode="HighQuality"
                           Stretch="None"
                           HorizontalAlignment="Center" VerticalAlignment="Center">
                        <Image.LayoutTransform>
                            <ScaleTransform x:Name="ZoomTransform" ScaleX="1" ScaleY="1"/>
                        </Image.LayoutTransform>
                    </Image>
                </Grid>
            </ScrollViewer>

            <!-- ─── 하단 툴바 ─────────────────────────────────────────────── -->
            <Border Grid.Row="2" CornerRadius="0,0,12,12"
                    Background="{DynamicResource ItemBackground}"
                    BorderBrush="{DynamicResource BorderColor}" BorderThickness="0,1,0,0">
                <Grid Margin="12,0">

                    <!-- 좌측: 줌 컨트롤 -->
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">

                        <!-- 축소 버튼 -->
                        <Border CornerRadius="6" Padding="8,5" Cursor="Hand" Margin="0,0,2,0"
                                ToolTip="축소 (−)" MouseLeftButtonUp="BtnZoomOut_Click">
                            <Border.Style>
                                <Style TargetType="Border">
                                    <Setter Property="Background" Value="Transparent"/>
                                    <Style.Triggers>
                                        <Trigger Property="IsMouseOver" Value="True">
                                            <Setter Property="Background" Value="{DynamicResource ItemHoverBackground}"/>
                                        </Trigger>
                                    </Style.Triggers>
                                </Style>
                            </Border.Style>
                            <TextBlock Text="&#xE1A9;" FontFamily="Segoe MDL2 Assets" FontSize="13"
                                       Foreground="{DynamicResource PrimaryText}"/>
                        </Border>

                        <!-- 줌 퍼센트 라벨 -->
                        <Border CornerRadius="4" Padding="6,4" Margin="2,0"
                                Background="{DynamicResource HintBackground}">
                            <TextBlock x:Name="ZoomLabel" Text="100%"
                                       FontSize="11" FontWeight="Medium"
                                       Foreground="{DynamicResource PrimaryText}"
                                       MinWidth="44" TextAlignment="Center"/>
                        </Border>

                        <!-- 확대 버튼 -->
                        <Border CornerRadius="6" Padding="8,5" Cursor="Hand" Margin="2,0,6,0"
                                ToolTip="확대 (+)" MouseLeftButtonUp="BtnZoomIn_Click">
                            <Border.Style>
                                <Style TargetType="Border">
                                    <Setter Property="Background" Value="Transparent"/>
                                    <Style.Triggers>
                                        <Trigger Property="IsMouseOver" Value="True">
                                            <Setter Property="Background" Value="{DynamicResource ItemHoverBackground}"/>
                                        </Trigger>
                                    </Style.Triggers>
                                </Style>
                            </Border.Style>
                            <TextBlock Text="&#xE1A8;" FontFamily="Segoe MDL2 Assets" FontSize="13"
                                       Foreground="{DynamicResource PrimaryText}"/>
                        </Border>

                        <!-- 구분선 -->
                        <Border Width="1" Height="20" Margin="2,0,8,0"
                                Background="{DynamicResource BorderColor}"/>

                        <!-- 실제 크기 -->
                        <Border CornerRadius="6" Padding="8,5" Cursor="Hand" Margin="0,0,2,0"
                                ToolTip="실제 크기 (0)" MouseLeftButtonUp="BtnActualSize_Click">
                            <Border.Style>
                                <Style TargetType="Border">
                                    <Setter Property="Background" Value="Transparent"/>
                                    <Style.Triggers>
                                        <Trigger Property="IsMouseOver" Value="True">
                                            <Setter Property="Background" Value="{DynamicResource ItemHoverBackground}"/>
                                        </Trigger>
                                    </Style.Triggers>
                                </Style>
                            </Border.Style>
                            <TextBlock Text="1:1" FontSize="11" FontWeight="Bold"
                                       Foreground="{DynamicResource SecondaryText}"/>
                        </Border>

                        <!-- 창에 맞추기 -->
                        <Border CornerRadius="6" Padding="8,5" Cursor="Hand"
                                ToolTip="창에 맞추기 (F)" MouseLeftButtonUp="BtnFitToWindow_Click">
                            <Border.Style>
                                <Style TargetType="Border">
                                    <Setter Property="Background" Value="Transparent"/>
                                    <Style.Triggers>
                                        <Trigger Property="IsMouseOver" Value="True">
                                            <Setter Property="Background" Value="{DynamicResource ItemHoverBackground}"/>
                                        </Trigger>
                                    </Style.Triggers>
                                </Style>
                            </Border.Style>
                            <TextBlock Text="&#xE744;" FontFamily="Segoe MDL2 Assets" FontSize="13"
                                       Foreground="{DynamicResource SecondaryText}"/>
                        </Border>
                    </StackPanel>

                    <!-- 우측: 복사 / 저장 버튼 -->
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center">

                        <!-- 파일로 저장 -->
                        <Border CornerRadius="8" Padding="12,6" Cursor="Hand" Margin="0,0,8,0"
                                ToolTip="파일로 저장 (Ctrl+S)"
                                MouseLeftButtonUp="BtnSave_Click">
                            <Border.Style>
                                <Style TargetType="Border">
                                    <Setter Property="Background" Value="{DynamicResource ItemBackground}"/>
                                    <Style.Triggers>
                                        <Trigger Property="IsMouseOver" Value="True">
                                            <Setter Property="Background" Value="{DynamicResource ItemHoverBackground}"/>
                                        </Trigger>
                                    </Style.Triggers>
                                </Style>
                            </Border.Style>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="&#xE74E;" FontFamily="Segoe MDL2 Assets" FontSize="12"
                                           Foreground="{DynamicResource SecondaryText}" VerticalAlignment="Center"/>
                                <TextBlock Text=" 저장" FontSize="12"
                                           Foreground="{DynamicResource SecondaryText}" Margin="4,0,0,0"/>
                            </StackPanel>
                        </Border>

                        <!-- 클립보드 복사 -->
                        <Border CornerRadius="8" Padding="12,6" Cursor="Hand"
                                ToolTip="클립보드에 복사 (Ctrl+C)"
                                MouseLeftButtonUp="BtnCopy_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="&#xE8C8;" FontFamily="Segoe MDL2 Assets" FontSize="12"
                                           Foreground="White" VerticalAlignment="Center"/>
                                <TextBlock Text=" 복사" FontSize="12" Foreground="White" Margin="4,0,0,0"/>
                            </StackPanel>
                        </Border>
                    </StackPanel>
                </Grid>
            </Border>
        </Grid>
    </Border>
</Window>
