{% extends "base.html" %}

{% block title %}Players - Pickleball ELO Tracker{% endblock %}

{% block content %}
<h1 class="pitt-primary text-4xl font-bold mb-8 text-center">👥 Players</h1>

{% include "components/nav.html" %}

{% if players.is_empty() %}
    <div class="alert-info">
        No players yet. <a href="/players/new" class="font-bold hover:underline">Add the first player</a>!
    </div>
{% else %}
    <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
        {% for player in players %}
        <div class="card">
            <h3 class="pitt-primary font-bold text-xl mb-2">
                <a href="/players/{{ player.id }}" class="hover:underline">{{ player.name }}</a>
            </h3>
            <div class="grid grid-cols-2 gap-4 mb-4">
                <div>
                    <div class="text-xs text-gray-500 uppercase">Rating</div>
                    <div class="text-2xl font-bold pitt-primary">{{ player.rating_display }}</div>
                </div>
                <div>
                    <div class="text-xs text-gray-500 uppercase">Record</div>
                    <div class="text-2xl font-bold">
                        <span class="text-green-600">{{ player.wins }}</span>-<span class="text-red-600">{{ player.losses }}</span>
                    </div>
                </div>
            </div>
            {% if player.has_email %}
                <p class="text-sm text-gray-600 mb-4">📧 {{ player.email }}</p>
            {% endif %}
            <div class="flex gap-2">
                <a href="/players/{{ player.id }}" class="btn-primary text-sm flex-1">View Profile</a>
                <a href="/players/{{ player.id }}/edit" class="btn-warning text-sm flex-1">Edit</a>
            </div>
        </div>
        {% endfor %}
    </div>
{% endif %}
{% endblock %}
