{{-- Inline Queue ops when Care Queue Engine is enabled. --}}
@php
  $qi = $queueIntegration ?? null;
  $callNextRoute = $queueCallNextRoute ?? null;
  $callNextParams = $queueCallNextParams ?? [];
  $callNextDescription = $queueCallNextDescription ?? 'Bring the next waiting patient to your desk';
  $currentAppointmentId = $currentAppointmentId ?? null;
  $variant = $variant ?? 'bar'; // bar | button
@endphp
@if (! empty($qi['enabled']) && $callNextRoute)
  <form method="POST" action="{{ route($callNextRoute, $callNextParams) }}" class="w-full" @click.stop>
    @csrf
    @foreach ($callNextParams as $key => $value)
      @if (is_scalar($value))
        <input type="hidden" name="{{ $key }}" value="{{ $value }}">
      @endif
    @endforeach
    @if (! empty($branchId))
      <input type="hidden" name="branch_id" value="{{ $branchId }}">
    @endif
    @if (! empty($currentAppointmentId))
      <input type="hidden" name="appointment_id" value="{{ $currentAppointmentId }}">
    @endif
    @if ($variant === 'bar')
      <button type="submit" class="group flex w-full items-center justify-between gap-3 rounded-xl bg-indigo-600 px-4 py-3 text-left shadow-sm transition hover:bg-indigo-700">
        <span class="min-w-0">
          <span class="block text-sm font-semibold text-white">Call next</span>
          <span class="mt-0.5 block text-xs text-indigo-100">{{ $callNextDescription }}</span>
        </span>
        <span class="flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-white/15 text-white transition group-hover:bg-white/25">
          <svg class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true">
            <path stroke-linecap="round" stroke-linejoin="round" d="M13.5 4.5 21 12m0 0-7.5 7.5M21 12H3" />
          </svg>
        </span>
      </button>
    @elseif ($variant === 'muted')
      <button type="submit" class="group flex w-full items-center justify-between gap-3 rounded-xl border border-slate-200 bg-white px-4 py-3 text-left transition hover:border-slate-300 hover:bg-slate-50">
        <span class="min-w-0">
          <span class="block text-sm font-medium text-slate-700">Call next</span>
          <span class="mt-0.5 block text-xs text-slate-500">{{ $callNextDescription }}</span>
        </span>
        <span class="flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-slate-100 text-slate-500 transition group-hover:bg-slate-200">
          <svg class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true">
            <path stroke-linecap="round" stroke-linejoin="round" d="M13.5 4.5 21 12m0 0-7.5 7.5M21 12H3" />
          </svg>
        </span>
      </button>
    @else
      <button type="submit" class="btn-primary flex w-full items-center justify-center text-sm">Call next</button>
    @endif
  </form>
@endif
