<UserControl xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:vm="using:ClaudeDo.Ui.ViewModels.MissionControl"
             xmlns:views="using:ClaudeDo.Ui.Views"
             xmlns:loc="using:ClaudeDo.Ui.Localization"
             xmlns:conv="using:Avalonia.Data.Converters"
             x:DataType="vm:ConPtyPaneViewModel"
             x:Class="ClaudeDo.Ui.Views.MissionControl.ConPtyPaneView">
  <Border Classes="monitor-pane" BorderThickness="1" CornerRadius="10" ClipToBounds="True">
    <DockPanel LastChildFill="True">

      <!-- Header: title + close -->
      <Border DockPanel.Dock="Top"
              Background="{DynamicResource Surface2Brush}"
              BorderBrush="{DynamicResource LineBrush}"
              BorderThickness="0,0,0,1" Padding="8,3">
        <Grid ColumnDefinitions="*,Auto">
          <TextBlock Grid.Column="0" Classes="meta" Text="{Binding DisplayTitle}"
                     TextTrimming="CharacterEllipsis"
                     ToolTip.Tip="{Binding DisplayTitle}"
                     Foreground="{DynamicResource TextDimBrush}"
                     VerticalAlignment="Center" Margin="4,0,0,0" />
          <Button Grid.Column="1" Classes="title-ctrl"
                  Command="{Binding CloseCommand}"
                  ToolTip.Tip="{loc:Tr missionControl.closeSession}">
            <PathIcon Data="{StaticResource Icon.WinClose}" Width="12" Height="12"/>
          </Button>
        </Grid>
      </Border>

      <!-- Start-failure banner -->
      <Border DockPanel.Dock="Top"
              IsVisible="{Binding Terminal.StartError, Converter={x:Static conv:ObjectConverters.IsNotNull}}"
              Background="{DynamicResource ErrorTintBrush}"
              BorderBrush="{DynamicResource BloodBrush}"
              BorderThickness="0,0,0,1" Padding="12,6">
        <TextBlock Classes="meta" Text="{Binding Terminal.StartError}"
                   Foreground="{DynamicResource BloodBrush}"
                   TextWrapping="Wrap" />
      </Border>

      <!-- Embedded ConPTY terminal -->
      <views:InteractiveTerminalView DataContext="{Binding Terminal}" />

    </DockPanel>
  </Border>
</UserControl>
