{% extends "admin/base.html" %}
{% load static %}
{% block content %}
<div class="k4w-maint-page">
  <section class="k4w-maint-result-hero is-{{ operation.status }}">
    <span class="material-symbols-outlined">{% if operation.status == 'completed' %}check_circle{% elif operation.status == 'failed' %}error{% else %}pending{% endif %}</span>
    <div><span class="k4w-maint-kicker">RESULTADO DA OPERAÇÃO</span><h1>{{ operation.get_status_display }}</h1><p>{{ operation.get_mode_display }} · {{ operation.created_at|date:'d/m/Y H:i:s' }}</p></div>
  </section>

  <section class="k4w-maint-result-cards">
    <article><span>Registos eliminados</span><strong>{{ operation.result.total_deleted|default:0 }}</strong></article>
    <article><span>Ficheiros eliminados</span><strong>{{ operation.result.deleted_files|default:0 }}</strong></article>
    <article><span>Administrador preservado</span><strong>{{ operation.result.preserved_admin|default:'—' }}</strong></article>
    <article><span>Cópia de segurança</span><strong>{% if operation.backup_path %}Criada{% else %}Não criada{% endif %}</strong></article>
  </section>

  <div class="k4w-maint-two-columns">
    <section class="k4w-maint-panel"><header><div><span>DETALHE</span><h2>Resultado por tabela</h2></div></header><div class="k4w-maint-impact-list">{% for label, count in operation.result.breakdown.items %}<div><span class="material-symbols-outlined">table_rows</span><div><strong>{{ label }}</strong></div><b>{{ count }}</b></div>{% empty %}<div class="k4w-maint-empty"><p>Sem detalhe disponível.</p></div>{% endfor %}</div></section>
    <section class="k4w-maint-panel"><header><div><span>AUDITORIA</span><h2>Execução e recuperação</h2></div></header><dl class="k4w-maint-summary"><div><dt>Solicitado por</dt><dd>{{ operation.requested_by|default:'Utilizador removido' }}</dd></div><div><dt>Início</dt><dd>{{ operation.started_at|date:'d/m/Y H:i:s'|default:'—' }}</dd></div><div><dt>Conclusão</dt><dd>{{ operation.completed_at|date:'d/m/Y H:i:s'|default:'—' }}</dd></div><div><dt>Backup</dt><dd class="is-path">{{ operation.backup_path|default:'Não criado' }}</dd></div></dl>{% if operation.error_message %}<div class="k4w-maint-alert is-danger"><pre>{{ operation.error_message }}</pre></div>{% endif %}</section>
  </div>
  <div class="k4w-maint-buttons is-left"><a href="{{ back_url }}">← Voltar à manutenção</a><a href="{% url 'admin:maintenance_databasecleanupoperation_changelist' %}">Abrir histórico</a></div>
</div>
{% endblock %}
