<UserControl x:Class="ConeCalorimeter.Views.ReportPageView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <UserControl.Resources>
        <Style x:Key="ReportPanelStyle" TargetType="Border">
            <Setter Property="Background" Value="#FFFFFF" />
            <Setter Property="BorderBrush" Value="#C9D0CC" />
            <Setter Property="BorderThickness" Value="1" />
            <Setter Property="CornerRadius" Value="6" />
        </Style>

        <DataTemplate x:Key="ReportFieldTemplate">
            <Grid Margin="0,0,14,12">
                <Grid.RowDefinitions>
                    <RowDefinition Height="22" />
                    <RowDefinition Height="34" />
                </Grid.RowDefinitions>
                <TextBlock Text="{Binding Label}"
                           FontSize="14"
                           FontWeight="SemiBold"
                           Foreground="#263431"
                           VerticalAlignment="Center" />
                <TextBox Grid.Row="1"
                         Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                         Height="32"
                         MinWidth="170"
                         Padding="8,3"
                         FontSize="15"
                         BorderBrush="#B7C0BC"
                         BorderThickness="1"
                         VerticalContentAlignment="Center" />
            </Grid>
        </DataTemplate>

        <DataTemplate x:Key="ReportSectionTemplate">
            <Border Margin="0,0,0,14"
                    Padding="16"
                    Style="{StaticResource ReportPanelStyle}">
                <StackPanel>
                    <TextBlock Text="{Binding Title}"
                               Margin="0,0,0,12"
                               FontSize="20"
                               FontWeight="SemiBold"
                               Foreground="#162321" />
                    <ItemsControl ItemsSource="{Binding Fields}"
                                  ItemTemplate="{StaticResource ReportFieldTemplate}">
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <WrapPanel />
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                    </ItemsControl>
                </StackPanel>
            </Border>
        </DataTemplate>

        <DataTemplate x:Key="SummaryItemTemplate">
            <Border Margin="0,0,0,10"
                    Padding="12,10"
                    Background="#F5F7F6"
                    BorderBrush="#D7DEDA"
                    BorderThickness="1"
                    CornerRadius="6">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="112" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="{Binding Label}"
                               FontSize="15"
                               Foreground="#40504B"
                               VerticalAlignment="Center" />
                    <TextBlock Grid.Column="1"
                               Text="{Binding Value}"
                               FontFamily="Consolas"
                               FontSize="16"
                               FontWeight="SemiBold"
                               Foreground="#101817"
                               TextAlignment="Right"
                               VerticalAlignment="Center" />
                </Grid>
            </Border>
        </DataTemplate>
    </UserControl.Resources>

    <Grid Background="#F4F6F5">
        <Grid.RowDefinitions>
            <RowDefinition Height="70" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Border Grid.Row="0"
                Background="#F9FAF9"
                BorderBrush="#CDD4D0"
                BorderThickness="0,0,0,1">
            <Grid Margin="18,0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="150" />
                </Grid.ColumnDefinitions>
                <TextBlock Text="{Binding StatusText}"
                           FontSize="16"
                           Foreground="#40504B"
                           VerticalAlignment="Center" />
                <Button Grid.Column="1"
                        Content="导出报表"
                        Command="{Binding ExportCommand}"
                        Style="{StaticResource InstrumentButtonStyle}"
                        Width="126"
                        Height="44"
                        HorizontalAlignment="Right"
                        VerticalAlignment="Center" />
            </Grid>
        </Border>

        <Grid Grid.Row="1" Margin="14">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="14" />
                <ColumnDefinition Width="330" />
            </Grid.ColumnDefinitions>

            <ScrollViewer Grid.Column="0"
                          VerticalScrollBarVisibility="Auto">
                <ItemsControl ItemsSource="{Binding Sections}"
                              ItemTemplate="{StaticResource ReportSectionTemplate}" />
            </ScrollViewer>

            <Border Grid.Column="2"
                    Padding="16"
                    Style="{StaticResource ReportPanelStyle}"
                    VerticalAlignment="Top">
                <StackPanel>
                    <TextBlock Text="采集数据"
                               Margin="0,0,0,14"
                               FontSize="20"
                               FontWeight="SemiBold"
                               Foreground="#162321" />
                    <ItemsControl ItemsSource="{Binding SummaryItems}"
                                  ItemTemplate="{StaticResource SummaryItemTemplate}" />
                </StackPanel>
            </Border>
        </Grid>
    </Grid>
</UserControl>
