{% extends "base.html" %}

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

{% block content %}
<h1>👥 Players</h1>
{% include "components/nav.html" %}

<div style="margin-bottom: 20px;">
    <a href="/players/new" class="btn btn-success">➕ Add Player</a>
</div>

{% if players.is_empty() %}
    <div class="alert alert-info">
        No players yet. <a href="/players/new">Create one</a> to get started!
    </div>
{% else %}
    <table>
        <thead>
            <tr>
                <th>Name</th>
                <th>Rating</th>
                <th>Matches</th>
                <th>Win Rate</th>
                <th>Email</th>
                <th>Actions</th>
            </tr>
        </thead>
        <tbody>
            {% for player in players %}
            <tr>
                <td><a href="/players/{{ player.id }}"><strong>{{ player.name }}</strong></a></td>
                <td style="font-weight: bold; color: #003594;">{{ player.rating }}</td>
                <td>{{ player.match_count }}</td>
                <td>{{ player.win_rate }}%</td>
                <td>{{ player.email.unwrap_or_default() }}</td>
                <td>
                    <a href="/players/{{ player.id }}" class="btn">View</a>
                    <a href="/players/{{ player.id }}/edit" class="btn btn-warning">Edit</a>
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
{% endif %}
{% endblock %}
