<UserControl x:Class="NexusShell.Views.NexusDeviceManagerView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:NexusShell.Controls"
             xmlns:conv="clr-namespace:NexusShell.Converters"
             xmlns:models="clr-namespace:NexusShell.Models"
             FontFamily="Segoe UI Variable Display, Segoe UI">
    <UserControl.Resources>
        <conv:NexusDeviceSectionVisibilityConverter x:Key="SectionVisibility"/>
        <conv:BoolToVisibilityConverter x:Key="BoolToVisibility"/>
        <conv:PercentToWidthConverter x:Key="PercentToWidth"/>
        <conv:HealthStatusBrushConverter x:Key="HealthBrush"/>

        <Style x:Key="DmCard" TargetType="Border">
            <Setter Property="CornerRadius" Value="18"/>
            <Setter Property="Padding" Value="18"/>
            <Setter Property="Margin" Value="0,0,0,14"/>
            <Setter Property="Background" Value="#A8081428"/>
            <Setter Property="BorderBrush" Value="#3800D9FF"/>
            <Setter Property="BorderThickness" Value="1"/>
        </Style>

        <Style x:Key="DmKpiCard" TargetType="Border" BasedOn="{StaticResource DmCard}">
            <Setter Property="Effect">
                <Setter.Value>
                    <DropShadowEffect Color="#8A4FFF" BlurRadius="18" ShadowDepth="0" Opacity="0.35"/>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="DmLabel" TargetType="TextBlock">
            <Setter Property="Foreground" Value="#8CA3C7"/>
            <Setter Property="FontSize" Value="12"/>
            <Setter Property="Margin" Value="0,0,0,6"/>
        </Style>

        <Style x:Key="DmValue" TargetType="TextBlock">
            <Setter Property="Foreground" Value="#FFFFFF"/>
            <Setter Property="FontSize" Value="22"/>
            <Setter Property="FontWeight" Value="SemiBold"/>
        </Style>

        <Style x:Key="DmNavItem" TargetType="ListBoxItem">
            <Setter Property="Padding" Value="0"/>
            <Setter Property="Margin" Value="0,0,0,4"/>
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="Cursor" Value="Hand"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBoxItem">
                        <Border x:Name="Root" CornerRadius="12" Padding="10,8" Background="Transparent"
                                BorderBrush="#2200D9FF" BorderThickness="1">
                            <ContentPresenter/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="True">
                                <Setter TargetName="Root" Property="Background" Value="#338A4FFF"/>
                                <Setter TargetName="Root" Property="BorderBrush" Value="#7700D9FF"/>
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter TargetName="Root" Property="Background" Value="#1800D9FF"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <DataTemplate DataType="{x:Type models:NexusDeviceNavItem}">
            <StackPanel Orientation="Horizontal">
                <Path Data="{Binding IconPath}" Stroke="#00D9FF" StrokeThickness="1.6" Fill="Transparent"
                      Width="16" Height="16" Stretch="Uniform" Margin="0,0,10,0" VerticalAlignment="Center"/>
                <TextBlock Text="{Binding Title}" Foreground="#E8F0FF" FontSize="13" VerticalAlignment="Center"/>
            </StackPanel>
        </DataTemplate>

        <DataTemplate DataType="{x:Type models:NexusDiskVolumeInfo}">
            <Border CornerRadius="14" Background="#12081428" BorderBrush="#2200D9FF" BorderThickness="1"
                    Padding="14,12" Margin="0,0,0,10">
                <StackPanel>
                    <TextBlock Text="{Binding FriendlyLabel}" Foreground="#FFFFFF" FontSize="14" FontWeight="SemiBold"/>
                    <TextBlock Foreground="#8CA3C7" FontSize="11" Margin="0,4,0,10">
                        <Run Text="{Binding DriveType, Mode=OneWay}"/>
                        <Run Text=" · "/>
                        <Run Text="{Binding FreeGb, StringFormat={}{0:0.#} GB ledig, Mode=OneWay}"/>
                    </TextBlock>
                    <Grid Height="8">
                        <Border CornerRadius="4" Background="#18081428"/>
                        <Border CornerRadius="4" HorizontalAlignment="Left"
                                Width="{Binding UsedPercent, Converter={StaticResource PercentToWidth}, ConverterParameter=400}"
                                Background="#668A4FFF"/>
                    </Grid>
                </StackPanel>
            </Border>
        </DataTemplate>

        <DataTemplate DataType="{x:Type models:NexusProcessInfo}">
            <Border CornerRadius="14" Background="#12081428" BorderBrush="#2200D9FF" BorderThickness="1"
                    Padding="14,12" Margin="0,0,0,8">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <StackPanel>
                        <TextBlock Text="{Binding Name}" Foreground="#FFFFFF" FontSize="13" FontWeight="SemiBold"/>
                        <TextBlock Text="{Binding ProcessId, StringFormat=PID {0}}" Foreground="#8CA3C7" FontSize="10"/>
                    </StackPanel>
                    <TextBlock Grid.Column="1" Text="{Binding CpuPercent, StringFormat={}{0:0.#}%}"
                               Foreground="#00D9FF" FontSize="12" VerticalAlignment="Center" Margin="12,0"/>
                    <TextBlock Grid.Column="2" Text="{Binding MemoryLabel}"
                               Foreground="#8CA3C7" FontSize="12" VerticalAlignment="Center"/>
                </Grid>
            </Border>
        </DataTemplate>
    </UserControl.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="220"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="260"/>
        </Grid.ColumnDefinitions>

        <Border Grid.Column="0" Background="#66081228" CornerRadius="18" Padding="10" Margin="0,0,12,0"
                BorderBrush="#2200D9FF" BorderThickness="1">
            <ListBox ItemsSource="{Binding NavItems}"
                     ItemContainerStyle="{StaticResource DmNavItem}" BorderThickness="0" Background="Transparent">
                <ListBox.ItemTemplate>
                    <DataTemplate DataType="{x:Type models:NexusDeviceNavItem}">
                        <Button Background="Transparent" BorderThickness="0" Padding="0"
                                Command="{Binding DataContext.SelectSectionCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
                                CommandParameter="{Binding}">
                            <StackPanel Orientation="Horizontal">
                                <Path Data="{Binding IconPath}" Stroke="#00D9FF" StrokeThickness="1.6" Fill="Transparent"
                                      Width="16" Height="16" Stretch="Uniform" Margin="0,0,10,0"/>
                                <TextBlock Text="{Binding Title}" Foreground="#E8F0FF" FontSize="13"/>
                            </StackPanel>
                        </Button>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </Border>

        <ScrollViewer Grid.Column="1" VerticalScrollBarVisibility="Auto" Padding="0,0,8,0">
            <StackPanel>
                <!-- Overview -->
                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=Overview}">
                    <TextBlock Text="Oversigt" Foreground="#FFFFFF" FontSize="20" FontWeight="SemiBold" Margin="0,0,0,16"/>
                    <UniformGrid Columns="2" Margin="0,0,0,8">
                        <Border Style="{StaticResource DmKpiCard}" Margin="0,0,8,14">
                            <StackPanel>
                                <TextBlock Text="CPU" Style="{StaticResource DmLabel}"/>
                                <TextBlock Text="{Binding CpuLoadPercent, StringFormat={}{0}%}" Style="{StaticResource DmValue}"/>
                            </StackPanel>
                        </Border>
                        <Border Style="{StaticResource DmKpiCard}" Margin="8,0,0,14">
                            <StackPanel>
                                <TextBlock Text="RAM" Style="{StaticResource DmLabel}"/>
                                <TextBlock Text="{Binding RamLoadPercent, StringFormat={}{0}%}" Style="{StaticResource DmValue}"/>
                                <TextBlock Foreground="#8CA3C7" FontSize="11" Margin="0,4,0,0">
                                    <Run Text="{Binding RamUsedLabel, Mode=OneWay}"/>
                                    <Run Text=" / "/>
                                    <Run Text="{Binding RamTotalLabel, Mode=OneWay}"/>
                                </TextBlock>
                            </StackPanel>
                        </Border>
                        <Border Style="{StaticResource DmKpiCard}" Margin="0,0,8,14">
                            <StackPanel>
                                <TextBlock Text="Disk" Style="{StaticResource DmLabel}"/>
                                <TextBlock Text="{Binding DiskFreeLabel}" Style="{StaticResource DmValue}" FontSize="18"/>
                            </StackPanel>
                        </Border>
                        <Border Style="{StaticResource DmKpiCard}" Margin="8,0,0,14">
                            <StackPanel>
                                <TextBlock Text="Netværk" Style="{StaticResource DmLabel}"/>
                                <TextBlock Text="{Binding NetworkDownload}" Style="{StaticResource DmValue}" FontSize="18"/>
                                <TextBlock Text="{Binding NetworkUpload, StringFormat=↑ {0}}" Foreground="#8CA3C7" FontSize="11" Margin="0,4,0,0"/>
                            </StackPanel>
                        </Border>
                    </UniformGrid>
                    <Border Style="{StaticResource DmCard}" Visibility="{Binding HasCpuTemperature, Converter={StaticResource BoolToVisibility}}">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="Temperatur" Style="{StaticResource DmLabel}" Margin="0,0,12,0"/>
                            <TextBlock Text="{Binding CpuTemperature}" Style="{StaticResource DmValue}" FontSize="16"/>
                        </StackPanel>
                    </Border>
                </StackPanel>

                <!-- Nexus Agent -->
                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=Agent}">
                    <TextBlock Text="Nexus Agent" Foreground="#FFFFFF" FontSize="20" FontWeight="SemiBold" Margin="0,0,0,16"/>
                    <UniformGrid Columns="2" Margin="0,0,0,8">
                        <Border Style="{StaticResource DmKpiCard}" Margin="0,0,8,14">
                            <StackPanel>
                                <TextBlock Text="Forbindelse" Style="{StaticResource DmLabel}"/>
                                <TextBlock Text="{Binding AgentConnectionLabel}" Style="{StaticResource DmValue}" FontSize="18"/>
                            </StackPanel>
                        </Border>
                        <Border Style="{StaticResource DmKpiCard}" Margin="8,0,0,14">
                            <StackPanel>
                                <TextBlock Text="Agent version" Style="{StaticResource DmLabel}"/>
                                <TextBlock Text="{Binding AgentVersionLabel}" Style="{StaticResource DmValue}" FontSize="18"/>
                            </StackPanel>
                        </Border>
                        <Border Style="{StaticResource DmKpiCard}" Margin="0,0,8,14">
                            <StackPanel>
                                <TextBlock Text="Device ID" Style="{StaticResource DmLabel}"/>
                                <TextBlock Text="{Binding AgentDeviceId}" Foreground="#00D9FF" FontSize="16" FontWeight="SemiBold" TextWrapping="Wrap"/>
                            </StackPanel>
                        </Border>
                        <Border Style="{StaticResource DmKpiCard}" Margin="8,0,0,14">
                            <StackPanel>
                                <TextBlock Text="Sidste heartbeat" Style="{StaticResource DmLabel}"/>
                                <TextBlock Text="{Binding AgentLastHeartbeat}" Style="{StaticResource DmValue}" FontSize="16"/>
                            </StackPanel>
                        </Border>
                    </UniformGrid>
                    <Border Style="{StaticResource DmCard}">
                        <StackPanel>
                            <TextBlock Text="Backend" Style="{StaticResource DmLabel}"/>
                            <TextBlock Text="{Binding AgentBackendUrl}" Foreground="#FFFFFF" FontSize="14" Margin="0,0,0,12"/>
                            <TextBlock Text="Registrering" Style="{StaticResource DmLabel}"/>
                            <TextBlock Text="{Binding AgentRegistrationLabel}" Foreground="#FFFFFF" FontSize="14" Margin="0,0,0,12"/>
                            <TextBlock Text="Sundhed (agent)" Style="{StaticResource DmLabel}"/>
                            <TextBlock Text="{Binding AgentHealthLabel}" Foreground="#FFFFFF" FontSize="14"/>
                        </StackPanel>
                    </Border>
                </StackPanel>

                <!-- Device Identity -->
                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=DeviceIdentity}">
                    <TextBlock Text="Device Identity" Foreground="#FFFFFF" FontSize="20" FontWeight="SemiBold" Margin="0,0,0,16"/>
                    <Border Style="{StaticResource DmCard}">
                        <StackPanel>
                            <TextBlock Text="Enhedsnavn" Style="{StaticResource DmLabel}"/>
                            <TextBlock Text="{Binding IdentityFriendlyName}" Foreground="#FFFFFF" FontSize="14" Margin="0,0,0,12"/>
                            <TextBlock Text="Ejer" Style="{StaticResource DmLabel}"/>
                            <TextBlock Text="{Binding IdentityOwner}" Foreground="#FFFFFF" FontSize="14" Margin="0,0,0,12"/>
                            <TextBlock Text="Organisation" Style="{StaticResource DmLabel}"/>
                            <TextBlock Text="{Binding IdentityOrganization}" Foreground="#FFFFFF" FontSize="14" Margin="0,0,0,12"/>
                            <TextBlock Text="Tillidsstatus" Style="{StaticResource DmLabel}"/>
                            <TextBlock Text="{Binding IdentityTrustStatus}" Foreground="#00D9FF" FontSize="16" FontWeight="SemiBold"/>
                        </StackPanel>
                    </Border>
                </StackPanel>

                <!-- Hardware -->
                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=Hardware}">
                    <TextBlock Text="Hardware" Foreground="#FFFFFF" FontSize="20" FontWeight="SemiBold" Margin="0,0,0,16"/>
                    <Border Style="{StaticResource DmCard}">
                        <StackPanel>
                            <TextBlock Text="Maskine" Style="{StaticResource DmLabel}"/>
                            <TextBlock Text="{Binding MachineName}" Foreground="#FFFFFF" FontSize="14" Margin="0,0,0,12"/>
                            <TextBlock Text="OS" Style="{StaticResource DmLabel}"/>
                            <TextBlock Text="{Binding OsLabel}" Foreground="#FFFFFF" FontSize="14" Margin="0,0,0,12"/>
                            <TextBlock Text="Prodcent" Style="{StaticResource DmLabel}"/>
                            <TextBlock Text="{Binding SystemManufacturer}" Foreground="#FFFFFF" FontSize="14" Margin="0,0,0,12"/>
                            <TextBlock Text="Model" Style="{StaticResource DmLabel}"/>
                            <TextBlock Text="{Binding SystemModel}" Foreground="#FFFFFF" FontSize="14" Margin="0,0,0,12"/>
                            <TextBlock Text="BIOS" Style="{StaticResource DmLabel}"/>
                            <TextBlock Text="{Binding BiosVersion}" Foreground="#FFFFFF" FontSize="14"/>
                        </StackPanel>
                    </Border>
                </StackPanel>

                <!-- CPU -->
                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=Cpu}">
                    <TextBlock Text="CPU" Foreground="#FFFFFF" FontSize="20" FontWeight="SemiBold" Margin="0,0,0,16"/>
                    <Border Style="{StaticResource DmCard}">
                        <StackPanel>
                            <TextBlock Text="{Binding CpuModel}" Foreground="#FFFFFF" FontSize="14" TextWrapping="Wrap" Margin="0,0,0,12"/>
                            <TextBlock Foreground="#8CA3C7" FontSize="12" Margin="0,0,0,12">
                                <Run Text="{Binding CpuCores, StringFormat={}{0} kerner, Mode=OneWay}"/>
                                <Run Text=" · "/>
                                <Run Text="{Binding CpuThreads, StringFormat={}{0} tråde, Mode=OneWay}"/>
                                <Run Text=" · "/>
                                <Run Text="{Binding CpuFrequency, Mode=OneWay}"/>
                            </TextBlock>
                            <TextBlock Text="{Binding CpuLoadPercent, StringFormat=Belastning {0}%}" Foreground="#00D9FF" FontSize="16" FontWeight="SemiBold" Margin="0,0,0,12"/>
                            <TextBlock Text="60 sek. historik" Style="{StaticResource DmLabel}"/>
                            <local:NexusSparklineControl Values="{Binding CpuHistory}" Height="120" Margin="0,0,0,8"/>
                        </StackPanel>
                    </Border>
                </StackPanel>

                <!-- RAM -->
                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=Ram}">
                    <TextBlock Text="RAM" Foreground="#FFFFFF" FontSize="20" FontWeight="SemiBold" Margin="0,0,0,16"/>
                    <Border Style="{StaticResource DmCard}">
                        <StackPanel>
                            <TextBlock Text="{Binding RamLoadPercent, StringFormat=Belastning {0}%}" Foreground="#00D9FF" FontSize="16" FontWeight="SemiBold" Margin="0,0,0,12"/>
                            <TextBlock Foreground="#FFFFFF" FontSize="14" Margin="0,0,0,8">
                                <Run Text="Brugt: "/><Run Text="{Binding RamUsedLabel, Mode=OneWay}"/>
                                <Run Text=" · Ledig: "/><Run Text="{Binding RamFreeLabel, Mode=OneWay}"/>
                                <Run Text=" · Total: "/><Run Text="{Binding RamTotalLabel, Mode=OneWay}"/>
                            </TextBlock>
                            <TextBlock Text="60 sek. historik" Style="{StaticResource DmLabel}"/>
                            <local:NexusSparklineControl Values="{Binding RamHistory}" Height="120"/>
                        </StackPanel>
                    </Border>
                </StackPanel>

                <!-- Storage -->
                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=Storage}">
                    <TextBlock Text="Lager" Foreground="#FFFFFF" FontSize="20" FontWeight="SemiBold" Margin="0,0,0,16"/>
                    <ItemsControl ItemsSource="{Binding Volumes}"/>
                </StackPanel>

                <!-- GPU -->
                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=Gpu}">
                    <TextBlock Text="GPU" Foreground="#FFFFFF" FontSize="20" FontWeight="SemiBold" Margin="0,0,0,16"/>
                    <Border Style="{StaticResource DmCard}">
                        <StackPanel>
                            <TextBlock Text="{Binding GpuName}" Foreground="#FFFFFF" FontSize="14" TextWrapping="Wrap" Margin="0,0,0,12"/>
                            <TextBlock Text="VRAM" Style="{StaticResource DmLabel}"/>
                            <TextBlock Text="{Binding GpuVram}" Foreground="#FFFFFF" FontSize="14" Margin="0,0,0,12"/>
                            <TextBlock Text="Belastning" Style="{StaticResource DmLabel}"/>
                            <TextBlock Text="{Binding GpuLoadLabel}" Foreground="#8CA3C7" FontSize="14"/>
                        </StackPanel>
                    </Border>
                </StackPanel>

                <!-- Network -->
                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=Network}">
                    <TextBlock Text="Netværk" Foreground="#FFFFFF" FontSize="20" FontWeight="SemiBold" Margin="0,0,0,16"/>
                    <UniformGrid Columns="2">
                        <Border Style="{StaticResource DmKpiCard}" Margin="0,0,8,14">
                            <StackPanel>
                                <TextBlock Text="Download" Style="{StaticResource DmLabel}"/>
                                <TextBlock Text="{Binding NetworkDownload}" Style="{StaticResource DmValue}" FontSize="18"/>
                            </StackPanel>
                        </Border>
                        <Border Style="{StaticResource DmKpiCard}" Margin="8,0,0,14">
                            <StackPanel>
                                <TextBlock Text="Upload" Style="{StaticResource DmLabel}"/>
                                <TextBlock Text="{Binding NetworkUpload}" Style="{StaticResource DmValue}" FontSize="18"/>
                            </StackPanel>
                        </Border>
                    </UniformGrid>
                    <Border Style="{StaticResource DmCard}">
                        <StackPanel>
                            <TextBlock Text="Forbindelse" Style="{StaticResource DmLabel}"/>
                            <TextBlock Text="{Binding NetworkConnection}" Foreground="#FFFFFF" FontSize="14" Margin="0,0,0,12"/>
                            <TextBlock Text="IP-adresse" Style="{StaticResource DmLabel}"/>
                            <TextBlock Text="{Binding NetworkIp}" Foreground="#FFFFFF" FontSize="14" Margin="0,0,0,12"/>
                            <TextBlock Text="Gateway" Style="{StaticResource DmLabel}"/>
                            <TextBlock Text="{Binding NetworkGateway}" Foreground="#FFFFFF" FontSize="14"/>
                        </StackPanel>
                    </Border>
                </StackPanel>

                <!-- Displays -->
                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=Displays}">
                    <TextBlock Text="Skærme" Foreground="#FFFFFF" FontSize="20" FontWeight="SemiBold" Margin="0,0,0,16"/>
                    <Border Style="{StaticResource DmCard}" MinHeight="180" Margin="0,0,0,14">
                        <Canvas MinHeight="160">
                            <ItemsControl ItemsSource="{Binding Displays}">
                                <ItemsControl.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <Canvas/>
                                    </ItemsPanelTemplate>
                                </ItemsControl.ItemsPanel>
                                <ItemsControl.ItemContainerStyle>
                                    <Style TargetType="ContentPresenter">
                                        <Setter Property="Canvas.Left" Value="{Binding LayoutLeft}"/>
                                        <Setter Property="Canvas.Top" Value="{Binding LayoutTop}"/>
                                    </Style>
                                </ItemsControl.ItemContainerStyle>
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate DataType="{x:Type models:NexusDisplaySnapshot}">
                                        <Border Width="{Binding LayoutWidth}" Height="{Binding LayoutHeight}"
                                                CornerRadius="8" BorderBrush="#00D9FF" BorderThickness="2"
                                                Background="#22081428" Padding="8">
                                            <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
                                                <TextBlock Text="{Binding Name}" Foreground="#FFFFFF" FontSize="10" TextAlignment="Center" TextWrapping="Wrap"/>
                                                <TextBlock Text="{Binding Resolution}" Foreground="#8CA3C7" FontSize="9" TextAlignment="Center"/>
                                                <TextBlock Text="{Binding RefreshRate, StringFormat={}{0} Hz}" Foreground="#00D9FF" FontSize="9" TextAlignment="Center"/>
                                            </StackPanel>
                                        </Border>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </Canvas>
                    </Border>
                    <ItemsControl ItemsSource="{Binding Displays}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate DataType="{x:Type models:NexusDisplaySnapshot}">
                                <Border Style="{StaticResource DmCard}" Padding="14,12" Margin="0,0,0,8">
                                    <StackPanel>
                                        <TextBlock Text="{Binding Name}" Foreground="#FFFFFF" FontSize="14"/>
                                        <TextBlock Foreground="#8CA3C7" FontSize="12" Margin="0,4,0,0">
                                            <Run Text="{Binding Resolution, Mode=OneWay}"/>
                                            <Run Text=" · "/>
                                            <Run Text="{Binding RefreshRate, StringFormat={}{0} Hz, Mode=OneWay}"/>
                                            <Run Text=" · "/>
                                            <Run Text="{Binding IsPrimary, Converter={StaticResource BoolToVisibility}, Mode=OneWay}"/>
                                        </TextBlock>
                                    </StackPanel>
                                </Border>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </StackPanel>

                <!-- Printers -->
                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=Printers}">
                    <TextBlock Text="Printere" Foreground="#FFFFFF" FontSize="20" FontWeight="SemiBold" Margin="0,0,0,16"/>
                    <ItemsControl ItemsSource="{Binding Printers}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate DataType="{x:Type models:NexusPrinterInfo}">
                                <Border Style="{StaticResource DmCard}" Padding="14,12" Margin="0,0,0,8">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>
                                        <StackPanel>
                                            <TextBlock Text="{Binding Name}" Foreground="#FFFFFF" FontSize="14"/>
                                            <TextBlock Text="{Binding Status}" Foreground="#8CA3C7" FontSize="12" Margin="0,4,0,0"/>
                                        </StackPanel>
                                        <TextBlock Grid.Column="1" Text="Standard" Foreground="#00D9FF" FontSize="11"
                                                   VerticalAlignment="Center"
                                                   Visibility="{Binding IsDefault, Converter={StaticResource BoolToVisibility}}"/>
                                    </Grid>
                                </Border>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </StackPanel>

                <!-- USB -->
                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=Usb}">
                    <TextBlock Text="USB-enheder" Foreground="#FFFFFF" FontSize="20" FontWeight="SemiBold" Margin="0,0,0,16"/>
                    <ItemsControl ItemsSource="{Binding UsbDevices}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate DataType="{x:Type models:NexusUsbDeviceInfo}">
                                <Border Style="{StaticResource DmCard}" Padding="14,12" Margin="0,0,0,8">
                                    <StackPanel>
                                        <TextBlock Text="{Binding Name}" Foreground="#FFFFFF" FontSize="14"/>
                                        <TextBlock Foreground="#8CA3C7" FontSize="12" Margin="0,4,0,0">
                                            <Run Text="{Binding DeviceType, Mode=OneWay}"/>
                                            <Run Text=" · "/>
                                            <Run Text="{Binding Manufacturer, Mode=OneWay}"/>
                                        </TextBlock>
                                    </StackPanel>
                                </Border>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </StackPanel>

                <!-- Bluetooth -->
                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=Bluetooth}">
                    <TextBlock Text="Bluetooth" Foreground="#FFFFFF" FontSize="20" FontWeight="SemiBold" Margin="0,0,0,16"/>
                    <Border Style="{StaticResource DmCard}">
                        <TextBlock Text="{Binding BluetoothStatus}" Foreground="#FFFFFF" FontSize="14"/>
                    </Border>
                    <ItemsControl ItemsSource="{Binding BluetoothDevices}" Margin="0,8,0,0">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate DataType="{x:Type models:NexusBluetoothDeviceInfo}">
                                <Border Style="{StaticResource DmCard}" Padding="14,12" Margin="0,0,0,8">
                                    <TextBlock Text="{Binding Name}" Foreground="#FFFFFF" FontSize="14"/>
                                </Border>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </StackPanel>

                <!-- Processes -->
                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=Processes}">
                    <TextBlock Text="Processer" Foreground="#FFFFFF" FontSize="20" FontWeight="SemiBold" Margin="0,0,0,8"/>
                    <TextBlock Text="Top CPU og RAM — read-only, ingen afslutning." Foreground="#8CA3C7" FontSize="12" Margin="0,0,0,16"/>
                    <ItemsControl ItemsSource="{Binding TopProcesses}"/>
                </StackPanel>

                <!-- System Health -->
                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=SystemHealth}">
                    <TextBlock Text="Systemstatus" Foreground="#FFFFFF" FontSize="20" FontWeight="SemiBold" Margin="0,0,0,16"/>
                    <Border Style="{StaticResource DmKpiCard}" HorizontalAlignment="Left" MinWidth="200" Margin="0,0,0,16">
                        <StackPanel HorizontalAlignment="Center">
                            <TextBlock Text="{Binding HealthPercent, StringFormat={}{0}%}" Style="{StaticResource DmValue}" FontSize="36" HorizontalAlignment="Center"/>
                            <TextBlock Text="{Binding HealthOverall}" Foreground="#00D9FF" FontSize="14" HorizontalAlignment="Center"/>
                        </StackPanel>
                    </Border>
                    <UniformGrid Columns="2">
                        <Border Style="{StaticResource DmCard}" Margin="0,0,8,14">
                            <StackPanel>
                                <TextBlock Text="CPU" Style="{StaticResource DmLabel}"/>
                                <TextBlock Text="{Binding HealthCpu}" Foreground="{Binding HealthCpu, Converter={StaticResource HealthBrush}}" FontSize="16" FontWeight="SemiBold"/>
                            </StackPanel>
                        </Border>
                        <Border Style="{StaticResource DmCard}" Margin="8,0,0,14">
                            <StackPanel>
                                <TextBlock Text="RAM" Style="{StaticResource DmLabel}"/>
                                <TextBlock Text="{Binding HealthRam}" Foreground="{Binding HealthRam, Converter={StaticResource HealthBrush}}" FontSize="16" FontWeight="SemiBold"/>
                            </StackPanel>
                        </Border>
                        <Border Style="{StaticResource DmCard}" Margin="0,0,8,14">
                            <StackPanel>
                                <TextBlock Text="Disk" Style="{StaticResource DmLabel}"/>
                                <TextBlock Text="{Binding HealthDisk}" Foreground="{Binding HealthDisk, Converter={StaticResource HealthBrush}}" FontSize="16" FontWeight="SemiBold"/>
                            </StackPanel>
                        </Border>
                        <Border Style="{StaticResource DmCard}" Margin="8,0,0,14">
                            <StackPanel>
                                <TextBlock Text="Netværk" Style="{StaticResource DmLabel}"/>
                                <TextBlock Text="{Binding HealthNetwork}" Foreground="{Binding HealthNetwork, Converter={StaticResource HealthBrush}}" FontSize="16" FontWeight="SemiBold"/>
                            </StackPanel>
                        </Border>
                    </UniformGrid>
                </StackPanel>
            </StackPanel>
        </ScrollViewer>

        <Border Grid.Column="2" Background="#66081228" CornerRadius="18" Padding="18" Margin="12,0,0,0"
                BorderBrush="#3800D9FF" BorderThickness="1">
            <StackPanel>
                <TextBlock Text="{Binding InfoPanelTitle}" Foreground="#FFFFFF" FontSize="16" FontWeight="SemiBold" Margin="0,0,0,10"/>
                <TextBlock Text="{Binding InfoPanelBody}" Foreground="#8CA3C7" FontSize="12" TextWrapping="Wrap" LineHeight="18"/>
                <Button Content="Opdater" Margin="0,18,0,0" Height="36" Cursor="Hand"
                        Command="{Binding RefreshCommand}"
                        Background="#14081428" BorderBrush="#33FFFFFF" Foreground="#E8F0FF"/>
            </StackPanel>
        </Border>
    </Grid>
</UserControl>
