<Window x:Class="PerformanceMonitorLite.Windows.ManageCredentialProfilesDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Credential Profiles"
        Height="420" Width="640"
        WindowStartupLocation="CenterOwner"
        Icon="/EDD.ico"
        ResizeMode="CanResizeWithGrip"
        Background="{DynamicResource BackgroundBrush}">
    <Grid Margin="16">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <TextBlock Grid.Row="0" Text="Credential Profiles" FontWeight="Bold" FontSize="16"
                   Foreground="{DynamicResource ForegroundBrush}" Margin="0,0,0,8"/>

        <TextBlock Grid.Row="1" TextWrapping="Wrap" FontSize="11"
                   Foreground="{DynamicResource ForegroundMutedBrush}" Margin="0,0,0,12"
                   Text="A credential profile is a named, reusable identity (a shared SQL login, an Azure service principal, or a managed identity) that many servers can reference. Secrets are stored only in Windows Credential Manager, never in config files. A profile can't be deleted while a server still uses it."/>

        <DataGrid Grid.Row="2" x:Name="ProfilesGrid" AutoGenerateColumns="False" IsReadOnly="True"
                  CanUserAddRows="False" HeadersVisibility="Column" SelectionMode="Single"
                  MouseDoubleClick="ProfilesGrid_MouseDoubleClick">
            <DataGrid.Columns>
                <DataGridTextColumn Header="Name" Binding="{Binding Name}" Width="*"/>
                <DataGridTextColumn Header="Auth Type" Binding="{Binding AuthTypeDisplay}" Width="200"/>
                <DataGridTextColumn Header="Username / Client ID" Width="200">
                    <DataGridTextColumn.Binding>
                        <PriorityBinding>
                            <Binding Path="Username"/>
                            <Binding Path="AzureClientId"/>
                            <Binding Path="ManagedIdentityClientId"/>
                        </PriorityBinding>
                    </DataGridTextColumn.Binding>
                </DataGridTextColumn>
            </DataGrid.Columns>
        </DataGrid>

        <TextBlock Grid.Row="3" x:Name="StatusText" FontSize="10" FontStyle="Italic"
                   Foreground="{DynamicResource ForegroundMutedBrush}" Margin="0,8,0,0"/>

        <StackPanel Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,12,0,0">
            <Button Content="Add…" Width="80" Height="28" Margin="0,0,8,0" Click="AddButton_Click" Style="{StaticResource AccentButton}"/>
            <Button Content="Edit…" Width="80" Height="28" Margin="0,0,8,0" Click="EditButton_Click"/>
            <Button Content="Delete" Width="80" Height="28" Margin="0,0,8,0" Click="DeleteButton_Click"/>
            <Button Content="Close" Width="80" Height="28" Click="CloseButton_Click" IsCancel="True"/>
        </StackPanel>
    </Grid>
</Window>
