<?php use App\Core\View; ?>

<h2>Пользователи</h2>

<table>
    <thead>
        <tr>
            <th>ID</th>
            <th>ФИО</th>
            <th>Email</th>
            <th>Телефон</th>
            <th>Город</th>
            <th>Роль</th>
            <th>Регистрация</th>
            <th>Последний вход</th>
        </tr>
    </thead>
    <tbody>
        <?php foreach ($users as $u): ?>
        <tr>
            <td><?= $u['user_id'] ?></td>
            <td><?= htmlspecialchars($u['full_name'] ?? '-') ?></td>
            <td><?= htmlspecialchars($u['email']) ?></td>
            <td><?= htmlspecialchars($u['phone'] ?? '-') ?></td>
            <td><?= htmlspecialchars($u['city'] ?? '-') ?></td>
            <td>
                <?php if ($u['is_admin']): ?>
                <span style="background: #617365; color: white; padding: 3px 10px; border-radius: 4px; font-size: 12px;">
                    <i class="fas fa-user-shield"></i> Админ
                </span>
                <?php else: ?>
                <span style="background: #28a745; color: white; padding: 3px 10px; border-radius: 4px; font-size: 12px;">
                    <i class="fas fa-user"></i> Пользователь
                </span>
                <?php endif; ?>
            </td>
            <td><?= $u['created_at'] ? View::formatDateTime($u['created_at']) : '-' ?></td>
            <td><?= $u['last_login'] ? View::formatDateTime($u['last_login']) : 'Не было' ?></td>
        </tr>
        <?php endforeach; ?>
    </tbody>
</table>

