<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Ambulance summary · {{ $patient->fullName() }}</title>
    <style>
        body { font-family: system-ui, sans-serif; color: #0f172a; margin: 2rem; }
        h1 { font-size: 1.25rem; margin: 0 0 .25rem; }
        h2 { font-size: .95rem; margin: 1.25rem 0 .5rem; border-bottom: 1px solid #e2e8f0; padding-bottom: .25rem; }
        .meta { color: #64748b; font-size: .875rem; }
        dl { display: grid; grid-template-columns: 10rem 1fr; gap: .35rem .75rem; font-size: .875rem; }
        dt { color: #64748b; }
        dd { margin: 0; font-weight: 500; }
        @media print { .no-print { display: none; } }
    </style>
</head>
<body>
    <p class="no-print"><a href="{{ route('care.specialty.workspace', ['module' => 'ambulance', 'visit' => $visit]) }}">Back</a></p>

    <h1>{{ $patient->fullName() }}</h1>
    <p class="meta">
        {{ $patient->patient_number }}
        · Visit #{{ $visit->id }}
        · Stage {{ $visit->specialty_stage ?? '—' }}
        · {{ $visit->checked_in_at?->format('d M Y H:i') ?? '—' }}
    </p>

    <h2>Dispatch</h2>
    @if ($dispatch)
        <dl>
            <dt>Call nature</dt><dd>{{ $dispatch->payload['call_nature'] ?? '—' }}</dd>
            <dt>Priority</dt><dd>{{ $dispatch->payload['priority'] ?? '—' }}</dd>
            <dt>Location</dt><dd>{{ $dispatch->payload['location'] ?? '—' }}</dd>
            <dt>Crew</dt><dd>{{ $dispatch->payload['crew'] ?? '—' }}</dd>
            <dt>Vehicle</dt><dd>{{ $dispatch->payload['vehicle'] ?? '—' }}</dd>
            <dt>Notes</dt><dd>{{ $dispatch->payload['dispatch_notes'] ?? '—' }}</dd>
        </dl>
    @else
        <p class="meta">No dispatch recorded.</p>
    @endif

    <h2>Scene / triage</h2>
    @if ($scene)
        <dl>
            <dt>Complaint</dt><dd>{{ $scene->payload['chief_complaint'] ?? '—' }}</dd>
            <dt>Acuity</dt><dd>{{ $scene->payload['acuity'] ?? '—' }}</dd>
            <dt>Findings</dt><dd>{{ $scene->payload['scene_findings'] ?? '—' }}</dd>
            <dt>Vitals</dt><dd>{{ $scene->payload['vitals_summary'] ?? '—' }}</dd>
            <dt>GCS</dt><dd>{{ $scene->payload['gcs'] ?? '—' }}</dd>
        </dl>
    @else
        <p class="meta">No scene assessment recorded.</p>
    @endif

    <h2>En-route care</h2>
    @if ($enRoute)
        <dl>
            <dt>Destination</dt><dd>{{ $enRoute->payload['destination'] ?? '—' }}</dd>
            <dt>Interventions</dt><dd>{{ $enRoute->payload['interventions'] ?? '—' }}</dd>
            <dt>Medications</dt><dd>{{ $enRoute->payload['medications'] ?? '—' }}</dd>
            <dt>Response</dt><dd>{{ $enRoute->payload['response_to_treatment'] ?? '—' }}</dd>
        </dl>
    @else
        <p class="meta">No en-route care recorded.</p>
    @endif

    <h2>Handover</h2>
    @if ($handover)
        <dl>
            <dt>Facility</dt><dd>{{ $handover->payload['receiving_facility'] ?? '—' }}</dd>
            <dt>Clinician</dt><dd>{{ $handover->payload['receiving_clinician'] ?? '—' }}</dd>
            <dt>Summary</dt><dd>{{ $handover->payload['handover_summary'] ?? '—' }}</dd>
            <dt>Outcome</dt><dd>{{ $handover->payload['outcome'] ?? '—' }}</dd>
            <dt>Pathway</dt><dd>{{ $handover->payload['time_critical'] ?? '—' }}</dd>
        </dl>
    @else
        <p class="meta">No handover recorded.</p>
    @endif

    <script>window.print();</script>
</body>
</html>
