<?php $pageTitle = 'Email Templates'; ?>
<div class="mb-4"><p class="text-secondary">Manage email templates used for automated notifications</p></div>
<div class="card-cix">
    <div class="table-responsive">
        <table class="table-cix"><thead><tr><th>Code</th><th>Name</th><th>Subject</th><th>Status</th><th>Actions</th></tr></thead>
        <tbody><?php if (empty($templates)): ?>
            <tr><td colspan="5" class="text-center text-secondary p-4">No templates</td></tr>
        <?php else: foreach ($templates as $t): ?>
        <tr>
            <td><code class="text-secondary"><?= e($t['code']) ?></code></td>
            <td><strong><?= e($t['name']) ?></strong></td>
            <td class="text-secondary small"><?= e($t['subject']) ?></td>
            <td><span class="badge-cix <?= $t['is_active'] ? 'badge-active' : 'badge-rejected' ?>"><?= $t['is_active'] ? 'Active' : 'Inactive' ?></span></td>
            <td><a href="<?= base_url('admin/email-template-edit/' . $t['id']) ?>" class="btn-cix btn-cix-sm btn-cix-primary"><i class="fas fa-edit"></i></a></td>
        </tr>
        <?php endforeach; endif; ?></tbody></table>
    </div>
</div>
<div class="card-cix mt-4">
    <div class="card-cix-header"><h5 class="mb-0"><i class="fas fa-info-circle text-orange me-2"></i> Template Variables</h5></div>
    <p class="text-secondary small mb-2">Use these variables in your templates (wrapped in curly braces):</p>
    <div class="row g-2">
        <div class="col-md-4"><code>{student_name}</code> - Student full name</div>
        <div class="col-md-4"><code>{student_number}</code> - Student number</div>
        <div class="col-md-4"><code>{course_name}</code> - Course name</div>
        <div class="col-md-4"><code>{login_url}</code> - Login URL</div>
        <div class="col-md-4"><code>{certificate_number}</code> - Certificate number</div>
        <div class="col-md-4"><code>{payment_amount}</code> - Payment amount</div>
        <div class="col-md-4"><code>{academy_name}</code> - Academy name</div>
        <div class="col-md-4"><code>{academic_email}</code> - Academic email</div>
        <div class="col-md-4"><code>{whatsapp_number}</code> - WhatsApp number</div>
    </div>
</div>
