<Window x:Class="NexusShell.Views.DeveloperConsoleWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Nexus Developer Console"
        Width="720" Height="560"
        WindowStartupLocation="CenterOwner"
        Background="{StaticResource NexusNavyBrush}"
        ResizeMode="NoResize">
    <Grid Margin="24">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <StackPanel>
            <TextBlock Text="Nexus Developer Console" FontSize="22" FontWeight="SemiBold" Foreground="{StaticResource NexusTextPrimaryBrush}"/>
            <TextBlock Text="Master Developer escape hatch — POC (ingen Windows-adgang endnu)"
                       Foreground="{StaticResource NexusTextMutedBrush}" Margin="0,4,0,0"/>
        </StackPanel>

        <!-- Login -->
        <Border Grid.Row="1" Style="{StaticResource NexusGlassPanelStyle}" Margin="0,16,0,16"
                Visibility="{Binding ShowLogin, Converter={StaticResource BoolToVisibility}}">
            <StackPanel VerticalAlignment="Center" MaxWidth="360" HorizontalAlignment="Center">
                <TextBlock Text="Master login" FontWeight="SemiBold" Foreground="{StaticResource NexusTextPrimaryBrush}"/>
                <TextBlock Text="POC: admin@nexus.local + Identity password" FontSize="11"
                           Foreground="{StaticResource NexusTextMutedBrush}" Margin="0,4,0,12"/>
                <TextBlock Text="Username" Foreground="{StaticResource NexusTextMutedBrush}"/>
                <TextBox Text="{Binding Username, UpdateSourceTrigger=PropertyChanged}" Margin="0,4,0,8"/>
                <TextBlock Text="Password" Foreground="{StaticResource NexusTextMutedBrush}"/>
                <PasswordBox x:Name="DevPasswordBox" Margin="0,4,0,8" PasswordChanged="DevPasswordBox_OnPasswordChanged"/>
                <TextBlock Text="{Binding ErrorMessage}" Foreground="#FF6B8A" TextWrapping="Wrap" MinHeight="18"/>
                <Button Content="Godkend Master Developer" Command="{Binding LoginCommand}"
                        IsEnabled="{Binding IsNotBusy}" Margin="0,12,0,0" Padding="12,8"
                        Background="{StaticResource NexusPurpleBrush}" Foreground="White" BorderThickness="0"/>
            </StackPanel>
        </Border>

        <!-- Console -->
        <ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto"
                      Visibility="{Binding ShowConsole, Converter={StaticResource BoolToVisibility}}">
            <StackPanel>
                <TextBlock Text="Developer actions (alle deaktiveret i POC)" FontWeight="SemiBold"
                           Foreground="{StaticResource NexusTextPrimaryBrush}" Margin="0,0,0,8"/>
                <UniformGrid Columns="2" Margin="0,0,0,16">
                    <Button Content="Open Windows Desktop" Command="{Binding DisabledActionCommand}" CommandParameter="Open Windows Desktop" Margin="4" Style="{StaticResource NexusGlassButtonStyle}"/>
                    <Button Content="Open Explorer" Command="{Binding DisabledActionCommand}" CommandParameter="Open Explorer" Margin="4" Style="{StaticResource NexusGlassButtonStyle}"/>
                    <Button Content="Open PowerShell" Command="{Binding DisabledActionCommand}" CommandParameter="Open PowerShell" Margin="4" Style="{StaticResource NexusGlassButtonStyle}"/>
                    <Button Content="Open CMD" Command="{Binding DisabledActionCommand}" CommandParameter="Open CMD" Margin="4" Style="{StaticResource NexusGlassButtonStyle}"/>
                    <Button Content="Open Registry Editor" Command="{Binding DisabledActionCommand}" CommandParameter="Open Registry Editor" Margin="4" Style="{StaticResource NexusGlassButtonStyle}"/>
                    <Button Content="Open Device Manager" Command="{Binding DisabledActionCommand}" CommandParameter="Open Device Manager" Margin="4" Style="{StaticResource NexusGlassButtonStyle}"/>
                    <Button Content="Restart Nexus Shell" Command="{Binding DisabledActionCommand}" CommandParameter="Restart Nexus Shell" Margin="4" Style="{StaticResource NexusGlassButtonStyle}"/>
                    <Button Content="Repair Nexus" Command="{Binding DisabledActionCommand}" CommandParameter="Repair Nexus" Margin="4" Style="{StaticResource NexusGlassButtonStyle}"/>
                </UniformGrid>
                <TextBlock Text="Disabled in POC for safety" FontStyle="Italic"
                           Foreground="{StaticResource NexusAccentCyanBrush}" Margin="0,0,0,16"/>

                <TextBlock Text="Audit preview (seneste events)" FontWeight="SemiBold"
                           Foreground="{StaticResource NexusTextPrimaryBrush}" Margin="0,0,0,8"/>
                <ItemsControl ItemsSource="{Binding AuditEntries}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Border Style="{StaticResource NexusGlassPanelStyle}" Margin="0,0,0,6" Padding="10">
                                <StackPanel>
                                    <TextBlock FontSize="11" Foreground="{StaticResource NexusTextMutedBrush}"
                                               Text="{Binding Timestamp, StringFormat='{}{0:yyyy-MM-dd HH:mm:ss}'}"/>
                                    <TextBlock Foreground="{StaticResource NexusTextPrimaryBrush}"
                                               Text="{Binding EventType}" FontWeight="SemiBold"/>
                                    <TextBlock Text="{Binding Detail}" TextWrapping="Wrap"
                                               Foreground="{StaticResource NexusTextMutedBrush}" FontSize="12"/>
                                </StackPanel>
                            </Border>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </StackPanel>
        </ScrollViewer>

        <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right">
            <Button Content="Luk" Command="{Binding ExitCommand}" Padding="16,8"
                    Style="{StaticResource NexusGlassButtonStyle}"/>
        </StackPanel>
    </Grid>
</Window>
