@extends('layouts.public')

@section('title', 'Events — '.setting('university_name'))
@section('description', 'Graduations, open days, deadlines and academic events at King Ceasor University.')

@section('content')

    <section class="border-b border-slate-200 bg-canvas">
        <div class="container-page py-12">
            <x-breadcrumb :items="[['label' => 'Home', 'url' => route('home')], ['label' => 'Events']]" />
            <h1 class="mt-4 font-display text-4xl tracking-tight text-slate-900 sm:text-5xl">Events</h1>
            <p class="mt-3 max-w-2xl text-lg text-slate-600">
                Graduations, open days, application deadlines and academic events.
            </p>
        </div>
    </section>

    <div class="container-page py-14">
        <h2 class="font-display text-3xl tracking-tight text-slate-900">Upcoming</h2>

        @if ($upcoming->isEmpty())
            <x-empty-state class="mt-6" title="No upcoming events"
                           description="There is nothing scheduled at the moment. Please check back soon." />
        @else
            <ul class="mt-8 space-y-4">
                @foreach ($upcoming as $event)
                    <li>
                        <a href="{{ route('events.show', $event) }}"
                           class="flex flex-col gap-5 rounded-xl border border-slate-200 bg-white p-6 transition hover:border-brand-300 hover:shadow-md sm:flex-row sm:items-center">
                            <div class="flex h-16 w-16 shrink-0 flex-col items-center justify-center rounded-lg bg-brand-700 text-white">
                                <span class="font-display text-2xl leading-none">{{ $event->starts_at->format('j') }}</span>
                                <span class="mt-0.5 text-[10px] uppercase tracking-wider">{{ $event->starts_at->format('M') }}</span>
                            </div>

                            <div class="min-w-0 flex-1">
                                <h3 class="text-base font-semibold text-slate-900">{{ $event->title }}</h3>
                                @if ($event->excerpt)
                                    <p class="mt-1 text-sm text-slate-600">{{ $event->excerpt }}</p>
                                @endif
                                <p class="mt-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-slate-500">
                                    <span>{{ $event->dateLabel() }}</span>
                                    @if ($event->location)
                                        <span class="flex items-center gap-1.5">
                                            <svg class="h-3.5 w-3.5" fill="currentColor" viewBox="0 0 20 20" aria-hidden="true"><path d="M10 2a6 6 0 0 0-6 6c0 4.2 5.2 9.4 5.4 9.6a.8.8 0 0 0 1.2 0C10.8 17.4 16 12.2 16 8a6 6 0 0 0-6-6Zm0 8a2 2 0 1 1 0-4 2 2 0 0 1 0 4Z"/></svg>
                                            {{ $event->location }}
                                        </span>
                                    @endif
                                </p>
                            </div>
                        </a>
                    </li>
                @endforeach
            </ul>

            <div class="mt-10">{{ $upcoming->links() }}</div>
        @endif

        @if ($past->isNotEmpty())
            <section class="mt-16 border-t border-slate-200 pt-12">
                <h2 class="font-display text-3xl tracking-tight text-slate-900">Recent events</h2>

                <ul class="mt-8 grid gap-4 sm:grid-cols-2">
                    @foreach ($past as $event)
                        <li>
                            <a href="{{ route('events.show', $event) }}"
                               class="block rounded-xl border border-slate-200 bg-slate-50/60 p-5 transition hover:border-slate-300">
                                <time datetime="{{ $event->starts_at->toDateString() }}" class="text-xs text-slate-500">
                                    {{ $event->dateLabel() }}
                                </time>
                                <h3 class="mt-1.5 text-sm font-semibold text-slate-800">{{ $event->title }}</h3>
                            </a>
                        </li>
                    @endforeach
                </ul>
            </section>
        @endif
    </div>

@endsection
