{
        "dataSource": {
            "endpoint": "/api/payment-reminders/config",
            "method": "GET"
        },
        "saveEndpoint": "/api/payment-reminders/config",
        "saveMethod": "POST",
        "sections": [
            {
                "title": "General Settings",
                "icon": "fa-sliders-h",
                "fields": [
                    {
                        "key": "enabled",
                        "label": "Enable Payment Reminders",
                        "type": "toggle",
                        "default": true,
                        "help": "Master switch for payment reminder system"
                    },
                    {
                        "key": "from_name",
                        "label": "From Name",
                        "type": "text",
                        "required": true,
                        "placeholder": "Your Company Name",
                        "help": "Name that appears in reminder emails"
                    },
                    {
                        "key": "from_email",
                        "label": "From Email",
                        "type": "email",
                        "required": true,
                        "placeholder": "reminders@yourcompany.com",
                        "help": "Email address for sending reminders"
                    },
                    {
                        "key": "reply_to_email",
                        "label": "Reply-To Email",
                        "type": "email",
                        "placeholder": "support@yourcompany.com",
                        "help": "Email address for customer replies"
                    },
                    {
                        "key": "cc_emails",
                        "label": "CC Recipients",
                        "type": "tags",
                        "placeholder": "accounting@yourcompany.com",
                        "help": "Additional recipients (comma-separated)"
                    },
                    {
                        "key": "bcc_emails",
                        "label": "BCC Recipients",
                        "type": "tags",
                        "placeholder": "admin@yourcompany.com",
                        "help": "Hidden copy recipients (comma-separated)"
                    }
                ]
            },
            {
                "title": "Reminder Schedule",
                "icon": "fa-calendar-alt",
                "fields": [
                    {
                        "key": "send_7_days_before",
                        "label": "Send 7 Days Before Due Date",
                        "type": "toggle",
                        "default": true,
                        "help": "Friendly advance notice"
                    },
                    {
                        "key": "send_on_due_date",
                        "label": "Send On Due Date",
                        "type": "toggle",
                        "default": true,
                        "help": "Payment due today reminder"
                    },
                    {
                        "key": "send_3_days_after",
                        "label": "Send 3 Days After Due Date",
                        "type": "toggle",
                        "default": true,
                        "help": "First overdue notice"
                    },
                    {
                        "key": "send_7_days_after",
                        "label": "Send 7 Days After Due Date",
                        "type": "toggle",
                        "default": true,
                        "help": "Second overdue notice with late fees"
                    },
                    {
                        "key": "send_30_days_after",
                        "label": "Send 30 Days After Due Date",
                        "type": "toggle",
                        "default": true,
                        "help": "Final notice before collections"
                    },
                    {
                        "key": "reminder_time",
                        "label": "Send Time (24-hour)",
                        "type": "time",
                        "default": "09:00",
                        "help": "Time of day to send reminders"
                    }
                ]
            },
            {
                "title": "Delivery Methods",
                "icon": "fa-paper-plane",
                "fields": [
                    {
                        "key": "email_enabled",
                        "label": "Email Delivery",
                        "type": "toggle",
                        "default": true,
                        "help": "Send reminders via email"
                    },
                    {
                        "key": "sms_enabled",
                        "label": "SMS Delivery",
                        "type": "toggle",
                        "default": false,
                        "help": "Send reminders via SMS (requires Twilio)"
                    },
                    {
                        "key": "portal_notification_enabled",
                        "label": "Portal Notifications",
                        "type": "toggle",
                        "default": true,
                        "help": "Show reminders in customer portal"
                    }
                ]
            },
            {
                "title": "Twilio Configuration (SMS)",
                "icon": "fa-mobile",
                "condition": "sms_enabled == true",
                "fields": [
                    {
                        "key": "twilio_account_sid",
                        "label": "Twilio Account SID",
                        "type": "text",
                        "placeholder": "ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                        "help": "Your Twilio Account SID"
                    },
                    {
                        "key": "twilio_auth_token",
                        "label": "Twilio Auth Token",
                        "type": "password",
                        "placeholder": "Enter your Twilio auth token",
                        "help": "Your Twilio authentication token"
                    },
                    {
                        "key": "twilio_phone_number",
                        "label": "Twilio Phone Number",
                        "type": "tel",
                        "placeholder": "+1234567890",
                        "help": "Your Twilio phone number (E.164 format)"
                    },
                    {
                        "key": "sms_template",
                        "label": "SMS Template",
                        "type": "textarea",
                        "rows": 4,
                        "default": "Payment reminder: Invoice {{invoice_number}} for ${{amount_due}} is due on {{due_date}}. Pay now: {{payment_link}}",
                        "help": "SMS message template (max 160 characters). Use {{variables}} for dynamic content."
                    }
                ]
            },
            {
                "title": "Late Fees & Penalties",
                "icon": "fa-dollar-sign",
                "fields": [
                    {
                        "key": "late_fee_enabled",
                        "label": "Enable Late Fees",
                        "type": "toggle",
                        "default": false,
                        "help": "Automatically apply late fees to overdue invoices"
                    },
                    {
                        "key": "late_fee_type",
                        "label": "Late Fee Type",
                        "type": "select",
                        "options": [
                            {"value": "fixed", "label": "Fixed Amount"},
                            {"value": "percentage", "label": "Percentage"}
                        ],
                        "default": "fixed",
                        "condition": "late_fee_enabled == true"
                    },
                    {
                        "key": "late_fee_amount",
                        "label": "Late Fee Amount",
                        "type": "number",
                        "min": 0,
                        "step": 0.01,
                        "default": 25,
                        "condition": "late_fee_enabled == true && late_fee_type == \"fixed\"",
                        "help": "Fixed late fee amount"
                    },
                    {
                        "key": "late_fee_percentage",
                        "label": "Late Fee Percentage",
                        "type": "number",
                        "min": 0,
                        "max": 100,
                        "step": 0.1,
                        "default": 5,
                        "condition": "late_fee_enabled == true && late_fee_type == \"percentage\"",
                        "help": "Late fee as percentage of invoice amount"
                    },
                    {
                        "key": "late_fee_grace_period",
                        "label": "Grace Period (days)",
                        "type": "number",
                        "min": 0,
                        "default": 7,
                        "condition": "late_fee_enabled == true",
                        "help": "Days after due date before applying late fees"
                    }
                ]
            },
            {
                "title": "Tracking & Analytics",
                "icon": "fa-chart-line",
                "fields": [
                    {
                        "key": "track_email_opens",
                        "label": "Track Email Opens",
                        "type": "toggle",
                        "default": true,
                        "help": "Insert tracking pixel to detect email opens"
                    },
                    {
                        "key": "track_link_clicks",
                        "label": "Track Link Clicks",
                        "type": "toggle",
                        "default": true,
                        "help": "Track when customers click payment links"
                    },
                    {
                        "key": "max_attempts",
                        "label": "Maximum Retry Attempts",
                        "type": "number",
                        "min": 1,
                        "max": 10,
                        "default": 3,
                        "help": "Maximum retry attempts for failed deliveries"
                    }
                ]
            },
            {
                "title": "Customer Preferences",
                "icon": "fa-user-cog",
                "fields": [
                    {
                        "key": "allow_opt_out",
                        "label": "Allow Customer Opt-Out",
                        "type": "toggle",
                        "default": true,
                        "help": "Allow customers to opt out of reminders"
                    },
                    {
                        "key": "opt_out_text",
                        "label": "Opt-Out Link Text",
                        "type": "text",
                        "default": "Unsubscribe from payment reminders",
                        "condition": "allow_opt_out == true",
                        "help": "Text for opt-out link in emails"
                    },
                    {
                        "key": "respect_customer_timezone",
                        "label": "Respect Customer Timezone",
                        "type": "toggle",
                        "default": false,
                        "help": "Send reminders based on customer timezone"
                    }
                ]
            }
        ],
        "actions": [
            {
                "label": "Save Configuration",
                "action": "save",
                "color": "primary",
                "icon": "fa-save"
            },
            {
                "label": "Test Email Delivery",
                "action": "payment-reminders:test-email",
                "color": "info",
                "icon": "fa-envelope",
                "confirm": "Send a test payment reminder email to {{from_email}}?"
            },
            {
                "label": "Test SMS Delivery",
                "action": "payment-reminders:test-sms",
                "color": "warning",
                "icon": "fa-mobile",
                "condition": "sms_enabled == true",
                "confirm": "Send a test SMS to {{twilio_phone_number}}?"
            },
            {
                "label": "View Email Templates",
                "action": "navigation:goto",
                "params": {"path": "/email-templates"},
                "color": "secondary",
                "icon": "fa-file-alt"
            },
            {
                "label": "Reset to Defaults",
                "action": "payment-reminders:reset-config",
                "color": "error",
                "icon": "fa-undo",
                "confirm": "Reset all settings to default values? This cannot be undone."
            }
        ],
        "validation": {
            "rules": [
                {
                    "field": "from_email",
                    "rule": "email",
                    "message": "Please enter a valid email address"
                },
                {
                    "field": "reply_to_email",
                    "rule": "email",
                    "message": "Please enter a valid reply-to email address"
                },
                {
                    "field": "twilio_phone_number",
                    "rule": "phone",
                    "message": "Please enter a valid phone number in E.164 format",
                    "condition": "sms_enabled == true"
                }
            ]
        }
    }