{% extends 'base.html' %}
{% load static %}

{% block content %}
<div class="container py-5">
    <div class="d-flex justify-content-between align-items-center mb-5">
        <div>
            <h1 class="display-4 fw-bold text-gradient-neon">BIBLIOTECA STUDIO AI</h1>
            <p class="lead text-muted">Sua coleção de Super Produções geradas por Inteligência Artificial.</p>
        </div>
        <a href="{% url 'studio_ai' %}" class="btn btn-neon-purple fw-bold px-4 py-2 rounded-pill">
            <i class="bi bi-plus-lg me-2"></i> NOVA PRODUÇÃO
        </a>
    </div>

    <div class="row g-4">
        {% for production in productions %}
        <div class="col-md-4">
            <div class="card glass-card border-0 h-100 shadow-sm hover-up overflow-hidden">
                <div class="position-relative">
                    {% if production.thumbnail_url %}
                    <img src="{% static production.thumbnail_url %}" class="card-img-top" alt="{{ production.title }}" style="height: 250px; object-fit: cover;">
                    {% else %}
                    <div class="bg-dark d-flex align-items-center justify-content-center" style="height: 250px;">
                        <i class="bi bi-film text-secondary display-1"></i>
                    </div>
                    {% endif %}
                    <div class="position-absolute top-0 start-0 m-3">
                        <span class="badge bg-cyan text-dark fw-bold px-2 py-1">{{ production.get_project_type_display }}</span>
                    </div>
                    <div class="position-absolute bottom-0 end-0 m-3">
                        <span class="badge bg-black bg-opacity-75 text-white fw-bold"><i class="bi bi-clock me-1"></i>{{ production.duration }}</span>
                    </div>
                </div>
                <div class="card-body p-4 text-white">
                    <div class="d-flex justify-content-between align-items-start mb-2">
                        <h3 class="h4 fw-bold mb-0 text-cyan">{{ production.title }}</h3>
                        <span class="badge border border-secondary text-secondary">{{ production.rating }}</span>
                    </div>
                    <p class="text-muted small mb-3">{{ production.category }} • {{ production.created_at|date:"d/m/Y" }}</p>
                    <p class="card-text text-light-muted mb-4 line-clamp-3">{{ production.description }}</p>
                    <div class="d-grid gap-2">
                        <a href="{% url 'watch_production' production.slug %}" class="btn btn-neon-purple fw-bold rounded-pill">
                            <i class="bi bi-play-fill me-1"></i> ASSISTIR EXPERIÊNCIA
                        </a>
                        <div class="d-flex justify-content-between mt-2">
                            <a href="{% url 'project_detail' production.slug %}" class="btn btn-link btn-sm text-muted text-decoration-none">
                                <i class="bi bi-gear-fill me-1"></i> Pipeline
                            </a>
                            <span class="text-muted small">AI Generation v2.0</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        {% empty %}
        <div class="col-12 text-center py-5">
            <div class="py-5">
                <div class="mb-4">
                    <i class="bi bi-collection-play text-muted display-1 opacity-25"></i>
                </div>
                <h2 class="text-white fw-bold">Ainda não há produções na sua biblioteca.</h2>
                <p class="text-muted lead">O Studio AI está pronto para transformar suas ideias em obras-primas.</p>
                <a href="{% url 'studio_ai' %}" class="btn btn-lg btn-neon-purple mt-3 px-5 py-3 fw-bold rounded-pill">COMEÇAR AGORA</a>
            </div>
        </div>
        {% endfor %}
    </div>
</div>

<style>
    .hover-up {
        transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    }
    .hover-up:hover {
        transform: translateY(-12px);
        box-shadow: 0 20px 40px rgba(0,255,255,0.1) !important;
        border: 1px solid rgba(0, 255, 255, 0.2) !important;
    }
    .text-light-muted {
        color: #adb5bd;
    }
    .line-clamp-3 {
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;  
        overflow: hidden;
    }
</style>
{% endblock %}