{% extends "layouts/base.html" %}
{% load i18n %}

{% block title %}{% trans "Completed Acknowledgements" %} - PX360{% endblock %}

{% block extra_css %}
<style>
.page-header-gradient {
    background: linear-gradient(135deg, #005696 0%, #0069a8 50%, #007bbd 100%);
    color: white;
    padding: 1.5rem 2rem;
    border-radius: 1rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 86, 150, 0.2);
}

.section-card {
    background: white;
    border-radius: 1rem;
    border: 2px solid #e2e8f0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: all 0.3s ease;
}
.section-card:hover {
    border-color: #005696;
    box-shadow: 0 10px 25px -5px rgba(0, 86, 150, 0.15);
}

.section-header {
    padding: 1rem 1.5rem;
    border-bottom: 2px solid #e2e8f0;
    background: linear-gradient(to right, #f8fafc, #f1f5f9);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-icon {
    width: 40px;
    height: 40px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
</style>
{% endblock %}

{% block content %}
<div class="p-6 md:p-8 bg-gradient-to-br from-light to-blue-50 min-h-screen">
    <!-- Page Header -->
    <div class="page-header-gradient">
        <div class="flex flex-col md:flex-row justify-between items-start md:items-center gap-4">
            <div class="flex items-center gap-3">
                <div class="section-icon bg-white/20">
                    <i data-lucide="check-circle" class="w-6 h-6 text-white"></i>
                </div>
                <div>
                    <h1 class="text-2xl font-bold">
                        {% trans "Completed Acknowledgements" %}
                    </h1>
                    <p class="text-white/80 text-sm">
                        {% trans "View your signed acknowledgements" %}
                    </p>
                </div>
            </div>
            <div class="flex gap-3">
                <a href="{% url 'accounts:acknowledgements:ack_dashboard' %}" class="inline-flex items-center gap-2 px-5 py-2.5 bg-white/20 border border-white/30 text-white rounded-xl font-semibold hover:bg-white/30 transition">
                    <i data-lucide="arrow-left" class="w-4 h-4"></i>
                    {% trans "Back to Dashboard" %}
                </a>
            </div>
        </div>
    </div>

    <!-- Stats Card -->
    <div class="section-card p-6 mb-6 border-emerald-200">
        <div class="flex items-center gap-3">
            <div class="section-icon bg-emerald-100">
                <i data-lucide="file-check" class="w-6 h-6 text-emerald-600"></i>
            </div>
            <div>
                <p class="text-xs font-semibold text-slate uppercase">{% trans "Total Signed" %}</p>
                <p class="text-3xl font-bold text-emerald-600">{{ acknowledgements.count }}</p>
            </div>
        </div>
    </div>

    <!-- Acknowledgements List -->
    <div class="section-card">
        <div class="section-header">
            <div class="section-icon bg-emerald-100">
                <i data-lucide="clipboard-check" class="w-5 h-5 text-emerald-600"></i>
            </div>
            <h2 class="text-lg font-bold text-navy">{% trans "Signed Documents" %}</h2>
        </div>
        <div class="p-6">
            {% if acknowledgements %}
            <div class="space-y-4">
                {% for ack in acknowledgements %}
                <div class="p-5 border-2 border-emerald-100 rounded-xl bg-emerald-50/30 hover:border-emerald-300 hover:shadow-md transition-all duration-200">
                    <div class="flex flex-col md:flex-row items-start md:items-center justify-between gap-4">
                        <div class="flex-1">
                            <div class="flex flex-wrap items-center gap-2 mb-3">
                                <span class="inline-flex items-center px-2.5 py-1 bg-blue-50 text-blue-700 rounded-lg text-xs font-bold">
                                    {{ ack.checklist_item.category.get_localized_name }}
                                </span>
                                <span class="inline-flex items-center px-2.5 py-1 bg-emerald-100 text-emerald-700 rounded-lg text-xs font-bold">
                                    <i data-lucide="check" class="w-3 h-3 mr-1"></i>
                                    {% trans "Signed" %}
                                </span>
                                {% if ack.checklist_item.code %}
                                <span class="inline-flex items-center px-2 py-1 bg-slate-100 text-slate-600 rounded-lg text-xs font-mono">
                                    {{ ack.checklist_item.code }}
                                </span>
                                {% endif %}
                            </div>
                            <h3 class="font-bold text-navy text-lg mb-2">{{ ack.checklist_item.get_localized_text }}</h3>
                            {% if ack.checklist_item.description_en %}
                            <p class="text-sm text-slate mb-3">{{ ack.checklist_item.description_en }}</p>
                            {% endif %}
                            <div class="flex flex-wrap items-center gap-4 text-sm text-slate">
                                <div class="flex items-center gap-1.5">
                                    <i data-lucide="calendar" class="w-4 h-4"></i>
                                    <span>{% trans "Signed on" %}: {{ ack.acknowledged_at|date:"F d, Y" }}</span>
                                </div>
                                <div class="flex items-center gap-1.5">
                                    <i data-lucide="clock" class="w-4 h-4"></i>
                                    <span>{{ ack.acknowledged_at|time:"H:i" }}</span>
                                </div>
                                {% if ack.signature %}
                                <div class="flex items-center gap-1.5">
                                    <i data-lucide="pen-tool" class="w-4 h-4"></i>
                                    <span>{% trans "Signature" %}: {{ ack.signature }}</span>
                                </div>
                                {% endif %}
                            </div>
                        </div>
                        <div class="flex gap-2">
                            {% if ack.pdf_file %}
                            <a href="{% url 'accounts:acknowledgements:ack_download_pdf' ack.id %}" class="inline-flex items-center gap-2 px-4 py-2.5 bg-gradient-to-r from-blue to-navy text-white rounded-xl font-semibold hover:from-navy hover:to-blue transition shadow-lg shadow-blue-200 text-sm whitespace-nowrap">
                                <i data-lucide="download" class="w-4 h-4"></i>
                                {% trans "Download PDF" %}
                            </a>
                            {% else %}
                            <span class="inline-flex items-center gap-2 px-4 py-2.5 bg-slate-100 text-slate-500 rounded-xl text-sm whitespace-nowrap">
                                <i data-lucide="file-x" class="w-4 h-4"></i>
                                {% trans "PDF not available" %}
                            </span>
                            {% endif %}
                        </div>
                    </div>
                </div>
                {% endfor %}
            </div>
            {% else %}
            <div class="text-center py-16">
                <div class="w-20 h-20 bg-gradient-to-br from-blue-100 to-indigo-100 rounded-full flex items-center justify-center mx-auto mb-4">
                    <i data-lucide="clipboard-list" class="w-10 h-10 text-blue-500"></i>
                </div>
                <h3 class="text-lg font-bold text-navy mb-2">{% trans "No Completed Acknowledgements" %}</h3>
                <p class="text-slate mb-6">{% trans "You haven't signed any acknowledgements yet." %}</p>
                <a href="{% url 'accounts:acknowledgements:ack_dashboard' %}" class="inline-flex items-center gap-2 px-6 py-3 bg-gradient-to-r from-blue to-navy text-white rounded-xl font-semibold hover:from-navy hover:to-blue transition shadow-lg shadow-blue-200">
                    <i data-lucide="clipboard-check" class="w-5 h-5"></i>
                    {% trans "View Pending Acknowledgements" %}
                </a>
            </div>
            {% endif %}
        </div>
    </div>
</div>

<script>
document.addEventListener('DOMContentLoaded', function() {
    lucide.createIcons();
});
</script>
{% endblock %}
