@php
    $programme = $programmeSnapshot ?? null;
    $linkedItems = $linkedProgrammeItems ?? [];
    $sessionNoun = $sessionNoun ?? 'session';
@endphp

@if(is_array($programme) && ! empty($programme['days']))
    <div class="space-y-4 text-sm">
        @if(! empty($programme['title']))
            <p class="text-xs text-slate-400">{{ $programme['title'] }}</p>
        @endif

        @if($linkedItems !== [])
            <div>
                <p class="text-xs font-semibold uppercase tracking-wide text-violet-400">This session</p>
                <ul class="mt-2 space-y-2">
                    @foreach($linkedItems as $item)
                        <li class="rounded-lg border border-violet-500/30 bg-violet-500/10 px-3 py-2 text-slate-100">
                            @if(! empty($item['time']))
                                <span class="font-mono text-xs text-violet-200/80">{{ $item['time'] }}</span>
                            @endif
                            <span class="font-medium">{{ $item['title'] ?? 'Item' }}</span>
                            @if(! empty($item['host']))
                                <span class="text-slate-400"> · {{ $item['host'] }}</span>
                            @endif
                        </li>
                    @endforeach
                </ul>
            </div>
        @endif

        @foreach((array) ($programme['days'] ?? []) as $day)
            <div>
                @if(! empty($day['label']) || ! empty($day['date']))
                    <h3 class="text-xs font-semibold uppercase tracking-wide text-slate-500">
                        {{ trim(($day['label'] ?? '').' '.($day['date'] ?? '')) }}
                    </h3>
                @endif
                <ul class="mt-2 divide-y divide-slate-800">
                    @foreach((array) ($day['items'] ?? []) as $item)
                        <li class="py-2.5">
                            <div class="flex gap-3">
                                @if(! empty($item['time']))
                                    <span class="w-14 shrink-0 font-mono text-xs text-slate-500">{{ $item['time'] }}</span>
                                @endif
                                <div class="min-w-0">
                                    <p class="font-medium text-slate-100">{{ $item['title'] ?? '' }}</p>
                                    @if(! empty($item['description']))
                                        <p class="mt-0.5 text-xs text-slate-400">{{ $item['description'] }}</p>
                                    @endif
                                    @if(! empty($item['location']) || ! empty($item['host']))
                                        <p class="mt-0.5 text-xs text-slate-500">
                                            @if(! empty($item['location'])){{ $item['location'] }}@endif
                                            @if(! empty($item['host'])) · {{ $item['host'] }}@endif
                                        </p>
                                    @endif
                                </div>
                            </div>
                        </li>
                    @endforeach
                </ul>
            </div>
        @endforeach
    </div>
@else
    <p class="px-2 py-4 text-center text-xs text-slate-500">No programme linked to this {{ $sessionNoun }} yet.</p>
@endif
