@extends('layouts.app')

@section('title', 'Letter Head Templates')
@section('heading', 'Letter Head Templates')

@section('content')
@include('documents.top-submenu')
@include('settings.partials.back-to-home')
    <x-card>
        <div class="mb-4 flex justify-between items-center">
            <p class="text-slate-600">Templates for letter heads and documents.</p>
            <a href="{{ route('letter-head-templates.create') }}" class="inline-flex items-center rounded-lg bg-slate-800 px-4 py-2 text-sm font-medium text-white hover:bg-slate-700"><i class="bi bi-plus-lg me-1"></i>Add Template</a>
        </div>
        <x-table>
            <x-slot name="head">
                <tr>
                    <th class="px-4 py-3 text-left text-xs font-medium uppercase text-slate-500">Name</th>
                    <th class="px-4 py-3 text-left text-xs font-medium uppercase text-slate-500">Actions</th>
                </tr>
            </x-slot>
            @forelse($templates as $t)
                <tr>
                    <td class="px-4 py-3 text-sm text-slate-900">{{ $t->name }}</td>
                    <td class="whitespace-nowrap px-4 py-3 text-sm space-x-2">
                        <a href="{{ route('letter-head-templates.preview', $t) }}" class="font-medium text-primary hover:underline">Preview</a>
                        <a href="{{ route('letter-head-templates.edit', $t) }}" class="btn-icon-action btn-icon-action--edit" title="Edit" aria-label="Edit"><i class="bi bi-pencil-square"></i></a>
                        <form action="{{ route('letter-head-templates.destroy', $t) }}" method="post" class="inline" onsubmit="return confirm('Delete this template?');">
                            @csrf
                            @method('DELETE')
                            <button type="submit" class="btn-icon-action btn-icon-action--delete" title="Delete" aria-label="Delete"><i class="bi bi-trash3"></i></button>
                        </form>
                    </td>
                </tr>
            @empty
                <tr><td colspan="2" class="px-4 py-8 text-center text-sm text-slate-500">No templates yet.</td></tr>
            @endforelse
        </x-table>
        @if($templates->hasPages())<div class="mt-4">{{ $templates->links() }}</div>@endif
    </x-card>
@endsection
