{% extends 'base.html' %}

{% block content %}
<div class="container">
    <div class="row align-items-center mb-5">
        <div class="col-lg-7">
            <h1 class="display-4 fw-bold mb-3">Create Magic with AI.</h1>
            <p class="lead text-secondary mb-4">Transform your ideas into viral short-form videos in seconds. No editing skills required.</p>
        </div>
        <div class="col-lg-5">
            <div class="glass-panel p-4 p-md-5">
                <h3 class="mb-4">New Project</h3>
                <form action="{% url 'create_project' %}" method="POST">
                    {% csrf_token %}
                    <div class="mb-3">
                        <label class="form-label text-white-50">Project Title</label>
                        <input type="text" name="title" class="form-control bg-dark text-white border-secondary" placeholder="e.g. My Awesome TikTok" required>
                    </div>
                    <div class="mb-4">
                        <label class="form-label text-white-50">Short Description (Optional)</label>
                        <textarea name="description" class="form-control bg-dark text-white border-secondary" rows="2"></textarea>
                    </div>
                    <button type="submit" class="btn btn-accent w-100">Start Creating</button>
                </form>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-12 mb-4">
            <h2 class="h3 mb-0">Recent Projects</h2>
        </div>
        
        {% for project in projects %}
        <div class="col-md-6 col-lg-4 mb-4">
            <div class="card-studio h-100 d-flex flex-column">
                <div class="d-flex justify-content-between align-items-start mb-3">
                    <span class="status-badge status-{{ project.status }}">{{ project.get_status_display }}</span>
                    <span class="text-white-50 small">{{ project.created_at|date:"M d, Y" }}</span>
                </div>
                <h4 class="mb-2">{{ project.title }}</h4>
                <p class="text-secondary small flex-grow-1">{{ project.description|truncatewords:20 }}</p>
                <div class="mt-4">
                    <a href="{% url 'project_detail' project.id %}" class="btn btn-outline-light btn-sm w-100 rounded-pill">Open Studio</a>
                </div>
            </div>
        </div>
        {% empty %}
        <div class="col-12">
            <div class="text-center py-5 border border-dashed rounded-4 border-secondary">
                <p class="text-secondary mb-0">No projects yet. Start by creating your first one above!</p>
            </div>
        </div>
        {% endfor %}
    </div>
</div>
{% endblock %}
