{% extends 'admin/base.html.twig' %}

{% block title %}System Logs{% endblock %}

{% block body %}
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h1 class="h3 mb-0"><i class="bi bi-terminal"></i> System Logs</h1>
    </div>

    <div class="card bg-dark border-secondary">
        <div class="card-body p-0">
            <table class="table table-dark table-striped mb-0">
                <thead>
                <tr>
                    <th>Datei</th>
                    <th>Größe</th>
                    <th>Letzte Änderung</th>
                    <th></th>
                </tr>
                </thead>
                <tbody>
                {% for file in files %}
                    <tr>
                        <td>{% set date = file.name == 'system.log'
                                ? 'current'
                                : file.name|replace({'system-':'','\.log':''}) %}
                        {{ file.name }}</td>
                        <td>{{ (file.size / 1024)|number_format(2) }} KB</td>
                        <td>{{ file.mtime|date('Y-m-d H:i:s') }}</td>
                        <td>
                            <a href="{{ path('admin_system_logs_view', { date: date }) }}"
                               class="btn btn-sm btn-outline-info">
                                Anzeigen
                            </a>
                        </td>
                    </tr>
                {% else %}
                    <tr>
                        <td colspan="4" class="text-center text-muted p-3">
                            Keine Logdateien gefunden.
                        </td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
{% endblock %}