{{--
  Ambulance / EMS dispatch board — stage columns, not Call next desk queue.

  Expected: $ambulanceDispatchBoard (from AmbulanceDispatchBoardService),
  $canAdvanceStage, $specialtyStageRoute, $canManageQueue (for New call CTA context)
--}}
@php
    $board = $ambulanceDispatchBoard ?? ['columns' => [], 'active_count' => 0, 'completed_today' => 0];
    $columns = $board['columns'] ?? [];
    $canAdvanceStage = $canAdvanceStage ?? false;
    $specialtyStageRoute = $specialtyStageRoute ?? 'care.specialty.ambulance.stage';
@endphp

<div class="overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm shadow-slate-100/80">
    <div class="border-b border-slate-100 bg-gradient-to-r from-amber-50/90 via-white to-slate-50 px-4 py-3 sm:px-5">
        <p class="text-sm font-semibold text-slate-900">Dispatch board</p>
        <p class="mt-0.5 text-sm text-slate-500">Track calls from intake through dispatch, scene, transport, and facility handover — not a desk call-next line.</p>
    </div>

    <div class="flex snap-x snap-mandatory gap-0 overflow-x-auto xl:grid xl:grid-cols-6 xl:overflow-visible" style="-ms-overflow-style:none;scrollbar-width:none;">
        @foreach ($columns as $index => $column)
            <section @class([
                'flex w-[min(78vw,18rem)] shrink-0 snap-start flex-col border-slate-100 xl:w-auto',
                'border-r' => $index < count($columns) - 1,
            ])>
                <header class="sticky top-0 z-[1] flex items-center justify-between gap-2 border-b border-slate-100 bg-white/95 px-3 py-3 backdrop-blur-sm">
                    <div class="flex min-w-0 items-center gap-2">
                        <span class="h-2 w-2 shrink-0 rounded-full {{ $column['dot'] }}"></span>
                        <h2 class="truncate text-xs font-semibold uppercase tracking-wide {{ $column['accent'] }}">{{ $column['label'] }}</h2>
                    </div>
                    <span class="rounded-md bg-slate-100 px-2 py-0.5 text-xs font-semibold tabular-nums text-slate-700">{{ $column['count'] }}</span>
                </header>
                <div class="flex-1 space-y-2 p-3 sm:min-h-[12rem]">
                    @forelse ($column['items'] as $visit)
                        @include('care.specialty.ambulance.dispatch-card', [
                            'visit' => $visit,
                            'column' => $column,
                            'canAdvanceStage' => $canAdvanceStage && $column['key'] !== 'completed',
                            'specialtyStageRoute' => $specialtyStageRoute,
                        ])
                    @empty
                        <p class="rounded-xl border border-dashed border-slate-200 px-3 py-8 text-center text-xs text-slate-400">{{ $column['empty'] }}</p>
                    @endforelse
                </div>
            </section>
        @endforeach
    </div>
</div>
