@php
    $programme = $room->setting('programme_snapshot');
    $linkedItems = (array) $room->setting('linked_programme_items', []);
@endphp

@if(is_array($programme) && ! empty($programme['days']))
    <div class="mt-6 rounded-2xl border border-slate-200 bg-white p-6">
        <h2 class="text-sm font-medium text-slate-700">Agenda</h2>
        @if(! empty($programme['title']))
            <p class="mt-1 text-xs text-slate-500">{{ $programme['title'] }}</p>
        @endif

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

        <div class="mt-4 space-y-4">
            @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-100 text-sm">
                        @foreach((array) ($day['items'] ?? []) as $item)
                            <li class="py-2">
                                <div class="flex gap-3">
                                    @if(! empty($item['time']))
                                        <span class="w-14 shrink-0 font-mono text-xs text-slate-400">{{ $item['time'] }}</span>
                                    @endif
                                    <div>
                                        <p class="font-medium text-slate-800">{{ $item['title'] ?? '' }}</p>
                                        @if(! empty($item['description']))
                                            <p class="mt-0.5 text-xs text-slate-500">{{ $item['description'] }}</p>
                                        @endif
                                        @if(! empty($item['location']) || ! empty($item['host']))
                                            <p class="mt-0.5 text-xs text-slate-400">
                                                @if(! empty($item['location'])){{ $item['location'] }}@endif
                                                @if(! empty($item['host'])) · {{ $item['host'] }}@endif
                                            </p>
                                        @endif
                                    </div>
                                </div>
                            </li>
                        @endforeach
                    </ul>
                </div>
            @endforeach
        </div>
    </div>
@endif
