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

{% block title %}{% trans "Appreciation Categories" %} - 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;
    }

    .category-table {
        width: 100%;
        border-collapse: separate;
        border-spacing: 0;
    }
    .category-table th {
        padding: 0.875rem 1.5rem;
        text-align: left;
        font-size: 0.75rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: #64748b;
        background: #f8fafc;
        border-bottom: 2px solid #e2e8f0;
    }
    .category-table td {
        padding: 1rem 1.5rem;
        border-bottom: 1px solid #e2e8f0;
        vertical-align: middle;
    }
    .category-table tr:hover td {
        background: #f8fafc;
    }
    .category-table tr:last-child td {
        border-bottom: none;
    }
</style>
{% endblock %}

{% block content %}
<!-- Page Header Gradient -->
<div class="page-header-gradient">
    <div class="flex justify-between items-start">
        <div>
            <h1 class="text-2xl font-bold flex items-center gap-3">
                <i data-lucide="tags" class="w-7 h-7"></i>
                {% trans "Appreciation Categories" %}
            </h1>
            <p class="text-sm opacity-90 mt-1">{% trans "Manage categories to organize appreciations" %}</p>
        </div>
        <a href="{% url 'appreciation:category_create' %}" class="bg-white text-navy px-5 py-2.5 rounded-xl text-sm font-bold shadow-lg hover:bg-gray-100 flex items-center gap-2 transition">
            <i data-lucide="plus" class="w-4 h-4"></i> {% trans "Add Category" %}
        </a>
    </div>
</div>

<!-- Breadcrumb -->
<nav class="mb-6 text-sm">
    <ol class="flex items-center gap-2 text-slate">
        <li><a href="{% url 'appreciation:appreciation_list' %}" class="hover:text-navy transition">{% trans "Appreciation" %}</a></li>
        <li><i data-lucide="chevron-right" class="w-4 h-4"></i></li>
        <li class="text-navy font-medium">{% trans "Categories" %}</li>
    </nav>
</nav>

<!-- Categories List -->
<div class="section-card">
    <div class="section-header">
        <div class="section-icon bg-blue-100">
            <i data-lucide="tags" class="w-5 h-5 text-blue-600"></i>
        </div>
        <h3 class="font-bold text-navy">{% trans "All Categories" %}</h3>
    </div>
    <div class="p-0">
        {% if categories %}
            <div class="overflow-x-auto">
                <table class="category-table">
                    <thead>
                        <tr>
                            <th>{% trans "Icon" %}</th>
                            <th>{% trans "Name (English)" %}</th>
                            <th>{% trans "Name (Arabic)" %}</th>
                            <th>{% trans "Color" %}</th>
                            <th>{% trans "Count" %}</th>
                            <th class="text-center">{% trans "Actions" %}</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for category in categories %}
                            <tr>
                                <td>
                                    <div class="w-10 h-10 bg-blue-100 rounded-lg flex items-center justify-center">
                                        <i data-lucide="{{ category.icon|default:'tag' }}" class="w-5 h-5 text-blue-600"></i>
                                    </div>
                                </td>
                                <td>
                                    <span class="font-medium text-navy">{{ category.get_localized_name }}</span>
                                </td>
                                <td dir="rtl">
                                    <span class="font-medium text-navy">{{ category.name_ar }}</span>
                                </td>
                                <td>
                                    <span class="inline-flex items-center px-2.5 py-1 rounded-lg text-xs font-bold bg-{{ category.color }}-100 text-{{ category.color }}-700">
                                        {{ category.color|title }}
                                    </span>
                                </td>
                                <td>
                                    <span class="inline-flex items-center justify-center w-8 h-8 bg-slate-100 rounded-full text-sm font-bold text-slate">
                                        {{ category.appreciation_count }}
                                    </span>
                                </td>
                                <td class="text-center">
                                    <div class="flex items-center justify-center gap-2">
                                        <a href="{% url 'appreciation:category_edit' category.id %}" class="inline-flex items-center justify-center w-9 h-9 border border-navy text-navy rounded-lg hover:bg-navy hover:text-white transition">
                                            <i data-lucide="pencil" class="w-4 h-4"></i>
                                        </a>
                                        <a href="{% url 'appreciation:category_delete' category.id %}" class="inline-flex items-center justify-center w-9 h-9 border border-red-500 text-red-500 rounded-lg hover:bg-red-500 hover:text-white transition">
                                            <i data-lucide="trash-2" class="w-4 h-4"></i>
                                        </a>
                                    </div>
                                </td>
                            </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        {% else %}
            <div class="text-center py-12">
                <div class="w-16 h-16 bg-blue-50 rounded-full flex items-center justify-center mx-auto mb-4">
                    <i data-lucide="tags" class="w-8 h-8 text-blue-400"></i>
                </div>
                <h4 class="text-lg font-bold text-navy mb-2">{% trans "No categories found" %}</h4>
                <p class="text-slate mb-4">{% trans "Create categories to organize appreciations" %}</p>
                <a href="{% url 'appreciation:category_create' %}" class="bg-navy text-white px-5 py-2.5 rounded-xl text-sm font-bold hover:bg-blue transition inline-flex items-center gap-2">
                    <i data-lucide="plus" class="w-4 h-4"></i> {% trans "Add Category" %}
                </a>
            </div>
        {% endif %}
    </div>
</div>
{% endblock %}
