-- ============================================================================
-- Fix Auth OTP Email Template - Content Only (for master template wrapper)
-- ============================================================================

-- Update auth_email_verification template to be content-only
-- This will be wrapped by EmailTemplateRenderer with master template
UPDATE notification_templates
SET
  email_subject = 'Kode Verifikasi Email Anda - {platform_name}',
  email_body_html = '---
<h1>🔐 Verifikasi Email</h1>
<p>Halo <strong>{nama}</strong>, terima kasih telah mendaftar di <strong>{platform_name}</strong>! Gunakan kode OTP berikut untuk memverifikasi alamat email Anda:</p>

<div class="otp-box">{otp_code}</div>

<p>Kode ini akan kedaluwarsa dalam <strong>{expiry_minutes} menit</strong>.</p>

<h3>Cara menggunakan:</h3>
<ol>
  <li>Salin kode 6 digit di atas</li>
  <li>Kembali ke halaman pendaftaran</li>
  <li>Masukkan kode tersebut pada form verifikasi</li>
</ol>

<blockquote class="alert-info">
  <strong>Info:</strong> Jika Anda tidak merasa mendaftar di {platform_name}, abaikan email ini dengan aman.
</blockquote>
---'
WHERE key = 'auth_email_verification';

-- Add comment documenting the change
COMMENT ON COLUMN notification_templates.email_body_html IS
'For templates wrapped with master template: Store ONLY content HTML (no <html>, <head>, <body> tags).
Use {variable} placeholders for dynamic data. Content will be auto-styled by .tiptap-content CSS.';

-- Return success message
DO $$
BEGIN
  RAISE NOTICE 'Auth email template updated to content-only format for master template wrapper';
END $$;
