<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:md="clr-namespace:Markdown.Xaml;assembly=Markdown.Xaml"
        xmlns:av="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="av"
        x:Class="GTPCorrgir.Chat" Title="Chat with OpenAI" Height="300" Width="300" ResizeMode="CanResizeWithGrip"
        WindowStyle="None" Background="Transparent" AllowsTransparency="True" MouseEnter="Window_MouseEnter"
        MouseLeave="Window_MouseLeave" KeyDown="Window_KeyDown" Opacity="0.8" av:DesignHeight="320.439"
        av:DesignWidth="609.769">
    <Window.Resources>
        <md:Markdown x:Key="MarkdownConverter" />
    </Window.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="2*" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <!-- Barra superior con controles -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <!-- Selector de modelo LLM -->
            <ComboBox x:Name="modelSelector" Grid.Column="0" Margin="1" SelectionChanged="CambiarModelo" />

            <!-- Botón de configuración -->
            <Button x:Name="settingsButton" Grid.Column="1" Content="⚙" Width="20" Height="20" Margin="5,0"
                    Click="SettingsButton_Click" ToolTip="Configuración" />

            <!-- Área para mover la ventana -->
            <Border Background="#444" Height="20" Width="20" Grid.Column="2" Margin="5,0,10,0"
                    MouseLeftButtonDown="Border_MouseLeftButtonDown" Cursor="SizeAll" ToolTip="Mover ventana">
                <TextBlock Text="&#x2630;" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White" />
            </Border>
        </Grid>

        <!-- Área de Respuesta -->
        <Grid Grid.Row="1" Margin="1">
            <RichTextBox Name="responseArea" IsReadOnly="True">
                <RichTextBox.Resources>
                    <md:Markdown x:Key="Markdown" />
                </RichTextBox.Resources>
            </RichTextBox>
            <Button x:Name="clearButton" Content="Limpiar" Width="40" Height="24" HorizontalAlignment="Right"
                    VerticalAlignment="Bottom" Margin="0" Click="clearButton_Click" />
        </Grid>

        <!-- Área de Pregunta con Botón -->
        <Grid Grid.Row="2" Margin="1">
            <TextBox x:Name="questionArea" Padding="10" VerticalScrollBarVisibility="Auto" TextWrapping="Wrap"
                    Background="White" PreviewKeyDown="QuestionArea_PreviewKeyDown" />
            <Button x:Name="sendButton" Content="Enviar" Width="40" Height="24" HorizontalAlignment="Right"
                    VerticalAlignment="Bottom" Margin="0" Click="SendButton_Click" />
        </Grid>
    </Grid>
</Window>