<UserControl xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:vm="using:OTSSignsOrchestrator.Desktop.ViewModels"
             x:Class="OTSSignsOrchestrator.Desktop.Views.LogsView"
             x:DataType="vm:LogsViewModel">

    <DockPanel>
        <!-- Page header -->
        <StackPanel DockPanel.Dock="Top" Margin="0,0,0,4">
            <TextBlock Text="Activity Logs" Classes="pageTitle" />
            <TextBlock Text="Deployment history and operations log" Classes="pageSubtitle" />
        </StackPanel>

        <!-- Toolbar -->
        <Border DockPanel.Dock="Top" Classes="toolbar" Margin="0,0,0,16">
            <StackPanel Orientation="Horizontal" Spacing="10">
                <Button Content="Refresh" Classes="accent" Command="{Binding LoadLogsCommand}" />
                <TextBlock Text="{Binding StatusMessage}" Classes="status"
                           VerticalAlignment="Center" Margin="4,0,0,0" />
            </StackPanel>
        </Border>

        <!-- Logs grid -->
        <DataGrid ItemsSource="{Binding Logs}"
                  AutoGenerateColumns="False"
                  IsReadOnly="True"
                  GridLinesVisibility="Horizontal"
                  CanUserResizeColumns="True">
            <DataGrid.Columns>
                <DataGridTextColumn Header="Time" Binding="{Binding Timestamp, StringFormat='{}{0:g}'}" Width="150" />
                <DataGridTextColumn Header="Operation" Binding="{Binding Operation}" Width="100" />
                <DataGridTextColumn Header="Status" Binding="{Binding Status}" Width="80" />
                <DataGridTextColumn Header="Stack" Binding="{Binding StackName}" Width="120" />
                <DataGridTextColumn Header="Message" Binding="{Binding Message}" Width="*" />
                <DataGridTextColumn Header="Duration" Binding="{Binding DurationMs, StringFormat='{}{0}ms'}" Width="80" />
            </DataGrid.Columns>
        </DataGrid>
    </DockPanel>
</UserControl>
