<?php defined('ABSPATH') || exit;
// phpcs:disable WordPress.Security.NonceVerification,WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
$current = 'fortisrestore'; ?>
<div class="wrap fortis-wrap">
<?php require __DIR__ . '/sidebar.php'; ?>
<main>
    <header><div><small>WORDPRESS PROTECTION</small><h1>Dashboard</h1><p>Encrypted backups built natively for WordPress.</p></div><span class="fortis-status">FREE</span></header>
    <?php if (!empty($_GET['fortis_notice'])): ?><div class="notice notice-<?php echo  sanitize_key(wp_unslash($_GET['fortis_type'] ?? '')) === 'error' ? 'error' : 'success' ?> is-dismissible"><p><?php echo  esc_html(sanitize_text_field(wp_unslash($_GET['fortis_notice']))) ?></p></div><?php endif; ?>
    <section class="fortis-stats"><article><small>WordPress</small><strong><?php echo  esc_html(get_bloginfo('version')) ?></strong></article><article><small>Backups</small><strong><?php echo  count($archives) ?></strong></article><article><small>Encryption</small><strong>AES-256</strong></article><article><small>System status</small><strong class="green">OK</strong></article></section>
    <section class="fortis-panel"><div class="fortis-panel-head"><div><h2>Recovery points</h2><p>Every archive contains WordPress files, database, and configuration.</p></div><button id="fortis-create" <?php echo  $active ? 'disabled' : '' ?>>Create Backup</button></div><div id="fortis-progress" class="fortis-progress" <?php echo  $active ? '' : 'hidden' ?> data-job="<?php echo  esc_attr($active['id'] ?? '') ?>"><div><span style="width:<?php echo  (int) ($active['percent'] ?? 0) ?>%"></span></div><p><?php echo  esc_html($active['message'] ?? 'Preparing backup') ?></p></div><div class="fortis-table"><table><thead><tr><th>Archive</th><th>Date</th><th>Size</th><th>Status</th><th></th></tr></thead><tbody><?php if (!$archives): ?><tr><td colspan="5" class="empty">No WordPress backups yet.</td></tr><?php endif; ?><?php foreach ($archives as $archive): ?><tr><td><b><?php echo  esc_html($archive['name']) ?></b><small>WordPress .fts recovery point</small></td><td><?php echo  esc_html(gmdate('M j, Y g:i A', $archive['created'])) ?> UTC</td><td><?php echo  esc_html(size_format($archive['size'], 2)) ?></td><td><span class="verified"><?php echo  $archive['verified'] ? 'Verified' : 'Invalid' ?></span></td><td><a href="<?php echo  esc_url(wp_nonce_url(admin_url('admin-post.php?action=fortis_download&file=' . rawurlencode($archive['name'])), 'fortis_download')) ?>">Download</a><a class="delete" onclick="return confirm('Delete this backup?')" href="<?php echo  esc_url(wp_nonce_url(admin_url('admin-post.php?action=fortis_delete&file=' . rawurlencode($archive['name'])), 'fortis_delete')) ?>">Delete</a></td></tr><?php endforeach; ?></tbody></table></div></section>
    <section class="fortis-panel fortis-recovery-panel"><div class="fortis-panel-head"><div><h2>Your Recovery Key</h2><p>Store this separately from your .fts archives. It is required if the original WordPress server is unavailable.</p></div><span class="fortis-status">AES-256</span></div><div class="fortis-recovery-actions"><a class="fortis-primary-link" href="<?php echo  esc_url(wp_nonce_url(admin_url('admin-post.php?action=fortis_recovery_key'), 'fortis_recovery_key')) ?>">Download Recovery Key</a></div></section>
    <section class="fortis-actions"><article><span class="dashicons dashicons-shield"></span><div><b>Encrypted by default</b><small>AES-256 protects every archive entry.</small></div></article><article><span class="dashicons dashicons-database-export"></span><div><b>WordPress-aware database</b><small>Tables and serialized values remain intact.</small></div></article><article><span class="dashicons dashicons-update"></span><div><b>Persistent jobs</b><small>Progress resumes when you return to this page.</small></div></article></section>
</main></div>
