<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Physiotherapy 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' => 'physiotherapy', '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>Assessment</h2>
    @if ($assessment)
        <dl>
            <dt>Complaint</dt><dd>{{ $assessment->payload['chief_complaint'] ?? '—' }}</dd>
            <dt>Onset</dt><dd>{{ $assessment->payload['onset'] ?? '—' }}</dd>
            <dt>Pain / region</dt><dd>{{ $assessment->payload['pain_score'] ?? '—' }} · {{ $assessment->payload['body_region'] ?? '—' }}</dd>
            <dt>ROM</dt><dd>{{ $assessment->payload['rom'] ?? '—' }}</dd>
            <dt>Strength</dt><dd>{{ $assessment->payload['strength'] ?? '—' }}</dd>
            <dt>Goals</dt><dd>{{ $assessment->payload['goals'] ?? '—' }}</dd>
        </dl>
    @else
        <p class="meta">No assessment recorded.</p>
    @endif

    <h2>Treatment plan</h2>
    @if ($plan)
        <dl>
            <dt>Diagnosis</dt><dd>{{ $plan->payload['diagnosis'] ?? '—' }}</dd>
            <dt>Frequency</dt><dd>{{ $plan->payload['frequency'] ?? '—' }}</dd>
            <dt>Interventions</dt><dd>{{ $plan->payload['interventions'] ?? '—' }}</dd>
            <dt>Precautions</dt><dd>{{ $plan->payload['precautions'] ?? '—' }}</dd>
        </dl>
    @else
        <p class="meta">No treatment plan recorded.</p>
    @endif

    <h2>Therapy session</h2>
    @if ($session)
        <dl>
            <dt>Modalities</dt><dd>{{ $session->payload['modalities'] ?? '—' }}</dd>
            <dt>Exercises</dt><dd>{{ $session->payload['exercises'] ?? '—' }}</dd>
            <dt>Pain before / after</dt><dd>{{ $session->payload['pain_before'] ?? '—' }} / {{ $session->payload['pain_after'] ?? '—' }}</dd>
            <dt>Outcome</dt><dd>{{ $session->payload['outcome'] ?? '—' }}</dd>
            <dt>Next review</dt><dd>{{ $session->payload['next_review'] ?? '—' }}</dd>
        </dl>
    @else
        <p class="meta">No session recorded.</p>
    @endif

    <h2>Home program</h2>
    @if ($homeProgram)
        <dl>
            <dt>Exercises</dt><dd>{{ $homeProgram->payload['exercises'] ?? '—' }}</dd>
            <dt>Frequency</dt><dd>{{ $homeProgram->payload['frequency'] ?? '—' }}</dd>
            <dt>Progress</dt><dd>{{ $homeProgram->payload['progress_notes'] ?? '—' }}</dd>
            <dt>Outcome</dt><dd>{{ $homeProgram->payload['outcome'] ?? '—' }}</dd>
        </dl>
    @else
        <p class="meta">No home program recorded.</p>
    @endif

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