-- ============================================
-- Migration 013: Update Email Templates with Background Image
-- Adds S3-hosted Monaco background image to all email templates
-- Matches login screen styling: image + gradient overlay
-- ============================================

-- Background image URL
-- Using: https://s3.monacousa.org/public/monaco_high_res.jpg
-- Gradient overlay: from-slate-900/80 via-slate-900/60 to-monaco-900/70

-- =====================
-- Update Welcome Email Template
-- =====================
UPDATE public.email_templates
SET body_html = '<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <!--[if mso]>
  <style type="text/css">
    body, table, td { font-family: Arial, sans-serif !important; }
  </style>
  <![endif]-->
</head>
<body style="margin: 0; padding: 0; font-family: Arial, sans-serif; background-color: #0f172a;">
  <!--[if gte mso 9]>
  <v:background xmlns:v="urn:schemas-microsoft-com:vml" fill="t">
    <v:fill type="tile" src="https://s3.monacousa.org/public/monaco_high_res.jpg" color="#0f172a"/>
  </v:background>
  <![endif]-->
  <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="background-image: url(''https://s3.monacousa.org/public/monaco_high_res.jpg''); background-size: cover; background-position: center; background-color: #0f172a;">
    <tr>
      <td>
        <div style="background: linear-gradient(135deg, rgba(15, 23, 42, 0.8) 0%, rgba(15, 23, 42, 0.6) 50%, rgba(127, 29, 29, 0.7) 100%);">
          <table role="presentation" width="100%" cellspacing="0" cellpadding="0">
            <tr>
              <td align="center" style="padding: 40px 20px;">
                <!-- Logo Section -->
                <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="max-width: 480px;">
                  <tr>
                    <td align="center" style="padding-bottom: 30px;">
                      <div style="background: rgba(255, 255, 255, 0.95); border-radius: 16px; padding: 12px; display: inline-block; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);">
                        <img src="{{logo_url}}" alt="Monaco USA" width="80" height="80" style="display: block; border-radius: 8px;">
                      </div>
                      <h1 style="margin: 16px 0 4px 0; font-size: 24px; font-weight: bold; color: #ffffff; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);">Monaco <span style="color: #fca5a5;">USA</span></h1>
                      <p style="margin: 0; font-size: 14px; color: rgba(255, 255, 255, 0.8);">Americans in Monaco</p>
                    </td>
                  </tr>
                </table>

                <!-- Main Content Card -->
                <table role="presentation" cellspacing="0" cellpadding="0" style="max-width: 480px; width: 100%; background: #ffffff; border-radius: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);">
                  <tr>
                    <td style="padding: 40px;">
                      <h2 style="margin: 0 0 20px 0; color: #CE1126; font-size: 24px;">Welcome to Monaco USA!</h2>
                      <p style="margin: 0 0 16px 0; color: #334155; line-height: 1.6;">Dear {{first_name}},</p>
                      <p style="margin: 0 0 16px 0; color: #334155; line-height: 1.6;">We are thrilled to welcome you to the Monaco USA community! Your membership has been created and you can now access all member features.</p>
                      <p style="margin: 0 0 12px 0; color: #334155; font-weight: 600;">To get started:</p>
                      <ol style="margin: 0 0 20px 20px; padding: 0; color: #334155; line-height: 1.8;">
                        <li>Set up your password using the separate email we sent</li>
                        <li>Complete your profile with your details</li>
                        <li>Explore upcoming events and connect with fellow members</li>
                      </ol>
                      <p style="margin: 0 0 20px 0; color: #334155; line-height: 1.6;">If you have any questions, please don''t hesitate to reach out to our board members.</p>
                      <p style="margin: 0; color: #334155;">Best regards,<br><strong style="color: #CE1126;">The Monaco USA Team</strong></p>
                    </td>
                  </tr>
                </table>

                <!-- Footer -->
                <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="max-width: 480px;">
                  <tr>
                    <td align="center" style="padding-top: 24px;">
                      <p style="margin: 0; font-size: 12px; color: rgba(255, 255, 255, 0.5);">&copy; 2026 Monaco USA. All rights reserved.</p>
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
          </table>
        </div>
      </td>
    </tr>
  </table>
</body>
</html>'
WHERE template_key = 'welcome';

-- =====================
-- Update RSVP Confirmation Template
-- =====================
UPDATE public.email_templates
SET body_html = '<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <!--[if mso]>
  <style type="text/css">
    body, table, td { font-family: Arial, sans-serif !important; }
  </style>
  <![endif]-->
</head>
<body style="margin: 0; padding: 0; font-family: Arial, sans-serif; background-color: #0f172a;">
  <!--[if gte mso 9]>
  <v:background xmlns:v="urn:schemas-microsoft-com:vml" fill="t">
    <v:fill type="tile" src="https://s3.monacousa.org/public/monaco_high_res.jpg" color="#0f172a"/>
  </v:background>
  <![endif]-->
  <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="background-image: url(''https://s3.monacousa.org/public/monaco_high_res.jpg''); background-size: cover; background-position: center; background-color: #0f172a;">
    <tr>
      <td>
        <div style="background: linear-gradient(135deg, rgba(15, 23, 42, 0.8) 0%, rgba(15, 23, 42, 0.6) 50%, rgba(127, 29, 29, 0.7) 100%);">
          <table role="presentation" width="100%" cellspacing="0" cellpadding="0">
            <tr>
              <td align="center" style="padding: 40px 20px;">
                <!-- Logo Section -->
                <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="max-width: 480px;">
                  <tr>
                    <td align="center" style="padding-bottom: 30px;">
                      <div style="background: rgba(255, 255, 255, 0.95); border-radius: 16px; padding: 12px; display: inline-block; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);">
                        <img src="{{logo_url}}" alt="Monaco USA" width="80" height="80" style="display: block; border-radius: 8px;">
                      </div>
                      <h1 style="margin: 16px 0 4px 0; font-size: 24px; font-weight: bold; color: #ffffff; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);">Monaco <span style="color: #fca5a5;">USA</span></h1>
                      <p style="margin: 0; font-size: 14px; color: rgba(255, 255, 255, 0.8);">Americans in Monaco</p>
                    </td>
                  </tr>
                </table>

                <!-- Main Content Card -->
                <table role="presentation" cellspacing="0" cellpadding="0" style="max-width: 480px; width: 100%; background: #ffffff; border-radius: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);">
                  <tr>
                    <td style="padding: 40px;">
                      <h2 style="margin: 0 0 20px 0; color: #CE1126; font-size: 24px;">RSVP Confirmed!</h2>
                      <p style="margin: 0 0 16px 0; color: #334155; line-height: 1.6;">Dear {{first_name}},</p>
                      <p style="margin: 0 0 16px 0; color: #334155; line-height: 1.6;">Your RSVP has been confirmed for the following event:</p>
                      <div style="background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: 20px; margin: 0 0 20px 0;">
                        <p style="margin: 0 0 8px 0; color: #CE1126; font-size: 18px; font-weight: 600;">{{event_title}}</p>
                        <p style="margin: 0 0 4px 0; color: #334155; font-size: 14px;"><strong>Date:</strong> {{event_date}}</p>
                        <p style="margin: 0 0 4px 0; color: #334155; font-size: 14px;"><strong>Location:</strong> {{event_location}}</p>
                        <p style="margin: 0; color: #334155; font-size: 14px;"><strong>Guests:</strong> {{guest_count}}</p>
                      </div>
                      <p style="margin: 0 0 16px 0; color: #334155; line-height: 1.6;">We look forward to seeing you there!</p>
                      <p style="margin: 0; color: #334155;">Best regards,<br><strong style="color: #CE1126;">The Monaco USA Team</strong></p>
                    </td>
                  </tr>
                </table>

                <!-- Footer -->
                <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="max-width: 480px;">
                  <tr>
                    <td align="center" style="padding-top: 24px;">
                      <p style="margin: 0; font-size: 12px; color: rgba(255, 255, 255, 0.5);">&copy; 2026 Monaco USA. All rights reserved.</p>
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
          </table>
        </div>
      </td>
    </tr>
  </table>
</body>
</html>'
WHERE template_key = 'rsvp_confirmation';

-- =====================
-- Update Payment Received Template
-- =====================
UPDATE public.email_templates
SET body_html = '<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <!--[if mso]>
  <style type="text/css">
    body, table, td { font-family: Arial, sans-serif !important; }
  </style>
  <![endif]-->
</head>
<body style="margin: 0; padding: 0; font-family: Arial, sans-serif; background-color: #0f172a;">
  <!--[if gte mso 9]>
  <v:background xmlns:v="urn:schemas-microsoft-com:vml" fill="t">
    <v:fill type="tile" src="https://s3.monacousa.org/public/monaco_high_res.jpg" color="#0f172a"/>
  </v:background>
  <![endif]-->
  <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="background-image: url(''https://s3.monacousa.org/public/monaco_high_res.jpg''); background-size: cover; background-position: center; background-color: #0f172a;">
    <tr>
      <td>
        <div style="background: linear-gradient(135deg, rgba(15, 23, 42, 0.8) 0%, rgba(15, 23, 42, 0.6) 50%, rgba(127, 29, 29, 0.7) 100%);">
          <table role="presentation" width="100%" cellspacing="0" cellpadding="0">
            <tr>
              <td align="center" style="padding: 40px 20px;">
                <!-- Logo Section -->
                <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="max-width: 480px;">
                  <tr>
                    <td align="center" style="padding-bottom: 30px;">
                      <div style="background: rgba(255, 255, 255, 0.95); border-radius: 16px; padding: 12px; display: inline-block; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);">
                        <img src="{{logo_url}}" alt="Monaco USA" width="80" height="80" style="display: block; border-radius: 8px;">
                      </div>
                      <h1 style="margin: 16px 0 4px 0; font-size: 24px; font-weight: bold; color: #ffffff; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);">Monaco <span style="color: #fca5a5;">USA</span></h1>
                      <p style="margin: 0; font-size: 14px; color: rgba(255, 255, 255, 0.8);">Americans in Monaco</p>
                    </td>
                  </tr>
                </table>

                <!-- Main Content Card -->
                <table role="presentation" cellspacing="0" cellpadding="0" style="max-width: 480px; width: 100%; background: #ffffff; border-radius: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);">
                  <tr>
                    <td style="padding: 40px;">
                      <h2 style="margin: 0 0 20px 0; color: #CE1126; font-size: 24px;">Payment Received</h2>
                      <p style="margin: 0 0 16px 0; color: #334155; line-height: 1.6;">Dear {{first_name}},</p>
                      <p style="margin: 0 0 16px 0; color: #334155; line-height: 1.6;">Thank you! We have received your membership dues payment.</p>
                      <div style="background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 12px; padding: 20px; margin: 0 0 20px 0;">
                        <p style="margin: 0 0 8px 0; color: #166534; font-size: 14px; font-weight: 600;">Payment Details:</p>
                        <p style="margin: 0 0 4px 0; color: #334155; font-size: 14px;"><strong>Amount:</strong> {{amount}}</p>
                        <p style="margin: 0 0 4px 0; color: #334155; font-size: 14px;"><strong>Payment Date:</strong> {{payment_date}}</p>
                        <p style="margin: 0 0 4px 0; color: #334155; font-size: 14px;"><strong>Period:</strong> {{period_start}} - {{period_end}}</p>
                        <p style="margin: 0; color: #334155; font-size: 14px;"><strong>Member ID:</strong> {{member_id}}</p>
                      </div>
                      <p style="margin: 0 0 16px 0; color: #334155; line-height: 1.6;">Your membership is now active through {{period_end}}. Thank you for your continued support of Monaco USA!</p>
                      <p style="margin: 0; color: #334155;">Best regards,<br><strong style="color: #CE1126;">The Monaco USA Team</strong></p>
                    </td>
                  </tr>
                </table>

                <!-- Footer -->
                <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="max-width: 480px;">
                  <tr>
                    <td align="center" style="padding-top: 24px;">
                      <p style="margin: 0; font-size: 12px; color: rgba(255, 255, 255, 0.5);">&copy; 2026 Monaco USA. All rights reserved.</p>
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
          </table>
        </div>
      </td>
    </tr>
  </table>
</body>
</html>'
WHERE template_key = 'payment_received';

-- =====================
-- Update Waitlist Promotion Template
-- =====================
UPDATE public.email_templates
SET body_html = '<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <!--[if mso]>
  <style type="text/css">
    body, table, td { font-family: Arial, sans-serif !important; }
  </style>
  <![endif]-->
</head>
<body style="margin: 0; padding: 0; font-family: Arial, sans-serif; background-color: #0f172a;">
  <!--[if gte mso 9]>
  <v:background xmlns:v="urn:schemas-microsoft-com:vml" fill="t">
    <v:fill type="tile" src="https://s3.monacousa.org/public/monaco_high_res.jpg" color="#0f172a"/>
  </v:background>
  <![endif]-->
  <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="background-image: url(''https://s3.monacousa.org/public/monaco_high_res.jpg''); background-size: cover; background-position: center; background-color: #0f172a;">
    <tr>
      <td>
        <div style="background: linear-gradient(135deg, rgba(15, 23, 42, 0.8) 0%, rgba(15, 23, 42, 0.6) 50%, rgba(127, 29, 29, 0.7) 100%);">
          <table role="presentation" width="100%" cellspacing="0" cellpadding="0">
            <tr>
              <td align="center" style="padding: 40px 20px;">
                <!-- Logo Section -->
                <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="max-width: 480px;">
                  <tr>
                    <td align="center" style="padding-bottom: 30px;">
                      <div style="background: rgba(255, 255, 255, 0.95); border-radius: 16px; padding: 12px; display: inline-block; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);">
                        <img src="{{logo_url}}" alt="Monaco USA" width="80" height="80" style="display: block; border-radius: 8px;">
                      </div>
                      <h1 style="margin: 16px 0 4px 0; font-size: 24px; font-weight: bold; color: #ffffff; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);">Monaco <span style="color: #fca5a5;">USA</span></h1>
                      <p style="margin: 0; font-size: 14px; color: rgba(255, 255, 255, 0.8);">Americans in Monaco</p>
                    </td>
                  </tr>
                </table>

                <!-- Main Content Card -->
                <table role="presentation" cellspacing="0" cellpadding="0" style="max-width: 480px; width: 100%; background: #ffffff; border-radius: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);">
                  <tr>
                    <td style="padding: 40px;">
                      <h2 style="margin: 0 0 20px 0; color: #CE1126; font-size: 24px;">Great News!</h2>
                      <p style="margin: 0 0 16px 0; color: #334155; line-height: 1.6;">Dear {{first_name}},</p>
                      <p style="margin: 0 0 16px 0; color: #334155; line-height: 1.6;">A spot has opened up! You have been promoted from the waitlist for:</p>
                      <div style="background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 12px; padding: 20px; margin: 0 0 20px 0;">
                        <p style="margin: 0 0 8px 0; color: #166534; font-size: 18px; font-weight: 600;">{{event_title}}</p>
                        <p style="margin: 0 0 4px 0; color: #334155; font-size: 14px;"><strong>Date:</strong> {{event_date}}</p>
                        <p style="margin: 0; color: #334155; font-size: 14px;"><strong>Location:</strong> {{event_location}}</p>
                      </div>
                      <p style="margin: 0 0 16px 0; color: #334155; line-height: 1.6;">Your attendance is now confirmed. We look forward to seeing you!</p>
                      <p style="margin: 0; color: #334155;">Best regards,<br><strong style="color: #CE1126;">The Monaco USA Team</strong></p>
                    </td>
                  </tr>
                </table>

                <!-- Footer -->
                <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="max-width: 480px;">
                  <tr>
                    <td align="center" style="padding-top: 24px;">
                      <p style="margin: 0; font-size: 12px; color: rgba(255, 255, 255, 0.5);">&copy; 2026 Monaco USA. All rights reserved.</p>
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
          </table>
        </div>
      </td>
    </tr>
  </table>
</body>
</html>'
WHERE template_key = 'waitlist_promotion';

-- =====================
-- Update Dues Reminder 30 Days Template
-- =====================
UPDATE public.email_templates
SET body_html = '<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <!--[if mso]>
  <style type="text/css">
    body, table, td { font-family: Arial, sans-serif !important; }
  </style>
  <![endif]-->
</head>
<body style="margin: 0; padding: 0; font-family: Arial, sans-serif; background-color: #0f172a;">
  <!--[if gte mso 9]>
  <v:background xmlns:v="urn:schemas-microsoft-com:vml" fill="t">
    <v:fill type="tile" src="https://s3.monacousa.org/public/monaco_high_res.jpg" color="#0f172a"/>
  </v:background>
  <![endif]-->
  <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="background-image: url(''https://s3.monacousa.org/public/monaco_high_res.jpg''); background-size: cover; background-position: center; background-color: #0f172a;">
    <tr>
      <td>
        <div style="background: linear-gradient(135deg, rgba(15, 23, 42, 0.8) 0%, rgba(15, 23, 42, 0.6) 50%, rgba(127, 29, 29, 0.7) 100%);">
          <table role="presentation" width="100%" cellspacing="0" cellpadding="0">
            <tr>
              <td align="center" style="padding: 40px 20px;">
                <!-- Logo Section -->
                <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="max-width: 480px;">
                  <tr>
                    <td align="center" style="padding-bottom: 30px;">
                      <div style="background: rgba(255, 255, 255, 0.95); border-radius: 16px; padding: 12px; display: inline-block; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);">
                        <img src="{{logo_url}}" alt="Monaco USA" width="80" height="80" style="display: block; border-radius: 8px;">
                      </div>
                      <h1 style="margin: 16px 0 4px 0; font-size: 24px; font-weight: bold; color: #ffffff; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);">Monaco <span style="color: #fca5a5;">USA</span></h1>
                      <p style="margin: 0; font-size: 14px; color: rgba(255, 255, 255, 0.8);">Americans in Monaco</p>
                    </td>
                  </tr>
                </table>

                <!-- Main Content Card -->
                <table role="presentation" cellspacing="0" cellpadding="0" style="max-width: 480px; width: 100%; background: #ffffff; border-radius: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);">
                  <tr>
                    <td style="padding: 40px;">
                      <h2 style="margin: 0 0 20px 0; color: #CE1126; font-size: 24px;">Dues Reminder</h2>
                      <p style="margin: 0 0 16px 0; color: #334155; line-height: 1.6;">Dear {{first_name}},</p>
                      <p style="margin: 0 0 16px 0; color: #334155; line-height: 1.6;">This is a friendly reminder that your Monaco USA membership dues will be due on <strong>{{due_date}}</strong>.</p>
                      <div style="background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: 20px; margin: 0 0 20px 0;">
                        <p style="margin: 0 0 8px 0; color: #334155; font-size: 14px; font-weight: 600;">Payment Details:</p>
                        <p style="margin: 0 0 4px 0; color: #334155; font-size: 14px;"><strong>Amount Due:</strong> {{amount}}</p>
                        <p style="margin: 0 0 4px 0; color: #334155; font-size: 14px;"><strong>Due Date:</strong> {{due_date}}</p>
                        <p style="margin: 0; color: #334155; font-size: 14px;"><strong>Member ID:</strong> {{member_id}}</p>
                      </div>
                      <div style="background: #fef3c7; border: 1px solid #fcd34d; border-radius: 12px; padding: 20px; margin: 0 0 20px 0;">
                        <p style="margin: 0 0 8px 0; color: #92400e; font-size: 14px; font-weight: 600;">Bank Transfer Details:</p>
                        <p style="margin: 0 0 4px 0; color: #78350f; font-size: 14px;"><strong>Account Holder:</strong> {{account_holder}}</p>
                        <p style="margin: 0 0 4px 0; color: #78350f; font-size: 14px;"><strong>Bank:</strong> {{bank_name}}</p>
                        <p style="margin: 0 0 4px 0; color: #78350f; font-size: 14px;"><strong>IBAN:</strong> {{iban}}</p>
                        <p style="margin: 0; color: #78350f; font-size: 14px;"><strong>Reference:</strong> {{member_id}}</p>
                      </div>
                      <p style="margin: 0 0 16px 0; color: #334155; line-height: 1.6;">You can also view your payment status and history in the member portal:</p>
                      <p style="margin: 0 0 20px 0;">
                        <a href="{{portal_url}}" style="display: inline-block; background: #CE1126; color: white; padding: 12px 24px; border-radius: 8px; text-decoration: none; font-weight: 600;">View My Account</a>
                      </p>
                      <p style="margin: 0; color: #64748b; font-size: 14px;">Thank you for being a valued member of Monaco USA!</p>
                    </td>
                  </tr>
                </table>

                <!-- Footer -->
                <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="max-width: 480px;">
                  <tr>
                    <td align="center" style="padding-top: 24px;">
                      <p style="margin: 0; font-size: 12px; color: rgba(255, 255, 255, 0.5);">&copy; 2026 Monaco USA. All rights reserved.</p>
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
          </table>
        </div>
      </td>
    </tr>
  </table>
</body>
</html>'
WHERE template_key = 'dues_reminder_30';

-- =====================
-- Update Dues Reminder 7 Days Template
-- =====================
UPDATE public.email_templates
SET body_html = '<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <!--[if mso]>
  <style type="text/css">
    body, table, td { font-family: Arial, sans-serif !important; }
  </style>
  <![endif]-->
</head>
<body style="margin: 0; padding: 0; font-family: Arial, sans-serif; background-color: #0f172a;">
  <!--[if gte mso 9]>
  <v:background xmlns:v="urn:schemas-microsoft-com:vml" fill="t">
    <v:fill type="tile" src="https://s3.monacousa.org/public/monaco_high_res.jpg" color="#0f172a"/>
  </v:background>
  <![endif]-->
  <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="background-image: url(''https://s3.monacousa.org/public/monaco_high_res.jpg''); background-size: cover; background-position: center; background-color: #0f172a;">
    <tr>
      <td>
        <div style="background: linear-gradient(135deg, rgba(15, 23, 42, 0.8) 0%, rgba(15, 23, 42, 0.6) 50%, rgba(127, 29, 29, 0.7) 100%);">
          <table role="presentation" width="100%" cellspacing="0" cellpadding="0">
            <tr>
              <td align="center" style="padding: 40px 20px;">
                <!-- Logo Section -->
                <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="max-width: 480px;">
                  <tr>
                    <td align="center" style="padding-bottom: 30px;">
                      <div style="background: rgba(255, 255, 255, 0.95); border-radius: 16px; padding: 12px; display: inline-block; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);">
                        <img src="{{logo_url}}" alt="Monaco USA" width="80" height="80" style="display: block; border-radius: 8px;">
                      </div>
                      <h1 style="margin: 16px 0 4px 0; font-size: 24px; font-weight: bold; color: #ffffff; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);">Monaco <span style="color: #fca5a5;">USA</span></h1>
                      <p style="margin: 0; font-size: 14px; color: rgba(255, 255, 255, 0.8);">Americans in Monaco</p>
                    </td>
                  </tr>
                </table>

                <!-- Main Content Card -->
                <table role="presentation" cellspacing="0" cellpadding="0" style="max-width: 480px; width: 100%; background: #ffffff; border-radius: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);">
                  <tr>
                    <td style="padding: 40px;">
                      <h2 style="margin: 0 0 20px 0; color: #CE1126; font-size: 24px;">Dues Due Soon</h2>
                      <p style="margin: 0 0 16px 0; color: #334155; line-height: 1.6;">Dear {{first_name}},</p>
                      <p style="margin: 0 0 16px 0; color: #334155; line-height: 1.6;">Your Monaco USA membership dues are due in <strong>7 days</strong> on {{due_date}}.</p>
                      <div style="background: #fef3c7; border: 1px solid #fcd34d; border-radius: 12px; padding: 20px; margin: 0 0 20px 0;">
                        <p style="margin: 0 0 8px 0; color: #92400e; font-size: 14px; font-weight: 600;">Payment Details:</p>
                        <p style="margin: 0 0 4px 0; color: #78350f; font-size: 14px;"><strong>Amount Due:</strong> {{amount}}</p>
                        <p style="margin: 0 0 4px 0; color: #78350f; font-size: 14px;"><strong>Due Date:</strong> {{due_date}}</p>
                        <p style="margin: 0; color: #78350f; font-size: 14px;"><strong>Member ID:</strong> {{member_id}}</p>
                      </div>
                      <div style="background: #fef3c7; border: 1px solid #fcd34d; border-radius: 12px; padding: 20px; margin: 0 0 20px 0;">
                        <p style="margin: 0 0 8px 0; color: #92400e; font-size: 14px; font-weight: 600;">Bank Transfer Details:</p>
                        <p style="margin: 0 0 4px 0; color: #78350f; font-size: 14px;"><strong>Account Holder:</strong> {{account_holder}}</p>
                        <p style="margin: 0 0 4px 0; color: #78350f; font-size: 14px;"><strong>Bank:</strong> {{bank_name}}</p>
                        <p style="margin: 0 0 4px 0; color: #78350f; font-size: 14px;"><strong>IBAN:</strong> {{iban}}</p>
                        <p style="margin: 0; color: #78350f; font-size: 14px;"><strong>Reference:</strong> {{member_id}}</p>
                      </div>
                      <p style="margin: 0 0 20px 0;">
                        <a href="{{portal_url}}" style="display: inline-block; background: #CE1126; color: white; padding: 12px 24px; border-radius: 8px; text-decoration: none; font-weight: 600;">Pay Now</a>
                      </p>
                      <p style="margin: 0; color: #64748b; font-size: 14px;">Thank you for your continued support!</p>
                    </td>
                  </tr>
                </table>

                <!-- Footer -->
                <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="max-width: 480px;">
                  <tr>
                    <td align="center" style="padding-top: 24px;">
                      <p style="margin: 0; font-size: 12px; color: rgba(255, 255, 255, 0.5);">&copy; 2026 Monaco USA. All rights reserved.</p>
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
          </table>
        </div>
      </td>
    </tr>
  </table>
</body>
</html>'
WHERE template_key = 'dues_reminder_7';

-- =====================
-- Update Dues Reminder 1 Day Template
-- =====================
UPDATE public.email_templates
SET body_html = '<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <!--[if mso]>
  <style type="text/css">
    body, table, td { font-family: Arial, sans-serif !important; }
  </style>
  <![endif]-->
</head>
<body style="margin: 0; padding: 0; font-family: Arial, sans-serif; background-color: #0f172a;">
  <!--[if gte mso 9]>
  <v:background xmlns:v="urn:schemas-microsoft-com:vml" fill="t">
    <v:fill type="tile" src="https://s3.monacousa.org/public/monaco_high_res.jpg" color="#0f172a"/>
  </v:background>
  <![endif]-->
  <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="background-image: url(''https://s3.monacousa.org/public/monaco_high_res.jpg''); background-size: cover; background-position: center; background-color: #0f172a;">
    <tr>
      <td>
        <div style="background: linear-gradient(135deg, rgba(15, 23, 42, 0.8) 0%, rgba(15, 23, 42, 0.6) 50%, rgba(127, 29, 29, 0.7) 100%);">
          <table role="presentation" width="100%" cellspacing="0" cellpadding="0">
            <tr>
              <td align="center" style="padding: 40px 20px;">
                <!-- Logo Section -->
                <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="max-width: 480px;">
                  <tr>
                    <td align="center" style="padding-bottom: 30px;">
                      <div style="background: rgba(255, 255, 255, 0.95); border-radius: 16px; padding: 12px; display: inline-block; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);">
                        <img src="{{logo_url}}" alt="Monaco USA" width="80" height="80" style="display: block; border-radius: 8px;">
                      </div>
                      <h1 style="margin: 16px 0 4px 0; font-size: 24px; font-weight: bold; color: #ffffff; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);">Monaco <span style="color: #fca5a5;">USA</span></h1>
                      <p style="margin: 0; font-size: 14px; color: rgba(255, 255, 255, 0.8);">Americans in Monaco</p>
                    </td>
                  </tr>
                </table>

                <!-- Main Content Card -->
                <table role="presentation" cellspacing="0" cellpadding="0" style="max-width: 480px; width: 100%; background: #ffffff; border-radius: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);">
                  <tr>
                    <td style="padding: 40px;">
                      <h2 style="margin: 0 0 20px 0; color: #CE1126; font-size: 24px;">Final Reminder</h2>
                      <p style="margin: 0 0 16px 0; color: #334155; line-height: 1.6;">Dear {{first_name}},</p>
                      <p style="margin: 0 0 16px 0; color: #334155; line-height: 1.6;">This is a final reminder that your Monaco USA membership dues are due <strong>tomorrow</strong> ({{due_date}}).</p>
                      <div style="background: #fef2f2; border: 1px solid #fecaca; border-radius: 12px; padding: 20px; margin: 0 0 20px 0;">
                        <p style="margin: 0 0 8px 0; color: #991b1b; font-size: 14px; font-weight: 600;">Urgent - Payment Required:</p>
                        <p style="margin: 0 0 4px 0; color: #991b1b; font-size: 14px;"><strong>Amount Due:</strong> {{amount}}</p>
                        <p style="margin: 0 0 4px 0; color: #991b1b; font-size: 14px;"><strong>Due Date:</strong> {{due_date}}</p>
                        <p style="margin: 0; color: #991b1b; font-size: 14px;"><strong>Member ID:</strong> {{member_id}}</p>
                      </div>
                      <div style="background: #fef3c7; border: 1px solid #fcd34d; border-radius: 12px; padding: 20px; margin: 0 0 20px 0;">
                        <p style="margin: 0 0 8px 0; color: #92400e; font-size: 14px; font-weight: 600;">Bank Transfer Details:</p>
                        <p style="margin: 0 0 4px 0; color: #78350f; font-size: 14px;"><strong>Account Holder:</strong> {{account_holder}}</p>
                        <p style="margin: 0 0 4px 0; color: #78350f; font-size: 14px;"><strong>Bank:</strong> {{bank_name}}</p>
                        <p style="margin: 0 0 4px 0; color: #78350f; font-size: 14px;"><strong>IBAN:</strong> {{iban}}</p>
                        <p style="margin: 0; color: #78350f; font-size: 14px;"><strong>Reference:</strong> {{member_id}}</p>
                      </div>
                      <p style="margin: 0 0 20px 0;">
                        <a href="{{portal_url}}" style="display: inline-block; background: #CE1126; color: white; padding: 12px 24px; border-radius: 8px; text-decoration: none; font-weight: 600;">Pay Now</a>
                      </p>
                      <p style="margin: 0; color: #64748b; font-size: 14px;">Please disregard this email if you have already made your payment.</p>
                    </td>
                  </tr>
                </table>

                <!-- Footer -->
                <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="max-width: 480px;">
                  <tr>
                    <td align="center" style="padding-top: 24px;">
                      <p style="margin: 0; font-size: 12px; color: rgba(255, 255, 255, 0.5);">&copy; 2026 Monaco USA. All rights reserved.</p>
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
          </table>
        </div>
      </td>
    </tr>
  </table>
</body>
</html>'
WHERE template_key = 'dues_reminder_1';

-- =====================
-- Update Dues Reminder (Generic) Template if exists
-- =====================
UPDATE public.email_templates
SET body_html = '<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <!--[if mso]>
  <style type="text/css">
    body, table, td { font-family: Arial, sans-serif !important; }
  </style>
  <![endif]-->
</head>
<body style="margin: 0; padding: 0; font-family: Arial, sans-serif; background-color: #0f172a;">
  <!--[if gte mso 9]>
  <v:background xmlns:v="urn:schemas-microsoft-com:vml" fill="t">
    <v:fill type="tile" src="https://s3.monacousa.org/public/monaco_high_res.jpg" color="#0f172a"/>
  </v:background>
  <![endif]-->
  <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="background-image: url(''https://s3.monacousa.org/public/monaco_high_res.jpg''); background-size: cover; background-position: center; background-color: #0f172a;">
    <tr>
      <td>
        <div style="background: linear-gradient(135deg, rgba(15, 23, 42, 0.8) 0%, rgba(15, 23, 42, 0.6) 50%, rgba(127, 29, 29, 0.7) 100%);">
          <table role="presentation" width="100%" cellspacing="0" cellpadding="0">
            <tr>
              <td align="center" style="padding: 40px 20px;">
                <!-- Logo Section -->
                <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="max-width: 480px;">
                  <tr>
                    <td align="center" style="padding-bottom: 30px;">
                      <div style="background: rgba(255, 255, 255, 0.95); border-radius: 16px; padding: 12px; display: inline-block; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);">
                        <img src="{{logo_url}}" alt="Monaco USA" width="80" height="80" style="display: block; border-radius: 8px;">
                      </div>
                      <h1 style="margin: 16px 0 4px 0; font-size: 24px; font-weight: bold; color: #ffffff; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);">Monaco <span style="color: #fca5a5;">USA</span></h1>
                      <p style="margin: 0; font-size: 14px; color: rgba(255, 255, 255, 0.8);">Americans in Monaco</p>
                    </td>
                  </tr>
                </table>

                <!-- Main Content Card -->
                <table role="presentation" cellspacing="0" cellpadding="0" style="max-width: 480px; width: 100%; background: #ffffff; border-radius: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);">
                  <tr>
                    <td style="padding: 40px;">
                      <h2 style="margin: 0 0 20px 0; color: #CE1126; font-size: 24px;">Membership Dues Reminder</h2>
                      <p style="margin: 0 0 16px 0; color: #334155; line-height: 1.6;">Dear {{first_name}},</p>
                      <p style="margin: 0 0 16px 0; color: #334155; line-height: 1.6;">This is a reminder about your Monaco USA membership dues.</p>
                      <div style="background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: 20px; margin: 0 0 20px 0;">
                        <p style="margin: 0 0 8px 0; color: #334155; font-size: 14px; font-weight: 600;">Payment Details:</p>
                        <p style="margin: 0 0 4px 0; color: #334155; font-size: 14px;"><strong>Amount Due:</strong> {{amount}}</p>
                        <p style="margin: 0 0 4px 0; color: #334155; font-size: 14px;"><strong>Due Date:</strong> {{due_date}}</p>
                        <p style="margin: 0; color: #334155; font-size: 14px;"><strong>Member ID:</strong> {{member_id}}</p>
                      </div>
                      <p style="margin: 0 0 20px 0;">
                        <a href="{{portal_url}}" style="display: inline-block; background: #CE1126; color: white; padding: 12px 24px; border-radius: 8px; text-decoration: none; font-weight: 600;">View My Account</a>
                      </p>
                      <p style="margin: 0; color: #64748b; font-size: 14px;">Thank you for being a valued member of Monaco USA!</p>
                    </td>
                  </tr>
                </table>

                <!-- Footer -->
                <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="max-width: 480px;">
                  <tr>
                    <td align="center" style="padding-top: 24px;">
                      <p style="margin: 0; font-size: 12px; color: rgba(255, 255, 255, 0.5);">&copy; 2026 Monaco USA. All rights reserved.</p>
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
          </table>
        </div>
      </td>
    </tr>
  </table>
</body>
</html>'
WHERE template_key = 'dues_reminder';
