<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ title }}</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            line-height: 1.6;
            color: #333;
            max-width: 600px;
            margin: 0 auto;
            padding: 20px;
        }
        .header {
            background-color: {{ primary_color|default('#007bff') }};
            color: white;
            padding: 20px;
            text-align: center;
            border-radius: 5px 5px 0 0;
        }
        .content {
            background-color: #f9f9f9;
            padding: 20px;
            border-left: 1px solid #ddd;
            border-right: 1px solid #ddd;
        }
        .attachments {
            margin-top: 20px;
            padding-top: 20px;
            border-top: 1px solid #ddd;
        }
        .attachments h3 {
            color: #666;
            margin-bottom: 10px;
            font-size: 14px;
        }
        .attachment-list {
            list-style: none;
            padding: 0;
            margin: 0;
        }
        .attachment-list li {
            margin-bottom: 5px;
        }
        .attachment-list a {
            color: {{ primary_color|default('#007bff') }};
            text-decoration: none;
            font-weight: 500;
        }
        .attachment-list a:hover {
            text-decoration: underline;
        }
        .footer {
            background-color: #f5f5f5;
            padding: 15px;
            text-align: center;
            border-radius: 0 0 5px 5px;
            border-left: 1px solid #ddd;
            border-right: 1px solid #ddd;
            border-bottom: 1px solid #ddd;
            font-size: 12px;
            color: #666;
        }
    </style>
</head>
<body>
    <div class="header">
        <h1>{{ title }}</h1>
    </div>

    <div class="content">
        {{ content|safe }}

        {% if attachments %}
        <div class="attachments">
            <h3>Attachments:</h3>
            <ul class="attachment-list">
                {% for attachment in attachments %}
                <li><a href="{{ attachment.url }}">{{ attachment.file_name }}</a></li>
                {% endfor %}
            </ul>
        </div>
        {% endif %}
    </div>

    <div class="footer">
        <p>{{ footer|default('') }}</p>
        <p>Sent on: {{ timestamp }}</p>
    </div>
</body>
</html>
