-- Default email template catalog + seeded content, exported from the live DB.
-- Idempotent: ON CONFLICT DO NOTHING so re-running never clobbers customized content.
-- Generated 2026-08-01 from prisma/seed.ts's upsertEmailTemplates() output.

-- ─── template_types ─────────────────────────────────────────
INSERT INTO platform.template_types
  (id, code, name, category, description, "isActive", "sortOrder", "createdBy", "createdOn", "updatedBy", "updatedOn")
VALUES
  ('6e0cd1c8-f3a4-42df-952c-87ce4ef00811', 'email_header', 'Email Header', 'layout', 'Shared banner shown at the top of every email — identical for all template types, not per-store.', TRUE, 0, 'system', '2026-07-31T18:02:20.390Z', 'system', '2026-07-31T19:53:05.885Z'),
  ('d83d8223-3dac-4925-a1a4-fb88dcf04f0f', 'email_footer', 'Email Footer', 'layout', 'Shared closing block shown at the bottom of every email — identical for all template types, not per-store.', TRUE, 1, 'system', '2026-07-31T18:02:20.404Z', 'system', '2026-07-31T19:53:05.899Z'),
  ('1d0547c4-2242-48fd-943c-a99d3b277392', 'order_placed', 'Order Placed', 'order', 'Sent when a customer''s order is created. Variables: customerName, orderNumber, grandTotal, itemsList', TRUE, 2, 'system', '2026-07-31T17:18:36.119Z', 'system', '2026-07-31T19:53:05.905Z'),
  ('8e3e9c9e-7f69-4ee2-bcd8-3ac23ddb8989', 'order_processing', 'Order Processing', 'order', 'Sent when an order moves to processing. Variables: customerName, orderNumber', TRUE, 3, 'system', '2026-07-31T17:18:36.133Z', 'system', '2026-07-31T19:53:05.912Z'),
  ('277c3387-388c-4168-a201-0aef6e0cc84c', 'order_shipped', 'Order Shipped', 'order', 'Sent when an order ships. Variables: customerName, orderNumber, carrier, trackingNumber', TRUE, 4, 'system', '2026-07-31T17:18:36.137Z', 'system', '2026-07-31T19:53:05.917Z'),
  ('4c2a855c-7d03-4a86-a05a-694f5e637888', 'order_out_for_delivery', 'Order Out for Delivery', 'order', 'Sent when an order is out for delivery. Variables: customerName, orderNumber', TRUE, 5, 'system', '2026-07-31T17:18:36.140Z', 'system', '2026-07-31T19:53:05.924Z'),
  ('31a5ae5c-8927-4fab-92b7-e00703730a0f', 'order_delivered', 'Order Delivered', 'order', 'Sent when an order is delivered. Variables: customerName, orderNumber', TRUE, 6, 'system', '2026-07-31T17:18:36.143Z', 'system', '2026-07-31T19:53:05.933Z'),
  ('a517b8af-8294-4595-b7d5-4218c011c4df', 'order_cancelled', 'Order Cancelled', 'order', 'Sent when an order is cancelled. Variables: customerName, orderNumber, reason', TRUE, 7, 'system', '2026-07-31T17:18:36.146Z', 'system', '2026-07-31T19:53:05.939Z'),
  ('73eb158c-49eb-428c-b7ea-a2e072984ee1', 'order_refunded', 'Order Refunded', 'order', 'Sent when a refund is processed. Variables: customerName, orderNumber, refundAmount', TRUE, 8, 'system', '2026-07-31T17:18:36.150Z', 'system', '2026-07-31T19:53:05.947Z'),
  ('b34d4399-a81b-40f5-8292-e84954b14f86', 'welcome_registration', 'Welcome / Registration', 'auth', 'Sent right after a new account is created. Variables: customerName', TRUE, 9, 'system', '2026-07-31T17:18:36.154Z', 'system', '2026-07-31T19:53:05.952Z'),
  ('421623c5-adb5-4a2a-bd10-021ffe6e48af', 'password_reset', 'Password Reset', 'auth', 'Sent when a password reset is requested. Variables: resetUrl', TRUE, 10, 'system', '2026-07-31T17:18:36.157Z', 'system', '2026-07-31T19:53:05.956Z'),
  ('1a51d305-0511-4817-978f-69fc0aba32f6', 'password_changed', 'Password Changed Confirmation', 'auth', 'Sent right after a password is successfully changed. Variables: customerName', TRUE, 11, 'system', '2026-07-31T17:18:36.160Z', 'system', '2026-07-31T19:53:05.963Z'),
  ('f21dbcfa-cd3e-4f34-bf07-4067791932ba', 'email_verification', 'Email Verification', 'auth', 'Phase 2 — needs a new emailVerifiedAt/token field on User plus a product decision (block login vs. soft-nag) before this can be wired.', TRUE, 12, 'system', '2026-07-31T17:18:36.164Z', 'system', '2026-07-31T19:53:05.968Z'),
  ('2d0f0c26-e0d3-4f92-a002-a068f654e8f1', 'wishlist_reminder', 'Wishlist Reminder', 'wishlist', 'Periodic digest of saved wishlist items. Variables: customerName, itemsList', TRUE, 13, 'system', '2026-07-31T17:18:36.166Z', 'system', '2026-07-31T19:53:05.969Z'),
  ('4c854d24-0784-4af7-bfa3-4e08c98bd16e', 'wishlist_price_drop', 'Wishlist Price Drop', 'wishlist', 'Phase 2 — needs a priceAtAdd snapshot field on WishlistItem before a price-drop comparison is possible.', TRUE, 14, 'system', '2026-07-31T17:18:36.171Z', 'system', '2026-07-31T19:53:05.973Z'),
  ('515036ca-05b3-4ae0-b6f4-8850e356f344', 'wishlist_back_in_stock', 'Wishlist Back In Stock', 'wishlist', 'Phase 2 — needs a lastKnownQuantity (or similar) field to detect the zero-to-positive stock transition.', TRUE, 15, 'system', '2026-07-31T17:18:36.173Z', 'system', '2026-07-31T19:53:05.974Z'),
  ('00265b81-93fd-443f-bddf-ae609fb8343f', 'staff_invite', 'Staff Invite', 'staff', 'Phase 2 — StoreStaff.inviteToken/inviteEmail/inviteExpiresAt columns exist but are unused; userId is a required FK today, so a real invite-by-email flow needs it made optional plus a new accept-invite endpoint.', TRUE, 16, 'system', '2026-07-31T17:18:36.174Z', 'system', '2026-07-31T19:53:05.976Z'),
  ('dd7b5ca2-ba03-4ed3-b821-e51f6e9e36d4', 'merchant_new_order', 'New Order Received', 'merchant', 'Phase 2 — merchant-facing counterpart to Order Placed; recipient resolution (which Users to notify) needs confirming before wiring.', TRUE, 17, 'system', '2026-07-31T17:18:36.175Z', 'system', '2026-07-31T19:53:05.978Z'),
  ('bb02273a-3467-4288-b6a7-da127e5674bc', 'merchant_low_stock', 'Low Stock Alert', 'merchant', 'Phase 2 — needs a lowStockThreshold field; Inventory only has quantity today.', TRUE, 18, 'system', '2026-07-31T17:18:36.177Z', 'system', '2026-07-31T19:53:05.980Z'),
  ('8654f5e2-f36e-4387-bb3d-9f70746bb245', 'cart_abandonment', 'Cart Abandonment Reminder', 'engagement', 'Sent when a cart sits inactive past a threshold. Variables: customerName, cartUrl. Only reaches carts with a resolvable customerId — guest carts are not reachable.', TRUE, 19, 'system', '2026-07-31T17:18:36.178Z', 'system', '2026-07-31T19:53:05.982Z'),
  ('8721dd5b-710d-4a78-be33-03dd71f7ff17', 'review_request', 'Post-Delivery Review Request', 'engagement', 'Phase 2 — needs a "days after delivered" scheduling mechanism (a delayed job), not just an immediate trigger.', TRUE, 20, 'system', '2026-07-31T17:18:36.181Z', 'system', '2026-07-31T19:53:05.989Z')
ON CONFLICT (code) DO NOTHING;

-- ─── templates (seeded content) ────────────────────────────
INSERT INTO platform.templates
  (id, "storeId", "templateTypeId", name, subject, "bodyHtml", "isActive", "isPublished", "sortOrder", "createdBy", "createdOn", "updatedBy", "updatedOn")
VALUES
  ('4c9fe080-e504-4c6f-b943-d6e88c4cab22', 'store_demo', '1a51d305-0511-4817-978f-69fc0aba32f6' /* password_changed */, 'Password Changed Confirmation — Default', 'Your password was changed', '<h1 style="margin:0 0 24px;color:#0f172a;font-size:30px;font-weight:700;line-height:1.25;letter-spacing:-0.02em;text-align:center;">Password Changed</h1><p style="margin:0 0 18px;color:#475569;font-size:16px;line-height:1.65;text-align:center;">Hi {{customerName}},</p><p style="margin:0 0 18px;color:#475569;font-size:16px;line-height:1.65;text-align:center;">Your password was just changed. If this wasn''t you, contact support immediately.</p>', TRUE, TRUE, 0, 'system', '2026-07-31T17:18:36.162Z', 'system', '2026-07-31T19:53:05.965Z'),
  ('6341952f-2eaa-44b3-91ad-b1a68d315dde', 'store_demo', 'd83d8223-3dac-4925-a1a4-fb88dcf04f0f' /* email_footer */, 'Email Footer — Default', '(layout — not used)', '<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background-color:#f1f5f9;"><tr><td align="center" style="padding:0 0 32px;"><table role="presentation" width="800" cellpadding="0" cellspacing="0" style="width:100%;max-width:800px;margin:0 auto;"><tr><td align="center" style="background-color:#ffffff;border-top:1px solid #e8edf3;border-radius:0 0 12px 12px;padding:28px 48px 40px;font-family:''Inter'',-apple-system,BlinkMacSystemFont,''Segoe UI'',Helvetica,Arial,sans-serif;color:#64748b;font-size:14px;line-height:1.65;text-align:center;"><p style="margin:0 0 8px;">If you have any questions, feel free to contact our support team.</p><p style="margin:0;font-weight:700;color:#334155;">Thank you!</p><p style="margin:20px 0 0;font-size:12px;color:#94a3b8;">&copy; {{storeName}}. All rights reserved.</p></td></tr></table></td></tr></table>', TRUE, TRUE, 0, 'system', '2026-07-31T18:02:20.407Z', 'system', '2026-07-31T19:53:05.901Z'),
  ('72eaf0ca-6f4a-49c1-a0aa-2bee34bb7471', 'store_demo', '1d0547c4-2242-48fd-943c-a99d3b277392' /* order_placed */, 'Order Placed — Default', 'Your order #{{orderNumber}} has been placed', '<h1 style="margin:0 0 24px;color:#0f172a;font-size:30px;font-weight:700;line-height:1.25;letter-spacing:-0.02em;text-align:center;">Order Placed</h1><p style="margin:0 0 18px;color:#475569;font-size:16px;line-height:1.65;text-align:center;">Hi {{customerName}},</p><p style="margin:0 0 18px;color:#475569;font-size:16px;line-height:1.65;text-align:center;">Thanks for your order! We''ve received order #{{orderNumber}} for {{grandTotal}}.</p><p style="margin:0 0 18px;color:#475569;font-size:16px;line-height:1.65;text-align:center;">{{itemsList}}</p><p style="margin:0 0 18px;color:#475569;font-size:16px;line-height:1.65;text-align:center;">We''ll email you again once it ships.</p>', TRUE, TRUE, 0, 'system', '2026-07-31T17:18:36.126Z', 'user_admin_demo', '2026-07-31T19:53:05.907Z'),
  ('12e69066-2449-46cf-a33a-cd8378cd4097', 'store_demo', '277c3387-388c-4168-a201-0aef6e0cc84c' /* order_shipped */, 'Order Shipped — Default', 'Your order #{{orderNumber}} has shipped', '<h1 style="margin:0 0 24px;color:#0f172a;font-size:30px;font-weight:700;line-height:1.25;letter-spacing:-0.02em;text-align:center;">Order Shipped</h1><p style="margin:0 0 18px;color:#475569;font-size:16px;line-height:1.65;text-align:center;">Hi {{customerName}},</p><p style="margin:0 0 18px;color:#475569;font-size:16px;line-height:1.65;text-align:center;">Your order #{{orderNumber}} has shipped via {{carrier}}.</p><p style="margin:0 0 18px;color:#475569;font-size:16px;line-height:1.65;text-align:center;">Tracking number: <strong>{{trackingNumber}}</strong></p>', TRUE, TRUE, 0, 'system', '2026-07-31T17:18:36.139Z', 'system', '2026-07-31T19:53:05.919Z'),
  ('6f31de1c-b2ba-4ec0-b2b3-89721fd74e17', 'store_demo', '8e3e9c9e-7f69-4ee2-bcd8-3ac23ddb8989' /* order_processing */, 'Order Processing — Default', 'Your order #{{orderNumber}} is being processed', '<h1 style="margin:0 0 24px;color:#0f172a;font-size:30px;font-weight:700;line-height:1.25;letter-spacing:-0.02em;text-align:center;">Order Processing</h1><p style="margin:0 0 18px;color:#475569;font-size:16px;line-height:1.65;text-align:center;">Hi {{customerName}},</p><p style="margin:0 0 18px;color:#475569;font-size:16px;line-height:1.65;text-align:center;">Your order #{{orderNumber}} is now being processed and will ship soon.</p>', TRUE, TRUE, 0, 'system', '2026-07-31T17:18:36.135Z', 'system', '2026-07-31T19:53:05.914Z'),
  ('2f166c1f-1f33-4f58-8302-9c7e43e23c3a', 'store_demo', '4c2a855c-7d03-4a86-a05a-694f5e637888' /* order_out_for_delivery */, 'Order Out for Delivery — Default', 'Your order #{{orderNumber}} is out for delivery', '<h1 style="margin:0 0 24px;color:#0f172a;font-size:30px;font-weight:700;line-height:1.25;letter-spacing:-0.02em;text-align:center;">Order Out for Delivery</h1><p style="margin:0 0 18px;color:#475569;font-size:16px;line-height:1.65;text-align:center;">Hi {{customerName}},</p><p style="margin:0 0 18px;color:#475569;font-size:16px;line-height:1.65;text-align:center;">Your order #{{orderNumber}} is out for delivery today.</p>', TRUE, TRUE, 0, 'system', '2026-07-31T17:18:36.142Z', 'system', '2026-07-31T19:53:05.926Z'),
  ('9cdb6daf-4c0d-428d-900d-6fc9bd8a64b1', 'store_demo', 'a517b8af-8294-4595-b7d5-4218c011c4df' /* order_cancelled */, 'Order Cancelled — Default', 'Your order #{{orderNumber}} has been cancelled', '<h1 style="margin:0 0 24px;color:#0f172a;font-size:30px;font-weight:700;line-height:1.25;letter-spacing:-0.02em;text-align:center;">Order Cancelled</h1><p style="margin:0 0 18px;color:#475569;font-size:16px;line-height:1.65;text-align:center;">Hi {{customerName}},</p><p style="margin:0 0 18px;color:#475569;font-size:16px;line-height:1.65;text-align:center;">Your order #{{orderNumber}} has been cancelled. {{reason}}</p>', TRUE, TRUE, 0, 'system', '2026-07-31T17:18:36.147Z', 'system', '2026-07-31T19:53:05.941Z'),
  ('6d699fc1-ae65-4dee-8b64-88c44aae905b', 'store_demo', '73eb158c-49eb-428c-b7ea-a2e072984ee1' /* order_refunded */, 'Order Refunded — Default', 'Your refund for order #{{orderNumber}} has been processed', '<h1 style="margin:0 0 24px;color:#0f172a;font-size:30px;font-weight:700;line-height:1.25;letter-spacing:-0.02em;text-align:center;">Order Refunded</h1><p style="margin:0 0 18px;color:#475569;font-size:16px;line-height:1.65;text-align:center;">Hi {{customerName}},</p><p style="margin:0 0 18px;color:#475569;font-size:16px;line-height:1.65;text-align:center;">A refund of {{refundAmount}} has been processed for order #{{orderNumber}}.</p>', TRUE, TRUE, 0, 'system', '2026-07-31T17:18:36.152Z', 'system', '2026-07-31T19:53:05.948Z'),
  ('8c082b19-c15e-4b5a-9bae-80cb9a3d2542', 'store_demo', '31a5ae5c-8927-4fab-92b7-e00703730a0f' /* order_delivered */, 'Order Delivered — Default', 'Your order #{{orderNumber}} has been delivered', '<h1 style="margin:0 0 24px;color:#0f172a;font-size:30px;font-weight:700;line-height:1.25;letter-spacing:-0.02em;text-align:center;">Order Delivered</h1><p style="margin:0 0 18px;color:#475569;font-size:16px;line-height:1.65;text-align:center;">Hi {{customerName}},</p><p style="margin:0 0 18px;color:#475569;font-size:16px;line-height:1.65;text-align:center;">Your order #{{orderNumber}} has been delivered. We hope you love it!</p>', TRUE, TRUE, 0, 'system', '2026-07-31T17:18:36.145Z', 'system', '2026-07-31T19:53:05.935Z'),
  ('632e4b11-7a55-479a-b0db-7efb0536f5ba', 'store_demo', '2d0f0c26-e0d3-4f92-a002-a068f654e8f1' /* wishlist_reminder */, 'Wishlist Reminder — Default', 'Still thinking about these?', '<h1 style="margin:0 0 24px;color:#0f172a;font-size:30px;font-weight:700;line-height:1.25;letter-spacing:-0.02em;text-align:center;">Your Wishlist</h1><p style="margin:0 0 18px;color:#475569;font-size:16px;line-height:1.65;text-align:center;">Hi {{customerName}},</p><p style="margin:0 0 18px;color:#475569;font-size:16px;line-height:1.65;text-align:center;">Here''s what''s still in your wishlist:</p><p style="margin:0 0 18px;color:#475569;font-size:16px;line-height:1.65;text-align:center;">{{itemsList}}</p>', TRUE, TRUE, 0, 'system', '2026-07-31T17:18:36.168Z', 'system', '2026-07-31T19:53:05.970Z'),
  ('59fce976-e657-47b1-94bc-598ac14dabf5', 'store_demo', '8654f5e2-f36e-4387-bb3d-9f70746bb245' /* cart_abandonment */, 'Cart Abandonment Reminder — Default', 'You left something in your cart', '<h1 style="margin:0 0 24px;color:#0f172a;font-size:30px;font-weight:700;line-height:1.25;letter-spacing:-0.02em;text-align:center;">You Left Something Behind</h1><p style="margin:0 0 18px;color:#475569;font-size:16px;line-height:1.65;text-align:center;">Hi {{customerName}},</p><p style="margin:0 0 18px;color:#475569;font-size:16px;line-height:1.65;text-align:center;">You still have items waiting in your cart.</p><table role="presentation" cellpadding="0" cellspacing="0" align="center" style="margin:26px auto 28px;"><tr><td align="center" bgcolor="{{primaryColor}}" style="background-color:{{primaryColor}};border-radius:8px;"><a href="{{cartUrl}}" style="display:inline-block;padding:16px 40px;color:#ffffff;font-family:''Inter'',-apple-system,BlinkMacSystemFont,''Segoe UI'',Helvetica,Arial,sans-serif;font-size:16px;font-weight:600;line-height:1;text-decoration:none;">Complete Your Order</a></td></tr></table>', TRUE, TRUE, 0, 'system', '2026-07-31T17:18:36.179Z', 'user_admin_demo', '2026-07-31T19:53:05.984Z'),
  ('a9a95fb4-e574-4529-9b1b-75363161f674', 'store_demo', 'b34d4399-a81b-40f5-8292-e84954b14f86' /* welcome_registration */, 'Welcome / Registration — Default', 'Welcome!', '<h1 style="margin:0 0 24px;color:#0f172a;font-size:30px;font-weight:700;line-height:1.25;letter-spacing:-0.02em;text-align:center;">Welcome!</h1><p style="margin:0 0 18px;color:#475569;font-size:16px;line-height:1.65;text-align:center;">Hi {{customerName}},</p><p style="margin:0 0 18px;color:#475569;font-size:16px;line-height:1.65;text-align:center;">Welcome — your account has been created successfully.</p>', TRUE, TRUE, 0, 'system', '2026-07-31T17:18:36.155Z', 'user_admin_demo', '2026-08-01T03:22:13.068Z'),
  ('7548c7ea-1a4d-4752-b488-6918694683e1', 'store_demo', '421623c5-adb5-4a2a-bd10-021ffe6e48af' /* password_reset */, 'Password Reset — Default', 'Shopora - Reset your password', '<h1 style="margin:0 0 24px;color:#0f172a;font-size:30px;font-weight:700;line-height:1.25;letter-spacing:-0.02em;text-align:center;">Password Reset Request</h1><p style="margin:0 0 18px;color:#475569;font-size:16px;line-height:1.65;text-align:center;">We received a request to reset your password.</p><table role="presentation" cellpadding="0" cellspacing="0" align="center" style="margin:26px auto 28px;"><tr><td align="center" bgcolor="{{primaryColor}}" style="background-color:{{primaryColor}};border-radius:8px;"><a href="{{resetUrl}}" style="display:inline-block;padding:16px 40px;color:#ffffff;font-family:''Inter'',-apple-system,BlinkMacSystemFont,''Segoe UI'',Helvetica,Arial,sans-serif;font-size:16px;font-weight:600;line-height:1;text-decoration:none;">Reset Your Password</a></td></tr></table><p style="margin:0 0 18px;color:#475569;font-size:16px;line-height:1.65;text-align:center;">This link will expire in 1 hour. If you didn''t request this, you can safely ignore this email.</p>', TRUE, TRUE, 0, 'system', '2026-07-31T17:18:36.159Z', 'user_admin_demo', '2026-08-01T03:25:41.258Z'),
  ('2781f814-dfb8-4c51-ac7b-9f97f8402d65', 'store_demo', '6e0cd1c8-f3a4-42df-952c-87ce4ef00811' /* email_header */, 'Email Header — Default', '(layout — not used)', '<table
  role="presentation"
  width="100%"
  cellpadding="0"
  cellspacing="0"
  style="background-color:#f1f5f9;"
>
  <tr>
    <td align="center" style="padding:32px 0 0;">
      <table
        role="presentation"
        width="800"
        cellpadding="0"
        cellspacing="0"
        style="width:100%;max-width:800px;margin:0 auto;"
      >
        <tr>
          <td
            align="center"
            bgcolor="{{primaryColor}}"
            style="background-color:{{primaryColor}};border-radius:12px 12px 0 0;padding:40px 24px 40px;font-family:''Inter'',-apple-system,BlinkMacSystemFont,''Segoe UI'',Helvetica,Arial,sans-serif;text-align:center;"
          >
            {{logoBlock}}
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>', TRUE, TRUE, 0, 'system', '2026-07-31T18:02:20.395Z', 'user_admin_demo', '2026-08-01T03:29:58.441Z')
ON CONFLICT ("storeId", "templateTypeId") DO NOTHING;
