<?php $pageTitle = 'Backup & Restore'; ?>
<div class="mb-4"><p class="text-secondary">Database backup management</p></div>
<div class="card-cix mb-4">
    <div class="card-cix-header"><h5 class="mb-0"><i class="fas fa-download text-orange me-2"></i> Create Backup</h5></div>
    <form method="POST" action="<?= base_url('admin/backup') ?>"><?= csrf_field() ?>
        <button type="submit" class="btn-cix btn-cix-accent"><i class="fas fa-database"></i> Create Full Backup</button>
    </form>
</div>
<div class="card-cix">
    <div class="card-cix-header"><h5 class="mb-0"><i class="fas fa-history text-orange me-2"></i> Backup History</h5></div>
    <?php if (empty($backups)): ?>
        <div class="empty-state"><i class="fas fa-database"></i><h5>No Backups</h5><p>Generate your first backup above.</p></div>
    <?php else: ?>
    <div class="table-responsive"><table class="table-cix"><thead><tr><th>File</th><th>Size</th><th>Type</th><th>Created By</th><th>Date</th></tr></thead>
    <tbody><?php foreach ($backups as $b): ?>
    <tr><td><strong><?= e($b['file_name']) ?></strong></td><td><?= number_format($b['file_size'] / 1024, 1) ?> KB</td><td><span class="badge-cix badge-submitted"><?= e($b['backup_type']) ?></span></td>
    <td class="text-secondary"><?= e(($b['first_name'] ?? '') . ' ' . ($b['last_name'] ?? '')) ?></td><td class="text-secondary small"><?= e($b['created_at']) ?></td></tr>
    <?php endforeach; ?></tbody></table></div>
    <?php endif; ?>
</div>
