<div class="page-title d-flex justify-content-between align-items-center">
    <h2><i class="bi bi-clock-history"></i> Send Logs - <?= $campaign->name ?></h2>
    <a href="<?= base_url('user/campaign_view/' . $campaign->id) ?>" class="btn btn-secondary">
        <i class="bi bi-arrow-left"></i> Back to Campaign
    </a>
</div>

<div class="panel">
    <div class="panel-header">
        <div class="panel-title"><i class="bi bi-clock-history"></i> Send Logs - <?= htmlspecialchars($campaign->name) ?></div>
        <div class="panel-actions">
            <a href="<?= base_url('user/campaign_view/' . $campaign->id) ?>" class="btn-outline"> <i class="bi bi-arrow-left"></i> Back</a>
        </div>
    </div>
    <div class="panel-body">
        <div class="panel-inner">
        <?php if (!empty($logs)): ?>
            <div class="table-responsive">
                <table class="table table-hover table-sm">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>Mobile </th>
                            <th>Message Content</th>
                            <th>Status</th>
                            <th>Date/Time</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($logs as $idx => $log): ?>
                            <tr>
                                <td><?= $idx + 1 ?></td>
                                <td><span class="masked-data"><?= $log->mobile ?></span></td>
                                <td><?= substr($log->message_content, 0, 50) ?><?= strlen($log->message_content) > 50 ? '...' : '' ?></td>
                                <td>
                                    <?php if ($log->status == 'sent'): ?>
                                        <span class="badge bg-success">Delivered</span>
                                    <?php else: ?>
                                        <span class="badge bg-danger" title="<?= $log->error_message ?>">Failed</span>
                                    <?php endif; ?>
                                </td>
                                <td><?= date('M d, Y h:i:s A', strtotime($log->created_at)) ?></td>
                            </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
            
            <?php if ($pagination['total_pages'] > 1): ?>
                <nav>
                    <ul class="pagination justify-content-center">
                        <?php for ($i = 1; $i <= $pagination['total_pages']; $i++): ?>
                            <li class="page-item <?= $i == $pagination['current_page'] ? 'active' : '' ?>">
                                <a class="page-link" href="<?= $pagination['base_url'] ?>?page=<?= $i ?>"><?= $i ?></a>
                            </li>
                        <?php endfor; ?>
                    </ul>
                </nav>
            <?php endif; ?>
        <?php else: ?>
            <p class="text-muted text-center py-4">No send logs available</p>
        <?php endif; ?>
        </div>
    </div>
</div>
