<div class="row">
  <div class="col-12">
    <div class="card">
      <div class="card-header">
        <h5>Login Logs</h5>
        <small>Recorded login attempts and sessions</small>
      </div>
      <div class="card-body table-responsive">
        <table class="table table-striped table-hover">
          <thead class="table-light">
            <tr>
              <th>#</th>
              <th>User</th>
              <th>Email</th>
              <th>Login Time</th>
              <th>Logout Time</th>
              <th>Status</th>
            </tr>
          </thead>
          <tbody>
            <?php if (!empty($logs)): $i = 1; foreach ($logs as $log): ?>
            <tr>
              <td><?= $i++ ?></td>
              <td><?= html_escape($log->name ?? $log->user_id ?? '-'); ?></td>
              <td><?= html_escape($log->email ?? '-'); ?></td>
              <td><?= !empty($log->login_time) ? html_escape(date('d M Y, h:i A', strtotime($log->login_time))) : '-'; ?></td>
              <td><?= !empty($log->logout_time) ? html_escape(date('d M Y, h:i A', strtotime($log->logout_time))) : '-'; ?></td>
              <td>
                <?php if (!empty($log->status) && (strtolower($log->status) === 'success')): ?>
                  <span class="badge bg-success">Success</span>
                <?php elseif (!empty($log->status) && (strtolower($log->status) === 'fail' || strtolower($log->status) === 'failure')): ?>
                  <span class="badge bg-danger">Failed</span>
                <?php else: ?>
                  <span class="badge bg-secondary"><?= html_escape($log->status ?? '-'); ?></span>
                <?php endif; ?>
              </td>
            </tr>
            <?php endforeach; else: ?>
            <tr><td colspan="6" class="text-center">No login logs found.</td></tr>
            <?php endif; ?>
          </tbody>
        </table>
      </div>
    </div>
  </div>
</div>