<Window x:Class="PSLauncher.App.Views.HealthCheckEditorDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:loc="clr-namespace:PSLauncher.Core.Localization;assembly=PSLauncher.Core"
        Title="{x:Static loc:Strings.HealthEditorTitle}"
        Icon="pack://application:,,,/Resources/favicon.ico"
        Width="540" Height="640"
        MinWidth="480" MinHeight="540"
        WindowStartupLocation="CenterOwner"
        Background="{StaticResource Brush.Bg.Window}"
        ResizeMode="CanResize">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <!-- Header -->
        <Border Grid.Row="0" Padding="24,20,24,12">
            <TextBlock x:Name="TitleText"
                       Text="{x:Static loc:Strings.HealthEditorTitle}"
                       FontSize="20" FontWeight="SemiBold"
                       Foreground="{StaticResource Brush.Text.Primary}" />
        </Border>

        <ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" Padding="24,0,24,12">
            <StackPanel>

                <!-- Nom -->
                <TextBlock Text="{x:Static loc:Strings.HealthEditorName}"
                           FontSize="11" FontWeight="Bold"
                           Foreground="{StaticResource Brush.Text.Secondary}"
                           Margin="0,0,0,4" />
                <TextBox x:Name="NameBox"
                         Background="#1A1A20"
                         Foreground="{StaticResource Brush.Text.Primary}"
                         BorderBrush="{StaticResource Brush.Border}"
                         BorderThickness="1" Padding="8" />
                <TextBlock Text="{x:Static loc:Strings.HealthEditorNameHint}"
                           FontSize="11" FontStyle="Italic"
                           Foreground="{StaticResource Brush.Text.Secondary}"
                           Margin="0,4,0,12" />

                <!-- Type de check -->
                <TextBlock Text="{x:Static loc:Strings.HealthEditorKind}"
                           FontSize="11" FontWeight="Bold"
                           Foreground="{StaticResource Brush.Text.Secondary}"
                           Margin="0,0,0,4" />
                <StackPanel Orientation="Horizontal" Margin="0,0,0,12">
                    <RadioButton x:Name="KindProcess"
                                 GroupName="Kind"
                                 Content="{x:Static loc:Strings.HealthEditorKindProcess}"
                                 Foreground="{StaticResource Brush.Text.Primary}"
                                 Margin="0,0,20,0"
                                 Checked="OnKindChanged" />
                    <RadioButton x:Name="KindPing"
                                 GroupName="Kind"
                                 Content="{x:Static loc:Strings.HealthEditorKindPing}"
                                 Foreground="{StaticResource Brush.Text.Primary}"
                                 Margin="0,0,20,0"
                                 Checked="OnKindChanged" />
                    <RadioButton x:Name="KindVrDevice"
                                 GroupName="Kind"
                                 Content="{x:Static loc:Strings.HealthEditorKindVrDevice}"
                                 Foreground="{StaticResource Brush.Text.Primary}"
                                 Checked="OnKindChanged" />
                </StackPanel>

                <!-- Cible (process name, IP/host, ou alias VR) -->
                <TextBlock x:Name="TargetLabel"
                           Text="{x:Static loc:Strings.HealthEditorTargetProcess}"
                           FontSize="11" FontWeight="Bold"
                           Foreground="{StaticResource Brush.Text.Secondary}"
                           Margin="0,0,0,4" />
                <TextBox x:Name="TargetBox"
                         Background="#1A1A20"
                         Foreground="{StaticResource Brush.Text.Primary}"
                         BorderBrush="{StaticResource Brush.Border}"
                         BorderThickness="1" Padding="8"
                         FontFamily="Consolas" />

                <!-- ComboBox d'alias VR (visible uniquement si Kind=VrDevice) -->
                <ComboBox x:Name="VrDeviceCombo"
                          Background="#1A1A20"
                          Foreground="{StaticResource Brush.Text.Primary}"
                          BorderBrush="{StaticResource Brush.Border}"
                          BorderThickness="1" Padding="8"
                          DisplayMemberPath="Label"
                          SelectedValuePath="Alias"
                          Visibility="Collapsed" />

                <TextBlock x:Name="TargetHint"
                           Text="{x:Static loc:Strings.HealthEditorTargetProcessHint}"
                           FontSize="11" FontStyle="Italic"
                           Foreground="{StaticResource Brush.Text.Secondary}"
                           Margin="0,4,0,12" TextWrapping="Wrap" />

                <!-- Refresh interval -->
                <TextBlock Text="{x:Static loc:Strings.HealthEditorRefresh}"
                           FontSize="11" FontWeight="Bold"
                           Foreground="{StaticResource Brush.Text.Secondary}"
                           Margin="0,0,0,4" />
                <Grid Margin="0,0,0,4">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="120" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <TextBox x:Name="RefreshMsBox"
                             Grid.Column="0"
                             Background="#1A1A20"
                             Foreground="{StaticResource Brush.Text.Primary}"
                             BorderBrush="{StaticResource Brush.Border}"
                             BorderThickness="1" Padding="8" />
                    <TextBlock Grid.Column="1" VerticalAlignment="Center"
                               Margin="8,0,0,0"
                               Text="ms"
                               Foreground="{StaticResource Brush.Text.Secondary}" />
                </Grid>
                <TextBlock Text="{x:Static loc:Strings.HealthEditorRefreshHint}"
                           FontSize="11" FontStyle="Italic"
                           Foreground="{StaticResource Brush.Text.Secondary}"
                           Margin="0,0,0,12" TextWrapping="Wrap" />

                <!-- Picto picker (grille d'emojis) -->
                <TextBlock Text="{x:Static loc:Strings.HealthEditorIcon}"
                           FontSize="11" FontWeight="Bold"
                           Foreground="{StaticResource Brush.Text.Secondary}"
                           Margin="0,0,0,4" />
                <Border Background="#1A1A20"
                        BorderBrush="{StaticResource Brush.Border}"
                        BorderThickness="1" CornerRadius="4" Padding="6">
                    <ItemsControl x:Name="IconPicker">
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <WrapPanel Orientation="Horizontal" />
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <Button Click="OnIconClicked"
                                        Tag="{Binding Emoji}"
                                        Content="{Binding Emoji}"
                                        FontSize="22"
                                        Width="40" Height="40"
                                        Margin="2"
                                        BorderThickness="2"
                                        Cursor="Hand">
                                    <Button.Style>
                                        <Style TargetType="Button">
                                            <Setter Property="Background" Value="#0F1117" />
                                            <Setter Property="BorderBrush" Value="#2A2F3A" />
                                            <Setter Property="Foreground" Value="{StaticResource Brush.Text.Primary}" />
                                            <Setter Property="Template">
                                                <Setter.Value>
                                                    <ControlTemplate TargetType="Button">
                                                        <Border CornerRadius="4"
                                                                Background="{TemplateBinding Background}"
                                                                BorderBrush="{TemplateBinding BorderBrush}"
                                                                BorderThickness="{TemplateBinding BorderThickness}">
                                                            <ContentPresenter HorizontalAlignment="Center"
                                                                              VerticalAlignment="Center" />
                                                        </Border>
                                                    </ControlTemplate>
                                                </Setter.Value>
                                            </Setter>
                                            <Style.Triggers>
                                                <Trigger Property="IsMouseOver" Value="True">
                                                    <Setter Property="Background" Value="#1F2530" />
                                                    <Setter Property="BorderBrush" Value="#3B82F6" />
                                                </Trigger>
                                                <DataTrigger Binding="{Binding IsSelected}" Value="True">
                                                    <Setter Property="Background" Value="#1B2A40" />
                                                    <Setter Property="BorderBrush" Value="#3B82F6" />
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </Button.Style>
                                </Button>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </Border>
                <TextBlock Text="{x:Static loc:Strings.HealthEditorIconHint}"
                           FontSize="11" FontStyle="Italic"
                           Foreground="{StaticResource Brush.Text.Secondary}"
                           Margin="0,4,0,12" TextWrapping="Wrap" />

                <!-- Section Avancé : seuils Ping. Visible uniquement si Kind=Ping. -->
                <Expander x:Name="PingAdvanced"
                          Header="{x:Static loc:Strings.HealthEditorPingAdvanced}"
                          Foreground="{StaticResource Brush.Text.Secondary}"
                          FontSize="11" FontWeight="Bold"
                          Background="Transparent" BorderThickness="0"
                          Margin="0,4,0,0" IsExpanded="False"
                          Visibility="Collapsed">
                    <Border Background="{StaticResource Brush.Bg.Card}"
                            BorderBrush="{StaticResource Brush.Border}" BorderThickness="1"
                            CornerRadius="6" Padding="16" Margin="0,8,0,0">
                        <StackPanel>
                            <TextBlock Text="{x:Static loc:Strings.HealthEditorPingWarn}"
                                       Foreground="{StaticResource Brush.Text.Secondary}"
                                       FontSize="12" Margin="0,0,0,4" />
                            <TextBox x:Name="PingWarnBox"
                                     Background="#1A1A20"
                                     Foreground="{StaticResource Brush.Text.Primary}"
                                     BorderBrush="{StaticResource Brush.Border}"
                                     BorderThickness="1" Padding="8"
                                     Width="120" HorizontalAlignment="Left" />

                            <TextBlock Text="{x:Static loc:Strings.HealthEditorPingError}"
                                       Foreground="{StaticResource Brush.Text.Secondary}"
                                       FontSize="12" Margin="0,12,0,4" />
                            <TextBox x:Name="PingErrorBox"
                                     Background="#1A1A20"
                                     Foreground="{StaticResource Brush.Text.Primary}"
                                     BorderBrush="{StaticResource Brush.Border}"
                                     BorderThickness="1" Padding="8"
                                     Width="120" HorizontalAlignment="Left" />

                            <TextBlock Text="{x:Static loc:Strings.HealthEditorPingTimeout}"
                                       Foreground="{StaticResource Brush.Text.Secondary}"
                                       FontSize="12" Margin="0,12,0,4" />
                            <TextBox x:Name="PingTimeoutBox"
                                     Background="#1A1A20"
                                     Foreground="{StaticResource Brush.Text.Primary}"
                                     BorderBrush="{StaticResource Brush.Border}"
                                     BorderThickness="1" Padding="8"
                                     Width="120" HorizontalAlignment="Left" />
                        </StackPanel>
                    </Border>
                </Expander>

                <TextBlock x:Name="ErrorText"
                           Foreground="#F87171"
                           FontSize="12"
                           Margin="0,12,0,0"
                           Visibility="Collapsed"
                           TextWrapping="Wrap" />

            </StackPanel>
        </ScrollViewer>

        <!-- Footer -->
        <Border Grid.Row="2" Background="{StaticResource Brush.Bg.Footer}"
                BorderBrush="{StaticResource Brush.Border}" BorderThickness="0,1,0,0"
                Padding="20,12">
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                <Button Style="{StaticResource SecondaryButton}"
                        Content="{x:Static loc:Strings.ActionCancel}"
                        IsCancel="True"
                        Margin="0,0,12,0"
                        Click="OnCancel" />
                <Button Style="{StaticResource AccentButton}"
                        Content="{x:Static loc:Strings.ActionSave}"
                        Padding="32,8"
                        IsDefault="True"
                        Click="OnSave" />
            </StackPanel>
        </Border>
    </Grid>
</Window>
