<UserControl x:Class="PerformanceMonitorDashboard.Controls.SystemEventsContent"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:ScottPlot="clr-namespace:ScottPlot.WPF;assembly=ScottPlot.WPF"
             mc:Ignorable="d"
             d:DesignHeight="600" d:DesignWidth="1200">
    <UserControl.Resources>
        <ResourceDictionary>
            <!-- Context Menu for DataGrid Copy/Export -->
            <ContextMenu x:Key="DataGridContextMenu">
                <MenuItem Header="Copy Cell" Click="CopyCell_Click">
                    <MenuItem.Icon><TextBlock Text="📋"/></MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="Copy Row" Click="CopyRow_Click">
                    <MenuItem.Icon><TextBlock Text="📄"/></MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="Copy All Rows" Click="CopyAllRows_Click">
                    <MenuItem.Icon><TextBlock Text="📑"/></MenuItem.Icon>
                </MenuItem>
                <Separator/>
                <MenuItem Header="Export to CSV..." Click="ExportToCsv_Click">
                    <MenuItem.Icon><TextBlock Text="📊"/></MenuItem.Icon>
                </MenuItem>
            </ContextMenu>

            <Style x:Key="DefaultRowStyle" TargetType="DataGridRow">
                <Setter Property="ContextMenu" Value="{StaticResource DataGridContextMenu}"/>
            </Style>
        </ResourceDictionary>
    </UserControl.Resources>

    <TabControl x:Name="SubTabControl" TabStripPlacement="Top" Margin="0,5,0,0" ItemContainerStyle="{DynamicResource SubTabItemStyle}">
        <!-- Overview Tab -->
        <TabItem Header="Corruption Events">
            <Grid Margin="10,5,10,10">
                <!-- Charts Grid (2x2) -->
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>

                    <Border Grid.Row="0" Grid.Column="0" BorderBrush="LightGray" BorderThickness="1" Margin="2">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <TextBlock Text="Bad Pages Detected" FontWeight="Bold" Margin="5,3,5,3" FontSize="11" Foreground="{DynamicResource ForegroundBrush}"/>
                            <ScottPlot:WpfPlot x:Name="BadPagesChart" Grid.Row="1"/>
                        </Grid>
                    </Border>

                    <Border Grid.Row="0" Grid.Column="1" BorderBrush="LightGray" BorderThickness="1" Margin="2">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <TextBlock Text="Interval Dump Requests" FontWeight="Bold" Margin="5,3,5,3" FontSize="11" Foreground="{DynamicResource ForegroundBrush}"/>
                            <ScottPlot:WpfPlot x:Name="DumpRequestsChart" Grid.Row="1"/>
                        </Grid>
                    </Border>

                    <Border Grid.Row="1" Grid.Column="0" BorderBrush="LightGray" BorderThickness="1" Margin="2">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <TextBlock Text="Access Violations Occurred" FontWeight="Bold" Margin="5,3,5,3" FontSize="11" Foreground="{DynamicResource ForegroundBrush}"/>
                            <ScottPlot:WpfPlot x:Name="AccessViolationsChart" Grid.Row="1"/>
                        </Grid>
                    </Border>

                    <Border Grid.Row="1" Grid.Column="1" BorderBrush="LightGray" BorderThickness="1" Margin="2">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <TextBlock Text="Write Access Violation Count" FontWeight="Bold" Margin="5,3,5,3" FontSize="11" Foreground="{DynamicResource ForegroundBrush}"/>
                            <ScottPlot:WpfPlot x:Name="WriteAccessViolationsChart" Grid.Row="1"/>
                        </Grid>
                    </Border>
                </Grid>

            </Grid>
        </TabItem>

        <!-- Contention Events Tab -->
        <TabItem Header="Contention Events">
            <Grid Margin="10,5,10,10">
                <!-- Charts Grid (2x2) -->
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>

                    <Border Grid.Row="0" Grid.Column="0" BorderBrush="LightGray" BorderThickness="1" Margin="2">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <TextBlock Text="Non-Yielding Tasks Reported" FontWeight="Bold" Margin="5,3,5,3" FontSize="11" Foreground="{DynamicResource ForegroundBrush}"/>
                            <ScottPlot:WpfPlot x:Name="NonYieldingTasksChart" Grid.Row="1"/>
                        </Grid>
                    </Border>

                    <Border Grid.Row="0" Grid.Column="1" BorderBrush="LightGray" BorderThickness="1" Margin="2">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <TextBlock Text="Latch Warnings" FontWeight="Bold" Margin="5,3,5,3" FontSize="11" Foreground="{DynamicResource ForegroundBrush}"/>
                            <ScottPlot:WpfPlot x:Name="LatchWarningsChart" Grid.Row="1"/>
                        </Grid>
                    </Border>

                    <Border Grid.Row="1" Grid.Column="0" BorderBrush="LightGray" BorderThickness="1" Margin="2">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <TextBlock Text="Sick Spinlocks by Type" FontWeight="Bold" Margin="5,3,5,3" FontSize="11" Foreground="{DynamicResource ForegroundBrush}"/>
                            <ScottPlot:WpfPlot x:Name="SickSpinlocksChart" Grid.Row="1"/>
                        </Grid>
                    </Border>

                    <Border Grid.Row="1" Grid.Column="1" BorderBrush="LightGray" BorderThickness="1" Margin="2">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <TextBlock Text="SQL CPU vs System CPU" FontWeight="Bold" Margin="5,3,5,3" FontSize="11" Foreground="{DynamicResource ForegroundBrush}"/>
                            <ScottPlot:WpfPlot x:Name="CpuComparisonChart" Grid.Row="1"/>
                        </Grid>
                    </Border>
                </Grid>
            </Grid>
        </TabItem>

        <!-- Severe Errors Tab -->
        <TabItem Header="Severe Errors">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="400"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

                <!-- Chart -->
                <Border Grid.Row="0" BorderBrush="LightGray" BorderThickness="1" Margin="10,5,10,2">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <TextBlock Text="Severe Errors Over Time" FontWeight="Bold" FontSize="14" Margin="10,5" Foreground="{DynamicResource ForegroundBrush}"/>
                        <ScottPlot:WpfPlot Grid.Row="1" x:Name="SevereErrorsChart" Margin="5"/>
                    </Grid>
                </Border>

                <!-- Data Grid with No Data Overlay -->
                <Grid Grid.Row="1">
                    <DataGrid x:Name="SevereErrorsDataGrid" Margin="10,5,10,10"
                          AutoGenerateColumns="False" IsReadOnly="True"
                          CanUserSortColumns="True" CanUserResizeColumns="True"
                          GridLinesVisibility="All" RowStyle="{StaticResource DefaultRowStyle}">
                <DataGrid.Columns>
                    <DataGridTextColumn Binding="{Binding CollectionTime, Converter={StaticResource ServerTimeConverter}}" Width="160">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="CollectionTime" Click="SevereErrorsFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Collection Time" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding EventTime, Converter={StaticResource ServerTimeConverter}}" Width="160">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="EventTime" Click="SevereErrorsFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Event Time" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding ErrorNumber}" ElementStyle="{StaticResource NumericCell}" Width="100">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="ErrorNumber" Click="SevereErrorsFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Error #" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding Severity}" ElementStyle="{StaticResource NumericCell}" Width="80">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="Severity" Click="SevereErrorsFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Severity" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding State}" ElementStyle="{StaticResource NumericCell}" Width="70">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="State" Click="SevereErrorsFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="State" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding DatabaseName}" Width="150">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="DatabaseName" Click="SevereErrorsFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Database" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding Message}" Width="500">
                        <DataGridTextColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <Button Style="{DynamicResource ColumnFilterButtonStyle}" Tag="Message" Click="SevereErrorsFilter_Click" Margin="0,0,4,0"/>
                                <TextBlock Text="Message" FontWeight="Bold" VerticalAlignment="Center"/>
                            </StackPanel>
                        </DataGridTextColumn.Header>
                    </DataGridTextColumn>
                </DataGrid.Columns>
                    </DataGrid>
                    <TextBlock x:Name="SevereErrorsNoDataMessage" Style="{StaticResource NoDataMessage}"/>
                </Grid>
            </Grid>
        </TabItem>

        <!-- I/O Issues Tab - Chart Only, grid removed per todo.md #19 -->
        <TabItem Header="I/O Issues">
            <Grid Margin="10,5,10,10">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

                <!-- Chart 1: Latch Timeouts + Interval Long IOs -->
                <Border Grid.Row="0" BorderBrush="LightGray" BorderThickness="1" Margin="0,0,0,2">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <TextBlock Text="Latch Timeouts + Interval Long IOs" FontWeight="Bold" Margin="5,3,5,3" FontSize="11" Foreground="{DynamicResource ForegroundBrush}"/>
                        <ScottPlot:WpfPlot Grid.Row="1" x:Name="IOIssuesChart" Margin="5"/>
                    </Grid>
                </Border>

                <!-- Chart 2: Longest Pending I/O by File Path -->
                <Border Grid.Row="1" BorderBrush="LightGray" BorderThickness="1" Margin="0,2,0,0">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <TextBlock Text="Longest Pending I/O by File Path" FontWeight="Bold" Margin="5,3,5,3" FontSize="11" Foreground="{DynamicResource ForegroundBrush}"/>
                        <ScottPlot:WpfPlot Grid.Row="1" x:Name="LongestPendingIOChart" Margin="5"/>
                    </Grid>
                </Border>
            </Grid>
        </TabItem>

        <!-- Scheduler Issues Tab - Chart Only with Summary Panel -->
        <TabItem Header="Scheduler Issues">
            <Border BorderBrush="LightGray" BorderThickness="1" Margin="10,5,10,10">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <TextBlock Text="Non-Yielding Time Over Time" FontWeight="Bold" FontSize="14" Margin="10,5" Foreground="{DynamicResource ForegroundBrush}"/>
                    <ScottPlot:WpfPlot Grid.Row="1" x:Name="SchedulerIssuesChart" Margin="5"/>

                    <!-- Summary Panel -->
                    <Border Grid.Row="2" Background="{DynamicResource BackgroundBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="0,1,0,0" Padding="10,8">
                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                            <TextBlock Text="Total Issues:" FontWeight="SemiBold" Foreground="{DynamicResource ForegroundDimBrush}" VerticalAlignment="Center" Margin="0,0,5,0"/>
                            <TextBlock x:Name="SchedulerIssuesTotalText" Text="0" Foreground="{DynamicResource ForegroundBrush}" VerticalAlignment="Center" Margin="0,0,20,0"/>
                            <TextBlock Text="Total Non-Yield:" FontWeight="SemiBold" Foreground="{DynamicResource ForegroundDimBrush}" VerticalAlignment="Center" Margin="0,0,5,0"/>
                            <TextBlock x:Name="SchedulerIssuesTotalNonYieldText" Text="0 ms" Foreground="{DynamicResource ForegroundBrush}" VerticalAlignment="Center" Margin="0,0,20,0"/>
                            <TextBlock Text="Max Non-Yield:" FontWeight="SemiBold" Foreground="{DynamicResource ForegroundDimBrush}" VerticalAlignment="Center" Margin="0,0,5,0"/>
                            <TextBlock x:Name="SchedulerIssuesMaxNonYieldText" Text="0 ms" Foreground="{DynamicResource ForegroundBrush}" VerticalAlignment="Center" Margin="0,0,20,0"/>
                            <TextBlock Text="Schedulers Affected:" FontWeight="SemiBold" Foreground="{DynamicResource ForegroundDimBrush}" VerticalAlignment="Center" Margin="0,0,5,0"/>
                            <TextBlock x:Name="SchedulerIssuesSchedulersText" Text="0" Foreground="{DynamicResource ForegroundBrush}" VerticalAlignment="Center" Margin="0,0,20,0"/>
                            <TextBlock Text="Offline Events:" FontWeight="SemiBold" Foreground="{DynamicResource ForegroundDimBrush}" VerticalAlignment="Center" Margin="0,0,5,0"/>
                            <TextBlock x:Name="SchedulerIssuesOfflineText" Text="0" Foreground="{DynamicResource ForegroundBrush}" VerticalAlignment="Center"/>
                        </StackPanel>
                    </Border>
                </Grid>
            </Border>
        </TabItem>

        <!-- Memory Conditions Tab -->
        <TabItem Header="Memory Conditions">
            <!-- Chart Only - Grid removed per todo.md #14 -->
            <Border BorderBrush="LightGray" BorderThickness="1" Margin="10,5,10,10">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <TextBlock Text="Memory Conditions Over Time" FontWeight="Bold" FontSize="14" Margin="10,5" Foreground="{DynamicResource ForegroundBrush}"/>
                    <ScottPlot:WpfPlot Grid.Row="1" x:Name="MemoryConditionsChart" Margin="5"/>
                </Grid>
            </Border>
        </TabItem>

        <!-- CPU Tasks Tab - Chart Only with Summary Panel -->
        <TabItem Header="CPU Tasks">
            <Border BorderBrush="LightGray" BorderThickness="1" Margin="10,5,10,10">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <TextBlock Text="Workers Created Over Time" FontWeight="Bold" FontSize="14" Margin="10,5" Foreground="{DynamicResource ForegroundBrush}"/>
                    <ScottPlot:WpfPlot Grid.Row="1" x:Name="CPUTasksChart" Margin="5"/>

                    <!-- Summary Panel -->
                    <Border Grid.Row="2" Background="{DynamicResource BackgroundBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="0,1,0,0" Padding="10,8">
                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                            <TextBlock Text="Unresolvable Deadlocks:" FontWeight="SemiBold" Foreground="{DynamicResource ForegroundDimBrush}" VerticalAlignment="Center" Margin="0,0,5,0"/>
                            <TextBlock x:Name="CPUTasksUnresolvableDLText" Text="0" Foreground="{DynamicResource ForegroundBrush}" VerticalAlignment="Center" Margin="0,0,20,0"/>
                            <TextBlock Text="Scheduler Deadlocks:" FontWeight="SemiBold" Foreground="{DynamicResource ForegroundDimBrush}" VerticalAlignment="Center" Margin="0,0,5,0"/>
                            <TextBlock x:Name="CPUTasksSchedDLText" Text="0" Foreground="{DynamicResource ForegroundBrush}" VerticalAlignment="Center" Margin="0,0,20,0"/>
                            <TextBlock Text="Blocking Events:" FontWeight="SemiBold" Foreground="{DynamicResource ForegroundDimBrush}" VerticalAlignment="Center" Margin="0,0,5,0"/>
                            <TextBlock x:Name="CPUTasksBlockingText" Text="0" Foreground="{DynamicResource ForegroundBrush}" VerticalAlignment="Center" Margin="0,0,20,0"/>
                            <TextBlock Text="Pending w/o Blocking:" FontWeight="SemiBold" Foreground="{DynamicResource ForegroundDimBrush}" VerticalAlignment="Center" Margin="0,0,5,0"/>
                            <TextBlock x:Name="CPUTasksPendingNoBlockText" Text="0" Foreground="{DynamicResource ForegroundBrush}" VerticalAlignment="Center"/>
                        </StackPanel>
                    </Border>
                </Grid>
            </Border>
        </TabItem>

        <!-- Memory Broker Tab -->
        <TabItem Header="Memory Broker">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

                <!-- Currently Allocated by Broker Over Time -->
                <Border Grid.Row="0" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1" Margin="10,5,10,2">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <TextBlock Text="Currently Allocated by Broker Over Time" FontWeight="Bold" FontSize="11" Margin="5,3" Foreground="{DynamicResource ForegroundBrush}"/>
                        <ScottPlot:WpfPlot Grid.Row="1" x:Name="MemoryBrokerChart" Margin="5"/>
                    </Grid>
                </Border>

                <!-- Memory Ratio and Overall Over Time -->
                <Border Grid.Row="1" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1" Margin="10,2,10,2">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <TextBlock Text="Memory Ratio and Overall Over Time" FontWeight="Bold" FontSize="11" Margin="5,3" Foreground="{DynamicResource ForegroundBrush}"/>
                        <ScottPlot:WpfPlot Grid.Row="1" x:Name="MemoryBrokerRatioChart" Margin="5"/>
                    </Grid>
                </Border>

                <!-- Hidden elements to preserve code-behind references -->
                <DataGrid x:Name="MemoryBrokerDataGrid" Visibility="Collapsed"/>
                <TextBlock x:Name="MemoryBrokerNoDataMessage" Visibility="Collapsed"/>
            </Grid>
        </TabItem>

        <!-- Memory Node OOM Tab -->
        <TabItem Header="Memory Node OOM">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

                <!-- Memory State Indicators Panel -->
                <Border Grid.Row="0" Background="{DynamicResource BackgroundLightBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1" Margin="10,5,10,2" Padding="10,8">
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                        <TextBlock Text="Memory State:" FontWeight="Bold" Foreground="{DynamicResource ForegroundBrush}" VerticalAlignment="Center" Margin="0,0,15,0"/>

                        <!-- System Physical Memory High -->
                        <Ellipse x:Name="SysMemHighIndicator" Width="12" Height="12" VerticalAlignment="Center" Margin="0,0,4,0"/>
                        <TextBlock Text="Sys High" FontSize="11" Foreground="{DynamicResource ForegroundBrush}" VerticalAlignment="Center" Margin="0,0,4,0"/>
                        <TextBlock x:Name="SysMemHighCountText" Text="(0)" FontSize="11" Foreground="{DynamicResource ForegroundDimBrush}" VerticalAlignment="Center" Margin="0,0,20,0"/>

                        <!-- System Physical Memory Low -->
                        <Ellipse x:Name="SysMemLowIndicator" Width="12" Height="12" VerticalAlignment="Center" Margin="0,0,4,0"/>
                        <TextBlock Text="Sys Low" FontSize="11" Foreground="{DynamicResource ForegroundBrush}" VerticalAlignment="Center" Margin="0,0,4,0"/>
                        <TextBlock x:Name="SysMemLowCountText" Text="(0)" FontSize="11" Foreground="{DynamicResource ForegroundDimBrush}" VerticalAlignment="Center" Margin="0,0,20,0"/>

                        <!-- Process Physical Memory Low -->
                        <Ellipse x:Name="ProcMemLowIndicator" Width="12" Height="12" VerticalAlignment="Center" Margin="0,0,4,0"/>
                        <TextBlock Text="Proc Phys Low" FontSize="11" Foreground="{DynamicResource ForegroundBrush}" VerticalAlignment="Center" Margin="0,0,4,0"/>
                        <TextBlock x:Name="ProcMemLowCountText" Text="(0)" FontSize="11" Foreground="{DynamicResource ForegroundDimBrush}" VerticalAlignment="Center" Margin="0,0,20,0"/>

                        <!-- Process Virtual Memory Low -->
                        <Ellipse x:Name="ProcVirtLowIndicator" Width="12" Height="12" VerticalAlignment="Center" Margin="0,0,4,0"/>
                        <TextBlock Text="Proc Virt Low" FontSize="11" Foreground="{DynamicResource ForegroundBrush}" VerticalAlignment="Center" Margin="0,0,4,0"/>
                        <TextBlock x:Name="ProcVirtLowCountText" Text="(0)" FontSize="11" Foreground="{DynamicResource ForegroundDimBrush}" VerticalAlignment="Center"/>
                    </StackPanel>
                </Border>

                <!-- Vertical Chart Stack -->
                <Grid Grid.Row="1" Margin="5">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>

                    <!-- Memory Utilization % -->
                    <Border Grid.Row="0" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1" Margin="5">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <TextBlock Text="Memory Utilization (%)" FontWeight="Bold" FontSize="14" Margin="10,5" Foreground="{DynamicResource ForegroundBrush}"/>
                            <ScottPlot:WpfPlot Grid.Row="1" x:Name="MemoryNodeOOMUtilChart" Margin="5"/>
                        </Grid>
                    </Border>

                    <!-- Combined Memory Metrics (MB) -->
                    <Border Grid.Row="1" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1" Margin="5">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <TextBlock Text="Memory Metrics (MB)" FontWeight="Bold" FontSize="14" Margin="10,5" Foreground="{DynamicResource ForegroundBrush}"/>
                            <ScottPlot:WpfPlot Grid.Row="1" x:Name="MemoryNodeOOMMemoryChart" Margin="5"/>
                        </Grid>
                    </Border>

                    <!-- OOM Event Count -->
                    <Border Grid.Row="2" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1" Margin="5">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <TextBlock Text="OOM Events Over Time" FontWeight="Bold" FontSize="14" Margin="10,5" Foreground="{DynamicResource ForegroundBrush}"/>
                            <ScottPlot:WpfPlot Grid.Row="1" x:Name="MemoryNodeOOMChart" Margin="5"/>
                        </Grid>
                    </Border>
                </Grid>
            </Grid>
        </TabItem>
    </TabControl>
</UserControl>
