{{-- Action buttons for consultation show (desktop sticky + mobile sheet). --}}
@php
    $canEdit = ! $isCompleted && ($canManage || $canVitals);
    $btn = 'flex w-full items-center justify-center rounded-xl px-3 py-2.5 text-sm font-semibold transition';
    $btnPrimary = $btn.' bg-indigo-600 text-white hover:bg-indigo-700';
    $btnSecondary = $btn.' border border-slate-200 bg-white text-slate-800 hover:bg-slate-50';
    $btnAccent = $btn.' border border-sky-200 bg-sky-50 text-sky-900 hover:bg-sky-100';
    $appointment = $consultation->appointment;
    $ticketCalled = $appointment && $appointment->queue_ticket_status === 'called';
@endphp

@include('care.partials.queue-ops', [
    'queueIntegration' => $queueIntegration ?? null,
    'queueCallNextRoute' => 'care.queue.call-next',
    'queueCallNextParams' => [],
    'branchId' => $queueBranchId ?? null,
    'currentAppointmentId' => $appointment?->id,
    'variant' => 'button',
])

@if ($ticketCalled && $appointment)
    <form method="POST" action="{{ route('care.queue.recall', $appointment) }}" class="w-full" @click.stop>
        @csrf
        <button type="submit" class="{{ $btnAccent }}">Call again</button>
    </form>
@endif

@if ($canManage && ! $isCompleted)
    <button
        type="button"
        class="{{ $btnPrimary }}"
        @click.stop="$dispatch('open-modal', {{ \Illuminate\Support\Js::from('complete-consultation-'.$consultation->id) }})"
    >
        Complete consultation
    </button>
@endif

@if ($canEdit)
    <button type="submit" form="consultation-form" class="{{ $btnPrimary }}">Save</button>
    @if ($canManage && ($canViewAssessments ?? false))
        <button type="submit" form="consultation-form" name="suggest_pathways" value="1" class="{{ $btnAccent }}">
            Show condition suggestions
        </button>
    @endif
@endif

@if ($canPrescribe)
    <button
        type="button"
        class="{{ $btnSecondary }}"
        @click.stop="$dispatch('open-modal', {{ \Illuminate\Support\Js::from('prescribe-'.$consultation->id) }})"
    >
        Prescribe
    </button>
@endif

@if ($canRequestInvestigations && $investigationTypes->isNotEmpty() && ! $isCompleted)
    <button
        type="button"
        class="{{ $btnSecondary }}"
        @click.stop="$dispatch('open-modal', {{ \Illuminate\Support\Js::from('request-investigations-'.$consultation->id) }})"
    >
        Request investigations
    </button>
@endif

@if ($canGenerateBill && $isCompleted && $consultation->visit)
    <form method="POST" action="{{ route('care.bills.generate', $consultation->visit) }}" class="w-full" @click.stop>
        @csrf
        <input type="hidden" name="from_consultation" value="{{ $consultation->uuid }}">
        <button type="submit" class="{{ $btn }} w-full bg-slate-800 text-white hover:bg-slate-900">Generate bill</button>
    </form>
@endif

@if (! empty($canAccessPatientQueue))
<a href="{{ route('care.queue.index') }}" class="{{ $btnSecondary }}">Back to queue</a>
@endif
