{% extends "admin/base_admin.html" %}

{% block title %}Select Group{% endblock %}

{% block content %}
<div class="px-4 py-6 mx-auto max-w-screen-xl">
    <div class="mb-6">
        <h1 class="text-3xl font-bold text-gray-900">Select Group</h1>
        <p class="text-gray-600 mt-2">Choose a group to manage</p>
    </div>

    <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
        {% for group in groups %}
        <div class="bg-white rounded-lg shadow-md hover:shadow-lg transition-shadow duration-200 border border-gray-200">
            <div class="p-6">
                <div class="flex items-center justify-between mb-4">
                    <h3 class="text-xl font-semibold text-gray-900">{{ group.name }}</h3>
                    <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
                        {{ group.group_code }}
                    </span>
                </div>
                
                {% if group.description %}
                <p class="text-gray-600 mb-4">{{ group.description }}</p>
                {% endif %}
                
                <div class="flex items-center justify-between text-sm text-gray-500 mb-4">
                    <span>{{ group.members|length }} members</span>
                    <span>{{ group.currency_ref.symbol if group.currency_ref else '৳' }}</span>
                </div>
                
                <a href="{{ url_for('group_admin_dashboard', group_code=group.group_code) }}" 
                   class="w-full inline-flex items-center justify-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors duration-200">
                    <i class="fas fa-arrow-right mr-2"></i>
                    Manage Group
                </a>
            </div>
        </div>
        {% endfor %}
        
        {% if not groups %}
        <div class="col-span-full text-center py-12">
            <div class="text-gray-400 mb-4">
                <i class="fas fa-users text-6xl"></i>
            </div>
            <h3 class="text-lg font-medium text-gray-900 mb-2">No Groups Available</h3>
            <p class="text-gray-500 mb-4">You don't have access to any groups yet.</p>
            {% if current_user.is_superadmin %}
            <a href="{{ url_for('superadmin_add_group') }}" 
               class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700">
                <i class="fas fa-plus mr-2"></i>
                Create First Group
            </a>
            {% endif %}
        </div>
        {% endif %}
    </div>
</div>
{% endblock %}