<UserControl x:Class="FasdDesktopUi.Basics.UserControls.TicketOverview"
             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:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
             xmlns:models="clr-namespace:FasdDesktopUi.Basics.Models"
             xmlns:local="clr-namespace:FasdDesktopUi.Basics.UserControls"
             d:DataContext="{d:DesignInstance Type=models:TicketOverviewModel}"
             mc:Ignorable="d"
             d:DesignHeight="450"
             d:DesignWidth="800"
             x:Name="_ticketOverview">

    <UserControl.Resources>
        <vc:LanguageDefinitionsConverter x:Key="LanguageConverter" />

        <!-- Style für Labels mit Auswahlzustand -->
        <Style x:Key="RoundedSelectedLabelStyle"
               TargetType="Label">
            <Setter Property="Padding"
                    Value="5 2 5 4" />
            <Setter Property="HorizontalContentAlignment"
                    Value="Center" />
            <Setter Property="VerticalContentAlignment"
                    Value="Center" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Label">
                        <Grid>
                            <Border x:Name="BorderElement"
                                    CornerRadius="1.5"
                                    Background="Transparent"
                                    BorderBrush="Transparent"
                                    BorderThickness="0"
                                    Padding="{TemplateBinding Padding}">
                                <ContentPresenter x:Name="contentPresenter"
                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                                  TextElement.Foreground="{TemplateBinding Foreground}" />
                            </Border>
                            <Border x:Name="HighlightDot"
                                    Width="8"
                                    Height="8"
                                    Background="{DynamicResource Color.Red}"
                                    BorderBrush="{DynamicResource BackgroundColor.DetailsPage.DataHistory.TitleColumn}"
                                    BorderThickness="1"
                                    CornerRadius="4"
                                    HorizontalAlignment="Right"
                                    VerticalAlignment="Top"
                                    Margin="0,-3,-3,0"
                                    Visibility="Collapsed" />
                        </Grid>
                        <ControlTemplate.Triggers>
                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self},Path=(local:TicketOverview.IsSelected)}"
                                         Value="True">
                                <Setter TargetName="BorderElement"
                                        Property="Background"
                                        Value="{DynamicResource Color.Menu.Icon.Hover}" />
                                <Setter TargetName="contentPresenter"
                                        Property="TextElement.Foreground"
                                        Value="{DynamicResource BackgroundColor.Menu.MainCategory}" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self},Path=(local:TicketOverview.IsHighlighted)}"
                                         Value="True">
                                <Setter TargetName="HighlightDot"
                                        Property="Visibility"
                                        Value="Visible" />
                            </DataTrigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    
    <Border Background="{DynamicResource BackgroundColor.DetailsPage.DataHistory.TitleColumn}"
            CornerRadius="8.5"
            Margin="0 19 0 1"
            Padding="1">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>


            <!-- TicketOverview Headers -->
            <Label Grid.Row="0"
                   Grid.Column="1"
                   HorizontalContentAlignment="Center"
                   Foreground="{DynamicResource FontColor.DetailsPage.TitleSection.Header}"
                   Content="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=TicketOverview.Column.Heading.New}"
                   FontWeight="Bold"
                   FontSize="12" />
            <Label Grid.Row="0"
                   Grid.Column="2"
                   HorizontalContentAlignment="Center"
                   Foreground="{DynamicResource FontColor.DetailsPage.TitleSection.Header}"
                   Content="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=TicketOverview.Column.Heading.Active}"
                   FontWeight="Bold"
                   FontSize="12" />
            <Label Grid.Row="0"
                   Grid.Column="3"
                   HorizontalContentAlignment="Center"
                   Foreground="{DynamicResource FontColor.DetailsPage.TitleSection.Header}"
                   Content="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=TicketOverview.Column.Heading.Critical}"
                   FontWeight="Bold"
                   FontSize="12" />
            <Label Grid.Row="0"
                   Grid.Column="4"
                   HorizontalContentAlignment="Center"
                   Foreground="{DynamicResource FontColor.DetailsPage.TitleSection.Header}"
                   Content="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=TicketOverview.Column.Heading.NewInfo}"
                   FontWeight="Bold"
                   FontSize="12" />

            <!-- Tickets -->
            <Label Grid.Row="2"
                   Grid.Column="0"
                   Foreground="{DynamicResource FontColor.DetailsPage.TitleSection.Header}"
                   Content="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=TicketOverview.Row.Heading.Tickets}"
                   FontWeight="Bold"
                   FontSize="12" />

            <Label Grid.Row="2"
                   Grid.Column="1"
                   Content="{Binding TicketsNew}"
                   Style="{StaticResource RoundedSelectedLabelStyle}"
                   local:TicketOverview.IsSelected="{Binding TicketsNewSelected, Mode=TwoWay}"
                   local:TicketOverview.IsHighlighted="{Binding TicketsNewHighlighted}"
                   ToolTip="{Binding TicketsNewChangeHint}"
                   Tag="TicketsNewSelected"
                   MouseLeftButtonUp="Label_MouseLeftButtonUp"
                   FontWeight="Medium"
                   Foreground="{DynamicResource Color.Green}"
                   FontSize="12"
                   VerticalAlignment="Center"
                   HorizontalAlignment="Center"
                   Cursor="Hand" />

            <Label Grid.Row="2"
                   Grid.Column="2"
                   Content="{Binding TicketsActive}"
                   Style="{StaticResource RoundedSelectedLabelStyle}"
                   local:TicketOverview.IsSelected="{Binding TicketsActiveSelected, Mode=TwoWay}"
                   local:TicketOverview.IsHighlighted="{Binding TicketsActiveHighlighted}"
                   ToolTip="{Binding TicketsActiveChangeHint}"
                   Tag="TicketsActiveSelected"
                   MouseLeftButtonUp="Label_MouseLeftButtonUp"
                   FontWeight="Medium"
                   Foreground="{DynamicResource Color.Green}"
                   FontSize="12"
                   VerticalAlignment="Center"
                   HorizontalAlignment="Center"
                   Cursor="Hand" />

            <Label Grid.Row="2"
                   Grid.Column="3"
                   Content="{Binding TicketsCritical}"
                   Style="{StaticResource RoundedSelectedLabelStyle}"
                   local:TicketOverview.IsSelected="{Binding TicketsCriticalSelected, Mode=TwoWay}"
                   local:TicketOverview.IsHighlighted="{Binding TicketsCriticalHighlighted}"
                   ToolTip="{Binding TicketsCriticalChangeHint}"
                   Tag="TicketsCriticalSelected"
                   MouseLeftButtonUp="Label_MouseLeftButtonUp"
                   FontWeight="Medium"
                   Foreground="{DynamicResource Color.Red}"
                   FontSize="12"
                   VerticalAlignment="Center"
                   HorizontalAlignment="Center"
                   Cursor="Hand" />

            <Label Grid.Row="2"
                   Grid.Column="4"
                   Content="{Binding TicketsNewInfo}"
                   Style="{StaticResource RoundedSelectedLabelStyle}"
                   local:TicketOverview.IsSelected="{Binding TicketsNewInfoSelected, Mode=TwoWay}"
                   local:TicketOverview.IsHighlighted="{Binding TicketsNewInfoHighlighted}"
                   ToolTip="{Binding TicketsNewInfoChangeHint}"
                   Tag="TicketsNewInfoSelected"
                   MouseLeftButtonUp="Label_MouseLeftButtonUp"
                   FontWeight="Medium"
                   Foreground="{DynamicResource Color.Orange}"
                   FontSize="12"
                   VerticalAlignment="Center"
                   HorizontalAlignment="Center"
                   Cursor="Hand" />

            <!-- Incidents -->
            <Label Grid.Row="3"
                   Grid.Column="0"
                   Foreground="{DynamicResource FontColor.DetailsPage.TitleSection.Header}"
                   Content="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=TicketOverview.Row.Heading.Incidents}"
                   FontWeight="Bold"
                   FontSize="12" />

            <Label Grid.Row="3"
                   Grid.Column="1"
                   Content="{Binding IncidentNew}"
                   Style="{StaticResource RoundedSelectedLabelStyle}"
                   local:TicketOverview.IsSelected="{Binding IncidentNewSelected, Mode=TwoWay}"
                   local:TicketOverview.IsHighlighted="{Binding IncidentNewHighlighted}"
                   ToolTip="{Binding IncidentNewChangeHint}"
                   Tag="IncidentNewSelected"
                   MouseLeftButtonUp="Label_MouseLeftButtonUp"
                   FontWeight="Medium"
                   Foreground="{DynamicResource Color.Green}"
                   FontSize="12"
                   VerticalAlignment="Center"
                   HorizontalAlignment="Center"
                   Cursor="Hand" />

            <Label Grid.Row="3"
                   Grid.Column="2"
                   Content="{Binding IncidentActive}"
                   Style="{StaticResource RoundedSelectedLabelStyle}"
                   local:TicketOverview.IsSelected="{Binding IncidentActiveSelected, Mode=TwoWay}"
                   local:TicketOverview.IsHighlighted="{Binding IncidentActiveHighlighted}"
                   ToolTip="{Binding IncidentActiveChangeHint}"
                   Tag="IncidentActiveSelected"
                   MouseLeftButtonUp="Label_MouseLeftButtonUp"
                   FontWeight="Medium"
                   Foreground="{DynamicResource Color.Green}"
                   FontSize="12"
                   VerticalAlignment="Center"
                   HorizontalAlignment="Center"
                   Cursor="Hand" />

            <Label Grid.Row="3"
                   Grid.Column="3"
                   Content="{Binding IncidentCritical}"
                   Style="{StaticResource RoundedSelectedLabelStyle}"
                   local:TicketOverview.IsSelected="{Binding IncidentCriticalSelected, Mode=TwoWay}"
                   local:TicketOverview.IsHighlighted="{Binding IncidentCriticalHighlighted}"
                   ToolTip="{Binding IncidentCriticalChangeHint}"
                   Tag="IncidentCriticalSelected"
                   MouseLeftButtonUp="Label_MouseLeftButtonUp"
                   FontWeight="Medium"
                   Foreground="{DynamicResource Color.Red}"
                   FontSize="12"
                   VerticalAlignment="Center"
                   HorizontalAlignment="Center"
                   Cursor="Hand" />

            <Label Grid.Row="3"
                   Grid.Column="4"
                   Content="{Binding IncidentNewInfo}"
                   Style="{StaticResource RoundedSelectedLabelStyle}"
                   local:TicketOverview.IsSelected="{Binding IncidentNewInfoSelected, Mode=TwoWay}"
                   local:TicketOverview.IsHighlighted="{Binding IncidentNewInfoHighlighted}"
                   ToolTip="{Binding IncidentNewInfoChangeHint}"
                   Tag="IncidentNewInfoSelected"
                   MouseLeftButtonUp="Label_MouseLeftButtonUp"
                   FontWeight="Medium"
                   Foreground="{DynamicResource Color.Orange}"
                   FontSize="12"
                   VerticalAlignment="Center"
                   HorizontalAlignment="Center"
                   Cursor="Hand" />

            <!-- Unassigned -->
            <Label Grid.Row="4"
                   Grid.Column="0"
                   Foreground="{DynamicResource FontColor.DetailsPage.TitleSection.Header}"
                   Content="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=TicketOverview.Row.Heading.UnassignedTickets}"
                   FontWeight="Bold"
                   FontSize="12" />

            <Label Grid.Row="4"
                   Grid.Column="1"
                   Content="{Binding UnassignedTickets}"
                   Style="{StaticResource RoundedSelectedLabelStyle}"
                   local:TicketOverview.IsSelected="{Binding UnassignedTicketsSelected, Mode=TwoWay}"
                   local:TicketOverview.IsHighlighted="{Binding UnassignedTicketsHighlighted}"
                   ToolTip="{Binding UnassignedTicketsChangeHint}"
                   Tag="UnassignedTicketsSelected"
                   MouseLeftButtonUp="Label_MouseLeftButtonUp"
                   FontWeight="Medium"
                   Foreground="{DynamicResource Color.Orange}"
                   FontSize="12"
                   VerticalAlignment="Center"
                   HorizontalAlignment="Center"
                   Cursor="Hand" />

            <Label Grid.Row="4"
                   Grid.Column="3"
                   Content="{Binding UnassignedTicketsCritical}"
                   Style="{StaticResource RoundedSelectedLabelStyle}"
                   local:TicketOverview.IsSelected="{Binding UnassignedTicketsCriticalSelected, Mode=TwoWay}"
                   local:TicketOverview.IsHighlighted="{Binding UnassignedTicketsCriticalHighlighted}"
                   ToolTip="{Binding UnassignedTicketsCriticalChangeHint}"
                   Tag="UnassignedTicketsCriticalSelected"
                   MouseLeftButtonUp="Label_MouseLeftButtonUp"
                   FontWeight="Medium"
                   Foreground="{DynamicResource Color.Red}"
                   FontSize="12"
                   VerticalAlignment="Center"
                   HorizontalAlignment="Center"
                   Cursor="Hand" />
        </Grid>
    </Border>
</UserControl>
