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

{% block title %}{% trans "Manager Review Questions" %} - PX360{% endblock %}

{% block content %}
<div class="p-6 max-w-4xl mx-auto">
    <div class="flex items-center justify-between mb-6">
        <div>
            <h1 class="text-2xl font-bold text-navy">{% trans "Manager Review Questions" %}</h1>
            <p class="text-sm text-slate-500 mt-1">{% trans "Configure questions shown to department managers when reviewing champion responses." %}</p>
        </div>
        <a href="{% url 'organizations:manager_review_question_create' %}"
            class="px-4 py-2 bg-gradient-to-r from-navy to-blue text-white rounded-xl font-semibold hover:opacity-90 transition flex items-center gap-2">
            <i data-lucide="plus" class="w-4 h-4"></i> {% trans "Add Question" %}
        </a>
    </div>

    {% if questions %}
    <div class="bg-white rounded-2xl border border-slate-200 overflow-hidden">
        <table class="w-full">
            <thead class="bg-slate-50 border-b">
                <tr>
                    <th class="px-4 py-3 text-left text-[10px] font-bold text-slate uppercase">#</th>
                    <th class="px-4 py-3 text-left text-[10px] font-bold text-slate uppercase">{% trans "Question" %}</th>
                    <th class="px-4 py-3 text-left text-[10px] font-bold text-slate uppercase">{% trans "Type" %}</th>
                    <th class="px-4 py-3 text-center text-[10px] font-bold text-slate uppercase">{% trans "Active" %}</th>
                    <th class="px-4 py-3 text-center text-[10px] font-bold text-slate uppercase">{% trans "Actions" %}</th>
                </tr>
            </thead>
            <tbody class="divide-y divide-slate-100">
                {% for q in questions %}
                <tr class="hover:bg-slate-50 transition">
                    <td class="px-4 py-3 text-sm text-slate-500">{{ q.order }}</td>
                    <td class="px-4 py-3">
                        <p class="text-sm font-medium text-navy">{{ q.text_en }}</p>
                        {% if q.text_ar %}
                        <p class="text-xs text-slate-500 mt-0.5" dir="rtl">{{ q.text_ar }}</p>
                        {% endif %}
                    </td>
                    <td class="px-4 py-3">
                        <span class="px-2 py-0.5 bg-slate-100 text-slate-600 rounded text-xs font-semibold">{{ q.get_question_type_display }}</span>
                    </td>
                    <td class="px-4 py-3 text-center">
                        {% if q.is_active %}
                        <span class="px-2 py-0.5 bg-green-50 text-green-700 rounded text-[10px] font-bold">{% trans "Active" %}</span>
                        {% else %}
                        <span class="px-2 py-0.5 bg-slate-100 text-slate-500 rounded text-[10px] font-bold">{% trans "Inactive" %}</span>
                        {% endif %}
                    </td>
                    <td class="px-4 py-3 text-center">
                        <div class="flex items-center justify-center gap-2">
                            <a href="{% url 'organizations:manager_review_question_update' q.pk %}"
                                class="p-1.5 text-slate hover:text-navy transition" title="{% trans 'Edit' %}">
                                <i data-lucide="edit-2" class="w-4 h-4"></i>
                            </a>
                            <form method="post" action="{% url 'organizations:manager_review_question_delete' q.pk %}" class="inline"
                                onsubmit="return confirm('{% trans 'Delete this question?' %}')">
                                {% csrf_token %}
                                <button type="submit" class="p-1.5 text-slate hover:text-red-500 transition" title="{% trans 'Delete' %}">
                                    <i data-lucide="trash-2" class="w-4 h-4"></i>
                                </button>
                            </form>
                        </div>
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
    {% else %}
    <div class="text-center py-16 bg-white rounded-2xl border border-slate-200">
        <i data-lucide="clipboard-list" class="w-16 h-16 mx-auto text-slate-300 mb-4"></i>
        <p class="text-slate mb-4">{% trans "No questions configured yet." %}</p>
        <a href="{% url 'organizations:manager_review_question_create' %}"
            class="px-4 py-2 bg-gradient-to-r from-navy to-blue text-white rounded-xl font-semibold hover:opacity-90 transition inline-flex items-center gap-2">
            <i data-lucide="plus" class="w-4 h-4"></i> {% trans "Add First Question" %}
        </a>
    </div>
    {% endif %}
</div>
{% endblock %}
