<Window x:Class="PerformanceMonitorDashboard.ManageMuteRulesWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Manage Mute Rules"
        Height="500" Width="800"
        WindowStartupLocation="CenterOwner"
        ResizeMode="CanResizeWithGrip"
        Background="{DynamicResource BackgroundBrush}">
    <Grid Margin="16">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <!-- Header -->
        <TextBlock Grid.Row="0" Text="Mute Rules" FontSize="18" FontWeight="Bold"
                   Foreground="{DynamicResource ForegroundBrush}" Margin="0,0,0,4"/>
        <TextBlock Grid.Row="1" Text="Muted alerts are still collected and logged, but suppressed from tray notifications and email alerts."
                   Foreground="{DynamicResource ForegroundDimBrush}" TextWrapping="Wrap" Margin="0,0,0,12"/>

        <!-- Rules Grid -->
        <DataGrid Grid.Row="2" x:Name="RulesGrid"
                  AutoGenerateColumns="False"
                  IsReadOnly="True"
                  SelectionMode="Single"
                  CanUserAddRows="False"
                  CanUserDeleteRows="False"
                  HeadersVisibility="Column"
                  GridLinesVisibility="Horizontal"
                  MouseDoubleClick="RulesGrid_MouseDoubleClick">
            <DataGrid.Columns>
                <DataGridTemplateColumn Header="Enabled" Width="60">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox IsChecked="{Binding Enabled, UpdateSourceTrigger=PropertyChanged}"
                                      HorizontalAlignment="Center" VerticalAlignment="Center"
                                      Click="EnabledCheckBox_Click"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn Header="Metric" Binding="{Binding MetricName}" Width="130">
                    <DataGridTextColumn.ElementStyle>
                        <Style TargetType="TextBlock">
                            <Setter Property="Foreground" Value="{DynamicResource ForegroundBrush}"/>
                        </Style>
                    </DataGridTextColumn.ElementStyle>
                </DataGridTextColumn>
                <DataGridTextColumn Header="Server" Binding="{Binding ServerName}" Width="120">
                    <DataGridTextColumn.ElementStyle>
                        <Style TargetType="TextBlock">
                            <Setter Property="Foreground" Value="{DynamicResource ForegroundBrush}"/>
                        </Style>
                    </DataGridTextColumn.ElementStyle>
                </DataGridTextColumn>
                <DataGridTextColumn Header="Reason" Binding="{Binding Reason}" Width="*">
                    <DataGridTextColumn.ElementStyle>
                        <Style TargetType="TextBlock">
                            <Setter Property="Foreground" Value="{DynamicResource ForegroundDimBrush}"/>
                        </Style>
                    </DataGridTextColumn.ElementStyle>
                </DataGridTextColumn>
                <DataGridTextColumn Header="Expires" Binding="{Binding ExpiresDisplay}" Width="120">
                    <DataGridTextColumn.ElementStyle>
                        <Style TargetType="TextBlock">
                            <Setter Property="Foreground" Value="{DynamicResource ForegroundDimBrush}"/>
                        </Style>
                    </DataGridTextColumn.ElementStyle>
                </DataGridTextColumn>
            </DataGrid.Columns>
        </DataGrid>

        <!-- Buttons -->
        <StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,12,0,0">
            <Button Content="Add Rule..." Width="100" Height="28" Margin="0,0,8,0"
                    Click="AddRule_Click" Style="{StaticResource AccentButton}"/>
            <Button Content="Edit" Width="80" Height="28" Margin="0,0,8,0"
                    Click="EditRule_Click" x:Name="EditButton"/>
            <Button Content="Toggle" Width="80" Height="28" Margin="0,0,8,0"
                    Click="ToggleRule_Click" x:Name="ToggleButton"/>
            <Button Content="Delete" Width="80" Height="28" Margin="0,0,8,0"
                    Click="DeleteRule_Click" x:Name="DeleteButton"/>
            <Button Content="Purge Expired" Width="110" Height="28"
                    Click="PurgeExpired_Click"/>
        </StackPanel>
        <Button Grid.Row="3" Content="Close" Width="80" Height="28" Margin="0,12,0,0"
                HorizontalAlignment="Right" Click="Close_Click"/>
    </Grid>
</Window>
