<?php
function base64img($path) {
    $type = pathinfo($path, PATHINFO_EXTENSION);
    $data = file_get_contents($path);
    return 'data:image/' . $type . ';base64,' . base64_encode($data);
}

$logo = base64img(__DIR__ . '/../assets/logo.png');
$sign = base64img(__DIR__ . '/../assets/signature.png');
?>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<style>
@page {
    size: A4 landscape;
    margin: 12mm;
}

body {
    font-family: Georgia, serif;
    margin: 0;
    padding: 0;
}

.certificate {
    border: 2px solid #0b8c9f;
    padding: 15mm;
}

.header {
    text-align: center;
}

.header img {
    height: 90px;
}

.title {
    font-size: 26px;
    letter-spacing: 2px;
    margin: 8mm 0;
}

.content {
    text-align: center;
}

.student {
    font-size: 30px;
    font-weight: bold;
    margin: 8px 0;
}

.track {
    font-size: 22px;
    font-weight: bold;
}

.footer {
    margin-top: 15mm;
    display: table;
    width: 100%;
    font-size: 13px;
}

.footer-left {
    display: table-cell;
}

.footer-right {
    display: table-cell;
    text-align: right;
}

.signature img {
    height: 75px;
}

.verify {
    text-align: center;
    margin-top: 6mm;
    font-size: 11px;
    color: #555;
}
</style>
</head>

<body>

<div class="certificate">

    <div class="header">
        <img src="<?= $logo ?>">
        <div class="title">CERTIFICATE OF PARTICIPATION</div>
    </div>

    <div class="content">
        <p>This is to certify that</p>

        <div class="student"><?= htmlspecialchars($student_name) ?></div>

        <p>has successfully participated in the</p>

        <div class="track"><?= htmlspecialchars($track_name) ?></div>

        <p>conducted by <b>RS Learning Lab</b></p>
    </div>

    <div class="footer">
        <div class="footer-left signature">
            <img src="<?= $sign ?>"><br>
            <b>Gokula Krishnan</b><br>
            Founder – RS Learning Lab
        </div>

        <div class="footer-right">
    Certificate ID: <?= htmlspecialchars($certificate_id) ?><br>
    Issued on: <?= date("d M Y", strtotime($issued_at)) ?><br>
    <small>Verify at: rslearninglab.com/verify</small>
</div>

    </div>


</body>
</html>
