-- Add test_email template for "Uji Coba Email" button in Integrasi tab
INSERT INTO notification_templates (key, name, email_subject, email_body_html, is_active, created_at, updated_at)
VALUES (
  'test_email',
  'Test Email',
  'Email Test - {platform_name}',
  '
<div style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto; padding: 20px;">
  <h2 style="color: #333;">Email Test - {platform_name}</h2>

  <p>Halo,</p>

  <p>Ini adalah email tes dari sistem <strong>{platform_name}</strong>.</p>

  <div style="margin: 20px 0; padding: 15px; background-color: #f0f0f0; border-left: 4px solid #000;">
    <p style="margin: 0; font-size: 14px;">
      <strong>✓ Konfigurasi email berhasil!</strong><br>
      Email Anda telah terkirim dengan benar menggunakan provider: <strong>Mailketing</strong>
    </p>
  </div>

  <p style="font-size: 14px; color: #666;">
    Jika Anda menerima email ini, berarti konfigurasi email sudah benar.
  </p>

  <p style="font-size: 14px;">
    Terima kasih,<br>
    Tim {platform_name}
  </p>
</div>
  ',
  true,
  NOW(),
  NOW()
)
ON CONFLICT (key) DO UPDATE SET
  email_subject = EXCLUDED.email_subject,
  email_body_html = EXCLUDED.email_body_html,
  updated_at = NOW();

-- Verify the template
SELECT
  key,
  name,
  email_subject,
  is_active
FROM notification_templates
WHERE key = 'test_email';
