@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: 36px;">#</th>
                <th style="width: 88px;">{{ __('dberp.fields.product_code') }}</th>
                <th>{{ __('dberp.fields.product_name') }}</th>
                <th style="width: 100px;">{{ __('dberp.fields.spec_model') }}</th>
                <th style="width: 48px;">{{ __('dberp.fields.unit') }}</th>
                <th style="width: 72px;">{{ __('dberp.fields.outbound_quantity') }}</th>
                <th style="width: 120px;">{{ __('dberp.fields.batch_no') }}</th>
                <th style="width: 72px;">{{ __('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['quantity'] }}</td>
                    <td class="meta">{{ $line['batch_serial'] !== '' ? $line['batch_serial'] : '—' }}</td>
                    <td>{{ $line['remark'] }}</td>
                </tr>
            @empty
                <tr>
                    <td colspan="8" class="center" style="color: #6b7280;">—</td>
                </tr>
            @endforelse
        </tbody>
    </table>

    @if (! empty($totals))
        <div class="totals">
            @foreach ($totals as $total)
                <span>{{ $total['label'] }}：{{ $total['value'] }}</span>
            @endforeach
        </div>
    @endif

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