-- RFQ Template Builder UI modal (launches drag-and-drop builder)
INSERT INTO modules (module_id, name, config, org_id, branch_id, icon, aria_label, description)
SELECT
  '0194a8b2-0021-7123-8123-123456789abc'::uuid,
  'rfq_template_builder',
  $json$
  {
    "title": "RFQ Template Builder",
    "header": [
      { "type": "html", "html": "<div class=\"alert alert-info\"><span class=\"font-semibold\">Drag & Drop:</span> Create and edit RFQ templates by arranging sections and attachments. Use Preview to sanity-check the narrative.</div>" },
      { "type": "button", "label": "Open Builder", "onClick": "openRfqTemplateBuilder", "class": "btn btn-primary btn-sm" }
    ],
    "body": [
      { "type": "html", "id": "rfqTplBuilderRoot", "html": "<div id=\"rfqTplBuilderRoot\"></div>" }
    ],
    "footer": [ { "type": "button", "label": "Close", "onClick": "closeModal" } ]
  }
  $json$::jsonb,
  NULL, NULL, 'fa-diagram-project', 'RFQ Template Builder', 'RFQ Template Builder'
WHERE NOT EXISTS (SELECT 1 FROM modules WHERE module_id = '0194a8b2-0021-7123-8123-123456789abc'::uuid);
