<?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 \Johncms\Users\User $item
 */
?>

<div class="border border-gray-200 rounded-lg p-4 mb-4 bg-white shadow-sm">
    <div class="flex justify-between items-start mb-3">
        <div class="flex items-center space-x-3">
            <div class="relative">
                <?php if ($item->id !== $user->id): ?>
                    <a href="<?= $item->profile_url ?>" class="block">
                        <div class="w-12 h-12 rounded-full overflow-hidden flex-shrink-0">
                            <img src="<?= $this->avatar($item->id) ?>" class="w-full h-full object-cover" alt=".">
                        </div>
                    </a>
                <?php else: ?>
                    <div class="w-12 h-12 rounded-full overflow-hidden flex-shrink-0">
                        <img src="<?= $this->avatar($item->id) ?>" class="w-full h-full object-cover" alt=".">
                    </div>
                <?php endif; ?>
                
                <span class="absolute -bottom-1 -right-1 w-3 h-3 rounded-full border-2 border-white <?= $item->is_online ? 'bg-green-500' : 'bg-gray-400' ?>"></span>
                
                <?php if (! empty($item->rights_name)): ?>
                    <div class="absolute -top-1 -right-1 w-5 h-5 bg-blue-500 rounded-full flex items-center justify-center"
                         title="<?= $item->rights_name ?>">
                        <svg class="w-3 h-3 text-white">
                            <use xlink:href="<?= $this->asset('icons/sprite.svg') ?>?4#check"/>
                        </svg>
                    </div>
                <?php endif ?>
            </div>
        </div>
        
        <div class="flex-1 ml-3 min-w-0">
            <div class="flex items-center flex-wrap">
                <?php if ($item->id !== $user->id): ?>
                    <a href="<?= $item->profile_url ?>" class="hover:underline">
                        <span class="font-semibold text-gray-900 text-lg mr-2 truncate"><?= $item->name ?></span>
                    </a>
                <?php else: ?>
                    <span class="font-semibold text-gray-900 text-lg mr-2 truncate"><?= $item->name ?></span>
                <?php endif; ?>
            </div>
            <?php if (! empty($item->status)): ?>
                <div class="truncate text-nowrap">
                    <span class="font-medium text-gray-700 text-sm"><?= $item->status ?></span>
                </div>
            <?php endif ?>
        </div>
    </div>
    
    <?php if (! empty($active_tab)): ?>
        <div class="py-2 text-gray-600">
            <?php if ($active_tab === 'guest'): ?>
                <?= $item['postguest'] ?> <?= n__('post', 'posts', $item['postguest']) ?>
            <?php elseif ($active_tab === 'comm'): ?>
                <?= $item['komm'] ?> <?= n__('comment', 'comments', $item['komm']) ?>
            <?php elseif ($active_tab === 'karma'): ?>
                <?= $item['karma'] ?> <?= n__('point', 'points', $item['karma']) ?>
            <?php elseif ($active_tab === 'forum'): ?>
                <?= $item['postforum'] ?> <?= n__('post', 'posts', $item['postforum']) ?>
            <?php endif; ?>
        </div>
    <?php endif; ?>
    
    <div class="flex justify-between items-center pt-3 border-t border-gray-100">
        <div class="flex-1 min-w-0">
            <?php if ($user->rights): ?>
                <div class="flex flex-wrap items-center gap-2 text-sm text-gray-500">
                    <div class="flex items-center">
                        <a href="<?= $item->search_ip_url ?>" class="hover:text-blue-600 hover:underline"><?= $item->ip ?></a>
                        <?php if (! empty($item->ip_via_proxy)): ?>
                            <span class="mx-1">/</span>
                            <a href="<?= $item->search_ip_via_proxy_url ?>" class="hover:text-blue-600 hover:underline"><?= $item->ip_via_proxy ?></a>
                        <?php endif; ?>
                    </div>
                    <div class="truncate">
                        <span><?= $item->browser ?></span>
                    </div>
                </div>
            <?php endif; ?>
        </div>
        <div class="flex items-center ml-4">
            <?php if (! empty($item['delete_url'])): ?>
                <a href="<?= $item['delete_url'] ?>" class="text-red-600 hover:text-red-800 hover:underline text-sm font-medium">
                    <?= __('Delete') ?>
                </a>
            <?php endif; ?>
        </div>
    </div>
</div>