@extends('print.layout')

@section('content')
    @include('print.partials.document-styles')

    <div class="header-grid">
        @foreach ($headerFields as $field)
            <div @class(['field', 'full-width' => strlen($field['value']) > 48])>
                <span class="label">{{ $field['label'] }}：</span>
                <span class="value">{{ $field['value'] }}</span>
            </div>
        @endforeach
    </div>

    <table class="line-table">
        <thead>
            <tr>
                <th style="width: 32px;">#</th>
                <th style="width: 76px;">{{ __('dberp.fields.product_code') }}</th>
                <th>{{ __('dberp.fields.product_name') }}</th>
                <th style="width: 80px;">{{ __('dberp.fields.spec_model') }}</th>
                <th style="width: 40px;">{{ __('dberp.fields.unit') }}</th>
                <th style="width: 56px;">{{ __('dberp.print.labels.book_quantity') }}</th>
                <th style="width: 56px;">{{ __('dberp.print.labels.actual_quantity') }}</th>
                <th style="width: 56px;">{{ __('dberp.print.labels.difference_quantity') }}</th>
                <th style="width: 52px;">{{ __('dberp.fields.result_type') }}</th>
                <th style="width: 72px;">{{ __('dberp.fields.batch_no') }}</th>
                <th style="width: 56px;">{{ __('dberp.fields.remark') }}</th>
            </tr>
        </thead>
        <tbody>
            @forelse ($lines as $line)
                <tr>
                    <td class="center">{{ $line['row_number'] }}</td>
                    <td>{{ $line['product_code'] }}</td>
                    <td>{{ $line['product_name'] }}</td>
                    <td>{{ $line['sku_spec'] }}</td>
                    <td class="center">{{ $line['unit_name'] }}</td>
                    <td class="num">{{ $line['book_quantity'] }}</td>
                    <td class="num">{{ $line['actual_quantity'] }}</td>
                    <td class="num">{{ $line['difference_quantity'] }}</td>
                    <td class="center">{{ $line['result_type'] }}</td>
                    <td class="meta">{{ $line['batch_serial'] !== '' ? $line['batch_serial'] : '—' }}</td>
                    <td>{{ $line['remark'] }}</td>
                </tr>
            @empty
                <tr>
                    <td colspan="11" class="center" style="color: #6b7280;">—</td>
                </tr>
            @endforelse
        </tbody>
    </table>

    <div class="signatures">
        @foreach ($signatures as $signature)
            <div class="slot">{{ $signature }}</div>
        @endforeach
    </div>
@endsection
