{% extends 'base.html' %}

{% block content %}
<div class="mb-5">
    <h1 class="display-4 fw-bold">Biblioteca de <span class="text-info">Jogos</span></h1>
    <p class="text-secondary">Escolha um título e alugue tempo para jogar instantaneamente.</p>
</div>

<div class="row g-4">
    {% for project in projects %}
    <div class="col-md-4">
        <div class="glass-card h-100 p-0 overflow-hidden d-flex flex-column border-0">
            <div style="height: 200px; background: linear-gradient(45deg, #1e293b, #0f172a); display: flex; align-items: center; justify-content: center;">
                {% if project.image_reference %}
                    <img src="{{ project.image_reference.url }}" class="w-100 h-100 object-fit-cover" alt="{{ project.title }}">
                {% else %}
                    <span class="display-1 opacity-25">🎮</span>
                {% endif %}
            </div>
            <div class="p-4 flex-grow-1 d-flex flex-column">
                <span class="badge bg-info text-dark mb-2 align-self-start">{{ project.get_genre_display }}</span>
                <h3 class="h4 mb-3">{{ project.title }}</h3>
                <p class="text-secondary small mb-4 flex-grow-1">{{ project.prompt|truncatewords:20 }}</p>
                <a href="{% url 'purchase_game' project.pk %}" class="btn btn-primary w-100 rounded-pill">ALUGAR TEMPO</a>
            </div>
        </div>
    </div>
    {% empty %}
    <div class="col-12 text-center py-5">
        <p class="text-secondary">Nenhum jogo disponível no momento.</p>
    </div>
    {% endfor %}
</div>
{% endblock %}
