@extends('layouts.admin')

@section('title', 'Template Sijil')

@section('content')
<div class="d-flex justify-content-between mb-4">
    <h2 class="mb-0">Template Sijil</h2>
    <a href="{{ route('admin.certificate-templates.create') }}" class="btn btn-esijil btn-sm">Muat Naik Template</a>
</div>

<div class="card"><div class="card-body p-0">
    <table class="table table-hover mb-0">
        <thead class="table-light"><tr><th>Nama</th><th>Saiz</th><th>Orientasi</th><th>Status</th><th>Tindakan</th></tr></thead>
        <tbody>
            @forelse($templates as $t)
            <tr>
                <td>{{ $t->template_name }}</td>
                <td>{{ $t->page_size }}</td>
                <td>{{ $t->orientation }}</td>
                <td>@if($t->is_active)<span class="badge bg-success">Aktif</span>@else<span class="badge bg-secondary">Tidak Aktif</span>@endif</td>
                <td>
                    <a href="{{ route('admin.certificate-templates.edit', $t) }}" class="btn btn-sm btn-outline-primary">Edit</a>
                    <a href="{{ route('admin.certificate-templates.preview', $t) }}" class="btn btn-sm btn-outline-info" target="_blank">Preview</a>
                    @unless($t->is_active)
                    <form action="{{ route('admin.certificate-templates.activate', $t) }}" method="POST" class="d-inline">@csrf<button class="btn btn-sm btn-success">Aktifkan</button></form>
                    @endunless
                </td>
            </tr>
            @empty
            <tr><td colspan="5" class="text-center text-muted py-4">Tiada template. Sila muat naik template sijil.</td></tr>
            @endforelse
        </tbody>
    </table>
    <div class="p-3">{{ $templates->links() }}</div>
</div></div>
@endsection
