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

{% block title %}{% trans "Roadmaps" %} - {% trans "Roadmap Manager" %}{% endblock %}

{% block extrastyle %}
{% include 'roadmap/manager/_roadmap_styles.html' %}
{% endblock %}

{% block content %}
<div class="roadmap-manager-bg">
    <div class="container">
        <div class="d-flex flex-column flex-md-row justify-content-between align-items-start align-items-md-center mb-5 roadmap-animate-in">
            <div class="roadmap-page-header mb-3 mb-md-0">
                <h2 class="mb-2">
                    <i class="bi bi-list-ul text-warning me-2"></i>
                    {% trans "Itens do Roadmap" %}
                </h2>
                <p>{% trans "Gerencie todos os itens do roadmap" %}</p>
            </div>
            <div class="d-flex gap-3">
                <a href="{% url 'roadmap:manager_dashboard' %}" class="roadmap-btn-solid-white">
                    <i class="bi bi-arrow-left me-2"></i>{% trans "Voltar" %}
                </a>
                <a href="{% url 'roadmap:manager_roadmap_create' %}" class="roadmap-btn-primary">
                    <i class="bi bi-plus-circle me-2"></i>{% trans "Novo Item" %}
                </a>
            </div>
        </div>

        <!-- Filtros -->
        <div class="roadmap-card mb-4 roadmap-animate-in">
            <div class="card-header">
                <h5 class="mb-0">
                    <i class="bi bi-funnel me-2"></i>
                    {% trans "Filtros" %}
                </h5>
            </div>
            <div class="card-body">
                <form method="get" class="row g-4">
                    <div class="col-md-4">
                        <label class="roadmap-form-label">
                            <i class="bi bi-tag"></i>
                            {% trans "Status" %}
                        </label>
                        <select name="status" class="roadmap-form-control form-select">
                            <option value="all" {% if status_filter == 'all' %}selected{% endif %}>{% trans "Todos" %}</option>
                            <option value="planned" {% if status_filter == 'planned' %}selected{% endif %}>{% trans "Planejado" %}</option>
                            <option value="in_progress" {% if status_filter == 'in_progress' %}selected{% endif %}>{% trans "Em Andamento" %}</option>
                            <option value="completed" {% if status_filter == 'completed' %}selected{% endif %}>{% trans "Concluído" %}</option>
                        </select>
                    </div>
                    <div class="col-md-4">
                        <label class="roadmap-form-label">
                            <i class="bi bi-eye"></i>
                            {% trans "Publicado" %}
                        </label>
                        <select name="published" class="roadmap-form-control form-select">
                            <option value="all" {% if published_filter == 'all' %}selected{% endif %}>{% trans "Todos" %}</option>
                            <option value="yes" {% if published_filter == 'yes' %}selected{% endif %}>{% trans "Sim" %}</option>
                            <option value="no" {% if published_filter == 'no' %}selected{% endif %}>{% trans "Não" %}</option>
                        </select>
                    </div>
                    <div class="col-md-4 d-flex align-items-end">
                        <button type="submit" class="roadmap-btn-primary w-100">
                            <i class="bi bi-funnel me-2"></i>{% trans "Filtrar" %}
                        </button>
                    </div>
                </form>
            </div>
        </div>

        <!-- Lista de Roadmaps -->
        <div class="roadmap-card roadmap-animate-in">
            <div class="card-body">
                {% if roadmaps %}
                <div class="roadmap-table-wrapper">
                    <div class="table-responsive">
                        <table class="table table-dark">
                            <thead>
                                <tr>
                                    <th>{% trans "Título" %}</th>
                                    <th>{% trans "Status" %}</th>
                                    <th>{% trans "Publicado" %}</th>
                                    <th>{% trans "Autor" %}</th>
                                    <th>{% trans "Data" %}</th>
                                    <th>{% trans "Ações" %}</th>
                                </tr>
                            </thead>
                            <tbody>
                                {% for roadmap in roadmaps %}
                                <tr>
                                    <td>
                                        <div class="d-flex align-items-center">
                                            <i class="bi bi-diagram-3 me-2 text-warning roadmap-icon"></i>
                                            <strong>
                                                {% for trans in roadmap.translations.all %}
                                                    {% if trans.language == 'pt' %}
                                                        {{ trans.title }}
                                                    {% endif %}
                                                {% empty %}
                                                    Roadmap #{{ roadmap.id }}
                                                {% endfor %}
                                            </strong>
                                        </div>
                                    </td>
                                    <td>
                                        <span class="roadmap-badge status-{{ roadmap.status }}">
                                            {{ roadmap.get_status_display }}
                                        </span>
                                    </td>
                                    <td>
                                        {% if roadmap.is_published %}
                                        <span class="roadmap-badge badge-active">{% trans "Sim" %}</span>
                                        {% else %}
                                        <span class="roadmap-badge badge-inactive">{% trans "Não" %}</span>
                                        {% endif %}
                                    </td>
                                    <td>{{ roadmap.author.username }}</td>
                                    <td>{{ roadmap.pub_date|date:"d/m/Y" }}</td>
                                    <td>
                                        <div class="btn-group" role="group">
                                            <a href="{% url 'roadmap:manager_roadmap_detail' roadmap_id=roadmap.id %}" 
                                               class="btn roadmap-action-btn btn-info" 
                                               title="{% trans 'Ver Detalhes' %}">
                                                <i class="bi bi-eye"></i>
                                            </a>
                                            <a href="{% url 'roadmap:manager_roadmap_edit' roadmap_id=roadmap.id %}" 
                                               class="btn roadmap-action-btn btn-warning" 
                                               title="{% trans 'Editar' %}">
                                                <i class="bi bi-pencil"></i>
                                            </a>
                                            <a href="{% url 'roadmap:manager_roadmap_delete' roadmap_id=roadmap.id %}" 
                                               class="btn roadmap-action-btn btn-danger" 
                                               title="{% trans 'Deletar' %}">
                                                <i class="bi bi-trash"></i>
                                            </a>
                                        </div>
                                    </td>
                                </tr>
                                {% endfor %}
                            </tbody>
                        </table>
                    </div>
                </div>
                {% else %}
                <div class="text-center py-5">
                    <i class="bi bi-diagram-3" style="font-size: 5rem; color: rgba(251, 191, 36, 0.3);"></i>
                    <h4 class="text-white mt-4 mb-3" style="font-weight: 700;">{% trans "Nenhum item encontrado" %}</h4>
                    <p class="text-white mb-4" style="opacity: 0.8;">{% trans "Crie seu primeiro item do roadmap" %}</p>
                    <a href="{% url 'roadmap:manager_roadmap_create' %}" class="roadmap-btn-primary">
                        <i class="bi bi-plus-circle me-2"></i>{% trans "Criar Item" %}
                    </a>
                </div>
                {% endif %}
            </div>
        </div>
    </div>
</div>
{% endblock %}