@extends('layouts.app')
@section('title', 'Generate Certificate')
@section('page_title', 'Generate Certificate')
@section('breadcrumbs')
    <li class="breadcrumb-item"><a href="{{ route('certificates.index') }}">Certificates</a></li><li class="breadcrumb-item active">Generate</li>
@endsection

@section('content')
    <div class="card"><div class="card-body">
        <form method="GET" action="{{ route('certificates.print') }}" target="_blank">
            <div class="row g-3">
                <div class="col-md-6"><label class="form-label">Certificate Template <span class="text-danger">*</span></label>
                    <select name="template_id" class="form-select js-select2" required>
                        <option value="">— Select template —</option>
                        @foreach($templates as $t)<option value="{{ $t->id }}">{{ $t->name }}</option>@endforeach
                    </select></div>
                <div class="col-md-6"><label class="form-label">Student <span class="text-danger">*</span></label>
                    <select name="student_id" class="form-select js-select2" required>
                        <option value="">— Select student —</option>
                        @foreach($students as $s)<option value="{{ $s->id }}" @selected($selectedStudent==$s->id)>{{ $s->name }} ({{ $s->admission_number }})</option>@endforeach
                    </select></div>
            </div>
            <div class="alert alert-info small mt-3 mb-0"><i class="bi bi-info-circle me-1"></i>Placeholders in the template are filled from the selected student's data. The certificate opens as a printable PDF.</div>
            <div class="mt-3">
                <button class="btn btn-primary"><i class="bi bi-file-earmark-pdf me-1"></i>Generate PDF</button>
                <a href="{{ route('certificates.index') }}" class="btn btn-light border">Cancel</a>
            </div>
        </form>
    </div></div>
@endsection
