<UserControl x:Class="NexusShell.Views.NexusSettingsView"
             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:NexusSettingsSectionVisibilityConverter x:Key="SectionVisibility"/>
        <conv:BoolToVisibilityConverter x:Key="BoolToVisibility"/>
        <conv:InitialsConverter x:Key="InitialsConverter"/>

        <Style x:Key="NsCard" 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="NsLabel" TargetType="TextBlock">
            <Setter Property="Foreground" Value="#8CA3C7"/>
            <Setter Property="FontSize" Value="12"/>
            <Setter Property="Margin" Value="0,0,0,6"/>
        </Style>

        <Style x:Key="NsValue" TargetType="TextBlock">
            <Setter Property="Foreground" Value="#FFFFFF"/>
            <Setter Property="FontSize" Value="14"/>
            <Setter Property="Margin" Value="0,0,0,12"/>
            <Setter Property="TextWrapping" Value="Wrap"/>
        </Style>

        <Style x:Key="NsRadio" TargetType="RadioButton">
            <Setter Property="Foreground" Value="#E8F0FF"/>
            <Setter Property="FontSize" Value="13"/>
            <Setter Property="Margin" Value="0,0,24,0"/>
            <Setter Property="Cursor" Value="Hand"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="RadioButton">
                        <StackPanel Orientation="Horizontal">
                            <Border x:Name="Ring" Width="18" Height="18" CornerRadius="9"
                                    BorderBrush="#5500D9FF" BorderThickness="1.5" Margin="0,0,10,0">
                                <Ellipse x:Name="Dot" Width="8" Height="8" Fill="#00D9FF" Opacity="0"/>
                            </Border>
                            <ContentPresenter VerticalAlignment="Center"/>
                        </StackPanel>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsChecked" Value="True">
                                <Setter TargetName="Dot" Property="Opacity" Value="1"/>
                                <Setter TargetName="Ring" Property="BorderBrush" Value="#00D9FF"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="NsCheckBox" TargetType="CheckBox">
            <Setter Property="Foreground" Value="#E8F0FF"/>
            <Setter Property="FontSize" Value="13"/>
            <Setter Property="Margin" Value="0,0,0,10"/>
            <Setter Property="Cursor" Value="Hand"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="CheckBox">
                        <StackPanel Orientation="Horizontal">
                            <Border x:Name="Box" Width="18" Height="18" CornerRadius="5"
                                    BorderBrush="#5500D9FF" BorderThickness="1.5" Margin="0,0,10,0">
                                <Path x:Name="Tick" Data="M4,9 L7,12 L13,6" Stroke="#00D9FF" StrokeThickness="1.8"
                                      Visibility="Collapsed" Stretch="Uniform" Margin="2"
                                      StrokeStartLineCap="Round" StrokeEndLineCap="Round"/>
                            </Border>
                            <ContentPresenter VerticalAlignment="Center"/>
                        </StackPanel>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsChecked" Value="True">
                                <Setter TargetName="Tick" Property="Visibility" Value="Visible"/>
                                <Setter TargetName="Box" Property="Background" Value="#2200D9FF"/>
                                <Setter TargetName="Box" Property="BorderBrush" Value="#00D9FF"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="NsGhostButton" TargetType="Button">
            <Setter Property="Height" Value="38"/>
            <Setter Property="Padding" Value="16,0"/>
            <Setter Property="Cursor" Value="Hand"/>
            <Setter Property="Foreground" Value="#E8F0FF"/>
            <Setter Property="FontSize" Value="13"/>
            <Setter Property="Background" Value="#14081428"/>
            <Setter Property="BorderBrush" Value="#33FFFFFF"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Border x:Name="Root" CornerRadius="12"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Padding="{TemplateBinding Padding}">
                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter TargetName="Root" Property="Background" Value="#2800D9FF"/>
                                <Setter TargetName="Root" Property="BorderBrush" Value="#6600D9FF"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="NsPrimaryButton" TargetType="Button" BasedOn="{StaticResource NsGhostButton}">
            <Setter Property="Background">
                <Setter.Value>
                    <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                        <GradientStop Color="#668A4FFF" Offset="0"/>
                        <GradientStop Color="#4400D9FF" Offset="1"/>
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="BorderBrush" Value="#8800D9FF"/>
            <Setter Property="FontWeight" Value="SemiBold"/>
        </Style>

        <Style x:Key="NsComboBox" TargetType="ComboBox">
            <Setter Property="Foreground" Value="#FFFFFF"/>
            <Setter Property="FontSize" Value="13"/>
            <Setter Property="Padding" Value="10,6"/>
            <Setter Property="Background" Value="#12081428"/>
            <Setter Property="BorderBrush" Value="#3800D9FF"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="MinHeight" Value="38"/>
        </Style>

        <Style x:Key="NsNavItem" 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:NexusSettingsNavItem}">
            <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:NexusPrinterInfo}">
            <Border CornerRadius="12" Background="#12081428" BorderBrush="#2200D9FF" BorderThickness="1"
                    Padding="12,10" Margin="0,0,0,8">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <StackPanel>
                        <TextBlock Text="{Binding Name}" Foreground="#FFFFFF" FontSize="13"/>
                        <TextBlock Text="{Binding Status}" Foreground="#8CA3C7" FontSize="11" Margin="0,2,0,0"/>
                    </StackPanel>
                    <TextBlock Grid.Column="1" Text="Standard" Foreground="#00D9FF" FontSize="11"
                               VerticalAlignment="Center"
                               Visibility="{Binding IsDefault, Converter={StaticResource BoolToVisibility}}"/>
                </Grid>
            </Border>
        </DataTemplate>
    </UserControl.Resources>

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

        <Border Grid.Column="0" Margin="0,0,12,0" Background="#66081428" CornerRadius="16"
                BorderBrush="#2200D9FF" BorderThickness="1" Padding="8">
            <ScrollViewer VerticalScrollBarVisibility="Auto">
                <ListBox ItemsSource="{Binding VisibleNavItems}"
                         SelectedValuePath="Section"
                         SelectedValue="{Binding SelectedSection, Mode=TwoWay}"
                         BorderThickness="0" Background="Transparent"
                         ItemContainerStyle="{StaticResource NsNavItem}"/>
            </ScrollViewer>
        </Border>

        <ScrollViewer Grid.Column="1" VerticalScrollBarVisibility="Auto" Margin="0,0,12,0">
            <Grid>
                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=General}">
                    <Border Style="{StaticResource NsCard}">
                        <StackPanel>
                            <local:LetterSpacedTextBlock Text="NEXUS SHELL" LetterSpacing="1.2" Foreground="#8CA3C7" Margin="0,0,0,12"/>
                            <CheckBox Style="{StaticResource NsCheckBox}" Content="Fuldskærm — skjul Windows taskbar og rammer" IsChecked="{Binding ShellFullscreen}"/>
                            <CheckBox Style="{StaticResource NsCheckBox}" Content="Skjul Windows taskbar" IsChecked="{Binding HideWindowsTaskbar}"/>
                            <CheckBox Style="{StaticResource NsCheckBox}" Margin="0,0,0,4" Content="Samlet skrivebord over alle skærme (ultra-bred)" IsChecked="{Binding SpanAllMonitors}"/>
                            <CheckBox Style="{StaticResource NsCheckBox}" Content="Performance mode — reducer polling og animationer" IsChecked="{Binding PerformanceMode}"/>
                            <CheckBox Style="{StaticResource NsCheckBox}" Content="Reduceret bevægelse når inaktiv" IsChecked="{Binding ReducedMotionWhenInactive}"/>
                        </StackPanel>
                    </Border>
                    <Border Style="{StaticResource NsCard}">
                        <StackPanel>
                            <TextBlock Text="{Binding LockdownStatusLabel}" FontSize="15" FontWeight="SemiBold" Foreground="#00D9FF" Margin="0,0,0,12"/>
                            <Grid Margin="0,0,0,8">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <TextBlock Text="Tilladte apps" Style="{StaticResource NsLabel}" Margin="0"/>
                                <TextBlock Grid.Column="1" Text="{Binding AllowedAppsCount}" Style="{StaticResource NsValue}" Margin="0"/>
                            </Grid>
                            <Grid Margin="0,0,0,8">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <TextBlock Text="Blokerede apps/processer" Style="{StaticResource NsLabel}" Margin="0"/>
                                <TextBlock Grid.Column="1" Text="{Binding BlockedAppsCount}" Style="{StaticResource NsValue}" Margin="0"/>
                            </Grid>
                            <Button Content="Åbn Nexus Console" Style="{StaticResource NsGhostButton}" HorizontalAlignment="Left"
                                    Command="{Binding OpenNexusConsoleCommand}" Visibility="{Binding CanOpenNexusConsole, Converter={StaticResource BoolToVisibility}}"/>
                        </StackPanel>
                    </Border>
                </StackPanel>

                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=Appearance}">
                    <Border Style="{StaticResource NsCard}">
                        <StackPanel>
                            <local:LetterSpacedTextBlock Text="TEMA" LetterSpacing="1.2" Foreground="#8CA3C7" Margin="0,0,0,12"/>
                            <StackPanel Orientation="Horizontal">
                                <RadioButton Content="Nexus Dark" Style="{StaticResource NsRadio}" IsChecked="{Binding IsDarkTheme}"/>
                                <RadioButton Content="Nexus Light" Style="{StaticResource NsRadio}" IsChecked="{Binding IsLightTheme}"/>
                            </StackPanel>
                        </StackPanel>
                    </Border>
                    <Border Style="{StaticResource NsCard}">
                        <StackPanel>
                            <local:LetterSpacedTextBlock Text="ACCENT" LetterSpacing="1.2" Foreground="#8CA3C7" Margin="0,0,0,12"/>
                            <StackPanel Orientation="Horizontal">
                                <RadioButton Content="Purple" Style="{StaticResource NsRadio}" IsChecked="{Binding IsAccentPurple}"/>
                                <RadioButton Content="Cyan" Style="{StaticResource NsRadio}" IsChecked="{Binding IsAccentCyan}"/>
                                <RadioButton Content="Auto" Style="{StaticResource NsRadio}" IsChecked="{Binding IsAccentAuto}"/>
                            </StackPanel>
                        </StackPanel>
                    </Border>
                    <Border Style="{StaticResource NsCard}">
                        <StackPanel>
                            <local:LetterSpacedTextBlock Text="ANIMATION" LetterSpacing="1.2" Foreground="#8CA3C7" Margin="0,0,0,12"/>
                            <StackPanel Orientation="Horizontal">
                                <RadioButton Content="Low" Style="{StaticResource NsRadio}" IsChecked="{Binding IsAnimationLow}"/>
                                <RadioButton Content="Normal" Style="{StaticResource NsRadio}" IsChecked="{Binding IsAnimationNormal}"/>
                                <RadioButton Content="High" Style="{StaticResource NsRadio}" IsChecked="{Binding IsAnimationHigh}"/>
                            </StackPanel>
                        </StackPanel>
                    </Border>
                    <Border Style="{StaticResource NsCard}">
                        <StackPanel>
                            <local:LetterSpacedTextBlock Text="BAGGRUND" LetterSpacing="1.2" Foreground="#8CA3C7" Margin="0,0,0,12"/>
                            <Border Height="140" CornerRadius="14" ClipToBounds="True" Margin="0,0,0,14" BorderBrush="#4400D9FF" BorderThickness="1">
                                <Image Source="{Binding WallpaperPreview}" Stretch="UniformToFill"/>
                            </Border>
                            <StackPanel Orientation="Horizontal">
                                <Button Content="Vælg billede…" Style="{StaticResource NsGhostButton}" Command="{Binding BrowseWallpaperCommand}" Margin="0,0,10,0"/>
                                <Button Content="Standard" Style="{StaticResource NsGhostButton}" Command="{Binding ResetWallpaperCommand}"/>
                            </StackPanel>
                        </StackPanel>
                    </Border>
                </StackPanel>

                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=Display}">
                    <Border Style="{StaticResource NsCard}">
                        <StackPanel>
                            <Grid Margin="0,0,0,4">
                                <local:LetterSpacedTextBlock Text="AKTIV SKÆRM" LetterSpacing="1.2" Foreground="#8CA3C7" Margin="0,0,0,12"/>
                                <TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Text="{Binding MonitorCountLabel}" Foreground="#8CA3C7" FontSize="12"/>
                            </Grid>
                            <ComboBox Style="{StaticResource NsComboBox}" ItemsSource="{Binding Monitors}" SelectedItem="{Binding SelectedMonitor}" DisplayMemberPath="DisplayLabel" Margin="0,0,0,14"/>
                            <TextBlock Text="Nuværende opløsning" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding SelectedMonitor.CurrentLabel}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="Skalering" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding DisplayScalingLabel}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="Vælg opløsning" Style="{StaticResource NsLabel}"/>
                            <ComboBox Style="{StaticResource NsComboBox}" ItemsSource="{Binding SelectedMonitor.Modes}" SelectedItem="{Binding SelectedResolution}" DisplayMemberPath="Label" Margin="0,0,0,14"/>
                            <StackPanel Orientation="Horizontal">
                                <Button Content="Anvend opløsning" Style="{StaticResource NsPrimaryButton}" Command="{Binding ApplyDisplayCommand}" Margin="0,0,10,0"/>
                                <Button Content="Opdater" Style="{StaticResource NsGhostButton}" Command="{Binding RefreshMonitorsCommand}"/>
                            </StackPanel>
                        </StackPanel>
                    </Border>
                </StackPanel>

                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=Audio}">
                    <Border Style="{StaticResource NsCard}">
                        <StackPanel>
                            <local:LetterSpacedTextBlock Text="OUTPUT" LetterSpacing="1.2" Foreground="#8CA3C7" Margin="0,0,0,12"/>
                            <TextBlock Text="{Binding AudioOutputDevice}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="Lydstyrke" Style="{StaticResource NsLabel}"/>
                            <Grid Margin="0,0,0,8">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="48"/>
                                </Grid.ColumnDefinitions>
                                <Slider Minimum="0" Maximum="100" Value="{Binding AudioVolume}"/>
                                <TextBlock Grid.Column="1" Text="{Binding AudioVolume, StringFormat={}{0}%}" Foreground="#FFFFFF" HorizontalAlignment="Right" VerticalAlignment="Center"/>
                            </Grid>
                            <Button Content="Opdater" Style="{StaticResource NsGhostButton}" HorizontalAlignment="Left" Command="{Binding RefreshSectionCommand}"/>
                        </StackPanel>
                    </Border>
                </StackPanel>

                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=Network}">
                    <Border Style="{StaticResource NsCard}">
                        <StackPanel>
                            <local:LetterSpacedTextBlock Text="FORBINDELSE" LetterSpacing="1.2" Foreground="#8CA3C7" Margin="0,0,0,12"/>
                            <TextBlock Text="Aktivt netværk" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding ActiveNetwork}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="IP-adresse" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding IpAddress}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="Signal" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding SignalStrength}" Style="{StaticResource NsValue}"/>
                            <Button Content="Opdater" Style="{StaticResource NsGhostButton}" HorizontalAlignment="Left" Command="{Binding RefreshSectionCommand}"/>
                        </StackPanel>
                    </Border>
                </StackPanel>

                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=Bluetooth}">
                    <Border Style="{StaticResource NsCard}">
                        <StackPanel>
                            <local:LetterSpacedTextBlock Text="BLUETOOTH" LetterSpacing="1.2" Foreground="#8CA3C7" Margin="0,0,0,12"/>
                            <TextBlock Text="{Binding BluetoothStatus}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="Parrede enheder" Style="{StaticResource NsLabel}"/>
                            <ItemsControl ItemsSource="{Binding PairedBluetoothDevices}" Margin="0,0,0,12">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding}" Foreground="#E8F0FF" FontSize="13" Margin="0,0,0,6"/>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                            <Button Content="Opdater" Style="{StaticResource NsGhostButton}" HorizontalAlignment="Left" Command="{Binding RefreshSectionCommand}"/>
                        </StackPanel>
                    </Border>
                </StackPanel>

                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=Devices}">
                    <Border Style="{StaticResource NsCard}">
                        <StackPanel>
                            <local:LetterSpacedTextBlock Text="HARDWARE" LetterSpacing="1.2" Foreground="#8CA3C7" Margin="0,0,0,12"/>
                            <TextBlock Text="CPU" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding CpuName}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="RAM" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding RamLabel}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="Disk" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding DiskLabel}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="GPU" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding GpuName}" Style="{StaticResource NsValue}"/>
                            <Button Content="Opdater" Style="{StaticResource NsGhostButton}" HorizontalAlignment="Left" Command="{Binding RefreshSectionCommand}"/>
                        </StackPanel>
                    </Border>
                </StackPanel>

                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=Printers}">
                    <Border Style="{StaticResource NsCard}">
                        <StackPanel>
                            <local:LetterSpacedTextBlock Text="PRINTERE" LetterSpacing="1.2" Foreground="#8CA3C7" Margin="0,0,0,12"/>
                            <ItemsControl ItemsSource="{Binding InstalledPrinters}"/>
                            <Button Content="Opdater" Style="{StaticResource NsGhostButton}" Margin="0,8,0,0" HorizontalAlignment="Left" Command="{Binding RefreshSectionCommand}"/>
                        </StackPanel>
                    </Border>
                </StackPanel>

                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=Updates}">
                    <Border Style="{StaticResource NsCard}">
                        <StackPanel>
                            <local:LetterSpacedTextBlock Text="NEXUS UPDATES" LetterSpacing="1.2" Foreground="#8CA3C7" Margin="0,0,0,12"/>
                            <TextBlock Text="Status" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding UpdateStatusSummary}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="Installeret version" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding CurrentVersionLabel}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="Seneste version" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding LatestVersionLabel}" Style="{StaticResource NsValue}"/>
                            <WrapPanel Margin="0,4,0,0">
                                <Button Content="Tjek for opdateringer" Style="{StaticResource NsPrimaryButton}" Command="{Binding CheckUpdatesCommand}" IsEnabled="{Binding IsNotCheckingUpdates}" Margin="0,0,10,8"/>
                                <Button Content="Download og installér" Style="{StaticResource NsPrimaryButton}" Command="{Binding DownloadAndInstallUpdateCommand}" IsEnabled="{Binding CanDownloadAndInstallUpdate}" Margin="0,0,10,8"/>
                                <Button Content="Detaljer…" Style="{StaticResource NsGhostButton}" Command="{Binding OpenUpdateInfoCommand}" Margin="0,0,10,8"/>
                            </WrapPanel>
                        </StackPanel>
                    </Border>
                </StackPanel>

                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=Account}">
                    <Border Style="{StaticResource NsCard}">
                        <StackPanel>
                            <local:LetterSpacedTextBlock Text="PROFIL" LetterSpacing="1.2" Foreground="#8CA3C7" Margin="0,0,0,12"/>
                            <Border Width="64" Height="64" CornerRadius="32" Margin="0,0,0,14" Background="#338A4FFF" BorderBrush="#7700D9FF" BorderThickness="1">
                                <TextBlock Text="{Binding AccountName, Converter={StaticResource InitialsConverter}}" Foreground="#FFFFFF" FontSize="22" FontWeight="SemiBold" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                            </Border>
                            <TextBlock Text="Navn" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding AccountName}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="Rolle" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding AccountRole}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="E-mail" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding AccountEmail}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="Session" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding AccountSession}" Style="{StaticResource NsValue}"/>
                        </StackPanel>
                    </Border>
                </StackPanel>

                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=Identity}">
                    <Border Style="{StaticResource NsCard}">
                        <StackPanel>
                            <local:LetterSpacedTextBlock Text="NEXUS IDENTITY" LetterSpacing="1.2" Foreground="#8CA3C7" Margin="0,0,0,12"/>
                            <TextBlock Text="Bruger" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding IdentityUser}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="Organisation" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding IdentityOrganization}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="Device ID" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding IdentityDeviceId}" Foreground="#00D9FF" FontSize="14" FontWeight="SemiBold" Margin="0,0,0,12"/>
                            <TextBlock Text="Status" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding IdentityStatus}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="Tillid" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding IdentityTrustStatus}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="Enrollment dato" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding IdentityEnrollmentDate}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="Windows lock" Style="{StaticResource NsLabel}" Margin="0,12,0,0"/>
                            <TextBlock Text="{Binding PlatformLockStatusLabel}" Foreground="#00D9FF" FontSize="13" TextWrapping="Wrap" Margin="0,0,0,12"/>
                            <StackPanel Orientation="Horizontal">
                                <Button Content="Lås Windows op (POC)" Style="{StaticResource NsPrimaryButton}" Command="{Binding UnlockWindowsCommand}" Margin="0,0,10,0"/>
                                <Button Content="Lås Windows igen" Style="{StaticResource NsGhostButton}" Command="{Binding LockWindowsCommand}"/>
                            </StackPanel>
                        </StackPanel>
                    </Border>
                </StackPanel>

                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=ControlCenter}">
                    <Border Style="{StaticResource NsCard}">
                        <StackPanel>
                            <local:LetterSpacedTextBlock Text="NEXUS CONTROL CENTER" LetterSpacing="1.2" Foreground="#8CA3C7" Margin="0,0,0,12"/>
                            <TextBlock Text="Kilde" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding ControlCenterSource}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="Platform oversigt" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding ControlCenterSummary}" Foreground="#00D9FF" FontSize="14" TextWrapping="Wrap" Margin="0,0,0,12"/>
                            <TextBlock Text="Tillid (platform)" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding ControlCenterTrustSummary}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="Afventende enrollments" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding ControlCenterPending}" Style="{StaticResource NsValue}"/>
                            <Button Content="Opdater dashboard" Style="{StaticResource NsGhostButton}" Margin="0,12,0,0" HorizontalAlignment="Left" Command="{Binding RefreshSectionCommand}"/>
                        </StackPanel>
                    </Border>
                    <Border Style="{StaticResource NsCard}" Margin="0,12,0,0">
                        <StackPanel>
                            <local:LetterSpacedTextBlock Text="ENHEDSTILSTEDEVÆRELSE" LetterSpacing="1.2" Foreground="#8CA3C7" Margin="0,0,0,12"/>
                            <TextBlock Text="Presence kilde" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding ControlCenterPresenceSource}" Style="{StaticResource NsValue}" Margin="0,0,0,12"/>
                            <Grid Margin="0,0,0,12">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <StackPanel Grid.Column="0" Margin="0,0,8,0">
                                    <TextBlock Text="Online" Style="{StaticResource NsLabel}"/>
                                    <TextBlock Text="{Binding ControlCenterOnlineCount}" Foreground="#00FF88" FontSize="20" FontWeight="SemiBold"/>
                                </StackPanel>
                                <StackPanel Grid.Column="1" Margin="0,0,8,0">
                                    <TextBlock Text="Offline" Style="{StaticResource NsLabel}"/>
                                    <TextBlock Text="{Binding ControlCenterOfflineCount}" Foreground="#8CA3C7" FontSize="20" FontWeight="SemiBold"/>
                                </StackPanel>
                                <StackPanel Grid.Column="2" Margin="0,0,8,0">
                                    <TextBlock Text="Advarsler" Style="{StaticResource NsLabel}"/>
                                    <TextBlock Text="{Binding ControlCenterWarningCount}" Foreground="#FFB800" FontSize="20" FontWeight="SemiBold"/>
                                </StackPanel>
                                <StackPanel Grid.Column="3">
                                    <TextBlock Text="Kritiske" Style="{StaticResource NsLabel}"/>
                                    <TextBlock Text="{Binding ControlCenterCriticalCount}" Foreground="#FF4466" FontSize="20" FontWeight="SemiBold"/>
                                </StackPanel>
                            </Grid>
                            <TextBlock Text="Enheder (navn · ejer · org · status · version · sidst set)" Style="{StaticResource NsLabel}" Margin="0,0,0,8"/>
                            <ItemsControl ItemsSource="{Binding ControlCenterDevices}">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <Border BorderBrush="#2200D9FF" BorderThickness="0,0,0,1" Padding="0,8">
                                            <StackPanel>
                                                <TextBlock Foreground="#FFFFFF" FontWeight="SemiBold">
                                                    <Run Text="{Binding FriendlyName}"/>
                                                    <Run Text=" · " Foreground="#8CA3C7"/>
                                                    <Run Text="{Binding Owner}" Foreground="#00D9FF"/>
                                                </TextBlock>
                                                <TextBlock Foreground="#8CA3C7" FontSize="12" TextWrapping="Wrap">
                                                    <Run Text="{Binding Organization}"/>
                                                    <Run Text=" · "/>
                                                    <Run Text="{Binding OnlineLabel}"/>
                                                    <Run Text=" · "/>
                                                    <Run Text="{Binding Health}"/>
                                                    <Run Text=" · "/>
                                                    <Run Text="{Binding VersionLabel}"/>
                                                    <Run Text=" · "/>
                                                    <Run Text="{Binding LastSeenLabel}"/>
                                                </TextBlock>
                                            </StackPanel>
                                        </Border>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </StackPanel>
                    </Border>
                </StackPanel>

                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=DefaultApps}">
                    <Border Style="{StaticResource NsCard}">
                        <StackPanel>
                            <local:LetterSpacedTextBlock Text="NEXUS DEFAULT APPS" LetterSpacing="1.2" Foreground="#8CA3C7" Margin="0,0,0,12"/>
                            <TextBlock Text="Vælg hvilken Nexus-app der håndterer filtyper. Præferencer gemmes lokalt — ikke i Windows registry."
                                       Foreground="#8CA3C7" FontSize="12" TextWrapping="Wrap" Margin="0,0,0,14"/>
                            <TextBlock Text="Lagring" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding DefaultAppsStoragePath}" Style="{StaticResource NsValue}"/>
                            <ItemsControl ItemsSource="{Binding DefaultAppPreferences}">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate DataType="{x:Type models:NexusDefaultAppPreferenceRow}">
                                        <Border CornerRadius="12" Background="#12081428" BorderBrush="#2200D9FF" BorderThickness="1"
                                                Padding="12,10" Margin="0,0,0,10">
                                            <Grid>
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="*"/>
                                                    <ColumnDefinition Width="180"/>
                                                </Grid.ColumnDefinitions>
                                                <StackPanel>
                                                    <TextBlock Text="{Binding CategoryLabel}" Foreground="#FFFFFF" FontSize="13" FontWeight="SemiBold"/>
                                                    <TextBlock Text="{Binding ExtensionsLabel}" Foreground="#8CA3C7" FontSize="11" Margin="0,2,0,0"/>
                                                </StackPanel>
                                                <ComboBox Grid.Column="1" Style="{StaticResource NsComboBox}"
                                                          ItemsSource="{Binding DataContext.AvailableDefaultApps, RelativeSource={RelativeSource AncestorType=UserControl}}"
                                                          DisplayMemberPath="Label"
                                                          SelectedValuePath="AppId"
                                                          SelectedValue="{Binding SelectedApp, Mode=TwoWay}"/>
                                            </Grid>
                                        </Border>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                            <TextBlock Text="Tryk Gem nederst for at gemme ændringer." Foreground="#8CA3C7" FontSize="11" Margin="0,4,0,0"/>
                        </StackPanel>
                    </Border>
                </StackPanel>

                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=DeveloperDiagnostics}">
                    <Border Style="{StaticResource NsCard}">
                        <StackPanel>
                            <local:LetterSpacedTextBlock Text="DIAGNOSTIK HUD" LetterSpacing="1.2" Foreground="#8CA3C7" Margin="0,0,0,12"/>
                            <TextBlock Text="Build" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding AboutBuildLabel}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="Version" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding AboutVersionLabel}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="Uptime" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding DiagnosticsUptimeLabel}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="CPU / RAM" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding DiagnosticsCpuLabel}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="{Binding DiagnosticsMemoryLabel}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="UI / API latency" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding DiagnosticsUiLatencyLabel}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="{Binding DiagnosticsApiLatencyLabel}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="Aktive workspace-vinduer" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding DiagnosticsActiveWindowsLabel}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="Aktive timers / polling" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding DiagnosticsTimersLabel}" Style="{StaticResource NsValue}" TextWrapping="Wrap"/>
                            <TextBlock Text="Session" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding DiagnosticsSessionLabel}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="Seneste events" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding DiagnosticsEventsSummary}" Style="{StaticResource NsValue}" TextWrapping="Wrap"/>
                        </StackPanel>
                    </Border>
                    <Border Style="{StaticResource NsCard}">
                        <WrapPanel Orientation="Horizontal">
                            <Button Content="Start session" Style="{StaticResource NsGhostButton}" Margin="0,0,8,0"
                                    Command="{Binding StartDiagnosticsSessionCommand}"/>
                            <Button Content="Stop session" Style="{StaticResource NsGhostButton}" Margin="0,0,8,0"
                                    Command="{Binding StopDiagnosticsSessionCommand}"/>
                            <Button Content="Eksportér diagnostikpakke" Style="{StaticResource NsGhostButton}" Margin="0,0,8,0"
                                    Command="{Binding ExportDiagnosticsCommand}"/>
                            <Button Content="Send diagnostik" Style="{StaticResource NsGhostButton}" Margin="0,0,8,0"
                                    ToolTip="Opt-in: eksporterer redacted logs og sender kun hvis endpoint er konfigureret"
                                    Command="{Binding SendDiagnosticsCommand}"/>
                            <Button Content="Åbn logs mappe" Style="{StaticResource NsGhostButton}" Margin="0,0,8,0"
                                    Command="{Binding OpenDiagnosticsLogsCommand}"/>
                            <Button Content="Kopiér diagnostikinfo" Style="{StaticResource NsGhostButton}"
                                    Command="{Binding CopyDiagnosticsInfoCommand}"/>
                        </WrapPanel>
                    </Border>
                    <TextBlock Text="{Binding DiagnosticsStatusMessage}" Foreground="#00D9FF" FontSize="12" TextWrapping="Wrap" Margin="4,0,0,8"/>
                </StackPanel>

                <StackPanel Visibility="{Binding SelectedSection, Converter={StaticResource SectionVisibility}, ConverterParameter=About}">
                    <Border Style="{StaticResource NsCard}">
                        <StackPanel>
                            <local:LetterSpacedTextBlock Text="OM NEXUS" LetterSpacing="1.2" Foreground="#8CA3C7" Margin="0,0,0,12"/>
                            <TextBlock Text="Version" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding AboutVersionLabel}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="Build" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding AboutBuildLabel}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="Opdateringskanal" Style="{StaticResource NsLabel}"/>
                            <TextBlock Text="{Binding BuildChannel}" Style="{StaticResource NsValue}"/>
                            <TextBlock Text="Nexus Settings 1.0 — første-party indstillinger til Ninja Nexus." Foreground="#8CA3C7" FontSize="12" TextWrapping="Wrap" Margin="0,8,0,0"/>
                        </StackPanel>
                    </Border>
                </StackPanel>
            </Grid>
        </ScrollViewer>

        <Border Grid.Column="2" Background="#66081428" CornerRadius="16" BorderBrush="#2200D9FF" BorderThickness="1" Padding="16">
            <StackPanel>
                <Path Data="M12,2 A10,10 0 1,1 12,22 A10,10 0 1,1 12,2 M11,8 L12,8 M11,12 L12,12 L12,16"
                      Stroke="#00D9FF" StrokeThickness="1.6" Fill="Transparent" Width="28" Height="28" Stretch="Uniform" Margin="0,0,0,12"/>
                <TextBlock Text="{Binding InfoPanelTitle}" Foreground="#FFFFFF" FontSize="15" FontWeight="SemiBold" Margin="0,0,0,8"/>
                <TextBlock Text="{Binding InfoPanelBody}" Foreground="#8CA3C7" FontSize="12" TextWrapping="Wrap" Margin="0,0,0,16"/>
                <Rectangle Height="1" Fill="#2200D9FF" Margin="0,0,0,12"/>
                <TextBlock Text="Nexus Settings — ikke Windows Settings." Foreground="#00D9FF" FontSize="11" TextWrapping="Wrap"/>
            </StackPanel>
        </Border>
    </Grid>
</UserControl>
