<?php

/**
 * This file is part of JohnCMS Content Management System.
 *
 * @copyright JohnCMS Community
 * @license   https://opensource.org/licenses/GPL-3.0 GPL-3.0
 * @link      https://johncms.com JohnCMS Project
 */

/**
 * @var $title
 * @var $page_title
 * @var $data
 */

$this->layout(
    'system::layout/default',
    [
        'title'      => $title,
        'page_title' => $page_title,
    ]
);
?>

<div class="flex flex-wrap gap-2 mb-4 -mt-1" role="group">
    <?php foreach ($data['tabs'] as $tab): ?>
        <a href="<?= $tab['url'] ?>" class="inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md transition-colors mt-1 <?= ($tab['active'] ? 'bg-blue-500 text-white border-blue-500' : 'text-gray-700 bg-white hover:bg-gray-50') ?>">
            <?= $tab['name'] ?>
        </a>
    <?php endforeach; ?>
</div>

<!-- List of Users -->
<?php if ($data['total']): ?>
    <div class="space-y-4">
        <?php foreach ($data['list'] as $usr): ?>
            <?= $this->fetch('users::user_row', ['item' => $usr, 'active_tab' => $data['active_tab']]) ?>
        <?php endforeach ?>
    </div>
<?php else: ?>
    <div class="flex justify-center">
        <div class="w-full max-w-md">
            <div class="bg-blue-100 border border-blue-400 text-blue-700 px-4 py-3 rounded"><?= __('List is empty') ?></div>
        </div>
    </div>
<?php endif ?>

<div class="mt-6">
    <div>
        <a href="../" class="text-blue-600 hover:text-blue-800 hover:underline"><?= __('Back') ?></a>
    </div>
</div>