@extends('layouts.admin')

@section('title', 'Tambah Peserta')
@section('header', 'Tambah Peserta')

@section('breadcrumb')
<li class="breadcrumb-item"><a href="{{ route('admin.programs.index') }}">Program</a></li>
<li class="breadcrumb-item"><a href="{{ route('admin.programs.show', $program) }}">{{ Str::limit($program->title, 25) }}</a></li>
<li class="breadcrumb-item"><a href="{{ route('admin.programs.participants.index', $program) }}">Peserta</a></li>
<li class="breadcrumb-item active">Tambah</li>
@endsection

@section('content')
<div class="row justify-content-center">
    <div class="col-lg-7">
        <div class="card border-0 shadow-sm">
            <div class="card-header bg-white border-bottom py-3">
                <span class="fw-semibold">
                    <i class="bi bi-person-plus me-2 text-primary"></i>Tambah Peserta Pra-Daftar
                </span>
            </div>
            <div class="card-body">
                <form method="POST" action="{{ route('admin.programs.participants.store', $program) }}">
                    @csrf
                    <div class="row g-3">
                        <div class="col-12">
                            <label class="form-label fw-medium">Nama Penuh <span class="text-danger">*</span></label>
                            <input type="text" name="name" class="form-control @error('name') is-invalid @enderror"
                                   value="{{ old('name') }}" placeholder="Contoh: Ahmad bin Ali">
                            @error('name')<div class="invalid-feedback">{{ $message }}</div>@enderror
                        </div>

                        <div class="col-md-6">
                            <label class="form-label fw-medium">No. Kad Pengenalan <span class="text-danger">*</span></label>
                            <input type="text" name="no_kp" class="form-control @error('no_kp') is-invalid @enderror"
                                   value="{{ old('no_kp') }}" placeholder="900101011234"
                                   maxlength="14">
                            <div class="form-text">Tanpa sempang. 12 digit.</div>
                            @error('no_kp')<div class="invalid-feedback">{{ $message }}</div>@enderror
                        </div>

                        <div class="col-md-6">
                            <label class="form-label fw-medium">Sesi</label>
                            <select name="session" class="form-select @error('session') is-invalid @enderror">
                                <option value="">— Pilih Sesi —</option>
                                <option value="pagi"     {{ old('session', $program->default_staff_session) === 'pagi'     ? 'selected' : '' }}>Pagi</option>
                                <option value="petang"   {{ old('session', $program->default_staff_session) === 'petang'   ? 'selected' : '' }}>Petang</option>
                                <option value="full_day" {{ old('session', $program->default_staff_session) === 'full_day' ? 'selected' : '' }}>Sehari Penuh</option>
                            </select>
                            @error('session')<div class="invalid-feedback">{{ $message }}</div>@enderror
                        </div>

                        <div class="col-md-6">
                            <label class="form-label fw-medium">Emel</label>
                            <input type="email" name="email" class="form-control @error('email') is-invalid @enderror"
                                   value="{{ old('email') }}" placeholder="ahmad@jabatan.gov.my">
                            @error('email')<div class="invalid-feedback">{{ $message }}</div>@enderror
                        </div>

                        <div class="col-md-6">
                            <label class="form-label fw-medium">No. Telefon</label>
                            <input type="text" name="phone" class="form-control @error('phone') is-invalid @enderror"
                                   value="{{ old('phone') }}" placeholder="0123456789">
                            @error('phone')<div class="invalid-feedback">{{ $message }}</div>@enderror
                        </div>

                        <div class="col-12">
                            <label class="form-label fw-medium">Jabatan / Agensi</label>
                            <input type="text" name="agency" class="form-control @error('agency') is-invalid @enderror"
                                   value="{{ old('agency') }}" placeholder="Jabatan Sumber Manusia">
                            @error('agency')<div class="invalid-feedback">{{ $message }}</div>@enderror
                        </div>
                    </div>

                    <div class="d-flex justify-content-end gap-2 mt-4">
                        <a href="{{ route('admin.programs.participants.index', $program) }}"
                           class="btn btn-outline-secondary">Batal</a>
                        <button type="submit" class="btn btn-primary px-4">
                            <i class="bi bi-check-lg me-1"></i> Tambah Peserta
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
@endsection
