{% extends 'base.html' %}

{% block content %}
<div class="d-flex justify-content-between align-items-center mb-5">
    <h1 class="h2">Painel de Controle</h1>
    <a href="{% url 'admin_create_game' %}" class="btn btn-primary rounded-pill px-4">+ Criar Novo Jogo</a>
</div>

<div class="row">
    <div class="col-lg-8">
        <div class="glass-card mb-4">
            <h3 class="mb-4">Gerenciar Jogos</h3>
            <div class="table-responsive">
                <table class="table table-dark table-hover">
                    <thead>
                        <tr>
                            <th>Título</th>
                            <th>Gênero</th>
                            <th>Data</th>
                            <th>Status</th>
                            <th>Ações</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for project in projects %}
                        <tr>
                            <td>{{ project.title }}</td>
                            <td>{{ project.get_genre_display }}</td>
                            <td>{{ project.created_at|date:"d/m/Y" }}</td>
                            <td>
                                {% if project.is_active %}
                                <span class="badge bg-success">Ativo</span>
                                {% else %}
                                <span class="badge bg-secondary">Inativo</span>
                                {% endif %}
                            </td>
                            <td>
                                <a href="{% url 'admin_edit_game' project.pk %}" class="btn btn-sm btn-outline-info">Editar</a>
                                <a href="{% url 'admin_delete_game' project.pk %}" class="btn btn-sm btn-outline-danger" onclick="return confirm('Tem certeza?')">Excluir</a>
                            </td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <div class="col-lg-4">
        <div class="glass-card">
            <h3 class="mb-4">Configurar Pagamentos</h3>
            <p class="text-secondary small">Edite os preços e QR Codes para aluguel de tempo.</p>
            <div class="list-group list-group-flush bg-transparent">
                {% for option in rental_options %}
                <div class="list-group-item bg-transparent border-secondary d-flex justify-content-between align-items-center px-0">
                    <div>
                        <div class="fw-bold">{{ option.title }}</div>
                        <div class="text-info">R$ {{ option.price }}</div>
                    </div>
                    <a href="{% url 'admin_edit_rental' option.pk %}" class="btn btn-sm btn-outline-light">Editar</a>
                </div>
                {% endfor %}
            </div>
        </div>
    </div>
</div>
{% endblock %}