<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        x:Class="DsmTool.MainWindow"
        Width="760" Height="640" MinWidth="640" MinHeight="520"
        Title="의존성 매트릭스 생성기 (DSM)"
        WindowStartupLocation="CenterScreen">

  <Grid Margin="16" RowDefinitions="Auto,Auto,Auto,Auto,Auto,*,Auto">

    <TextBlock Grid.Row="0" Text="프로젝트 의존성 매트릭스 (DSM) → HTML/CSV 생성기"
               FontSize="18" FontWeight="SemiBold" Margin="0,0,0,12"/>

    <!-- Root -->
    <Grid Grid.Row="1" ColumnDefinitions="90,*,Auto" Margin="0,0,0,8">
      <TextBlock Grid.Column="0" Text="대상 폴더" VerticalAlignment="Center"/>
      <TextBox Grid.Column="1" x:Name="RootBox" Watermark="분석할 저장소 루트 (*.csproj / *.vcxproj 검색)"/>
      <Button Grid.Column="2" Content="찾기…" Margin="8,0,0,0" Click="BrowseRoot"/>
    </Grid>

    <!-- Output -->
    <Grid Grid.Row="2" ColumnDefinitions="90,*,Auto" Margin="0,0,0,8">
      <TextBlock Grid.Column="0" Text="출력 폴더" VerticalAlignment="Center"/>
      <TextBox Grid.Column="1" x:Name="OutBox" Watermark="비워두면 대상 폴더에 생성"/>
      <Button Grid.Column="2" Content="찾기…" Margin="8,0,0,0" Click="BrowseOut"/>
    </Grid>

    <!-- Options -->
    <StackPanel Grid.Row="3" Orientation="Horizontal" Margin="90,0,0,4" Spacing="18">
      <CheckBox x:Name="SamplesBox" IsChecked="True" Content="Sample/Test/Example 제외"/>
      <CheckBox x:Name="AutoInternalBox" IsChecked="True" Content="내부 NuGet 자동 감지"/>
      <StackPanel Orientation="Horizontal" Spacing="6">
        <TextBlock Text="그룹:" VerticalAlignment="Center"/>
        <ComboBox x:Name="GroupCombo" Width="130" SelectedIndex="0">
          <ComboBoxItem>auto</ComboBoxItem>
          <ComboBoxItem>topfolder</ComboBoxItem>
          <ComboBoxItem>prefix</ComboBoxItem>
          <ComboBoxItem>none</ComboBoxItem>
        </ComboBox>
      </StackPanel>
    </StackPanel>

    <Expander Grid.Row="4" Header="고급 설정 (제외 경로 · 수동 패키지 매핑)" Margin="0,4,0,8">
      <StackPanel Spacing="6" Margin="4">
        <TextBlock Text="제외 경로 조각 (한 줄에 하나, 소문자 부분일치) — 빌드 산출물 등" Foreground="Gray"/>
        <TextBox x:Name="ExcludeBox" AcceptsReturn="True" Height="100"
                 FontFamily="Consolas" TextWrapping="NoWrap"
                 ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto"/>
        <TextBlock Text="수동 패키지 매핑 (선택)  pkgid=노드명 — 자동감지 보정용, 비워도 됨" Foreground="Gray" Margin="0,6,0,0"/>
        <TextBox x:Name="ComponentBox" AcceptsReturn="True" Height="80"
                 FontFamily="Consolas" TextWrapping="NoWrap"
                 ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto"/>
      </StackPanel>
    </Expander>

    <!-- Log -->
    <Border Grid.Row="5" BorderBrush="#3A3A3A" BorderThickness="1" CornerRadius="4">
      <TextBox x:Name="LogBox" IsReadOnly="True" AcceptsReturn="True"
               FontFamily="Consolas" FontSize="12"
               ScrollViewer.VerticalScrollBarVisibility="Auto"
               Background="Transparent" BorderThickness="0"/>
    </Border>

    <!-- Buttons -->
    <StackPanel Grid.Row="6" Orientation="Horizontal" HorizontalAlignment="Right" Spacing="8" Margin="0,12,0,0">
      <Button x:Name="OpenFolderBtn" Content="출력 폴더 열기" Click="OpenFolder" IsEnabled="False"/>
      <Button x:Name="OpenHtmlBtn" Content="HTML 브라우저로 열기" Click="OpenHtml" IsEnabled="False"/>
      <Button x:Name="GenBtn" Content="생성" Click="Generate"
              Background="#1F6FEB" Foreground="White" FontWeight="SemiBold" Padding="18,6"/>
    </StackPanel>

  </Grid>
</Window>
