{% extends 'layouts/base.html' %}
{% load i18n static %}

{% block title %}{% trans "Presentations" %} — PX360{% endblock %}

{% block extra_css %}
<link rel="stylesheet" href="{% static 'css/presentations/slide-theme.css' %}">
<style>
    .presentation-card {
        transition: all 0.3s ease;
        cursor: pointer;
    }
    .presentation-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 12px 32px rgba(0, 86, 150, 0.12);
        border-color: var(--navy);
    }
    .slide-preview {
        aspect-ratio: 16/9;
        background: linear-gradient(135deg, #005696 0%, #007bbd 50%, #0EA5E9 100%);
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        font-weight: 700;
        font-size: 14px;
        position: relative;
        overflow: hidden;
    }
    .slide-preview::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 40%;
        background: linear-gradient(transparent, rgba(0,0,0,0.3));
    }
</style>
{% endblock %}

{% block content %}
<div class="max-w-7xl mx-auto">
    <div class="flex items-center justify-between mb-8">
        <div>
            <h1 class="text-2xl font-bold text-gray-800">{% trans "Presentations" %}</h1>
            <p class="text-sm text-gray-500 mt-1">{% trans "Create and present beautiful slide decks from your reports" %}</p>
        </div>
        <div class="flex items-center gap-3">
            <a href="{% url 'presentations:template_list' %}" class="bg-white border-2 border-teal text-teal px-5 py-2.5 rounded-xl hover:bg-teal/5 transition flex items-center gap-2 font-medium text-sm">
                <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"/></svg>
                {% trans "Templates" %}
            </a>
            <a href="{% url 'presentations:generate' %}" class="bg-gradient-to-r from-navy to-teal text-white px-5 py-2.5 rounded-xl hover:opacity-90 transition flex items-center gap-2 font-medium text-sm">
                <i data-lucide="sparkles" class="w-4 h-4"></i>
                {% trans "Generate" %}
            </a>
            <a href="{% url 'presentations:create' %}" class="bg-navy text-white px-5 py-2.5 rounded-xl hover:bg-navy/90 transition flex items-center gap-2 font-medium text-sm">
                <i data-lucide="plus" class="w-4 h-4"></i>
                {% trans "New Presentation" %}
            </a>
        </div>
    </div>

    <div class="flex items-center gap-3 mb-6">
        <a href="{% url 'presentations:list' %}" class="px-4 py-2 rounded-lg text-sm font-medium {% if not status_filter %}bg-navy text-white{% else %}text-gray-600 hover:bg-gray-100{% endif %} transition">
            {% trans "All" %}
        </a>
        {% for status_val, status_label in status_choices %}
        <a href="?status={{ status_val }}" class="px-4 py-2 rounded-lg text-sm font-medium {% if status_filter == status_val %}bg-navy text-white{% else %}text-gray-600 hover:bg-gray-100{% endif %} transition">
            {{ status_label }}
        </a>
        {% endfor %}
    </div>

    {% if presentations %}
    <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
        {% for pres in presentations %}
        <a href="{% url 'presentations:detail' pk=pres.pk %}" class="presentation-card bg-white rounded-2xl border-2 border-gray-200 overflow-hidden block">
            <div class="slide-preview">
                <span class="relative z-10">{{ pres.slide_count }} {% trans "slides" %}</span>
            </div>
            <div class="p-5">
                <h3 class="font-bold text-gray-800 text-lg mb-1">{{ pres.title }}</h3>
                {% if pres.subtitle %}
                <p class="text-sm text-gray-500 mb-3 line-clamp-2">{{ pres.subtitle }}</p>
                {% endif %}
                <div class="flex items-center justify-between">
                    <div class="flex items-center gap-2">
                        <span class="px-2.5 py-1 rounded-full text-xs font-semibold
                            {% if pres.status == 'published' %}bg-green-50 text-green-700
                            {% elif pres.status == 'draft' %}bg-amber-50 text-amber-700
                            {% else %}bg-gray-50 text-gray-500{% endif %}">
                            {{ pres.get_status_display }}
                        </span>
                        <span class="text-xs text-gray-400">{{ pres.created_at|date:"M d, Y" }}</span>
                    </div>
                    {% if pres.hospital %}
                    <span class="text-xs text-gray-400">{{ pres.hospital.name }}</span>
                    {% endif %}
                </div>
            </div>
        </a>
        {% endfor %}
    </div>
    {% else %}
    <div class="bg-white rounded-2xl border-2 border-gray-200 p-16 text-center">
        <div class="w-20 h-20 bg-blue-50 rounded-full flex items-center justify-center mx-auto mb-6">
            <i data-lucide="presentation" class="w-10 h-10 text-navy"></i>
        </div>
        <h3 class="text-xl font-bold text-gray-800 mb-2">{% trans "No Presentations Yet" %}</h3>
        <p class="text-gray-500 mb-6 max-w-md mx-auto">{% trans "Create your first presentation to replace PDF and PowerPoint reports with beautiful in-app slides." %}</p>
        <div class="flex items-center justify-center gap-3">
            <a href="{% url 'presentations:generate' %}" class="bg-gradient-to-r from-navy to-teal text-white px-6 py-3 rounded-xl hover:opacity-90 transition inline-flex items-center gap-2 font-medium">
                <i data-lucide="sparkles" class="w-4 h-4"></i>
                {% trans "Generate with AI" %}
            </a>
            <a href="{% url 'presentations:create' %}" class="bg-navy text-white px-6 py-3 rounded-xl hover:bg-navy/90 transition inline-flex items-center gap-2 font-medium">
                <i data-lucide="plus" class="w-4 h-4"></i>
                {% trans "Create Manually" %}
            </a>
        </div>
    </div>
    {% endif %}
</div>
{% endblock %}
