<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Certificate - {{ $certificate->certificate_number }}</title>
    <style>
        * { margin: 0; padding: 0; box-sizing: border-box; }

        body {
            font-family: DejaVu Sans, Arial, sans-serif;
            background: #ffffff;
            color: #1f2937;
        }

        .page {
            width: 100%;
            height: 100%;
            padding: 40px;
            border: 12px solid #10b981;
            position: relative;
        }

        .inner-border {
            border: 3px solid #10b981;
            padding: 30px;
            height: 100%;
            text-align: center;
        }

        .org-logo {
            margin-bottom: 20px;
        }

        .org-logo img {
            max-height: 60px;
        }

        .cert-title {
            font-size: 32px;
            font-weight: bold;
            color: #10b981;
            letter-spacing: 4px;
            text-transform: uppercase;
            margin-bottom: 8px;
        }

        .cert-subtitle {
            font-size: 14px;
            color: #6b7280;
            margin-bottom: 30px;
            letter-spacing: 2px;
            text-transform: uppercase;
        }

        .divider {
            width: 80px;
            height: 3px;
            background: #10b981;
            margin: 0 auto 30px;
        }

        .presented-to {
            font-size: 13px;
            color: #6b7280;
            margin-bottom: 8px;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        .recipient-name {
            font-size: 36px;
            font-weight: bold;
            color: #1f2937;
            margin-bottom: 20px;
            border-bottom: 2px solid #e5e7eb;
            padding-bottom: 16px;
            display: inline-block;
            min-width: 300px;
        }

        .completion-text {
            font-size: 14px;
            color: #6b7280;
            margin-bottom: 12px;
        }

        .program-name {
            font-size: 22px;
            font-weight: bold;
            color: #1f2937;
            margin-bottom: 8px;
        }

        .program-duration {
            font-size: 13px;
            color: #6b7280;
            margin-bottom: 30px;
        }

        .signatures {
            display: table;
            width: 100%;
            margin: 30px 0 20px;
        }

        .sig-block {
            display: table-cell;
            width: 33%;
            text-align: center;
            padding: 0 20px;
        }

        .sig-line {
            border-top: 1px solid #9ca3af;
            padding-top: 8px;
            margin-top: 40px;
        }

        .sig-name {
            font-size: 13px;
            font-weight: bold;
            color: #1f2937;
        }

        .sig-title {
            font-size: 11px;
            color: #6b7280;
        }

        .cert-footer {
            margin-top: 20px;
            padding-top: 16px;
            border-top: 1px solid #e5e7eb;
            display: table;
            width: 100%;
        }

        .cert-footer-left,
        .cert-footer-right {
            display: table-cell;
            width: 50%;
            font-size: 10px;
            color: #9ca3af;
        }

        .cert-footer-right {
            text-align: right;
        }

        .cert-number {
            font-family: monospace;
            font-size: 11px;
            color: #6b7280;
            margin-top: 4px;
        }

        .verification-code {
            font-family: monospace;
            font-size: 11px;
            color: #6b7280;
        }

        .issue-date {
            font-size: 13px;
            color: #374151;
            margin-bottom: 4px;
        }
    </style>
</head>
<body>
<div class="page">
    <div class="inner-border">

        {{-- Organization --}}
        <div class="org-logo">
            @if(config('app.logo'))
                <img src="{{ public_path('images/' . config('app.logo')) }}" alt="{{ config('app.name') }}">
            @else
                <div style="font-size: 18px; font-weight: bold; color: #10b981;">{{ $certificate->organization_name ?? config('app.name') }}</div>
            @endif
        </div>

        {{-- Title --}}
        <div class="cert-title">Certificate of Completion</div>
        <div class="cert-subtitle">This is to certify that</div>
        <div class="divider"></div>

        {{-- Recipient --}}
        <div class="recipient-name">{{ $certificate->user->name }}</div>

        {{-- Completion text --}}
        <div class="completion-text">has successfully completed the training program</div>
        <div class="program-name">{{ $certificate->trainingPackage->name }}</div>

        @if($certificate->trainingPackage->duration_hours)
            <div class="program-duration">
                Duration: {{ $certificate->trainingPackage->duration_hours }} hours
                @if($certificate->trainingPackage->duration_days)
                    / {{ $certificate->trainingPackage->duration_days }} days
                @endif
            </div>
        @endif

        {{-- Issue date --}}
        <div class="issue-date">
            Issued on: <strong>{{ $certificate->issue_date->format('F j, Y') }}</strong>
        </div>

        {{-- Signatures --}}
        <div class="signatures">
            <div class="sig-block">
                <div class="sig-line">
                    <div class="sig-name">{{ $certificate->trainer_name ?? '___________________' }}</div>
                    <div class="sig-title">{{ $certificate->trainer_title ?? 'Lead Trainer' }}</div>
                </div>
            </div>
            <div class="sig-block">
                <div class="sig-line">
                    <div class="sig-name">{{ $certificate->organization_name ?? config('app.name') }}</div>
                    <div class="sig-title">Issuing Organization</div>
                </div>
            </div>
            <div class="sig-block">
                <div class="sig-line">
                    <div class="sig-name">{{ $certificate->issue_date->format('M d, Y') }}</div>
                    <div class="sig-title">Date of Issue</div>
                </div>
            </div>
        </div>

        {{-- Footer --}}
        <div class="cert-footer">
            <div class="cert-footer-left">
                <div class="cert-number">Certificate No: {{ $certificate->certificate_number }}</div>
                <div class="verification-code">Verification: {{ $certificate->verification_code }}</div>
            </div>
            <div class="cert-footer-right">
                Verify at: {{ route('public.training.certificates.verify-page') }}
            </div>
        </div>

    </div>
</div>
</body>
</html>
