<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style>
    body { font-family: sans-serif; font-size: 12px; color:#333; }
    h1 { font-size:18px; } table { width:100%; border-collapse:collapse; margin-top:8px; }
    th,td { border:1px solid #ddd; padding:5px; text-align:left; }
    .ok{color:#00a65a} .attention{color:#f39c12} .critical{color:#dd4b39;font-weight:bold} .na{color:#999}
</style>
</head>
<body>
    <h1>{{ __('vrc::lang.inspection') }} — {{ __('vrc::lang.dvi_'.$inspection->type) }}</h1>
    <p><strong>{{ __('vrc::lang.repair_order') }}:</strong> {{ optional($inspection->repairOrder)->number }} &nbsp;
       <strong>{{ __('vrc::lang.vehicle') }}:</strong> {{ optional(optional($inspection->repairOrder)->vehicle)->label }}</p>

    <table>
        <thead><tr><th>{{ __('vrc::lang.label') }}</th><th>{{ __('vrc::lang.status') }}</th><th>{{ __('vrc::lang.note') }}</th></tr></thead>
        <tbody>
        @forelse($inspection->results as $r)
            <tr><td>{{ $r->label }}</td><td class="{{ $r->result }}">{{ $r->result ? __('vrc::lang.dvi_'.$r->result) : '—' }}</td><td>{{ $r->note }}</td></tr>
        @empty
            <tr><td colspan="3">—</td></tr>
        @endforelse
        </tbody>
    </table>

    @php $marks = is_array($inspection->body_diagram) ? $inspection->body_diagram : []; @endphp
    @if(count($marks))
        <h3 style="font-size:13px; margin-top:14px;">Body damage</h3>
        <table style="width:55%;">
            <thead><tr><th>#</th><th>Type</th><th>Position</th><th>Note</th></tr></thead>
            <tbody>
            @foreach($marks as $i => $mk)
                <tr><td>{{ $i + 1 }}</td><td>{{ ucfirst($mk['type'] ?? 'mark') }}</td>
                    <td>{{ round($mk['x'] ?? 0) }}%, {{ round($mk['y'] ?? 0) }}%</td>
                    <td>{{ $mk['note'] ?? '' }}</td></tr>
            @endforeach
            </tbody>
        </table>
    @endif

    @if($inspection->type === 'final' && ($inspection->test_drive_done || $inspection->test_drive_result))
        <p style="margin-top:12px;"><strong>{{ __('vrc::lang.test_drive') }}:</strong>
            @if($inspection->test_drive_result)
                <span class="{{ $inspection->test_drive_result === 'pass' ? 'ok' : 'critical' }}">{{ __('vrc::lang.test_drive_'.$inspection->test_drive_result) }}</span>
            @else
                {{ __('vrc::lang.test_drive_done') }}
            @endif
            @if($inspection->test_drive_odometer) &nbsp;·&nbsp; {{ __('vrc::lang.odometer') }}: {{ number_format($inspection->test_drive_odometer) }}@endif
            @if($inspection->test_drive_notes) <br><span style="color:#666;">{{ $inspection->test_drive_notes }}</span>@endif
        </p>
    @endif

    @if($inspection->summary)<p><strong>{{ __('vrc::lang.summary') }}:</strong> {{ $inspection->summary }}</p>@endif

    @if($inspection->customer_signature_path)
        <p>{{ __('vrc::lang.customer_signature') }}:</p>
        <img src="{{ public_path('uploads/media/'.$inspection->customer_signature_path) }}" style="max-height:80px;" alt="signature">
    @endif
</body>
</html>
