<UserControl x:Class="OutlookAIAssistant.UI.TaskPaneControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="700" d:DesignWidth="350" Background="#1E1E1E" Foreground="White">
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/> <!-- Header -->
            <RowDefinition Height="*"/>    <!-- Chat Display -->
            <RowDefinition Height="Auto"/> <!-- Response Actions -->
            <RowDefinition Height="Auto"/> <!-- Input Area -->
        </Grid.RowDefinitions>

        <!-- Header -->
        <Border Grid.Row="0" Background="#2D2D30" Padding="15">
            <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                <TextBlock Text="Outlook AI" FontSize="18" FontWeight="SemiBold" Foreground="#0078D7"/>
                <TextBlock x:Name="LblStatus" Text="Ready" FontSize="12" Foreground="LightGreen" Margin="10,4,0,0" VerticalAlignment="Center"/>
            </StackPanel>
        </Border>

        <!-- Chat Display Area -->
        <ScrollViewer x:Name="ChatScrollViewer" Grid.Row="1" Padding="15" Background="#1E1E1E" VerticalScrollBarVisibility="Auto">
            <StackPanel x:Name="ChatPanel" Spacing="10">
                <!-- Initial Welcome Message -->
                <Border Background="#2D2D30" CornerRadius="8" Padding="10" Margin="0,0,30,10">
                    <TextBlock Text="Select an email and tell me how you want to reply!" TextWrapping="Wrap" Foreground="#CCCCCC"/>
                </Border>
            </StackPanel>
        </ScrollViewer>

        <!-- Response Actions (Hidden by default, shown when response exists) -->
        <Border x:Name="ActionPanel" Grid.Row="2" Background="#252526" Padding="10" Visibility="Collapsed">
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Spacing="10">
                <Button Content="Copy" Width="70" Padding="5" Background="#333337" Foreground="White" BorderThickness="0" Cursor="Hand" Click="OnCopyClicked"/>
                <Button Content="Insert into Draft" Padding="10,5" Background="#0078D7" Foreground="White" BorderThickness="0" Cursor="Hand" Click="OnInsertDraftClicked"/>
            </StackPanel>
        </Border>

        <!-- Input Area -->
        <Border Grid.Row="3" Background="#2D2D30" Padding="10">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>

                <StackPanel Grid.Row="0" Grid.ColumnSpan="2" Orientation="Horizontal" Margin="0,0,0,10" Spacing="5">
                    <Button Content="Professional" Padding="5" Background="#333337" Foreground="White" BorderThickness="0" Cursor="Hand" Click="OnQuickPromptClicked" Tag="professional"/>
                    <Button Content="Concise" Padding="5" Background="#333337" Foreground="White" BorderThickness="0" Cursor="Hand" Click="OnQuickPromptClicked" Tag="concise"/>
                    <Button Content="Polite Support" Padding="5" Background="#333337" Foreground="White" BorderThickness="0" Cursor="Hand" Click="OnQuickPromptClicked" Tag="support"/>
                </StackPanel>

                <TextBox x:Name="TxtPrompt" Grid.Row="1" Grid.Column="0" Height="60" TextWrapping="Wrap" AcceptsReturn="True" 
                         Background="#1E1E1E" Foreground="White" BorderThickness="1" BorderBrush="#3F3F46" Padding="5" 
                         VerticalScrollBarVisibility="Auto" KeyDown="TxtPrompt_KeyDown"/>
                
                <Button Grid.Row="1" Grid.Column="1" Content="Send" Width="60" Margin="10,0,0,0" 
                        Background="#0078D7" Foreground="White" BorderThickness="0" Cursor="Hand" Click="OnGenerateClicked"/>
            </Grid>
        </Border>
    </Grid>
</UserControl>
