@extends('admin.layouts.app')

@section('title', $pageTitle)

@section('content')
<div class="container-fluid">
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-header">
                    <h3 class="card-title">{{ $pageTitle }}</h3>
                    <div class="card-tools">
                        <a href="{{ route('admin.new-certificates-templates.edit', $template->id) }}" class="btn btn-warning">
                            <i class="fas fa-edit"></i> Edit
                        </a>
                        <a href="{{ route('admin.new-certificates-templates.index') }}" class="btn btn-secondary">
                            <i class="fas fa-arrow-left"></i> Back to List
                        </a>
                    </div>
                </div>
                <div class="card-body">
                    <div class="row">
                        <div class="col-md-6">
                            <table class="table table-bordered">
                                <tr>
                                    <th width="30%">Template ID</th>
                                    <td>{{ $template->id }}</td>
                                </tr>
                                <tr>
                                    <th>Name</th>
                                    <td>{{ $template->name }}</td>
                                </tr>
                                <tr>
                                    <th>Created At</th>
                                    <td>{{ $template->created_at->format('Y-m-d H:i:s') }}</td>
                                </tr>
                                <tr>
                                    <th>Updated At</th>
                                    <td>{{ $template->updated_at->format('Y-m-d H:i:s') }}</td>
                                </tr>
                            </table>
                        </div>

                        <div class="col-md-6">
                            <h5>Text Positioning Coordinates</h5>
                            <table class="table table-bordered">
                                <tr>
                                    <th>Element</th>
                                    <th>X Position</th>
                                    <th>Y Position</th>
                                </tr>
                                <tr>
                                    <td>Student Name</td>
                                    <td>{{ $template->name_x }}</td>
                                    <td>{{ $template->name_y }}</td>
                                </tr>
                                <tr>
                                    <td>Graduation Date</td>
                                    <td>{{ $template->date_x }}</td>
                                    <td>{{ $template->date_y }}</td>
                                </tr>
                                <tr>
                                    <td>Serial Number</td>
                                    <td>{{ $template->serial_x }}</td>
                                    <td>{{ $template->serial_y }}</td>
                                </tr>
                            </table>
                        </div>
                    </div>

                    <div class="row mt-4">
                        <div class="col-12">
                            <h5>Template Preview</h5>
                            @if($template->image_path)
                                <div class="text-center">
                                    <img src="{{ Storage::url($template->image_path) }}"
                                         alt="{{ $template->name }}"
                                         class="img-fluid"
                                         style="max-width: 100%; max-height: 500px; object-fit: contain;">
                                </div>
                            @else
                                <div class="alert alert-warning">
                                    No background image uploaded for this template.
                                </div>
                            @endif
                        </div>
                    </div>

                    <div class="row mt-4">
                        <div class="col-12">
                            <h5>Actions</h5>
                            <a href="{{ route('admin.new-certificates-templates.edit', $template->id) }}"
                               class="btn btn-warning">
                                <i class="fas fa-edit"></i> Edit Template
                            </a>
                            <form action="{{ route('admin.new-certificates-templates.destroy', $template->id) }}"
                                  method="POST"
                                  style="display: inline-block;"
                                  onsubmit="return confirm('Are you sure you want to delete this template?')">
                                @csrf
                                @method('DELETE')
                                <button type="submit" class="btn btn-danger">
                                    <i class="fas fa-trash"></i> Delete Template
                                </button>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection


