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

@if(is_array($programme) && ! empty($programme['days']))
    <div class="programme-agenda mt-6 rounded-2xl border border-slate-200 bg-white p-6 font-sans">
        <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-3 text-[11px] font-semibold uppercase tracking-wide text-violet-600">Linked to this session</p>
            <ul class="mt-2 space-y-2 text-sm">
                @foreach($linkedItems as $item)
                    <li class="rounded-xl border border-violet-100 bg-violet-50/50 px-3 py-2.5">
                        @if(! empty($item['time']))
                            <p class="text-[11px] font-medium text-indigo-600">{{ $item['time'] }}</p>
                        @endif
                        <p @class(['font-medium text-slate-800', ! empty($item['time']) ? 'mt-0.5' : ''])>{{ $item['title'] ?? 'Item' }}</p>
                        @if(! empty($item['host']))
                            <p class="mt-0.5 text-xs text-slate-500">{{ $item['host'] }}</p>
                        @endif
                    </li>
                @endforeach
            </ul>
        @endif

        <div class="mt-4 space-y-4">
            @foreach((array) ($programme['days'] ?? []) as $day)
                <section>
                    @if(! empty($day['label']) || ! empty($day['date']))
                        <h3 class="text-[11px] font-semibold uppercase tracking-wide text-slate-500">
                            {{ trim(($day['label'] ?? '').' '.($day['date'] ?? '')) }}
                        </h3>
                    @endif
                    <ul @class(['space-y-2 text-sm', ! empty($day['label']) || ! empty($day['date']) ? 'mt-2' : ''])>
                        @foreach((array) ($day['items'] ?? []) as $item)
                            <li class="rounded-xl border border-slate-100 bg-slate-50/80 px-3 py-2.5">
                                @if(! empty($item['time']))
                                    <p class="text-[11px] font-medium text-slate-500">{{ $item['time'] }}</p>
                                @endif
                                <p @class(['font-medium leading-snug text-slate-800', ! empty($item['time']) ? 'mt-0.5' : ''])>{{ $item['title'] ?? '' }}</p>
                                @if(! empty($item['description']))
                                    <p class="mt-1 text-xs leading-relaxed text-slate-500">{{ $item['description'] }}</p>
                                @endif
                                @if(! empty($item['location']) || ! empty($item['host']))
                                    <p class="mt-1 text-xs text-slate-400">
                                        @if(! empty($item['location'])){{ $item['location'] }}@endif
                                        @if(! empty($item['location']) && ! empty($item['host'])) · @endif
                                        @if(! empty($item['host'])){{ $item['host'] }}@endif
                                    </p>
                                @endif
                            </li>
                        @endforeach
                    </ul>
                </section>
            @endforeach
        </div>
    </div>
@endif
