<?= $this->extend('layout/main_layout') ?>
<?= $this->section('content') ?>
<div class="container-xxl py-5">
    <div class="container">
        <h1>Trash</h1>
        <?php if (!empty($trashedMessages)): ?>
            <div class="table-responsive">
                <table class="table table-striped">
                    <thead>
                        <tr>
                            <th>Subject</th>
                            <th>Date</th>
                            <th>Actions</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($trashedMessages as $message): ?>
                            <tr>
                                <td><?= esc($message['subject']) ?></td>
                                <td><?= esc(!empty($message['created_at']) ? local_datetime($message['created_at'], 'm-d-Y H:i') : '') ?></td>
                                <td>
                                    <a href="<?= base_url('messages/restore/' . $message['id']) ?>">Restore</a> |
                                    <a href="<?= base_url('messages/deletePermanent/' . $message['id']) ?>">Delete Permanently</a>
                                </td>
                            </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
        <?php else: ?>
            <p>No messages found in trash.</p>
        <?php endif; ?>
    </div>
<?= $this->endSection() ?>
