<?= $this->extend('layout/admin') ?>
<?= $this->section('title') ?>Manage Domains<?= $this->endSection() ?>

<?= $this->section('content') ?>
<div class="page-header">
    <h1 style="font-size: 1.5rem; font-weight: 700;">Registered Domains</h1>
</div>

<div class="table-wrapper">
    <table>
        <thead>
            <tr>
                <th>Domain Name</th>
                <th>User</th>
                <th>Status</th>
                <th>Custom NS</th>
                <th>Registered On</th>
                <th>Action</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach($domains as $domain): ?>
            <tr>
                <td style="font-weight: 600; color: var(--primary);"><?= esc($domain->full_domain) ?></td>
                <td>
                    <div><?= esc($domain->username) ?></div>
                    <div style="font-size: 0.75rem; color: var(--text-muted);"><?= esc($domain->email) ?></div>
                </td>
                <td><span class="status-badge status-<?= esc($domain->status) ?>"><?= ucfirst(esc($domain->status)) ?></span></td>
                <td style="font-size: 0.75rem; color: var(--text-muted);">
                    <?= !empty($domain->custom_ns1) ? esc($domain->custom_ns1) : 'Disabled' ?>
                </td>
                <td style="color: var(--text-muted); font-size: 0.875rem;"><?= date('M j, Y', strtotime($domain->created_at)) ?></td>
                <td>
                    <a href="<?= base_url('admin/domains/delete/' . $domain->id) ?>" class="btn btn-outline" style="font-size: 0.75rem; padding: 0.25rem 0.5rem; border-color: var(--error); color: var(--error);" onclick="return confirm('Are you sure you want to completely delete this domain and all records?')">Delete</a>
                </td>
            </tr>
            <?php endforeach; ?>
            <?php if(empty($domains)): ?>
            <tr><td colspan="6" style="text-align: center; padding: 2rem;">No domains registered yet.</td></tr>
            <?php endif; ?>
        </tbody>
    </table>
</div>
<?= $this->endSection() ?>
