{% extends 'client_portal/base.html' %}{% load portal_tags %}{% block content %}<a class="portal-back" href="{% url 'client_portal:tickets' %}">← Voltar aos tickets</a><div class="portal-detail-hero ticket-hero"><div><p>{{ ticket.reference }} · {{ ticket.get_category_display|upper }}</p><h2>{{ ticket.subject }}</h2><span>Última atividade em {{ ticket.last_activity_at|date:'d/m/Y H:i' }}</span></div><div><span class="status status--lg status--{{ ticket.status|status_tone }}">{{ ticket.get_status_display }}</span></div></div><div class="portal-conversation">{% for item in ticket_messages %}<article class="message {% if item.author_type == 'client' %}message--client{% elif item.author_type == 'system' %}message--system{% else %}message--staff{% endif %}"><header><div><strong>{{ item.author_name|default:item.get_author_type_display }}</strong><small>{{ item.created_at|date:'d/m/Y H:i' }}</small></div><span>{{ item.get_author_type_display }}</span></header><div class="message-body">{{ item.message|linebreaksbr }}</div>{% if item.attachment %}<a class="message-attachment" href="{% url 'client_portal:ticket_attachment' item.pk %}">📎 {{ item.attachment.name|basename }}</a>{% endif %}</article>{% empty %}<div class="portal-empty">Sem mensagens.</div>{% endfor %}</div>{% if ticket.status == 'resolved' or ticket.status == 'closed' %}<div class="portal-resolution"><div><strong>Este ticket está resolvido.</strong><p>Pode reabri-lo caso a situação persista.</p></div><form method="post" action="{% url 'client_portal:ticket_reopen' ticket.pk %}">{% csrf_token %}<button class="portal-button portal-button--outline" type="submit">Reabrir ticket</button></form></div>{% else %}<div class="portal-reply-card"><form method="post" enctype="multipart/form-data" class="portal-form">{% csrf_token %}{% for field in form %}<label>{{ field.label }}{{ field }}{% for error in field.errors %}<em>{{ error }}</em>{% endfor %}</label>{% endfor %}<div class="reply-actions"><button class="portal-button portal-button--primary" type="submit">Enviar resposta</button></div></form><form method="post" action="{% url 'client_portal:ticket_resolve' ticket.pk %}" onsubmit="return confirm('Marcar este ticket como resolvido?')">{% csrf_token %}<button class="portal-button portal-button--success" type="submit">✓ Marcar como resolvido</button></form></div>{% endif %}{% endblock %}
