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

{% block title %}{% trans "Onboarding Progress Detail" %}{% endblock %}

{% block content %}
<div class="p-6 md:p-8 bg-gradient-to-br from-light to-blue-50 min-h-screen">
    <!-- Header -->
    <div class="flex flex-col md:flex-row md:items-center md:justify-between gap-4 mb-8">
        <div class="flex items-center gap-3">
            <div class="flex items-center justify-center w-14 h-14 bg-gradient-to-br from-blue to-purple-500 rounded-2xl shadow-lg shadow-blue-200">
                <span class="text-white font-bold text-xl">{{ account.first_name|first|default:"U" }}</span>
            </div>
            <div>
                <a href="{% url 'accounts:onboarding-dashboard' %}" class="inline-flex items-center text-blue hover:text-navy mb-2 font-medium">
                    <i data-lucide="arrow-left" class="w-4 h-4 mr-2"></i>
                    {% trans "Back to Dashboard" %}
                </a>
                <h1 class="text-3xl font-bold text-navy">
                    {{ account.get_full_name|default:account.email }}
                </h1>
                <p class="text-slate">
                    {{ account.email }}
                </p>
            </div>
        </div>
        <div class="flex gap-3">
            <span class="inline-flex items-center bg-blue-50 border border-blue-200 text-navy px-4 py-2 rounded-xl font-medium">
                <i data-lucide="mail" class="w-4 h-4 mr-2 text-blue"></i>
                {{ account.email }}
            </span>
            <span class="inline-flex items-center bg-white border border-blue-100 text-slate px-4 py-2 rounded-xl font-medium">
                <i data-lucide="calendar" class="w-4 h-4 mr-2 text-blue"></i>
                {{ account.created_at|date:"M d, Y" }}
            </span>
        </div>
    </div>

    <!-- Progress Overview -->
    <div class="bg-white rounded-2xl shadow-sm border border-blue-100 p-8 mb-8">
        <h2 class="text-xl font-bold text-navy mb-6 flex items-center gap-2">
            <i data-lucide="circle-help" class="w-5 h-5 text-blue"></i>
            {% trans "Progress Overview" %}
        </h2>
        <div class="grid grid-cols-1 md:grid-cols-4 gap-6">
            <div class="text-center p-6 bg-gradient-to-br from-blue-50 to-indigo-50 rounded-2xl border border-blue-100">
                <div class="text-5xl font-bold text-navy mb-2">
                    {{ progress.overall_percentage|default:0 }}%
                </div>
                <div class="text-sm text-slate font-medium mb-3">{% trans "Overall Progress" %}</div>
                <div class="w-full bg-blue-100 h-3 rounded-full overflow-hidden">
                    <div class="bg-gradient-to-r from-blue to-navy h-full rounded-full" style="width: {{ progress.overall_percentage|default:0 }}%"></div>
                </div>
            </div>
            <div class="text-center p-6 bg-white rounded-2xl border-2 border-blue-100">
                <div class="flex items-center justify-center w-12 h-12 bg-gradient-to-br from-blue to-cyan-500 rounded-xl mx-auto mb-3">
                    <i data-lucide="list-checks" class="w-6 h-6 text-white"></i>
                </div>
                <div class="text-3xl font-bold text-navy mb-2">
                    {{ progress.checklist_completed|default:0 }}/{{ progress.checklist_total|default:0 }}
                </div>
                <div class="text-sm text-slate">{% trans "Checklist Items" %}</div>
            </div>
            <div class="text-center p-6 bg-white rounded-2xl border-2 border-blue-100">
                <div class="flex items-center justify-center w-12 h-12 bg-gradient-to-br from-blue to-indigo-500 rounded-xl mx-auto mb-3">
                    <i data-lucide="file-text" class="w-6 h-6 text-white"></i>
                </div>
                <div class="text-3xl font-bold text-navy mb-2">
                    {{ progress.content_viewed|default:0 }}/{{ progress.content_total|default:0 }}
                </div>
                <div class="text-sm text-slate">{% trans "Content Items" %}</div>
            </div>
            <div class="text-center p-6 bg-white rounded-2xl border-2 border-blue-100">
                <div class="flex items-center justify-center w-12 h-12 bg-gradient-to-br from-blue to-purple-500 rounded-xl mx-auto mb-3">
                    <i data-lucide="footprints" class="w-6 h-6 text-white"></i>
                </div>
                <div class="text-3xl font-bold text-navy mb-2">
                    {{ progress.current_step|default:"-" }}
                </div>
                <div class="text-sm text-slate">{% trans "Current Step" %}</div>
            </div>
        </div>
    </div>

    <!-- Progress Timeline -->
    <div class="bg-white rounded-2xl shadow-sm border border-blue-100 p-8 mb-8">
        <h2 class="text-xl font-bold text-navy mb-6 flex items-center gap-2">
            <i data-lucide="timeline" class="w-5 h-5 text-blue"></i>
            {% trans "Onboarding Timeline" %}
        </h2>

        <div class="space-y-6">
            <!-- Step 1 -->
            <div class="flex gap-4">
                <div class="flex flex-col items-center">
                    <div class="flex items-center justify-center w-12 h-12 rounded-full {% if progress.activation_complete %}bg-gradient-to-br from-blue to-navy{% else %}bg-slate-200{% endif %} flex-shrink-0">
                        {% if progress.activation_complete %}
                            <i data-lucide="check" class="w-6 h-6 text-white"></i>
                        {% else %}
                            <span class="text-slate-500 font-bold">1</span>
                        {% endif %}
                    </div>
                    {% if not progress.checklist_complete %}<div class="w-0.5 h-16 bg-slate-200"></div>{% endif %}
                </div>
                <div class="flex-1 pb-6">
                    <div class="flex items-center justify-between mb-2">
                        <h3 class="font-bold text-navy">{% trans "Account Activation" %}</h3>
                        {% if progress.activation_complete %}
                            <span class="inline-flex items-center gap-1 text-sm font-bold text-emerald-600">
                                <i data-lucide="check-circle" class="w-4 h-4"></i>
                                {% trans "Completed" %}
                            </span>
                        {% else %}
                            <span class="inline-flex items-center gap-1 text-sm font-medium text-slate-500">
                                <i data-lucide="clock" class="w-4 h-4"></i>
                                {% trans "Pending" %}
                            </span>
                        {% endif %}
                    </div>
                    <p class="text-sm text-slate">{% trans "Create account and set password" %}</p>
                    {% if progress.activation_completed_at %}
                        <p class="text-xs text-slate mt-2">
                            <i data-lucide="clock" class="w-3 h-3 inline mr-1"></i>
                            {{ progress.activation_completed_at|date:"M d, Y H:i" }}
                        </p>
                    {% endif %}
                </div>
            </div>

            <!-- Step 2 -->
            <div class="flex gap-4">
                <div class="flex flex-col items-center">
                    <div class="flex items-center justify-center w-12 h-12 rounded-full {% if progress.checklist_complete %}bg-gradient-to-br from-blue to-navy{% else %}bg-slate-200{% endif %} flex-shrink-0">
                        {% if progress.checklist_complete %}
                            <i data-lucide="check" class="w-6 h-6 text-white"></i>
                        {% else %}
                            <span class="text-slate-500 font-bold">2</span>
                        {% endif %}
                    </div>
                    {% if not progress.content_complete %}<div class="w-0.5 h-16 bg-slate-200"></div>{% endif %}
                </div>
                <div class="flex-1 pb-6">
                    <div class="flex items-center justify-between mb-2">
                        <h3 class="font-bold text-navy">{% trans "Checklist Completion" %}</h3>
                        {% if progress.checklist_complete %}
                            <span class="inline-flex items-center gap-1 text-sm font-bold text-emerald-600">
                                <i data-lucide="check-circle" class="w-4 h-4"></i>
                                {% trans "Completed" %}
                            </span>
                        {% else %}
                            <span class="inline-flex items-center gap-1 text-sm font-medium text-slate-500">
                                <i data-lucide="clock" class="w-4 h-4"></i>
                                {% trans "In Progress" %}
                            </span>
                        {% endif %}
                    </div>
                    <p class="text-sm text-slate">{% trans "Complete all required checklist items" %}</p>
                    {% if progress.checklist_completed_at %}
                        <p class="text-xs text-slate mt-2">
                            <i data-lucide="clock" class="w-3 h-3 inline mr-1"></i>
                            {{ progress.checklist_completed_at|date:"M d, Y H:i" }}
                        </p>
                    {% endif %}
                </div>
            </div>

            <!-- Step 3 -->
            <div class="flex gap-4">
                <div class="flex flex-col items-center">
                    <div class="flex items-center justify-center w-12 h-12 rounded-full {% if progress.content_complete %}bg-gradient-to-br from-blue to-navy{% else %}bg-slate-200{% endif %} flex-shrink-0">
                        {% if progress.content_complete %}
                            <i data-lucide="check" class="w-6 h-6 text-white"></i>
                        {% else %}
                            <span class="text-slate-500 font-bold">3</span>
                        {% endif %}
                    </div>
                </div>
                <div class="flex-1">
                    <div class="flex items-center justify-between mb-2">
                        <h3 class="font-bold text-navy">{% trans "Content Review" %}</h3>
                        {% if progress.content_complete %}
                            <span class="inline-flex items-center gap-1 text-sm font-bold text-emerald-600">
                                <i data-lucide="check-circle" class="w-4 h-4"></i>
                                {% trans "Completed" %}
                            </span>
                        {% else %}
                            <span class="inline-flex items-center gap-1 text-sm font-medium text-slate-500">
                                <i data-lucide="clock" class="w-4 h-4"></i>
                                {% trans "Pending" %}
                            </span>
                        {% endif %}
                    </div>
                    <p class="text-sm text-slate">{% trans "Review all onboarding content sections" %}</p>
                    {% if progress.content_completed_at %}
                        <p class="text-xs text-slate mt-2">
                            <i data-lucide="clock" class="w-3 h-3 inline mr-1"></i>
                            {{ progress.content_completed_at|date:"M d, Y H:i" }}
                        </p>
                    {% endif %}
                </div>
            </div>
        </div>
    </div>

    <!-- Detailed Checklist -->
    <div class="bg-white rounded-2xl shadow-sm border border-blue-100 overflow-hidden">
        <div class="px-6 py-5 border-b border-blue-100 bg-gradient-to-r from-blue-50 to-transparent">
            <h3 class="font-bold text-navy flex items-center gap-2">
                <i data-lucide="list-checks" class="w-5 h-5 text-blue"></i>
                {% trans "Detailed Checklist Progress" %}
            </h3>
        </div>
        <div class="p-6">
            {% if progress.checklist_details %}
            <div class="space-y-3">
                {% for item in progress.checklist_details %}
                <div class="flex items-center gap-4 p-4 {% if item.completed %}bg-emerald-50 border border-emerald-100{% else %}bg-slate-50 border border-slate-100{% endif %} rounded-xl">
                    <div class="flex items-center justify-center w-8 h-8 {% if item.completed %}bg-emerald-500{% else %}bg-slate-300{% endif %} rounded-lg flex-shrink-0">
                        {% if item.completed %}
                            <i data-lucide="check" class="w-5 h-5 text-white"></i>
                        {% else %}
                            <i data-lucide="minus" class="w-5 h-5 text-white"></i>
                        {% endif %}
                    </div>
                    <div class="flex-1">
                        <p class="font-bold text-navy">{{ item.name }}</p>
                        {% if item.completed_at %}
                            <p class="text-xs text-slate">
                                <i data-lucide="clock" class="w-3 h-3 inline mr-1"></i>
                                {{ item.completed_at|date:"M d, Y H:i" }}
                            </p>
                        {% endif %}
                    </div>
                    {% if item.required %}
                    <span class="inline-flex items-center px-2 py-1 rounded-full text-xs font-bold {% if item.completed %}bg-emerald-100 text-emerald-700{% else %}bg-red-100 text-red-700{% endif %}">
                        {% trans "Required" %}
                    </span>
                    {% endif %}
                </div>
                {% endfor %}
            </div>
            {% else %}
            <div class="text-center py-12">
                <i data-lucide="list-checks" class="w-12 h-12 text-blue-200 mx-auto mb-3"></i>
                <p class="text-slate">{% trans "No checklist items available" %}</p>
            </div>
            {% endif %}
        </div>
    </div>
</div>

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