<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Contact Form Submission</title>
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
            line-height: 1.6;
            color: #333;
            max-width: 600px;
            margin: 0 auto;
            padding: 20px;
            background-color: #f8f9fa;
        }
        .container {
            background-color: #ffffff;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            overflow: hidden;
        }
        .header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 30px;
            text-align: center;
        }
        .header h1 {
            margin: 0;
            font-size: 28px;
            font-weight: 600;
        }
        .header p {
            margin: 10px 0 0 0;
            opacity: 0.9;
            font-size: 16px;
        }
        .content {
            padding: 30px;
        }
        .field {
            margin-bottom: 20px;
            padding: 15px;
            background-color: #f8f9fa;
            border-radius: 6px;
            border-left: 4px solid #667eea;
        }
        .field-label {
            font-weight: 600;
            color: #495057;
            font-size: 14px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-bottom: 8px;
        }
        .field-value {
            color: #212529;
            font-size: 16px;
            line-height: 1.5;
        }
        .message-field {
            background-color: #fff;
            border: 1px solid #dee2e6;
            border-radius: 6px;
            padding: 20px;
            margin-top: 10px;
        }
        .message-field .field-value {
            white-space: pre-wrap;
            word-wrap: break-word;
        }
        .metadata {
            margin-top: 30px;
            padding-top: 20px;
            border-top: 1px solid #dee2e6;
            background-color: #f8f9fa;
            padding: 20px;
            border-radius: 6px;
        }
        .metadata h3 {
            margin: 0 0 15px 0;
            color: #495057;
            font-size: 16px;
            font-weight: 600;
        }
        .metadata-item {
            display: flex;
            justify-content: space-between;
            margin-bottom: 8px;
            font-size: 14px;
        }
        .metadata-label {
            color: #6c757d;
            font-weight: 500;
        }
        .metadata-value {
            color: #495057;
        }
        .footer {
            background-color: #f8f9fa;
            padding: 20px;
            text-align: center;
            border-top: 1px solid #dee2e6;
        }
        .footer p {
            margin: 0;
            color: #6c757d;
            font-size: 14px;
        }
        .highlight {
            background-color: #fff3cd;
            border: 1px solid #ffeaa7;
            padding: 15px;
            border-radius: 6px;
            margin-bottom: 20px;
        }
        .highlight strong {
            color: #856404;
        }
        @media (max-width: 600px) {
            body {
                padding: 10px;
            }
            .header, .content {
                padding: 20px;
            }
            .metadata-item {
                flex-direction: column;
                margin-bottom: 12px;
            }
            .metadata-label {
                margin-bottom: 4px;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1>📧 New Contact Form Submission</h1>
            <p>You have received a new message from your website</p>
        </div>

        <div class="content">
            <div class="highlight">
                <strong>Reply directly to this email</strong> to respond to the sender, or use the contact information below.
            </div>

            <div class="field">
                <div class="field-label">Name</div>
                <div class="field-value">{{name}}</div>
            </div>

            <div class="field">
                <div class="field-label">Email Address</div>
                <div class="field-value">
                    <a href="mailto:{{email}}" style="color: #667eea; text-decoration: none;">{{email}}</a>
                </div>
            </div>

            <div class="field">
                <div class="field-label">Subject</div>
                <div class="field-value">{{subject}}</div>
            </div>

            <div class="field">
                <div class="field-label">Message</div>
                <div class="message-field">
                    <div class="field-value">{{message}}</div>
                </div>
            </div>

            {{#if fields}}
            <div class="field">
                <div class="field-label">Additional Information</div>
                <div style="margin-top: 10px;">
                    {{#each fields}}
                    <div style="margin-bottom: 10px; padding: 10px; background-color: #fff; border-radius: 4px; border-left: 3px solid #28a745;">
                        <strong>{{@key}}:</strong> {{this}}
                    </div>
                    {{/each}}
                </div>
            </div>
            {{/if}}

            <div class="metadata">
                <h3>Submission Details</h3>
                <div class="metadata-item">
                    <span class="metadata-label">Submitted:</span>
                    <span class="metadata-value">{{date_format submitted_at "%B %d, %Y at %I:%M %p UTC"}}</span>
                </div>
                <div class="metadata-item">
                    <span class="metadata-label">Form Type:</span>
                    <span class="metadata-value">{{capitalize form_type}}</span>
                </div>
                {{#if ip_address}}
                <div class="metadata-item">
                    <span class="metadata-label">IP Address:</span>
                    <span class="metadata-value">{{ip_address}}</span>
                </div>
                {{/if}}
                {{#if user_agent}}
                <div class="metadata-item">
                    <span class="metadata-label">User Agent:</span>
                    <span class="metadata-value">{{truncate user_agent 100}}</span>
                </div>
                {{/if}}
            </div>
        </div>

        <div class="footer">
            <p>This email was generated automatically from your website contact form.</p>
        </div>
    </div>
</body>
</html>
