<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Overdue Payment Notice</title>
    <style>
        body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; line-height: 1.6; color: #333; margin: 0; padding: 0; background-color: #f5f5f5; }
        .container { max-width: 600px; margin: 20px auto; background: #ffffff; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); overflow: hidden; border-top: 4px solid #dc2626; }
        .header { background: #dc2626; color: #ffffff; padding: 30px 20px; text-align: center; }
        .header img { max-width: 200px; height: auto; margin-bottom: 10px; }
        .header h1 { margin: 0; font-size: 24px; font-weight: 600; }
        .overdue-badge { background: #fee2e2; color: #991b1b; padding: 10px 20px; border-radius: 6px; font-weight: 700; display: inline-block; margin: 15px 0; font-size: 16px; }
        .content { padding: 30px 20px; }
        .greeting { font-size: 18px; font-weight: 500; margin-bottom: 20px; }
        .message { margin-bottom: 20px; }
        .invoice-details { background: #fef2f2; border: 2px solid #fecaca; padding: 20px; margin: 20px 0; border-radius: 6px; }
        .invoice-details table { width: 100%; }
        .invoice-details td { padding: 10px 0; }
        .invoice-details td:first-child { font-weight: 600; width: 45%; }
        .amount { font-size: 32px; font-weight: 700; color: #dc2626; }
        .late-fee { background: #fef3c7; color: #92400e; padding: 12px; border-radius: 4px; margin: 15px 0; font-weight: 600; }
        .button { display: inline-block; padding: 14px 35px; background: #dc2626; color: #ffffff !important; text-decoration: none; border-radius: 6px; font-weight: 600; margin: 20px 0; font-size: 16px; }
        .button:hover { background: #b91c1c; }
        .warning-box { background: #fffbeb; border-left: 4px solid #f59e0b; padding: 15px; margin: 20px 0; border-radius: 4px; }
        .footer { background: #f8f9fa; padding: 20px; text-align: center; font-size: 12px; color: #6c757d; border-top: 1px solid #e9ecef; }
        .footer a { color: #dc2626; text-decoration: none; }
        @media only screen and (max-width: 600px) {
            .container { margin: 0; border-radius: 0; }
            .content { padding: 20px 15px; }
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            {{#if header_image_url}}
            <img src="{{header_image_url}}" alt="Company Logo">
            {{/if}}
            <h1>🔴 OVERDUE PAYMENT NOTICE</h1>
            <div class="overdue-badge">{{days_overdue}} DAYS OVERDUE</div>
        </div>
        
        <div class="content">
            <div class="greeting">Dear {{customer_name}},</div>
            
            <div class="message">
                <p><strong>Our records indicate that the following invoice is now {{days_overdue}} days overdue.</strong></p>
                <p>We have not yet received payment for this invoice. Immediate payment is required to avoid additional late fees and potential service interruption.</p>
            </div>
            
            <div class="invoice-details">
                <table>
                    <tr>
                        <td>Invoice Number:</td>
                        <td><strong>{{invoice_number}}</strong></td>
                    </tr>
                    <tr>
                        <td>Original Due Date:</td>
                        <td><strong style="color: #dc2626;">{{due_date}}</strong></td>
                    </tr>
                    <tr>
                        <td>Amount Due:</td>
                        <td class="amount">{{currency_symbol}}{{amount_due}}</td>
                    </tr>
                    <tr>
                        <td>Days Overdue:</td>
                        <td><strong style="color: #dc2626; font-size: 18px;">{{days_overdue}} Days</strong></td>
                    </tr>
                </table>
            </div>
            
            {{#if late_fee_amount}}
            <div class="late-fee">
                ⚠️ Late Fee Applied: {{currency_symbol}}{{late_fee_amount}}
            </div>
            {{/if}}
            
            <center>
                <a href="{{payment_link}}" class="button">MAKE PAYMENT NOW</a>
            </center>
            
            <div class="warning-box">
                <p><strong>⚠️ Important Notice:</strong></p>
                <p>If payment is not received within the next {{grace_period_days}} days, your account may be:</p>
                <ul style="margin: 10px 0;">
                    <li>Subject to additional late fees</li>
                    <li>Placed on hold for future services</li>
                    <li>Referred to collections</li>
                </ul>
            </div>
            
            <div class="message">
                <p><strong>Need Help?</strong></p>
                <p>If you are experiencing financial difficulties or need to discuss payment arrangements, please contact our accounts team immediately at <a href="mailto:{{accounts_email}}">{{accounts_email}}</a> or call {{accounts_phone}}.</p>
            </div>
            
            <div class="message" style="margin-top: 30px; font-size: 14px; color: #6c757d;">
                <p>If you have recently made this payment, please contact us with your payment reference and disregard this notice.</p>
            </div>
        </div>
        
        <div class="footer">
            <p>{{footer_text}}</p>
            <p>
                <a href="{{company_website}}">Visit Our Website</a> | 
                <a href="mailto:{{accounts_email}}">Contact Accounts</a> | 
                <a href="{{unsubscribe_link}}">Unsubscribe</a>
            </p>
        </div>
    </div>
    
    <!-- Tracking Pixel -->
    <img src="{{tracking_pixel_url}}" width="1" height="1" style="display:none;" alt="">
</body>
</html>