@extends('layouts.admin')

@section('title', __('Team List'))

@section('content')
    <!-- Page Header -->
    <div class="flex flex-col md:flex-row md:items-center md:justify-between gap-4 mb-6">
        <div>
            <h1 class="text-2xl font-bold text-gray-900 dark:text-white">{{ __('Team Members') }}</h1>
            <p class="text-gray-500 dark:text-gray-400 mt-1">{{ __('View all team members') }}</p>
        </div>
    </div>
    
    <!-- Team Grid -->
    <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
        @forelse($users as $user)
            <div class="bg-white dark:bg-dark-800 rounded-xl border border-gray-200 dark:border-dark-700 overflow-hidden hover:shadow-lg transition-shadow">
                <!-- Card Header -->
                <div class="p-6 {{ $user->is_admin ? 'bg-gradient-to-r from-purple-500 to-primary-500' : 'bg-gradient-to-r from-blue-500 to-cyan-500' }}">
                    <div class="flex items-center gap-4">
                        @if($user->avatar)
                            <img src="{{ asset('storage/' . $user->avatar) }}" alt="{{ $user->name }}" class="w-16 h-16 rounded-full object-cover border-2 border-white/30">
                        @else
                            <img src="https://ui-avatars.com/api/?name={{ urlencode($user->name) }}&color=fff&background=random" alt="{{ $user->name }}" class="w-16 h-16 rounded-full border-2 border-white/30">
                        @endif
                        <div class="flex-1">
                            <h3 class="text-lg font-bold text-white">{{ $user->name }}</h3>
                            <div class="mt-1">
                                @if($user->is_admin)
                                    <span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-white/20 text-white">
                                        <i class="fas fa-user-shield mr-1"></i>
                                        {{ __('Admin') }}
                                    </span>
                                @else
                                    <span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-white/20 text-white">
                                        <i class="fas fa-user mr-1"></i>
                                        {{ __('User') }}
                                    </span>
                                @endif
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- Card Body -->
                <div class="p-6 space-y-4">
                    <!-- Email -->
                    <div class="flex items-center gap-3">
                        <div class="w-8 h-8 bg-gray-100 dark:bg-dark-700 rounded-lg flex items-center justify-center">
                            <i class="fas fa-envelope text-gray-500 dark:text-gray-400 text-sm"></i>
                        </div>
                        <div class="flex-1 min-w-0">
                            <p class="text-xs text-gray-500 dark:text-gray-400">{{ __('Email') }}</p>
                            <p class="text-sm font-medium text-gray-900 dark:text-white truncate">{{ $user->email }}</p>
                        </div>
                    </div>
                    
                    <!-- Task -->
                    @if($user->task)
                        <div class="flex items-center gap-3">
                            <div class="w-8 h-8 bg-gray-100 dark:bg-dark-700 rounded-lg flex items-center justify-center">
                                <i class="fas fa-briefcase text-gray-500 dark:text-gray-400 text-sm"></i>
                            </div>
                            <div class="flex-1 min-w-0">
                                <p class="text-xs text-gray-500 dark:text-gray-400">{{ __('Task') }}</p>
                                <p class="text-sm font-medium text-gray-900 dark:text-white">{{ $user->task }}</p>
                            </div>
                        </div>
                    @endif
                    
                    <!-- Bio -->
                    @if($user->bio)
                        <div>
                            <p class="text-xs text-gray-500 dark:text-gray-400 mb-1">{{ __('Bio') }}</p>
                            <p class="text-sm text-gray-700 dark:text-gray-300">{{ Str::limit($user->bio, 100) }}</p>
                        </div>
                    @endif
                    
                    <!-- Member Since -->
                    <div class="flex items-center gap-3">
                        <div class="w-8 h-8 bg-gray-100 dark:bg-dark-700 rounded-lg flex items-center justify-center">
                            <i class="fas fa-calendar text-gray-500 dark:text-gray-400 text-sm"></i>
                        </div>
                        <div class="flex-1 min-w-0">
                            <p class="text-xs text-gray-500 dark:text-gray-400">{{ __('Member since') }}</p>
                            <p class="text-sm font-medium text-gray-900 dark:text-white">{{ $user->created_at->format('d.m.Y') }}</p>
                        </div>
                    </div>
                </div>
                
                <!-- Card Footer -->
                <div class="px-6 py-4 bg-gray-50 dark:bg-dark-700/50 border-t border-gray-200 dark:border-dark-700">
                    <a href="mailto:{{ $user->email }}" class="flex items-center justify-center gap-2 w-full px-4 py-2 bg-primary-500 hover:bg-primary-600 text-white rounded-lg transition-colors">
                        <i class="fas fa-envelope"></i>
                        {{ __('Contact') }}
                    </a>
                </div>
            </div>
        @empty
            <div class="col-span-full">
                <div class="bg-white dark:bg-dark-800 rounded-xl border border-gray-200 dark:border-dark-700 p-12 text-center">
                    <i class="fas fa-users text-4xl text-gray-400 mb-4"></i>
                    <p class="text-gray-500 dark:text-gray-400">{{ __('No team members found') }}</p>
                </div>
            </div>
        @endforelse
    </div>
@endsection
