<?php
// Printable certificate page
$lang = current_lang();
$title = ($lang==='ar') ? 'شهادة تقدير' : 'Certificate of Appreciation';
$name = trim((string)($user['first_name'] ?? '').' '.(string)($user['last_name'] ?? ''));
$confTitle = ($lang==='ar') ? (string)($conf['title_ar'] ?? '') : (string)($conf['title_en'] ?? '');
$issue = (string)($cert['issue_no'] ?? '');
?><!doctype html>
<html lang="<?= e($lang) ?>" dir="<?= e($lang==='ar'?'rtl':'ltr') ?>">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Cairo:wght@400;700;900&display=swap" rel="stylesheet">
  <title><?= e($title) ?></title>
  <style>
    body{font-family:'Cairo',Tahoma,Arial,sans-serif;background:#f6f8fc;margin:0}
    .page{max-width:980px;margin:30px auto;background:#fff;border:6px solid #0b2a6f;border-radius:18px;padding:40px}
    .hdr{display:flex;justify-content:space-between;align-items:center}
    .badge{padding:6px 12px;border-radius:999px;background:#0b2a6f;color:#fff;font-weight:900}
    .title{font-size:38px;font-weight:900;color:#0b2a6f;margin:28px 0 8px}
    .sub{color:#334155;margin-bottom:24px}
    .name{font-size:32px;font-weight:900}
    .footer{margin-top:40px;display:flex;justify-content:space-between;color:#64748b}
    @media print {.print-hide{display:none} body{background:#fff}}
  </style>
</head>
<body>
  <div class="page">
    <div class="hdr">
      <div class="badge"><?= e($issue ?: 'CERT') ?></div>
      <button class="print-hide" onclick="window.print()" style="border:0;background:#0b2a6f;color:#fff;padding:10px 14px;border-radius:12px;font-weight:800;cursor:pointer">
        <?= e($lang==='ar'?'طباعة':'Print') ?>
      </button>
    </div>

    <div class="title"><?= e($title) ?></div>
    <div class="sub">
      <?= e($lang==='ar' ? 'تشهد إدارة المؤتمر بتقديم هذه الشهادة إلى:' : 'This certificate is proudly presented to:') ?>
    </div>

    <div class="name"><?= e($name) ?></div>

    <div style="margin-top:22px;font-size:18px;color:#334155;line-height:1.9">
      <?= e($lang==='ar'
        ? 'وذلك تقديراً لمساهمته/مساهمتها في أعمال التحكيم/اللجنة ضمن: '
        : 'In recognition of their valuable contribution as reviewer/committee member in: ') ?>
      <b><?= e($confTitle) ?></b>
    </div>

    <div class="footer">
      <div><?= e($lang==='ar'?'التاريخ: ':'Date: ') ?><?= e(date('Y-m-d')) ?></div>
      <div><?= e($lang==='ar'?'التوقيع: ':'Signature: ') ?>__________</div>
    </div>
  </div>
</body>
</html>
