@extends('layout')

@section('content')
    <section class="hero-card narrow-card">
        <div class="brand-lockup">
            <img class="brand-logo" src="{{ asset('images/neutro-pharma-logo.svg') }}" alt="Neutro Pharma logo">
            <div>
                <strong>Neutro Pharma (Pvt) Ltd.</strong>
                <small>Periume Advance Quiz</small>
            </div>
        </div>
        <p class="eyebrow">Participant Entry</p>
        <h1>{{ $quiz?->title ?? 'No Active Test' }}</h1>
        <p class="muted">
            @if ($quiz)
                Enter your name to join the live {{ strtolower($quiz->test_type ?? 'test') }}. Your session ID will be generated automatically.
            @else
                No test is currently active. Please ask the admin to activate a test.
            @endif
        </p>

        @if ($errors->any())
            <div class="alert error">
                {{ $errors->first() }}
            </div>
        @endif

        @if (($activeQuizzes ?? collect())->count() > 1)
            <div class="test-choice-list">
                @foreach ($activeQuizzes as $activeQuiz)
                    <a class="test-choice @if ($quiz && $quiz->id === $activeQuiz->id) is-selected @endif" href="{{ route('quiz.join', ['quizSlug' => $activeQuiz->slug]) }}">
                        <span>{{ $activeQuiz->test_type }}</span>
                        <strong>{{ $activeQuiz->title }}</strong>
                        <small>{{ $activeQuiz->questions_count }} questions</small>
                    </a>
                @endforeach
            </div>
        @endif

        @if ($quiz)
            <form method="POST" action="{{ route('quiz.participant.store') }}" class="stack-form">
                @csrf
                <input type="hidden" name="quiz_id" value="{{ $quiz->id }}">
                <label for="name">Participant name</label>
                <input id="name" name="name" value="{{ old('name') }}" required maxlength="80" placeholder="Enter your full name">
                <button class="primary-button" type="submit">Join Test</button>
            </form>
        @endif

        <div class="footer-note">
            Admin dashboard: <a href="{{ route('admin.quiz') }}">Open admin</a>
        </div>
    </section>
@endsection

@push('vite')
    @vite(['resources/css/app.css'])
@endpush
