@props([
    'consultation' => null,
])

@php
    use App\Services\Care\ConsultationReturnContext;

    /** @var \App\Models\Consultation|null $consultation */
    $consultation = $consultation
        ?? app(ConsultationReturnContext::class)->resolve(request());

    $appointment = $consultation?->appointment;
    $queueOn = filled($appointment?->queue_ticket_number);
@endphp

@if ($consultation)
    <div {{ $attributes->merge(['class' => 'mb-6 flex flex-wrap items-center justify-between gap-3 rounded-xl border border-amber-200 bg-amber-50/80 px-4 py-3']) }}>
        <div class="min-w-0">
            <p class="text-xs font-semibold uppercase tracking-wide text-amber-800">Continue consultation</p>
            <p class="mt-0.5 text-sm text-slate-800">
                <span class="font-medium">{{ $consultation->patient->fullName() }}</span>
                @if ($queueOn)
                    <span class="ml-2 inline-flex items-center gap-1.5 align-middle">
                        @include('care.partials.queue-ticket', [
                            'ticketNumber' => $appointment->queue_ticket_number,
                            'ticketStatus' => $appointment->queue_ticket_status,
                            'destination' => $appointment->queue_destination,
                            'staffDisplayName' => $appointment->queue_staff_display_name,
                        ])
                    </span>
                @endif
            </p>
        </div>
        <a
            href="{{ route('care.consultations.show', $consultation) }}"
            class="shrink-0 rounded-lg border border-amber-300 bg-white px-3 py-1.5 text-sm font-medium text-amber-900 hover:bg-amber-100"
        >
            Back to consultation
        </a>
    </div>
@endif
