<x-meet-kiosk-layout :title="'Join · '.$room->title" :organization="$organization">
    <div class="flex min-h-[calc(100vh-8rem)] flex-col items-center justify-center text-center">
        <div class="w-full max-w-lg">
            <h1 class="text-3xl font-bold tracking-tight text-slate-900 sm:text-4xl">{{ $room->title }}</h1>

            @if ($room->scheduled_at)
                <p class="mt-3 text-base text-slate-500">
                    {{ $room->scheduled_at->timezone($room->timezone)->format('l, j F Y · g:i A T') }}
                </p>
            @endif

            @if ($room->host_user_ref && ($host = \App\Models\User::query()->where('public_id', $room->host_user_ref)->first()))
                <p class="mt-2 text-sm text-slate-500">Hosted by <span class="font-medium text-slate-700">{{ $host->name }}</span></p>
            @endif

            @if ($room->description)
                <p class="mt-4 text-sm leading-relaxed text-slate-600">{{ $room->description }}</p>
            @endif

            @if ($errors->any())
                <div class="mt-6 rounded-2xl border border-red-200 bg-red-50 px-4 py-3 text-left text-sm text-red-700">
                    {{ $errors->first() }}
                </div>
            @endif

            <form method="POST" action="{{ route('meet.join.enter', $room) }}" class="mt-10 text-left">
                @csrf

                @guest
                    <label class="block text-sm font-medium text-slate-700">Your name</label>
                    <input type="text" name="display_name" required placeholder="How should we show your name?"
                           value="{{ old('display_name', $defaultDisplayName ?? '') }}"
                           class="mt-2 w-full rounded-2xl border-slate-200 bg-white px-4 py-3.5 text-slate-900 shadow-sm ring-1 ring-slate-200 placeholder:text-slate-400 focus:border-indigo-500 focus:ring-indigo-500">
                @endguest

                @auth
                    <div class="rounded-2xl border border-slate-200 bg-white px-4 py-3 text-sm text-slate-600 shadow-sm">
                        Joining as <span class="font-semibold text-slate-900">{{ auth()->user()->name }}</span>
                    </div>
                @endauth

                @if ($room->setting('waiting_room', true) && ! ($user && $user->ownerRef() === $room->host_user_ref))
                    <p class="mt-4 text-xs text-slate-500">The host will admit you when the {{ $sessionNoun ?? 'session' }} is ready.</p>
                @endif

                <button type="submit" class="btn-primary btn-primary-lg mt-8 w-full py-4 text-base font-semibold">
                    Join {{ $sessionNoun ?? 'session' }}
                </button>
            </form>

            @guest
                <p class="mt-6 text-center text-sm text-slate-500">
                    Have a Ladill account?
                    <a href="{{ route('sso.connect', ['redirect' => route('meet.join', $room), 'interactive' => 1]) }}" class="font-medium text-indigo-600 hover:text-indigo-700">Sign in</a>
                </p>
            @endguest
        </div>
    </div>
</x-meet-kiosk-layout>
