{{define "title"}}View Full Message - Email Log{{end}}

{{define "content"}}
<div class="container mt-4">
    <h2>Full Message Content</h2>
    <div class="mb-3">
        <strong>From:</strong> {{.log.mail_from}}<br>
        <strong>To:</strong> {{.log.to_address}}<br>
        <strong>CC:</strong> {{if .log.cc_addresses}}{{.log.cc_addresses}}{{else}}None{{end}}<br>
        <strong>BCC:</strong> {{if .log.bcc_addresses}}{{.log.bcc_addresses}}{{else}}None{{end}}<br>
        <strong>Subject:</strong> {{if .log.subject}}{{.log.subject}}{{else}}N/A{{end}}<br>
        <strong>Date:</strong> {{strftime "%Y-%m-%d %H:%M:%S" .log.created_at}}<br>
    </div>

    {{if .log.attachments}}
    <div class="card mb-3">
        <div class="card-header"><strong>Attachments:</strong></div>
        <div class="card-body">
            <ul class="list-group">
            {{range .log.attachments}}
                <li class="list-group-item d-flex justify-content-between align-items-center">
                    <div><i class="fas fa-paperclip"></i> {{.Filename}} <small class="text-muted">({{filesize .Size}})</small></div>
                    <div class="btn-group" role="group">
                        <a href="/pymta-manager/msg/attachment/{{.ID}}/download" class="btn btn-sm btn-outline-primary" target="_blank" title="Open in new tab"><i class="fas fa-external-link-alt"></i> View</a>
                        <a href="/pymta-manager/msg/attachment/{{.ID}}/download?download=true" class="btn btn-sm btn-outline-secondary" title="Download file"><i class="fas fa-download"></i> Download</a>
                        <form method="POST" action="/pymta-manager/msg/attachment/{{.ID}}/delete" style="display: inline;">
                            <button type="submit" class="btn btn-sm btn-outline-danger" title="Delete attachment" data-confirm="Are you sure you want to delete this attachment?"><i class="fas fa-trash-alt"></i> Delete</button>
                        </form>
                    </div>
                </li>
            {{end}}
            </ul>
        </div>
    </div>
    {{end}}

    <div class="card">
        <div class="card-header"><strong>Message Content:</strong></div>
        <div class="card-body"><pre style="white-space: pre-wrap; word-break: break-all;">{{.log.message_body}}</pre></div>
    </div>

    <div class="card mt-3">
        <div class="card-header"><strong>Message Headers:</strong></div>
        <div class="card-body"><pre style="white-space: pre-wrap;">{{.log.email_headers}}</pre></div>
    </div>

    <a href="/pymta-manager/logs?type=emails" class="btn btn-secondary mt-3">Back to Logs</a>
</div>
{{end}}
