<Window x:Class="AxCopilot.Views.QuickLookWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="AX Commander — 빠른 미리보기"
        Width="400" Height="500"
        MinWidth="260" MinHeight="200"
        WindowStyle="None" AllowsTransparency="True"
        Background="Transparent"
        WindowStartupLocation="Manual"
        ResizeMode="CanResizeWithGrip"
        Topmost="True">

    <!-- F3 빠른 미리보기: 이미지/텍스트/폴더/파일 정보 -->

    <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="*"/>    <!-- 컨텐츠 -->
                <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 x:Name="FileTypeIcon"
                                   Text="&#xE7C3;"
                                   FontFamily="Segoe MDL2 Assets" FontSize="15"
                                   Foreground="{DynamicResource AccentColor}"
                                   VerticalAlignment="Center" Margin="0,1,10,0"/>
                        <TextBlock x:Name="FileNameText" Text=""
                                   FontSize="13" FontWeight="SemiBold"
                                   Foreground="{DynamicResource PrimaryText}"
                                   VerticalAlignment="Center"
                                   TextTrimming="CharacterEllipsis"
                                   MaxWidth="270"/>
                    </StackPanel>

                    <!-- 우측 버튼 그룹 -->
                    <StackPanel HorizontalAlignment="Right" VerticalAlignment="Center"
                                Orientation="Horizontal">

                        <!-- 편집 버튼 (텍스트 파일일 때만 표시) -->
                        <Border x:Name="BtnEdit"
                                CornerRadius="4" Padding="8,4" Cursor="Hand"
                                Visibility="Collapsed" Margin="0,0,2,0"
                                ToolTip="편집 모드 전환 (Ctrl+E)"
                                MouseLeftButtonUp="BtnEdit_Click">
                            <Border.Style>
                                <Style TargetType="Border">
                                    <Setter Property="Background" Value="Transparent"/>
                                    <Style.Triggers>
                                        <Trigger Property="IsMouseOver" Value="True">
                                            <Setter Property="Background" Value="#28FFFFFF"/>
                                        </Trigger>
                                    </Style.Triggers>
                                </Style>
                            </Border.Style>
                            <TextBlock x:Name="BtnEditIcon"
                                       Text="&#xE70F;"
                                       FontFamily="Segoe MDL2 Assets" FontSize="13"
                                       Foreground="{DynamicResource SecondaryText}"/>
                        </Border>

                        <!-- 닫기 버튼 -->
                        <Border 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>
                    </StackPanel>
                </Grid>
            </Border>

            <!-- ─── 컨텐츠 영역 ───────────────────────────────────────────── -->
            <Grid Grid.Row="1">

                <!-- 이미지 미리보기 -->
                <ScrollViewer x:Name="ImageScrollViewer"
                              HorizontalScrollBarVisibility="Auto"
                              VerticalScrollBarVisibility="Auto"
                              Visibility="Collapsed"
                              Background="{DynamicResource LauncherBackground}">
                    <Image x:Name="PreviewImage"
                           RenderOptions.BitmapScalingMode="HighQuality"
                           Stretch="Uniform"
                           HorizontalAlignment="Center"
                           VerticalAlignment="Center"
                           Margin="8"/>
                </ScrollViewer>

                <!-- 텍스트/코드 미리보기 -->
                <ScrollViewer x:Name="TextScrollViewer"
                              HorizontalScrollBarVisibility="Auto"
                              VerticalScrollBarVisibility="Auto"
                              Visibility="Collapsed">
                    <Grid>
                        <!-- 코드 배경 (줄 번호 열) -->
                        <Border x:Name="LineNumBg"
                                HorizontalAlignment="Left"
                                Width="40"
                                Background="#0AFFFFFF"
                                Visibility="Collapsed"/>
                        <!-- 줄 번호 텍스트 -->
                        <TextBlock x:Name="LineNumbers"
                                   FontFamily="Cascadia Code, Consolas, Courier New"
                                   FontSize="12"
                                   Foreground="{DynamicResource SecondaryText}"
                                   TextWrapping="NoWrap"
                                   HorizontalAlignment="Left"
                                   Opacity="0.5"
                                   Margin="6,12,0,12"
                                   Visibility="Collapsed"/>
                        <!-- 코드/텍스트 본문 -->
                        <TextBlock x:Name="PreviewText"
                                   FontFamily="Cascadia Code, Consolas, Courier New"
                                   FontSize="12"
                                   Foreground="{DynamicResource PrimaryText}"
                                   TextWrapping="NoWrap"
                                   Margin="14,12"/>
                    </Grid>
                </ScrollViewer>

                <!-- 인라인 편집 TextBox (편집 모드에서만 표시) -->
                <TextBox x:Name="TextEditBox"
                         FontFamily="Cascadia Code, Consolas, Courier New"
                         FontSize="12"
                         Foreground="{DynamicResource PrimaryText}"
                         Background="{DynamicResource LauncherBackground}"
                         BorderThickness="0"
                         Padding="14,12"
                         AcceptsReturn="True"
                         AcceptsTab="True"
                         HorizontalScrollBarVisibility="Auto"
                         VerticalScrollBarVisibility="Auto"
                         TextWrapping="NoWrap"
                         SpellCheck.IsEnabled="False"
                         Visibility="Collapsed"
                         TextChanged="TextEditBox_TextChanged"/>

                <!-- PDF 미리보기 (텍스트 추출) -->
                <ScrollViewer x:Name="PdfScrollViewer"
                              HorizontalScrollBarVisibility="Disabled"
                              VerticalScrollBarVisibility="Auto"
                              Visibility="Collapsed">
                    <StackPanel>
                        <!-- PDF 헤더 배지 -->
                        <Border Background="#15EA4335" CornerRadius="6"
                                Padding="12,6" Margin="10,10,10,0">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="&#xEA90;"
                                           FontFamily="Segoe MDL2 Assets" FontSize="13"
                                           Foreground="#EA4335" VerticalAlignment="Center"
                                           Margin="0,0,8,0"/>
                                <TextBlock x:Name="PdfMetaText"
                                           FontSize="11"
                                           Foreground="{DynamicResource SecondaryText}"
                                           VerticalAlignment="Center"/>
                            </StackPanel>
                        </Border>
                        <TextBlock x:Name="PdfPreviewText"
                                   FontFamily="Segoe UI, Malgun Gothic"
                                   FontSize="12"
                                   Foreground="{DynamicResource PrimaryText}"
                                   TextWrapping="Wrap"
                                   Margin="14,12"/>
                    </StackPanel>
                </ScrollViewer>

                <!-- Office 문서 미리보기 (텍스트 추출) -->
                <ScrollViewer x:Name="OfficeScrollViewer"
                              HorizontalScrollBarVisibility="Disabled"
                              VerticalScrollBarVisibility="Auto"
                              Visibility="Collapsed">
                    <StackPanel>
                        <!-- Office 헤더 배지 -->
                        <Border Background="#152196F3" CornerRadius="6"
                                Padding="12,6" Margin="10,10,10,0">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock x:Name="OfficeTypeIcon"
                                           FontFamily="Segoe MDL2 Assets" FontSize="13"
                                           Foreground="#2196F3" VerticalAlignment="Center"
                                           Margin="0,0,8,0"/>
                                <TextBlock x:Name="OfficeMetaText"
                                           FontSize="11"
                                           Foreground="{DynamicResource SecondaryText}"
                                           VerticalAlignment="Center"/>
                            </StackPanel>
                        </Border>
                        <TextBlock x:Name="OfficePreviewText"
                                   FontFamily="Segoe UI, Malgun Gothic"
                                   FontSize="12"
                                   Foreground="{DynamicResource PrimaryText}"
                                   TextWrapping="Wrap"
                                   Margin="14,12"/>
                    </StackPanel>
                </ScrollViewer>

                <!-- 정보 패널 (폴더/앱/기타 파일) -->
                <StackPanel x:Name="InfoPanel"
                            VerticalAlignment="Center"
                            HorizontalAlignment="Center"
                            Visibility="Collapsed">
                    <TextBlock x:Name="InfoTypeIcon"
                               Text="&#xE7C3;"
                               FontFamily="Segoe MDL2 Assets"
                               FontSize="52"
                               Foreground="{DynamicResource AccentColor}"
                               HorizontalAlignment="Center"/>
                    <TextBlock x:Name="InfoTypeName"
                               Text=""
                               FontSize="14"
                               FontWeight="Medium"
                               Foreground="{DynamicResource PrimaryText}"
                               HorizontalAlignment="Center"
                               Margin="0,10,0,0"
                               TextWrapping="Wrap"
                               TextAlignment="Center"
                               MaxWidth="320"/>
                    <TextBlock x:Name="InfoSubText"
                               Text=""
                               FontSize="11"
                               Foreground="{DynamicResource SecondaryText}"
                               HorizontalAlignment="Center"
                               Margin="0,4,0,0"/>
                </StackPanel>

            </Grid>

            <!-- ─── 하단 메타 정보 ─────────────────────────────────────────── -->
            <Border Grid.Row="2" CornerRadius="0,0,12,12"
                    Background="{DynamicResource ItemBackground}"
                    BorderBrush="{DynamicResource BorderColor}" BorderThickness="0,1,0,0"
                    Padding="14,7">
                <Grid>
                    <TextBlock x:Name="FooterPath"
                               Text=""
                               FontSize="10"
                               Foreground="{DynamicResource SecondaryText}"
                               TextTrimming="CharacterEllipsis"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center"
                               MaxWidth="240"/>
                    <TextBlock x:Name="FooterMeta"
                               Text=""
                               FontSize="10"
                               Foreground="{DynamicResource SecondaryText}"
                               HorizontalAlignment="Right"
                               VerticalAlignment="Center"/>
                </Grid>
            </Border>
        </Grid>
    </Border>
</Window>
