<UserControl x:Class="PerformanceMonitorDashboard.Controls.LandingPage"
             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:local="clr-namespace:PerformanceMonitorDashboard.Controls"
             mc:Ignorable="d"
             d:DesignHeight="600" d:DesignWidth="1000">
    <Grid Background="{DynamicResource BackgroundBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <!-- Header -->
        <Border Grid.Row="0"
                Background="{DynamicResource BackgroundDarkBrush}"
                BorderBrush="{DynamicResource BorderBrush}"
                BorderThickness="0,0,0,1"
                Padding="16,12">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>

                <StackPanel Grid.Column="0">
                    <TextBlock Text="Server Health Overview"
                               FontSize="20"
                               FontWeight="SemiBold"
                               Foreground="{DynamicResource ForegroundBrush}"/>
                    <TextBlock x:Name="SubtitleText"
                               Text="Monitoring 0 servers"
                               FontSize="12"
                               Foreground="{DynamicResource ForegroundMutedBrush}"
                               Margin="0,2,0,0"/>
                </StackPanel>

                <StackPanel Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center">
                    <Button x:Name="RefreshAllButton"
                            Content="↻ Refresh All"
                            Click="RefreshAll_Click"
                            Padding="12,6"
                            Margin="0,0,8,0"/>
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                        <TextBlock Text="Auto-refresh:"
                                   FontSize="11"
                                   Foreground="{DynamicResource ForegroundMutedBrush}"
                                   VerticalAlignment="Center"
                                   Margin="0,0,6,0"/>
                        <TextBlock x:Name="AutoRefreshStatusText"
                                   Text="Off"
                                   FontSize="11"
                                   Foreground="{DynamicResource ForegroundBrush}"
                                   VerticalAlignment="Center"/>
                    </StackPanel>
                </StackPanel>
            </Grid>
        </Border>

        <!-- Server Cards Grid -->
        <ScrollViewer Grid.Row="1"
                      VerticalScrollBarVisibility="Auto"
                      HorizontalScrollBarVisibility="Disabled"
                      Padding="12">
            <ItemsControl x:Name="ServerCardsPanel">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel Orientation="Horizontal"/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <local:ServerHealthCard Width="300"
                                                Height="220"
                                                CardClicked="ServerHealthCard_CardClicked"
                                                EditServerRequested="ServerHealthCard_EditServerRequested"
                                                CheckVersionRequested="ServerHealthCard_CheckVersionRequested"/>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </ScrollViewer>

        <!-- Empty state -->
        <StackPanel x:Name="EmptyStatePanel"
                    Grid.Row="1"
                    VerticalAlignment="Center"
                    HorizontalAlignment="Center"
                    Visibility="Collapsed">
            <TextBlock Text="No Servers Configured"
                       FontSize="18"
                       Foreground="{DynamicResource ForegroundMutedBrush}"
                       HorizontalAlignment="Center"/>
            <TextBlock Text="Add a server using the sidebar to get started"
                       FontSize="12"
                       Foreground="{DynamicResource ForegroundDimBrush}"
                       HorizontalAlignment="Center"
                       Margin="0,8,0,0"/>
        </StackPanel>

        <!-- Footer: Legend -->
        <Border Grid.Row="2"
                Background="{DynamicResource BackgroundDarkBrush}"
                BorderBrush="{DynamicResource BorderBrush}"
                BorderThickness="0,1,0,0"
                Padding="16,8">
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                <StackPanel Orientation="Horizontal" Margin="0,0,20,0">
                    <Ellipse Width="10" Height="10" Fill="#81C784" Margin="0,0,6,0"/>
                    <TextBlock Text="Healthy" FontSize="11" Foreground="{DynamicResource ForegroundMutedBrush}"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal" Margin="0,0,20,0">
                    <Ellipse Width="10" Height="10" Fill="#FFD54F" Margin="0,0,6,0"/>
                    <TextBlock Text="Warning" FontSize="11" Foreground="{DynamicResource ForegroundMutedBrush}"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal" Margin="0,0,20,0">
                    <Ellipse Width="10" Height="10" Fill="#E57373" Margin="0,0,6,0"/>
                    <TextBlock Text="Critical" FontSize="11" Foreground="{DynamicResource ForegroundMutedBrush}"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <Ellipse Width="10" Height="10" Fill="#888888" Margin="0,0,6,0"/>
                    <TextBlock Text="Unknown" FontSize="11" Foreground="{DynamicResource ForegroundMutedBrush}"/>
                </StackPanel>
            </StackPanel>
        </Border>
    </Grid>
</UserControl>
