<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.SecretsView"
             x:DataType="vm:SecretsViewModel">

    <DockPanel>
        <!-- Page header -->
        <StackPanel DockPanel.Dock="Top" Margin="0,0,0,4">
            <TextBlock Text="Secrets" Classes="pageTitle" />
            <TextBlock Text="View Docker secrets on remote hosts" Classes="pageSubtitle" />
        </StackPanel>

        <!-- Toolbar -->
        <Border DockPanel.Dock="Top" Classes="toolbar" Margin="0,0,0,16">
            <StackPanel Orientation="Horizontal" Spacing="10">
                <ComboBox ItemsSource="{Binding AvailableHosts}"
                          SelectedItem="{Binding SelectedSshHost}"
                          PlaceholderText="Select SSH Host..."
                          Width="260">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Label}" />
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>
                <Button Content="Load Secrets" Classes="accent" Command="{Binding LoadSecretsCommand}" />
            </StackPanel>
        </Border>

        <!-- Status -->
        <TextBlock DockPanel.Dock="Bottom" Text="{Binding StatusMessage}" Classes="status"
                   Margin="0,10,0,0" />

        <!-- Secrets grid -->
        <DataGrid ItemsSource="{Binding Secrets}"
                  AutoGenerateColumns="False"
                  IsReadOnly="True"
                  GridLinesVisibility="Horizontal"
                  CanUserResizeColumns="True">
            <DataGrid.Columns>
                <DataGridTextColumn Header="ID" Binding="{Binding Id}" Width="200" />
                <DataGridTextColumn Header="Name" Binding="{Binding Name}" Width="250" />
                <DataGridTextColumn Header="Created" Binding="{Binding CreatedAt, StringFormat='{}{0:g}'}" Width="180" />
            </DataGrid.Columns>
        </DataGrid>
    </DockPanel>
</UserControl>
