<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Verify Vaccination Certificate</title>
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    background: #f1f5f9; color: #1e293b; min-height: 100vh;
    display: flex; align-items: center; justify-content: center; padding: 18px;
}
.card {
    background: #fff; border-radius: 14px; padding: 26px 28px; max-width: 560px; width: 100%;
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.08); border: 1px solid #e2e8f0;
}
.icon-bubble {
    width: 64px; height: 64px; border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 30px; margin: 0 auto 14px;
}
.icon-ok  { background: #ecfdf5; color: #059669; border: 2px solid #a7f3d0; }
.icon-err { background: #fef2f2; color: #b91c1c; border: 2px solid #fecaca; }

h1 { font-size: 19px; font-weight: 800; text-align: center; margin-bottom: 6px; }
.subtitle { text-align: center; color: #64748b; font-size: 13px; margin-bottom: 22px; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 8px; }
.lbl { color: #64748b; font-size: 10px; font-weight: 700; text-transform: uppercase;
       letter-spacing: .5px; margin-bottom: 2px; }
.val { color: #1e293b; font-weight: 700; font-size: 13px; }

.divider { height: 1px; background: #e2e8f0; margin: 18px 0; }

table.vx { width: 100%; border-collapse: collapse; font-size: 12px; }
table.vx th, table.vx td {
    text-align: left; padding: 7px 9px; border-bottom: 1px solid #e2e8f0;
}
table.vx th { background: #f8fafc; font-size: 10px; font-weight: 700; color: #64748b;
              text-transform: uppercase; letter-spacing: .5px; }
table.vx tr:last-child td { border-bottom: 0; }

.footer { text-align: center; font-size: 11px; color: #94a3b8; margin-top: 18px; }
.bad-msg { text-align: center; color: #475569; font-size: 14px; line-height: 1.6; }
</style>
</head>
<body>
<div class="card">

    @if(empty($ok))
        @php
            $r   = $reason ?? '';
            $msg = $r === 'bad_format'
                ? 'The verification code in the link is not in a recognised format.'
                : 'No vaccination certificate was found for this code.';
        @endphp
        <div class="icon-bubble icon-err">⚠</div>
        <h1>Certificate not verified</h1>
        <div class="subtitle">We could not match this code to any record.</div>
        <div class="bad-msg">{{ $msg }}</div>

    @else
        <div class="icon-bubble icon-ok">✓</div>
        <h1>Certificate verified</h1>
        <div class="subtitle">Issued by <strong>{{ $business->name ?? '—' }}</strong></div>

        <div class="row">
            <div><div class="lbl">Patient</div><div class="val">{{ $pet->petname ?? '—' }}</div></div>
            <div><div class="lbl">Owner</div><div class="val">{{ optional($pet->owner)->name ?? '—' }}</div></div>
        </div>
        <div class="row">
            <div><div class="lbl">Species · Breed</div>
                <div class="val">{{ $pet->species ?? '—' }}{{ $pet->breed ? ' · ' . $pet->breed : '' }}</div>
            </div>
            <div><div class="lbl">Microchip</div>
                <div class="val">{{ $pet->microchip_no ?: '—' }}</div>
            </div>
        </div>

        <div class="divider"></div>

        <div class="lbl" style="margin-bottom:6px;">Recent vaccinations on record</div>
        @if($pet->vaccinations->isEmpty())
            <div class="bad-msg" style="padding:14px 0;">No vaccinations recorded for this pet.</div>
        @else
            <table class="vx">
                <thead>
                    <tr>
                        <th>Date</th>
                        <th>Vaccine</th>
                        <th>Next due</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach($pet->vaccinations as $vax)
                        <tr>
                            <td>{{ optional($vax->administered_date)->format('d M Y') ?: '—' }}</td>
                            <td>{{ optional($vax->vaccineType)->name ?? '—' }}</td>
                            <td>{{ optional($vax->next_due_date)->format('d M Y') ?: '—' }}</td>
                        </tr>
                    @endforeach
                </tbody>
            </table>
        @endif

    @endif

    <div class="footer">Veterinary Vaccination Certificate Verification</div>
</div>
</body>
</html>
