<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Admin Dashboard</title>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet">
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
            font-family: 'Roboto', sans-serif;
        }

        body {
            background-color: #f4f7f9;
            padding: 20px;
        }

        h2 {
            text-align: center;
            margin-bottom: 20px;
            color: #333;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
        }

        .top-actions {
            display: flex;
            justify-content: space-between;
            margin-bottom: 20px;
        }

        .top-actions a {
            padding: 10px 20px;
            background-color: #667eea;
            color: white;
            text-decoration: none;
            border-radius: 6px;
            transition: 0.3s;
        }

        .top-actions a:hover {
            background-color: #5a67d8;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            background-color: #fff;
            box-shadow: 0 5px 15px rgba(0,0,0,0.05);
            border-radius: 8px;
            overflow: hidden;
        }

        th, td {
            padding: 12px 15px;
            text-align: left;
        }

        th {
            background-color: #667eea;
            color: white;
            font-weight: 600;
        }

        tr:nth-child(even) {
            background-color: #f9f9f9;
        }

        tr:hover {
            background-color: #e2e8f0;
        }

        .logout-btn {
            display: inline-block;
            margin-top: 20px;
            padding: 10px 20px;
            background-color: #e74c3c;
            color: white;
            text-decoration: none;
            border-radius: 6px;
            transition: 0.3s;
        }

        .logout-btn:hover {
            background-color: #c0392b;
        }

        @media (max-width: 768px) {
            .top-actions {
                flex-direction: column;
                gap: 10px;
            }

            table, th, td {
                font-size: 14px;
            }
        }
        .action-btn { padding: 5px 10px; border-radius: 5px; border: none; cursor: pointer; margin: 2px; font-size: 14px; }
        .edit-btn { background-color: #f39c12; color: #fff; }
        .edit-btn:hover { background-color: #d68910; }
        .delete-btn { background-color: #e74c3c; color: #fff; }
        .delete-btn:hover { background-color: #c0392b; }
        .message { text-align: center; margin-bottom: 15px; font-weight: 500; }
        .success { color: green; }
        .error { color: red; }
    </style>
</head>
<body>

<div class="container">
    <h2>Admin Dashboard</h2>
    <div class="top-actions">
        <a href="<?= site_url('admin/attendance/export') ?>">Export Attendance</a>
        <a class="logout-btn" href="<?= site_url('logout') ?>">Logout</a>
    </div>
    <table>
        <thead>
            <tr>
                <th>Employee</th>
                <th>Date</th>
                <th>Punch In</th>
                <th>Punch Out</th>
                <th>Mode</th>
                <th>Actions</th>
            </tr>
        </thead>
        <tbody>
        <?php foreach($records as $r): ?>
            <tr>
               <td><?= esc($r['name'] ?? '---') ?></td>
                <td><?= esc($r['created_at']) ?></td>
                <td><?= esc($r['punch_in']) ?></td>
                <td><?= esc($r['punch_out']) ?></td>
                <td><?= esc($r['work_mode']) ?></td>
                <td>
                    <a href="<?= site_url('admin/employees/edit'.$r['id']) ?>" class="action-btn edit-btn">Edit</a>
                    <a href="<?= site_url('admin/employees/delete/'.$r['id']) ?>" class="action-btn delete-btn" onclick="return confirm('Are you sure you want to delete this record?')">Delete</a>
                </td>
            </tr>
        <?php endforeach; ?>
        </tbody>
    </table>
</div>
</body>
</html>
