<UserControl x:Class="NexusShell.Controls.NexusTopStatusBar"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:converters="clr-namespace:NexusShell.Converters"
             xmlns:local="clr-namespace:NexusShell.Controls"
             Height="54">
    <UserControl.Resources>
        <converters:BoolToVisibilityConverter x:Key="BoolToVisibility"/>
    </UserControl.Resources>

    <Border Background="{DynamicResource NexusShellTopBarBgBrush}"
            BorderBrush="{DynamicResource NexusShellTopBarBorderBrush}"
            BorderThickness="0,0,0,1" Padding="16,0">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>

            <Viewbox Grid.Column="0" Height="30" MaxWidth="220" Margin="0,0,20,0"
                     VerticalAlignment="Center" Stretch="Uniform" StretchDirection="DownOnly">
                <Image Source="{Binding LogoTopBarUri}"
                       RenderOptions.BitmapScalingMode="HighQuality"/>
            </Viewbox>

            <ScrollViewer Grid.Column="1" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Disabled"
                          PanningMode="HorizontalOnly" VerticalAlignment="Center">
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
                <Border Style="{DynamicResource NexusShellStatusPillStyle}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Ellipse Width="9" Height="9" Fill="#22C55E" VerticalAlignment="Center" Margin="0,0,10,0">
                            <Ellipse.Effect>
                                <DropShadowEffect Color="#22C55E" BlurRadius="10" ShadowDepth="0" Opacity="0.95"/>
                            </Ellipse.Effect>
                        </Ellipse>
                        <StackPanel Grid.Column="1" VerticalAlignment="Center">
                            <local:LetterSpacedTextBlock Text="SYSTEM STATUS" LetterSpacing="1.1"
                                                         Foreground="{DynamicResource NexusShellLabelBrush}" Opacity="0.88"
                                                         TextElement.FontSize="7.5"/>
                            <TextBlock Text="{Binding SystemStatus}" FontSize="12" FontWeight="SemiBold"
                                       Foreground="{DynamicResource NexusShellValueBrush}" Margin="0,1,0,0"/>
                        </StackPanel>
                    </Grid>
                </Border>

                <Border Style="{DynamicResource NexusShellStatusPillStyle}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Viewbox Width="16" Height="16" Margin="0,0,10,0" VerticalAlignment="Center">
                            <Path Data="M12,19 C8,19 5,16 5,12 C5,8 8,5 12,5 C16,5 19,8 19,12 C19,16 16,19 12,19 M12,8 C10,8 8,10 8,12 C8,14 10,16 12,16 C14,16 16,14 16,12 C16,10 14,8 12,8 Z"
                                  Stroke="{DynamicResource NexusShellAccentStrokeBrush}" StrokeThickness="1.4" Fill="Transparent"
                                  StrokeStartLineCap="Round" StrokeEndLineCap="Round"/>
                        </Viewbox>
                        <StackPanel Grid.Column="1" VerticalAlignment="Center">
                            <local:LetterSpacedTextBlock Text="NETVÆRK" LetterSpacing="1.1"
                                                         Foreground="{DynamicResource NexusShellLabelBrush}" Opacity="0.88"
                                                         TextElement.FontSize="7.5"/>
                            <TextBlock Text="{Binding NetworkLabel}" FontSize="12" FontWeight="SemiBold"
                                       Foreground="{DynamicResource NexusShellValueBrush}" Margin="0,1,0,0"/>
                        </StackPanel>
                    </Grid>
                </Border>

                <Border Style="{DynamicResource NexusShellStatusPillStyle}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Viewbox Width="16" Height="16" Margin="0,0,10,0" VerticalAlignment="Center">
                            <Path Data="M2,10 L5,7 L8,9 L11,5 L14,8"
                                  Stroke="{DynamicResource NexusShellAccentStrokeBrush}" StrokeThickness="1.6" Fill="Transparent"
                                  StrokeStartLineCap="Round" StrokeEndLineCap="Round"/>
                        </Viewbox>
                        <StackPanel Grid.Column="1" VerticalAlignment="Center">
                            <local:LetterSpacedTextBlock Text="CPU" LetterSpacing="1.1"
                                                         Foreground="{DynamicResource NexusShellLabelBrush}" Opacity="0.88"
                                                         TextElement.FontSize="7.5"/>
                            <TextBlock Text="{Binding CpuPercent, StringFormat={}{0}%}"
                                       FontSize="12" FontWeight="SemiBold"
                                       Foreground="{DynamicResource NexusShellValueBrush}" Margin="0,1,0,0"/>
                        </StackPanel>
                    </Grid>
                </Border>

                <Border Style="{DynamicResource NexusShellStatusPillStyle}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Viewbox Width="16" Height="16" Margin="0,0,10,0" VerticalAlignment="Center">
                            <Grid Width="16" Height="14">
                                <Rectangle Width="14" Height="10" RadiusX="1.5" RadiusY="1.5"
                                           Stroke="{DynamicResource NexusShellAccentStrokeBrush}" StrokeThickness="1.3" Fill="Transparent"/>
                                <Rectangle Width="10" Height="4" RadiusX="0.5" RadiusY="0.5"
                                           Fill="{DynamicResource NexusShellAccentStrokeBrush}"
                                           HorizontalAlignment="Center" VerticalAlignment="Center"/>
                            </Grid>
                        </Viewbox>
                        <StackPanel Grid.Column="1" VerticalAlignment="Center">
                            <local:LetterSpacedTextBlock Text="RAM" LetterSpacing="1.1"
                                                         Foreground="{DynamicResource NexusShellLabelBrush}" Opacity="0.88"
                                                         TextElement.FontSize="7.5"/>
                            <TextBlock Text="{Binding MemoryLabel}" FontSize="12" FontWeight="SemiBold"
                                       Foreground="{DynamicResource NexusShellValueBrush}" Margin="0,1,0,0" TextTrimming="CharacterEllipsis"/>
                        </StackPanel>
                    </Grid>
                </Border>

                <Border Style="{DynamicResource NexusShellStatusPillStyle}" Margin="0">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Viewbox Width="16" Height="16" Margin="0,0,10,0" VerticalAlignment="Center">
                            <Grid Width="16" Height="14">
                                <Rectangle Width="14" Height="10" RadiusX="1.5" RadiusY="1.5"
                                           Stroke="{DynamicResource NexusShellAccentStrokeBrush}" StrokeThickness="1.3" Fill="Transparent"/>
                                <Rectangle Width="6" Height="2" RadiusX="0.5" RadiusY="0.5"
                                           Fill="{DynamicResource NexusShellAccentStrokeBrush}"
                                           HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,1"/>
                            </Grid>
                        </Viewbox>
                        <StackPanel Grid.Column="1" VerticalAlignment="Center">
                            <local:LetterSpacedTextBlock Text="LAGERPLADS" LetterSpacing="1.1"
                                                         Foreground="{DynamicResource NexusShellLabelBrush}" Opacity="0.88"
                                                         TextElement.FontSize="7.5"/>
                            <TextBlock Text="{Binding StorageLabel}" FontSize="12" FontWeight="SemiBold"
                                       Foreground="{DynamicResource NexusShellValueBrush}" Margin="0,1,0,0" TextTrimming="CharacterEllipsis"/>
                        </StackPanel>
                    </Grid>
                </Border>

                <Border Style="{DynamicResource NexusShellStatusPillStyle}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Viewbox Width="16" Height="16" Margin="0,0,10,0" VerticalAlignment="Center">
                            <Canvas Width="24" Height="24">
                                <Path Data="M12,4 L12,10 M12,14 L12,14.5"
                                      Stroke="{DynamicResource NexusShellAccentStrokeBrush}" StrokeThickness="1.6" Fill="Transparent"
                                      StrokeStartLineCap="Round" StrokeEndLineCap="Round"/>
                                <Path Data="M4,12 L20,12"
                                      Stroke="{DynamicResource NexusShellAccentStrokeBrush}" StrokeThickness="1.3" Fill="Transparent"
                                      StrokeStartLineCap="Round" StrokeEndLineCap="Round"/>
                            </Canvas>
                        </Viewbox>
                        <StackPanel Grid.Column="1" VerticalAlignment="Center">
                            <local:LetterSpacedTextBlock Text="OPDATERINGER" LetterSpacing="1.1"
                                                         Foreground="{DynamicResource NexusShellLabelBrush}" Opacity="0.88"
                                                         TextElement.FontSize="7.5"/>
                            <TextBlock Text="{Binding UpdateLabel}" FontSize="12" FontWeight="SemiBold"
                                       Foreground="{DynamicResource NexusShellValueBrush}" Margin="0,1,0,0" TextTrimming="CharacterEllipsis"/>
                        </StackPanel>
                    </Grid>
                </Border>

                <Border Style="{DynamicResource NexusShellStatusPillStyle}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Viewbox Width="16" Height="16" Margin="0,0,10,0" VerticalAlignment="Center">
                            <Canvas Width="24" Height="24">
                                <Path Data="M12,3 C7,3 3,7 3,12 C3,17 7,21 12,21 C17,21 21,17 21,12"
                                      Stroke="{DynamicResource NexusShellAccentStrokeBrush}" StrokeThickness="1.3" Fill="Transparent"
                                      StrokeStartLineCap="Round" StrokeEndLineCap="Round"/>
                                <Path Data="M12,7 L12,12 L15,14"
                                      Stroke="{DynamicResource NexusShellAccentStrokeBrush}" StrokeThickness="1.3" Fill="Transparent"
                                      StrokeStartLineCap="Round" StrokeEndLineCap="Round"/>
                            </Canvas>
                        </Viewbox>
                        <StackPanel Grid.Column="1" VerticalAlignment="Center">
                            <local:LetterSpacedTextBlock Text="LATENCY" LetterSpacing="1.1"
                                                         Foreground="{DynamicResource NexusShellLabelBrush}" Opacity="0.88"
                                                         TextElement.FontSize="7.5"/>
                            <TextBlock Text="{Binding IdentityLatencyLabel}" FontSize="12" FontWeight="SemiBold"
                                       Foreground="{DynamicResource NexusShellValueBrush}" Margin="0,1,0,0"/>
                        </StackPanel>
                    </Grid>
                </Border>

                <Border Style="{DynamicResource NexusShellStatusPillStyle}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Ellipse Width="9" Height="9" Fill="#8A4FFF" VerticalAlignment="Center" Margin="0,0,10,0">
                            <Ellipse.Effect>
                                <DropShadowEffect Color="#8A4FFF" BlurRadius="10" ShadowDepth="0" Opacity="0.95"/>
                            </Ellipse.Effect>
                        </Ellipse>
                        <StackPanel Grid.Column="1" VerticalAlignment="Center">
                            <local:LetterSpacedTextBlock Text="NEXUS AGENT" LetterSpacing="1.1"
                                                         Foreground="{DynamicResource NexusShellLabelBrush}" Opacity="0.88"
                                                         TextElement.FontSize="7.5"/>
                            <TextBlock Text="{Binding AgentStatusLabel}" FontSize="12" FontWeight="SemiBold"
                                       Foreground="{DynamicResource NexusShellValueBrush}" Margin="0,1,0,0"/>
                        </StackPanel>
                    </Grid>
                </Border>

                <Border Style="{DynamicResource NexusShellStatusPillStyle}" Margin="0">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Viewbox Width="16" Height="16" Margin="0,0,10,0" VerticalAlignment="Center">
                            <Path Data="M12,2 L4,6 L4,12 C4,16.5 7.5,20.5 12,22 C16.5,20.5 20,16.5 20,12 L20,6 Z"
                                  Stroke="{DynamicResource NexusShellAccentStrokeBrush}" StrokeThickness="1.3" Fill="Transparent"
                                  StrokeStartLineCap="Round" StrokeEndLineCap="Round"/>
                        </Viewbox>
                        <StackPanel Grid.Column="1" VerticalAlignment="Center">
                            <local:LetterSpacedTextBlock Text="THREAT SCAN" LetterSpacing="1.1"
                                                         Foreground="{DynamicResource NexusShellLabelBrush}" Opacity="0.88"
                                                         TextElement.FontSize="7.5"/>
                            <TextBlock Text="{Binding ThreatScanLabel}" FontSize="12" FontWeight="SemiBold"
                                       Foreground="{DynamicResource NexusShellValueBrush}" Margin="0,1,0,0" TextTrimming="CharacterEllipsis"/>
                        </StackPanel>
                    </Grid>
                </Border>
            </StackPanel>
            </ScrollViewer>

            <StackPanel Grid.Column="2" HorizontalAlignment="Right" VerticalAlignment="Center" Orientation="Horizontal">
                <Grid Margin="0,0,8,0">
                    <Button Style="{DynamicResource NexusShellTopRoundButtonStyle}"
                            Command="{Binding OpenNotificationCenterCommand}" ToolTip="Notifikationer">
                        <Path Data="M12,4 C8,4 6,7 6,10 L6,12 L4,14 L4,15 L20,15 L20,14 L18,12 L18,10 C18,7 16,4 12,4 Z M12,19 C13.1,19 14,18.1 14,17 L10,17 C10,18.1 10.9,19 12,19 Z"
                              Fill="{DynamicResource NexusShellIconBrush}" Stretch="Uniform" Width="16" Height="16"/>
                    </Button>
                    <Border Background="#8A4FFF" CornerRadius="7" MinWidth="16" Height="16" Padding="4,1"
                            HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,-5,-4,0"
                            Visibility="{Binding HasNotifications, Converter={StaticResource BoolToVisibility}}">
                        <TextBlock Text="{Binding NotificationCount}" FontSize="9" Foreground="White"
                                   FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </Border>
                </Grid>
                <Button Style="{DynamicResource NexusShellTopRoundButtonStyle}" ToolTip="Sikkerhed" Margin="0,0,8,0">
                    <Viewbox Width="16" Height="16">
                        <Path Data="M12,2 L4,6 L4,12 C4,16.5 7.5,20.5 12,22 C16.5,20.5 20,16.5 20,12 L20,6 Z M9.5,12.5 L11,14 L14.5,10.5"
                              Stroke="{DynamicResource NexusShellIconBrush}" StrokeThickness="1.3" Fill="Transparent"
                              StrokeStartLineCap="Round" StrokeEndLineCap="Round"/>
                    </Viewbox>
                </Button>
                <Button Style="{DynamicResource NexusShellTopRoundButtonStyle}"
                        Command="{Binding OpenSettingsCommand}" ToolTip="Indstillinger" Margin="0">
                    <Viewbox Width="16" Height="16">
                        <Canvas Width="18" Height="14">
                            <Line X1="3" Y1="4" X2="15" Y2="4" Stroke="{DynamicResource NexusShellIconBrush}" StrokeThickness="1.4"/>
                            <Line X1="3" Y1="10" X2="15" Y2="10" Stroke="{DynamicResource NexusShellIconBrush}" StrokeThickness="1.4"/>
                            <Ellipse Width="5" Height="5" Fill="{DynamicResource NexusShellIconBrush}" Canvas.Left="9" Canvas.Top="1.5"/>
                            <Ellipse Width="5" Height="5" Fill="{DynamicResource NexusShellIconBrush}" Canvas.Left="4" Canvas.Top="7.5"/>
                        </Canvas>
                    </Viewbox>
                </Button>
            </StackPanel>
        </Grid>
    </Border>
</UserControl>
