<UserControl x:Class="SharepointToolbox.Views.Tabs.TransferView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:loc="clr-namespace:SharepointToolbox.Localization"
             xmlns:common="clr-namespace:SharepointToolbox.Views.Common">
    <DockPanel Margin="10">
        <!-- Options Panel (Left) -->
        <ScrollViewer DockPanel.Dock="Left" Width="340" Margin="0,0,10,0"
                      VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
        <StackPanel>
            <!-- Source -->
            <GroupBox Header="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[transfer.sourcesite]}"
                      Margin="0,0,0,10">
                <StackPanel Margin="5">
                    <TextBox Text="{Binding SourceSiteUrl, UpdateSourceTrigger=PropertyChanged}"
                             IsReadOnly="True" Margin="0,0,0,5" />
                    <Button Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[transfer.browse]}"
                            Click="BrowseSource_Click" Margin="0,0,0,5" />
                    <TextBlock Text="{Binding SourceLibrary}" FontWeight="SemiBold" />
                    <TextBlock Text="{Binding SourceFolderPath}" Foreground="{DynamicResource TextMutedBrush}" />
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Foreground="{DynamicResource AccentBrush}" FontStyle="Italic" FontSize="11"
                                   Text="{Binding SelectedFileCount, Mode=OneWay}" />
                        <TextBlock Foreground="{DynamicResource AccentBrush}" FontStyle="Italic" FontSize="11"
                                   Text="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[transfer.text.files_selected]}" />
                    </StackPanel>
                            <StackPanel Orientation="Horizontal" Margin="0,6,0,0">
                        <CheckBox Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[transfer.chk.include_source]}"
                                  IsChecked="{Binding IncludeSourceFolder}"
                                  VerticalAlignment="Center"
                                  ToolTip="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[transfer.chk.include_source.tooltip]}" />
                        <common:InfoButton Margin="6,0,0,0"
                                           Title="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[help.transfer.incsource.title]}"
                                           Body="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[help.transfer.incsource.body]}" />
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Margin="0,4,0,0">
                        <CheckBox Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[transfer.chk.copy_contents]}"
                                  IsChecked="{Binding CopyFolderContents}"
                                  VerticalAlignment="Center"
                                  ToolTip="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[transfer.chk.copy_contents.tooltip]}" />
                        <common:InfoButton Margin="6,0,0,0"
                                           Title="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[help.transfer.copycontent.title]}"
                                           Body="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[help.transfer.copycontent.body]}" />
                    </StackPanel>
                </StackPanel>
            </GroupBox>

            <!-- Destination -->
            <GroupBox Header="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[transfer.destsite]}"
                      Margin="0,0,0,10">
                <StackPanel Margin="5">
                    <TextBox Text="{Binding DestSiteUrl, UpdateSourceTrigger=PropertyChanged}"
                             IsReadOnly="True" Margin="0,0,0,5" />
                    <Button Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[transfer.browse]}"
                            Click="BrowseDest_Click" Margin="0,0,0,5" />
                    <TextBlock Text="{Binding DestLibrary}" FontWeight="SemiBold" />
                    <TextBlock Text="{Binding DestFolderPath}" Foreground="{DynamicResource TextMutedBrush}" />
                </StackPanel>
            </GroupBox>

            <!-- Transfer Mode -->
            <GroupBox Header="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[transfer.mode]}"
                      Margin="0,0,0,10">
                <StackPanel Margin="5">
                    <RadioButton Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[transfer.mode.copy]}"
                                 IsChecked="{Binding TransferMode, Converter={StaticResource EnumBoolConverter}, ConverterParameter=Copy}"
                                 Margin="0,0,0,3" />
                    <RadioButton Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[transfer.mode.move]}"
                                 IsChecked="{Binding TransferMode, Converter={StaticResource EnumBoolConverter}, ConverterParameter=Move}" />
                </StackPanel>
            </GroupBox>

            <!-- Conflict Policy -->
            <GroupBox Margin="0,0,0,10">
                <GroupBox.Header>
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                        <TextBlock Text="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[transfer.conflict]}" VerticalAlignment="Center" />
                        <common:InfoButton Margin="6,0,0,0"
                                           Title="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[help.transfer.conflict.title]}"
                                           Body="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[help.transfer.conflict.body]}" />
                    </StackPanel>
                </GroupBox.Header>
                <ComboBox SelectedIndex="0" x:Name="ConflictCombo" SelectionChanged="ConflictCombo_SelectionChanged">
                    <ComboBoxItem Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[transfer.conflict.skip]}" />
                    <ComboBoxItem Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[transfer.conflict.overwrite]}" />
                    <ComboBoxItem Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[transfer.conflict.rename]}" />
                </ComboBox>
            </GroupBox>

            <!-- Actions -->
            <Button Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[transfer.start]}"
                    Command="{Binding RunCommand}" Margin="0,0,0,5"
                    IsEnabled="{Binding IsRunning, Converter={StaticResource InverseBoolConverter}}" />
            <Button Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[status.cancelled]}"
                    Command="{Binding CancelCommand}"
                    Visibility="{Binding IsRunning, Converter={StaticResource BoolToVisibilityConverter}}" />

            <!-- Progress -->
            <common:Spinner Width="20" Height="20" HorizontalAlignment="Left" Margin="0,10,0,5"
                            Visibility="{Binding IsRunning, Converter={StaticResource BoolToVisibilityConverter}}" />
            <TextBlock Text="{Binding StatusMessage}" TextWrapping="Wrap" />

            <!-- Results -->
            <TextBlock Text="{Binding ResultSummary}" FontWeight="Bold" Margin="0,10,0,5"
                       Visibility="{Binding ResultSummary, Converter={StaticResource StringToVisibilityConverter}}" />
            <Button Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[bulk.exportfailed]}"
                    Command="{Binding ExportFailedCommand}"
                    Visibility="{Binding HasFailures, Converter={StaticResource BoolToVisibilityConverter}}" />
        </StackPanel>
        </ScrollViewer>

        <!-- Right panel placeholder for future enhancements -->
        <Border />
    </DockPanel>
</UserControl>
