<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Duplicati Backup Report</title>
    <style>
        body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif; line-height: 1.6; max-width: 800px; margin: 0 auto; padding: 20px; background: #f5f5f5; }
        .container { background: white; border-radius: 8px; padding: 30px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
        h1 { margin-top: 0; color: #333; }
        .status { display: inline-block; padding: 8px 16px; border-radius: 4px; font-weight: bold; text-transform: uppercase; }
        .status.success { background: #d4edda; color: #155724; }
        .status.warning { background: #fff3cd; color: #856404; }
        .status.error { background: #f8d7da; color: #721c24; }
        .status.fatal { background: #721c24; color: white; }
        .section { margin: 20px 0; padding: 15px; background: #f8f9fa; border-radius: 4px; }
        .section h2 { margin-top: 0; font-size: 1.1em; color: #495057; }
        table { width: 100%; border-collapse: collapse; }
        td { padding: 8px 0; border-bottom: 1px solid #eee; }
        td:first-child { font-weight: 500; color: #666; width: 40%; }
        .logs { background: #2d2d2d; color: #f8f8f2; padding: 15px; border-radius: 4px; font-family: monospace; font-size: 13px; overflow-x: auto; max-height: 400px; overflow-y: auto; }
        .logs p { margin: 4px 0; }
        .error-box { background: #f8d7da; border: 1px solid #f5c6cb; padding: 15px; border-radius: 4px; color: #721c24; }
        .footer { margin-top: 20px; padding-top: 20px; border-top: 1px solid #eee; color: #888; font-size: 0.9em; }
    </style>
</head>
<body>
    <div class="container">
        <h1>Duplicati Backup Report</h1>

        <p><span class="status {{statusClass ParsedResult}}">{{ParsedResult}}</span></p>

        <div class="section">
            <h2>Backup Details</h2>
            <table>
                <tr><td>Operation</td><td>{{OperationName}}</td></tr>
                {{#if BackupName}}<tr><td>Backup Name</td><td>{{BackupName}}</td></tr>{{/if}}
                {{#if MachineName}}<tr><td>Machine</td><td>{{MachineName}}</td></tr>{{/if}}
                {{#if OperatingSystem}}<tr><td>OS</td><td>{{OperatingSystem}}</td></tr>{{/if}}
            </table>
        </div>

        {{#if Data}}
        <div class="section">
            <h2>Statistics</h2>
            <table>
                {{#if Data.ExaminedFiles}}<tr><td>Files Examined</td><td>{{Data.ExaminedFiles}}</td></tr>{{/if}}
                {{#if Data.SizeOfExaminedFiles}}<tr><td>Data Examined</td><td>{{formatSize Data.SizeOfExaminedFiles}}</td></tr>{{/if}}
                {{#if Data.AddedFiles}}<tr><td>Files Added</td><td>{{Data.AddedFiles}}</td></tr>{{/if}}
                {{#if Data.SizeOfAddedFiles}}<tr><td>Data Added</td><td>{{formatSize Data.SizeOfAddedFiles}}</td></tr>{{/if}}
                {{#if Data.ModifiedFiles}}<tr><td>Files Modified</td><td>{{Data.ModifiedFiles}}</td></tr>{{/if}}
                {{#if Data.SizeOfModifiedFiles}}<tr><td>Data Modified</td><td>{{formatSize Data.SizeOfModifiedFiles}}</td></tr>{{/if}}
                {{#if Data.DeletedFiles}}<tr><td>Files Deleted</td><td>{{Data.DeletedFiles}}</td></tr>{{/if}}
                {{#if Data.Duration}}<tr><td>Duration</td><td>{{formatDuration Data.Duration}}</td></tr>{{/if}}
            </table>
        </div>
        {{/if}}

        {{#if LogLines}}
        <div class="section">
            <h2>Log Messages</h2>
            <div class="logs">
                {{#each LogLines}}
                <p>{{this}}</p>
                {{/each}}
            </div>
        </div>
        {{/if}}

        {{#if Exception}}
        <div class="section">
            <h2>Error Details</h2>
            <div class="error-box">
                <pre>{{Exception}}</pre>
            </div>
        </div>
        {{/if}}

        <div class="footer">
            Generated by Duplicati
        </div>
    </div>
</body>
</html>
