<Window x:Class="AxCopilot.Views.PreviewWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
        Title="AX Copilot — 미리보기"
        Width="860" Height="680"
        WindowStyle="None" AllowsTransparency="True"
        Background="Transparent"
        WindowStartupLocation="CenterScreen"
        ResizeMode="CanResizeWithGrip"
        MinWidth="400" MinHeight="300">
    <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="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <!-- 타이틀바 -->
            <Border Grid.Row="0" CornerRadius="12,12,0,0"
                    Background="{DynamicResource ItemBackground}"
                    MouseLeftButtonDown="TitleBar_MouseLeftButtonDown">
                <Grid Margin="16,0,8,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>

                    <!-- 좌측: 아이콘 + 제목 -->
                    <StackPanel Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center">
                        <TextBlock Text="&#xE8A1;" FontFamily="Segoe MDL2 Assets" FontSize="15"
                                   Foreground="{DynamicResource AccentColor}"
                                   VerticalAlignment="Center" Margin="0,1,10,0"/>
                        <TextBlock x:Name="TitleText" Text="미리보기"
                                   FontSize="14" FontWeight="SemiBold"
                                   Foreground="{DynamicResource PrimaryText}"
                                   VerticalAlignment="Center"/>
                    </StackPanel>

                    <!-- 우측: 외부열기, 최소화, 최대화, 닫기 -->
                    <StackPanel Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center">
                        <!-- 외부 프로그램으로 열기 -->
                        <Border Width="40" Height="40" Background="Transparent" Cursor="Hand"
                                CornerRadius="8" ToolTip="외부 프로그램으로 열기"
                                MouseLeftButtonDown="OpenExternalBtn_Click"
                                MouseEnter="TitleBtn_Enter" MouseLeave="TitleBtn_Leave">
                            <TextBlock Text="&#xE8A7;" FontFamily="Segoe MDL2 Assets" FontSize="12"
                                       Foreground="{DynamicResource SecondaryText}"
                                       HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Border>
                        <Border Width="40" Height="40" Background="Transparent" Cursor="Hand"
                                CornerRadius="8"
                                MouseLeftButtonDown="MinBtn_Click"
                                MouseEnter="TitleBtn_Enter" MouseLeave="TitleBtn_Leave">
                            <TextBlock Text="&#xE921;" FontFamily="Segoe MDL2 Assets" FontSize="10"
                                       Foreground="{DynamicResource SecondaryText}"
                                       HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Border>
                        <Border Width="40" Height="40" Background="Transparent" Cursor="Hand"
                                CornerRadius="8"
                                MouseLeftButtonDown="MaxBtn_Click"
                                MouseEnter="TitleBtn_Enter" MouseLeave="TitleBtn_Leave">
                            <TextBlock x:Name="MaxBtnIcon" Text="&#xE922;" FontFamily="Segoe MDL2 Assets" FontSize="10"
                                       Foreground="{DynamicResource SecondaryText}"
                                       HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Border>
                        <Border Width="40" Height="40" Background="Transparent" Cursor="Hand"
                                CornerRadius="8"
                                MouseLeftButtonDown="CloseBtn_Click"
                                MouseEnter="CloseBtnEnter" MouseLeave="TitleBtn_Leave">
                            <TextBlock Text="&#xE711;" FontFamily="Segoe MDL2 Assets" FontSize="10"
                                       Foreground="{DynamicResource SecondaryText}"
                                       HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Border>
                    </StackPanel>
                </Grid>
            </Border>

            <!-- 탭 바 -->
            <Border Grid.Row="1" Background="#0AFFFFFF"
                    BorderBrush="{DynamicResource BorderColor}" BorderThickness="0,0,0,1"
                    Padding="4,0">
                <ScrollViewer HorizontalScrollBarVisibility="Hidden"
                              VerticalScrollBarVisibility="Disabled" CanContentScroll="True">
                    <StackPanel x:Name="TabPanel" Orientation="Horizontal"/>
                </ScrollViewer>
            </Border>

            <!-- 콘텐츠 영역 -->
            <Grid Grid.Row="2" ClipToBounds="True">
                <wv2:WebView2 x:Name="PreviewBrowser" Visibility="Collapsed"/>
                <ScrollViewer x:Name="TextScroll" Visibility="Collapsed"
                              VerticalScrollBarVisibility="Auto" Padding="16,12">
                    <TextBlock x:Name="TextContent" TextWrapping="Wrap"
                               FontFamily="Consolas" FontSize="12"
                               Foreground="{DynamicResource PrimaryText}"/>
                </ScrollViewer>
                <DataGrid x:Name="DataGridContent" Visibility="Collapsed"
                          AutoGenerateColumns="True" IsReadOnly="True"
                          HeadersVisibility="Column" GridLinesVisibility="All"
                          Background="Transparent"
                          Foreground="{DynamicResource PrimaryText}"
                          BorderThickness="0" CanUserAddRows="False"
                          RowBackground="#0AFFFFFF" AlternatingRowBackground="#15FFFFFF"
                          ColumnHeaderHeight="30" RowHeight="28" FontSize="11.5"/>
                <TextBlock x:Name="EmptyMessage" Text="미리보기할 파일이 없습니다"
                           HorizontalAlignment="Center" VerticalAlignment="Center"
                           FontSize="13" Foreground="{DynamicResource SecondaryText}"
                           Visibility="Collapsed"/>
            </Grid>
        </Grid>
    </Border>
</Window>
