"""Default email copy seeded into NotificationTemplate.

Each entry maps a Notification.Verb value to a (name, subject, body_text,
body_html, headline_default, action_label_default) tuple. The seeder
``seed_notification_templates`` loads these on a fresh DB and is safe to
re-run (it skips rows that already exist).

Subject and body fields use Django template syntax — variables come from
the ``email_context`` passed to ``send_notification``. Common variables:

  - {{ recipient_name }}: full name or email local-part of the recipient.
  - {{ recipient }}: the User object.
  - {{ message }}: the human-readable message argument.
  - Any extra keys the caller put into ``email_context``.
"""

from __future__ import annotations

from apps.core.notifications.models import Notification

V = Notification.Verb

DEFAULT_TEMPLATES: list[dict] = [
    {
        "verb": V.APPLICATION_STATUS,
        "name": "Application status change",
        "headline_default": "Your application status changed",
        "subject": "Application update: {{ call_title|default:'IILMP' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "{{ message }}\n\n"
            "{% if action_url %}Open: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>{{ message }}</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">View application</a></p>{% endif %}"
        ),
        "action_label_default": "View application",
    },
    {
        "verb": V.CALL_PUBLISHED,
        "name": "Call published",
        "headline_default": "A new opportunity is open",
        "subject": "New call: {{ call_title|default:'IILMP funding opportunity' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "{{ message }}\n\n"
            "Closes: {{ call_closes_at|default:'see portal' }}\n"
            "{% if action_url %}Apply: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>{{ message }}</p>"
            "{% if call_closes_at %}<p><strong>Closes:</strong> {{ call_closes_at }}</p>{% endif %}"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open the call</a></p>{% endif %}"
        ),
        "action_label_default": "Open the call",
    },
    {
        "verb": V.DEADLINE_REMINDER,
        "name": "Deadline reminder",
        "headline_default": "Deadline approaching",
        "subject": "Reminder: {{ call_title|default:'IILMP deadline approaching' }}",
        "body_text": "Hi {{ recipient_name }},\n\n{{ message }}\n\n{% if action_url %}Continue: {{ action_url }}{% endif %}",
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>{{ message }}</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Continue</a></p>{% endif %}"
        ),
        "action_label_default": "Continue",
    },
    {
        "verb": V.REVIEWER_ASSIGNED,
        "name": "Reviewer assignment",
        "headline_default": "You have a new review assignment",
        "subject": "Review assignment: {{ call_title|default:'IILMP' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "{{ message }}\n\n"
            "Due: {{ review_due_at|default:'see portal' }}\n"
            "{% if action_url %}Open: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>{{ message }}</p>"
            "{% if review_due_at %}<p><strong>Due:</strong> {{ review_due_at }}</p>{% endif %}"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open review</a></p>{% endif %}"
        ),
        "action_label_default": "Open review",
    },
    {
        "verb": V.GRANT_AWARDED,
        "name": "Award notification",
        "headline_default": "Congratulations — you have been awarded",
        "subject": "Award: {{ call_title|default:'IILMP' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "Congratulations — your application to \"{{ call_title }}\" has been awarded.\n\n"
            "{{ message }}\n\n"
            "Your award letter is attached as a PDF. Please review it and upload your signed agreement.\n"
            "{% if action_url %}Open award: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p><strong>Congratulations</strong> — your application to \"{{ call_title }}\" has been awarded.</p>"
            "<p>{{ message }}</p>"
            "<p>Your award letter is attached as a PDF. Please review it and upload your signed agreement.</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open award</a></p>{% endif %}"
        ),
        "action_label_default": "Open award",
    },
    {
        "verb": V.INTERVIEW_COMPLETED,
        "name": "Interview completed",
        "headline_default": "Interview stage complete",
        "subject": "Interview recorded: {{ call_title|default:'IILMP' }}",
        "body_text": "Hi {{ recipient_name }},\n\n{{ message }}",
        "body_html": "<p>Hi {{ recipient_name }},</p><p>{{ message }}</p>",
        "action_label_default": "View application",
    },
    {
        "verb": V.REVIEW_INTAKE_MANAGER,
        "name": "Manager: assign reviewers",
        "headline_default": "Application ready for reviewer assignment",
        "subject": "Under review — assign reviewers: {{ call_title|default:'IILMP' }}",
        "body_text": "Hi {{ recipient_name }},\n\n{{ message }}\n\n{% if action_url %}Open: {{ action_url }}{% endif %}",
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>{{ message }}</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open application</a></p>{% endif %}"
        ),
        "action_label_default": "Open application",
    },
    {
        "verb": V.MILESTONE_OVERDUE,
        "name": "Milestone overdue",
        "headline_default": "A milestone is overdue",
        "subject": "Overdue milestone: {{ milestone_label|default:'IILMP' }}",
        "body_text": "Hi {{ recipient_name }},\n\n{{ message }}",
        "body_html": "<p>Hi {{ recipient_name }},</p><p>{{ message }}</p>",
        "action_label_default": "Open milestone",
    },
    {
        "verb": V.FINANCE_DISBURSEMENT,
        "name": "Finance disbursement update",
        "headline_default": "Disbursement update",
        "subject": "Disbursement: {{ disbursement_reference|default:'IILMP' }}",
        "body_text": "Hi {{ recipient_name }},\n\n{{ message }}",
        "body_html": "<p>Hi {{ recipient_name }},</p><p>{{ message }}</p>",
        "action_label_default": "View disbursement",
    },
    # ------------------------------------------------------------------
    # REP — Regional E-Learning Platform (PRD §5.5)
    # Wording is anchored to the PRD use-case "Main Success Scenario" prose
    # so subject/body content is PRD-specific, not generic.
    # ------------------------------------------------------------------
    # SP1 — User Registration & Profile Management
    {
        "verb": V.REP_PROFILE_UPDATED,
        "name": "REP profile updated",
        "headline_default": "Your profile was updated",
        "subject": "Your REP profile has been updated",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "Your REP profile was updated on {{ updated_at|default:'today' }}. "
            "If this wasn't you, please update your password immediately.\n\n"
            "{% if action_url %}Review your profile: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>Your REP profile was updated on {{ updated_at|default:'today' }}. "
            "If this wasn't you, please update your password immediately.</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Review your profile</a></p>{% endif %}"
        ),
        "action_label_default": "Review profile",
    },
    {
        "verb": V.REP_ROLE_CHANGED,
        "name": "REP role changed",
        "headline_default": "Your role on REP has changed",
        "subject": "Your REP role is now: {{ new_role|default:'updated' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "An administrator has changed your REP role to {{ new_role|default:'a new role' }}. "
            "This affects what you can access and do on the platform.\n\n"
            "{% if action_url %}Open REP: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>An administrator has changed your REP role to <strong>{{ new_role|default:'a new role' }}</strong>. "
            "This affects what you can access and do on the platform.</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open REP</a></p>{% endif %}"
        ),
        "action_label_default": "Open REP",
    },
    {
        "verb": V.REP_BULK_IMPORT_COMPLETE,
        "name": "REP bulk user import complete",
        "headline_default": "Bulk user import finished",
        "subject": "REP bulk import: {{ created_count|default:0 }} created, {{ failed_count|default:0 }} errors",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "Your REP bulk user import has finished.\n"
            "Created: {{ created_count|default:0 }}\n"
            "Failed: {{ failed_count|default:0 }}\n\n"
            "{% if action_url %}Review the import report: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>Your REP bulk user import has finished.</p>"
            "<ul>"
            "<li>Created: <strong>{{ created_count|default:0 }}</strong></li>"
            "<li>Failed: <strong>{{ failed_count|default:0 }}</strong></li>"
            "</ul>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Review the import report</a></p>{% endif %}"
        ),
        "action_label_default": "Open import report",
    },
    # SP2 — Course & Programme Management
    {
        "verb": V.REP_COURSE_ARCHIVED,
        "name": "REP course archived",
        "headline_default": "A course you are enrolled in has been archived",
        "subject": "{{ course_title|default:'Your course' }} has been archived",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "{{ course_title|default:'Your course' }} has been archived. "
            "You still have access to your existing materials and certificates, "
            "but new enrolments are now closed.\n\n"
            "{% if action_url %}Open the course: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p><strong>{{ course_title|default:'Your course' }}</strong> has been archived. "
            "You still have access to your existing materials and certificates, "
            "but new enrolments are now closed.</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open the course</a></p>{% endif %}"
        ),
        "action_label_default": "Open course",
    },
    {
        "verb": V.REP_COURSE_SIGNIFICANT_UPDATE,
        "name": "REP significant course update",
        "headline_default": "Your course was updated",
        "subject": "Update: {{ course_title|default:'your REP course' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "{{ course_title|default:'A course you are enrolled in' }} has been updated.\n"
            "{% if change_summary %}Changes: {{ change_summary }}{% endif %}\n\n"
            "{% if action_url %}Open the course: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p><strong>{{ course_title|default:'A course you are enrolled in' }}</strong> has been updated.</p>"
            "{% if change_summary %}<p>Changes: {{ change_summary }}</p>{% endif %}"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open the course</a></p>{% endif %}"
        ),
        "action_label_default": "Open course",
    },
    {
        "verb": V.REP_COURSE_REVISION_PUBLISHED,
        "name": "REP course revision published",
        "headline_default": "A new course revision is available",
        "subject": "Revision published: {{ course_title|default:'your REP course' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "A new revision of {{ course_title|default:'your course' }} has been published "
            "({{ revision_label|default:'see course' }}).\n\n"
            "{% if action_url %}Open the course: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>A new revision of <strong>{{ course_title|default:'your course' }}</strong> has been published "
            "({{ revision_label|default:'see course' }}).</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open the course</a></p>{% endif %}"
        ),
        "action_label_default": "Open course",
    },
    # SP3 — Enrolment & Access Management
    {
        "verb": V.REP_ENROLMENT_CONFIRMED,
        "name": "REP enrolment confirmed",
        "headline_default": "You are enrolled",
        "subject": "Enrolment confirmed: {{ course_title|default:'your REP course' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "You are now enrolled in {{ course_title|default:'your REP course' }}. "
            "Your access is active and you can begin learning at any time.\n\n"
            "{% if action_url %}Open the course: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>You are now enrolled in <strong>{{ course_title|default:'your REP course' }}</strong>. "
            "Your access is active and you can begin learning at any time.</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open the course</a></p>{% endif %}"
        ),
        "action_label_default": "Open course",
    },
    {
        "verb": V.REP_ENROLMENT_APPROVED,
        "name": "REP enrolment approved",
        "headline_default": "Your enrolment was approved",
        "subject": "Enrolment approved: {{ course_title|default:'your REP course' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "Your enrolment request for {{ course_title|default:'this course' }} has been approved.\n\n"
            "{% if action_url %}Open the course: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>Your enrolment request for <strong>{{ course_title|default:'this course' }}</strong> has been approved.</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open the course</a></p>{% endif %}"
        ),
        "action_label_default": "Open course",
    },
    {
        "verb": V.REP_ENROLMENT_REJECTED,
        "name": "REP enrolment rejected",
        "headline_default": "Your enrolment was not approved",
        "subject": "Enrolment update: {{ course_title|default:'your REP course' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "Your enrolment request for {{ course_title|default:'this course' }} was not approved.\n"
            "{% if reason %}Reason: {{ reason }}{% endif %}\n\n"
            "If you believe this was a mistake, please contact the course administrator."
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>Your enrolment request for <strong>{{ course_title|default:'this course' }}</strong> was not approved.</p>"
            "{% if reason %}<p>Reason: {{ reason }}</p>{% endif %}"
            "<p>If you believe this was a mistake, please contact the course administrator.</p>"
        ),
        "action_label_default": "Contact administrator",
    },
    {
        "verb": V.REP_RIMS_AUTO_ENROLLED,
        "name": "REP auto-enrolled via scholarship",
        "headline_default": "You have been enrolled in a course as part of your scholarship",
        "subject": "You're enrolled: {{ course_title|default:'your REP course' }} (scholarship)",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "Because you have been awarded a RUFORUM scholarship "
            "{% if award_label %}({{ award_label }}){% endif %}, "
            "we have automatically enrolled you in {{ course_title|default:'a required course' }}. "
            "This course is part of your scholarship requirements.\n\n"
            "{% if action_url %}Open the course: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>Because you have been awarded a RUFORUM scholarship "
            "{% if award_label %}(<em>{{ award_label }}</em>){% endif %}, "
            "we have automatically enrolled you in <strong>{{ course_title|default:'a required course' }}</strong>. "
            "This course is part of your scholarship requirements.</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open the course</a></p>{% endif %}"
        ),
        "action_label_default": "Open course",
    },
    {
        "verb": V.REP_WAITLIST_PROMOTED,
        "name": "REP waitlist promoted",
        "headline_default": "A spot opened up — you're enrolled",
        "subject": "A spot opened up: {{ course_title|default:'your REP course' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "A spot has opened up in {{ course_title|default:'a course you were waitlisted for' }} "
            "and you have been auto-enrolled. Welcome aboard!\n\n"
            "{% if action_url %}Open the course: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>A spot has opened up in <strong>{{ course_title|default:'a course you were waitlisted for' }}</strong> "
            "and you have been auto-enrolled. Welcome aboard!</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open the course</a></p>{% endif %}"
        ),
        "action_label_default": "Open course",
    },
    # SP4 — Learning Delivery & Engagement
    {
        "verb": V.REP_LIVE_SESSION_SCHEDULED,
        "name": "REP live session scheduled",
        "headline_default": "Live session scheduled",
        "subject": "Live session: {{ session_title|default:'upcoming session' }} on {{ session_starts_at|default:'see course' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "A live session has been scheduled for {{ course_title|default:'your course' }}.\n"
            "Topic: {{ session_title|default:'see course' }}\n"
            "Starts: {{ session_starts_at|default:'see course' }}\n\n"
            "{% if action_url %}Join link: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>A live session has been scheduled for <strong>{{ course_title|default:'your course' }}</strong>.</p>"
            "<ul>"
            "<li>Topic: {{ session_title|default:'see course' }}</li>"
            "<li>Starts: {{ session_starts_at|default:'see course' }}</li>"
            "</ul>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Join the session</a></p>{% endif %}"
        ),
        "action_label_default": "Join session",
    },
    {
        "verb": V.REP_LIVE_SESSION_STARTING,
        "name": "REP live session starting soon",
        "headline_default": "Your live session starts soon",
        "subject": "Starting soon: {{ session_title|default:'your live session' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "{{ session_title|default:'Your live session' }} starts in "
            "{{ minutes_until|default:'a few' }} minutes.\n\n"
            "{% if action_url %}Join now: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p><strong>{{ session_title|default:'Your live session' }}</strong> starts in "
            "<strong>{{ minutes_until|default:'a few' }} minutes</strong>.</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Join now</a></p>{% endif %}"
        ),
        "action_label_default": "Join now",
    },
    {
        "verb": V.REP_LIVE_SESSION_CANCELLED,
        "name": "REP live session cancelled",
        "headline_default": "Live session cancelled",
        "subject": "Cancelled: {{ session_title|default:'your live session' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "The live session \"{{ session_title|default:'your live session' }}\" in "
            "{{ course_title|default:'your course' }} has been cancelled.\n"
            "{% if cancellation_reason %}Reason: {{ cancellation_reason }}\n{% endif %}\n"
            "{% if action_url %}View course updates: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>The live session <strong>\"{{ session_title|default:'your live session' }}\"</strong> in "
            "<strong>{{ course_title|default:'your course' }}</strong> has been cancelled.</p>"
            "{% if cancellation_reason %}<p>Reason: {{ cancellation_reason }}</p>{% endif %}"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">View course updates</a></p>{% endif %}"
        ),
        "action_label_default": "View course",
    },
    {
        "verb": V.REP_LIVE_RECORDING_READY,
        "name": "REP live recording ready",
        "headline_default": "Session recording available",
        "subject": "Recording available: {{ session_title|default:'your session' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "The recording of {{ session_title|default:'your live session' }} is now available "
            "in {{ course_title|default:'your course' }}.\n\n"
            "{% if action_url %}Watch the recording: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>The recording of <strong>{{ session_title|default:'your live session' }}</strong> is now available "
            "in <strong>{{ course_title|default:'your course' }}</strong>.</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Watch the recording</a></p>{% endif %}"
        ),
        "action_label_default": "Watch recording",
    },
    {
        "verb": V.REP_WIKI_PAGE_UPDATED,
        "name": "REP wiki page updated",
        "headline_default": "Wiki page updated",
        "subject": "Wiki updated: {{ page_title|default:'a page you watch' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "{{ editor_name|default:'A collaborator' }} updated \"{{ page_title|default:'a wiki page' }}\" "
            "in {{ course_title|default:'your course' }}.\n"
            "{% if summary %}Summary: {{ summary }}\n{% endif %}\n"
            "{% if action_url %}Open the page: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p><strong>{{ editor_name|default:'A collaborator' }}</strong> updated "
            "\"{{ page_title|default:'a wiki page' }}\" in <strong>{{ course_title|default:'your course' }}</strong>.</p>"
            "{% if summary %}<p><em>{{ summary }}</em></p>{% endif %}"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open the page</a></p>{% endif %}"
        ),
        "action_label_default": "Open wiki page",
    },
    {
        "verb": V.REP_FORUM_REPLY,
        "name": "REP forum reply",
        "headline_default": "New reply on a thread you follow",
        "subject": "New reply: {{ thread_title|default:'a forum thread you follow' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "{{ author_name|default:'Someone' }} replied on \"{{ thread_title|default:'a thread you follow' }}\".\n\n"
            "{% if message %}\"{{ message }}\"\n\n{% endif %}"
            "{% if action_url %}Open the thread: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p><strong>{{ author_name|default:'Someone' }}</strong> replied on "
            "\"{{ thread_title|default:'a thread you follow' }}\".</p>"
            "{% if message %}<blockquote>{{ message }}</blockquote>{% endif %}"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open the thread</a></p>{% endif %}"
        ),
        "action_label_default": "Open thread",
    },
    {
        "verb": V.REP_FORUM_POST_FLAGGED,
        "name": "REP forum post flagged",
        "headline_default": "A post has been flagged for review",
        "subject": "Flagged for moderation: {{ thread_title|default:'a forum post' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "A post in \"{{ thread_title|default:'a thread' }}\" has been flagged for moderator review.\n"
            "{% if reason %}Reason given: {{ reason }}{% endif %}\n\n"
            "{% if action_url %}Open the moderation queue: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>A post in <strong>{{ thread_title|default:'a thread' }}</strong> has been flagged for moderator review.</p>"
            "{% if reason %}<p>Reason given: <em>{{ reason }}</em></p>{% endif %}"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open the moderation queue</a></p>{% endif %}"
        ),
        "action_label_default": "Open moderation",
    },
    {
        "verb": V.REP_FORUM_MODERATION_OUTCOME,
        "name": "REP forum moderation outcome",
        "headline_default": "Moderation decision",
        "subject": "Moderation outcome: {{ thread_title|default:'a forum post' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "A moderation decision was made on a post you reported or authored in "
            "\"{{ thread_title|default:'a thread' }}\".\n"
            "Outcome: {{ outcome|default:'see thread' }}\n"
            "{% if reason %}Reason: {{ reason }}{% endif %}\n\n"
            "{% if action_url %}Open the thread: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>A moderation decision was made on a post you reported or authored in "
            "<strong>{{ thread_title|default:'a thread' }}</strong>.</p>"
            "<p>Outcome: <strong>{{ outcome|default:'see thread' }}</strong>.</p>"
            "{% if reason %}<p>Reason: {{ reason }}</p>{% endif %}"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open the thread</a></p>{% endif %}"
        ),
        "action_label_default": "Open thread",
    },
    # SP5 — Assessment & Grading Management
    {
        "verb": V.REP_ASSIGNMENT_SUBMITTED,
        "name": "REP assignment submitted",
        "headline_default": "A learner submitted an assignment",
        "subject": "New submission: {{ assignment_title|default:'assignment' }} ({{ learner_name|default:'a learner' }})",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "{{ learner_name|default:'A learner' }} submitted "
            "\"{{ assignment_title|default:'an assignment' }}\" "
            "in {{ course_title|default:'your course' }}.\n\n"
            "{% if action_url %}Grade the submission: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p><strong>{{ learner_name|default:'A learner' }}</strong> submitted "
            "\"{{ assignment_title|default:'an assignment' }}\" "
            "in <strong>{{ course_title|default:'your course' }}</strong>.</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Grade the submission</a></p>{% endif %}"
        ),
        "action_label_default": "Open submission",
    },
    {
        "verb": V.REP_ASSIGNMENT_GRADED,
        "name": "REP assignment graded",
        "headline_default": "Your assignment has been graded",
        "subject": "Grade released: {{ assignment_title|default:'your assignment' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "Your assignment \"{{ assignment_title|default:'submission' }}\" "
            "in {{ course_title|default:'your course' }} has been graded.\n"
            "Grade: {{ grade|default:'see course' }}{% if max_points %} / {{ max_points }}{% endif %}\n"
            "{% if feedback %}\nFeedback:\n{{ feedback }}{% endif %}\n\n"
            "{% if action_url %}View grade and feedback: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>Your assignment \"<strong>{{ assignment_title|default:'submission' }}</strong>\" "
            "in <strong>{{ course_title|default:'your course' }}</strong> has been graded.</p>"
            "<p>Grade: <strong>{{ grade|default:'see course' }}{% if max_points %} / {{ max_points }}{% endif %}</strong></p>"
            "{% if feedback %}<p>Feedback:</p><blockquote>{{ feedback|linebreaksbr }}</blockquote>{% endif %}"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">View grade and feedback</a></p>{% endif %}"
        ),
        "action_label_default": "View grade",
    },
    {
        "verb": V.REP_QUIZ_AUTO_GRADED,
        "name": "REP quiz auto-graded",
        "headline_default": "Your quiz has been graded",
        "subject": "Quiz result: {{ quiz_title|default:'your quiz' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "Your attempt at \"{{ quiz_title|default:'a quiz' }}\" "
            "in {{ course_title|default:'your course' }} has been auto-graded.\n"
            "Score: {{ percentage|default:'see course' }}%\n\n"
            "Note: any essay or open-text questions may still be pending instructor review.\n\n"
            "{% if action_url %}View your result: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>Your attempt at \"<strong>{{ quiz_title|default:'a quiz' }}</strong>\" "
            "in <strong>{{ course_title|default:'your course' }}</strong> has been auto-graded.</p>"
            "<p>Score: <strong>{{ percentage|default:'see course' }}%</strong></p>"
            "<p><em>Note: any essay or open-text questions may still be pending instructor review.</em></p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">View your result</a></p>{% endif %}"
        ),
        "action_label_default": "View result",
    },
    {
        "verb": V.REP_LATE_SUBMISSION,
        "name": "REP late submission",
        "headline_default": "Your submission was recorded late",
        "subject": "Late submission recorded: {{ assignment_title|default:'your assignment' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "Your submission for \"{{ assignment_title|default:'this assignment' }}\" "
            "was recorded after the deadline. {% if penalty_pct %}A late penalty of "
            "{{ penalty_pct }}% has been applied.{% endif %}\n\n"
            "{% if action_url %}View the submission: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>Your submission for <strong>{{ assignment_title|default:'this assignment' }}</strong> "
            "was recorded after the deadline."
            "{% if penalty_pct %} A late penalty of <strong>{{ penalty_pct }}%</strong> has been applied.{% endif %}</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">View the submission</a></p>{% endif %}"
        ),
        "action_label_default": "View submission",
    },
    {
        "verb": V.REP_GRADE_OVERRIDE_APPLIED,
        "name": "REP grade override applied",
        "headline_default": "An instructor has updated your grade",
        "subject": "Grade updated: {{ assessment_title|default:'your assessment' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "An instructor has updated your grade for "
            "\"{{ assessment_title|default:'an assessment' }}\".\n"
            "{% if old_grade %}Previous: {{ old_grade }}\n{% endif %}"
            "New grade: {{ new_grade|default:'see course' }}\n"
            "{% if reason %}Reason given: {{ reason }}\n{% endif %}\n"
            "{% if action_url %}View your gradebook: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>An instructor has updated your grade for "
            "<strong>{{ assessment_title|default:'an assessment' }}</strong>.</p>"
            "<ul>"
            "{% if old_grade %}<li>Previous: {{ old_grade }}</li>{% endif %}"
            "<li>New grade: <strong>{{ new_grade|default:'see course' }}</strong></li>"
            "{% if reason %}<li>Reason given: {{ reason }}</li>{% endif %}"
            "</ul>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">View your gradebook</a></p>{% endif %}"
        ),
        "action_label_default": "View gradebook",
    },
    {
        "verb": V.REP_GRADE_APPEAL_SUBMITTED,
        "name": "REP grade appeal submitted",
        "headline_default": "A learner has appealed a grade",
        "subject": "Grade appeal: {{ assessment_title|default:'an assessment' }} ({{ learner_name|default:'a learner' }})",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "{{ learner_name|default:'A learner' }} has appealed their grade on "
            "\"{{ assessment_title|default:'an assessment' }}\".\n"
            "{% if reason %}Reason given: {{ reason }}{% endif %}\n\n"
            "{% if action_url %}Review the appeal: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p><strong>{{ learner_name|default:'A learner' }}</strong> has appealed their grade on "
            "\"<strong>{{ assessment_title|default:'an assessment' }}</strong>\".</p>"
            "{% if reason %}<p>Reason given: <em>{{ reason }}</em></p>{% endif %}"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Review the appeal</a></p>{% endif %}"
        ),
        "action_label_default": "Review appeal",
    },
    {
        "verb": V.REP_WORKSHOP_PEER_REVIEW_ASSIGNED,
        "name": "REP peer review assigned",
        "headline_default": "You have peer reviews to complete",
        "subject": "Peer review assigned: {{ assignment_title|default:'workshop' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "You have been assigned {{ review_count|default:'one or more' }} peer review(s) for "
            "\"{{ assignment_title|default:'a workshop' }}\" in {{ course_title|default:'your course' }}. "
            "Please complete them by {{ due_at|default:'see course' }}.\n\n"
            "{% if action_url %}Open peer reviews: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>You have been assigned <strong>{{ review_count|default:'one or more' }}</strong> peer review(s) for "
            "<strong>{{ assignment_title|default:'a workshop' }}</strong> in "
            "<strong>{{ course_title|default:'your course' }}</strong>. "
            "Please complete them by <strong>{{ due_at|default:'see course' }}</strong>.</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open peer reviews</a></p>{% endif %}"
        ),
        "action_label_default": "Open peer reviews",
    },
    # SP6 — Certification & Credentials
    {
        "verb": V.REP_CERTIFICATE_REVOKED,
        "name": "REP certificate revoked",
        "headline_default": "A certificate has been revoked",
        "subject": "Certificate revoked: {{ course_title|default:'your REP course' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "Your certificate for {{ course_title|default:'a REP course' }} has been revoked "
            "by the course administrator.\n"
            "{% if reason %}Reason: {{ reason }}{% endif %}\n\n"
            "If you believe this was a mistake, please contact the course administrator."
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>Your certificate for <strong>{{ course_title|default:'a REP course' }}</strong> has been revoked "
            "by the course administrator.</p>"
            "{% if reason %}<p>Reason: <em>{{ reason }}</em></p>{% endif %}"
            "<p>If you believe this was a mistake, please contact the course administrator.</p>"
        ),
        "action_label_default": "Contact administrator",
    },
    # SP7 — Networking & Community
    {
        "verb": V.REP_CONNECTION_REQUEST,
        "name": "REP connection request",
        "headline_default": "New connection request",
        "subject": "{{ requester_name|default:'Someone' }} wants to connect",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "{{ requester_name|default:'Someone' }} sent you a connection request on the REP network.\n\n"
            "{% if action_url %}Review the request: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p><strong>{{ requester_name|default:'Someone' }}</strong> sent you a connection request on the REP network.</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Review the request</a></p>{% endif %}"
        ),
        "action_label_default": "Review request",
    },
    {
        "verb": V.REP_CONNECTION_ACCEPTED,
        "name": "REP connection accepted",
        "headline_default": "Connection accepted",
        "subject": "{{ peer_name|default:'A connection' }} accepted your request",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "{{ peer_name|default:'Your connection request was accepted' }}. "
            "You can now message each other directly.\n\n"
            "{% if action_url %}Open the conversation: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p><strong>{{ peer_name|default:'Your connection request was accepted' }}</strong>. "
            "You can now message each other directly.</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open the conversation</a></p>{% endif %}"
        ),
        "action_label_default": "Open conversation",
    },
    {
        "verb": V.REP_DM_RECEIVED,
        "name": "REP direct message received",
        "headline_default": "New direct message",
        "subject": "New message from {{ sender_name|default:'a connection' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "{{ sender_name|default:'A connection' }} sent you a direct message.\n"
            "{% if message %}\n\"{{ message|truncatewords:30 }}\"\n{% endif %}\n"
            "{% if action_url %}Open the conversation: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p><strong>{{ sender_name|default:'A connection' }}</strong> sent you a direct message.</p>"
            "{% if message %}<blockquote>{{ message|truncatewords:30 }}</blockquote>{% endif %}"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open the conversation</a></p>{% endif %}"
        ),
        "action_label_default": "Open conversation",
    },
    {
        "verb": V.REP_MENTOR_MATCHED,
        "name": "REP mentor matched",
        "headline_default": "You have been matched with a mentor",
        "subject": "Mentor match: {{ mentor_name|default:'your new mentor' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "You have been matched with a mentor on the REP: "
            "{{ mentor_name|default:'see profile' }}{% if expertise %} ({{ expertise }}){% endif %}.\n\n"
            "Use the platform messaging to introduce yourself and schedule a session.\n\n"
            "{% if action_url %}Open the mentorship: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>You have been matched with a mentor on the REP: "
            "<strong>{{ mentor_name|default:'see profile' }}</strong>"
            "{% if expertise %} (<em>{{ expertise }}</em>){% endif %}.</p>"
            "<p>Use the platform messaging to introduce yourself and schedule a session.</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open the mentorship</a></p>{% endif %}"
        ),
        "action_label_default": "Open mentorship",
    },
    # SP8 — Career
    {
        "verb": V.REP_JOB_LISTING_MATCH,
        "name": "REP job listing match",
        "headline_default": "New opportunity matches your profile",
        "subject": "New job match: {{ listing_title|default:'opportunity' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "A new opportunity matches your profile: "
            "{{ listing_title|default:'see job board' }}{% if employer_name %} at {{ employer_name }}{% endif %}.\n"
            "{% if listing_summary %}\n{{ listing_summary }}\n{% endif %}\n"
            "{% if action_url %}View the listing: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>A new opportunity matches your profile: "
            "<strong>{{ listing_title|default:'see job board' }}</strong>"
            "{% if employer_name %} at <strong>{{ employer_name }}</strong>{% endif %}.</p>"
            "{% if listing_summary %}<p>{{ listing_summary }}</p>{% endif %}"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">View the listing</a></p>{% endif %}"
        ),
        "action_label_default": "View listing",
    },
    {
        "verb": V.REP_CV_EXPORT_READY,
        "name": "REP CV export ready",
        "headline_default": "Your CV is ready to download",
        "subject": "Your CV PDF is ready",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "Your CV has been generated as a PDF and is ready to download.\n\n"
            "{% if action_url %}Download CV: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>Your CV has been generated as a PDF and is ready to download.</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Download CV</a></p>{% endif %}"
        ),
        "action_label_default": "Download CV",
    },
    # SP9 — Personalisation (optional, opt-out)
    {
        "verb": V.REP_RECOMMENDATION_SURFACED,
        "name": "REP recommendation surfaced",
        "headline_default": "We think you'll like this",
        "subject": "Recommended for you: {{ course_title|default:'a new course' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "Based on your activity and interests, we think you'll like "
            "{{ course_title|default:'this course' }}.\n\n"
            "{% if action_url %}Open the course: {{ action_url }}{% endif %}\n\n"
            "You can turn off these emails from your notification preferences."
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>Based on your activity and interests, we think you'll like "
            "<strong>{{ course_title|default:'this course' }}</strong>.</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open the course</a></p>{% endif %}"
            "<p style=\"color:#666;font-size:0.9em\">You can turn off these emails from your notification preferences.</p>"
        ),
        "action_label_default": "Open course",
    },
    # SP10 — Reporting / M&EL
    {
        "verb": V.REP_REPORT_READY,
        "name": "REP report ready",
        "headline_default": "Your report is ready",
        "subject": "Report ready: {{ report_label|default:'REP report' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "Your REP report \"{{ report_label|default:'analytics export' }}\" "
            "({{ report_format|default:'CSV' }}) is ready to download.\n\n"
            "{% if action_url %}Download the report: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>Your REP report \"<strong>{{ report_label|default:'analytics export' }}</strong>\" "
            "(<strong>{{ report_format|default:'CSV' }}</strong>) is ready to download.</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Download the report</a></p>{% endif %}"
        ),
        "action_label_default": "Download report",
    },
    {
        "verb": V.REP_MEL_PUSH_FAILED,
        "name": "REP M&EL push failed",
        "headline_default": "M&EL push has failed repeatedly",
        "subject": "Action required: REP→M&EL push failing",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "The scheduled push of REP indicators to M&EL has failed "
            "{{ failure_count|default:'multiple' }} times in a row.\n"
            "{% if last_error %}Last error: {{ last_error }}{% endif %}\n\n"
            "Please check the integration configuration and the M&EL endpoint health.\n\n"
            "{% if action_url %}Open the integration outbox: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>The scheduled push of REP indicators to M&EL has failed "
            "<strong>{{ failure_count|default:'multiple' }}</strong> times in a row.</p>"
            "{% if last_error %}<p>Last error: <code>{{ last_error }}</code></p>{% endif %}"
            "<p>Please check the integration configuration and the M&EL endpoint health.</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open the integration outbox</a></p>{% endif %}"
        ),
        "action_label_default": "Open outbox",
    },
    # Existing REP verbs (added before WS2.1) — make sure they have templates too.
    {
        "verb": V.REP_CERTIFICATE_ISSUED,
        "name": "REP certificate issued",
        "headline_default": "Your certificate is ready",
        "subject": "Certificate issued: {{ course_title|default:'your REP course' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "Congratulations on completing {{ course_title|default:'your REP course' }}!\n"
            "Your certificate (number {{ certificate_number|default:'see attachment' }}) is attached as a PDF "
            "and is also available from \"My Certificates\" on your profile.\n"
            "{% if verification_url %}\nAnyone can verify your certificate at:\n{{ verification_url }}\n{% endif %}\n"
            "{% if action_url %}Open My Certificates: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>Congratulations on completing <strong>{{ course_title|default:'your REP course' }}</strong>!</p>"
            "<p>Your certificate (number <code>{{ certificate_number|default:'see attachment' }}</code>) "
            "is attached as a PDF and is also available from <em>My Certificates</em> on your profile.</p>"
            "{% if verification_url %}<p>Anyone can verify your certificate at "
            "<a href=\"{{ verification_url }}\">{{ verification_url }}</a>.</p>{% endif %}"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open My Certificates</a></p>{% endif %}"
        ),
        "action_label_default": "Open My Certificates",
    },
    {
        "verb": V.REP_COURSE_PUBLISHED,
        "name": "REP course published",
        "headline_default": "Your course has been published",
        "subject": "Course published: {{ course_title|default:'your course' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "{{ course_title|default:'Your course' }} has been published and is now visible to learners.\n\n"
            "{% if action_url %}Open the course: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p><strong>{{ course_title|default:'Your course' }}</strong> has been published and is now visible to learners.</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open the course</a></p>{% endif %}"
        ),
        "action_label_default": "Open course",
    },
    {
        "verb": V.REP_COURSE_UNPUBLISHED,
        "name": "REP course returned to draft",
        "headline_default": "A course has been returned to draft",
        "subject": "Course returned to draft: {{ course_title|default:'your course' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "{{ course_title|default:'A course' }} has been returned to draft.\n"
            "{% if reason %}Reason: {{ reason }}{% endif %}\n\n"
            "{% if action_url %}Open the course: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p><strong>{{ course_title|default:'A course' }}</strong> has been returned to draft.</p>"
            "{% if reason %}<p>Reason: <em>{{ reason }}</em></p>{% endif %}"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open the course</a></p>{% endif %}"
        ),
        "action_label_default": "Open course",
    },
    {
        "verb": V.REP_COURSE_REVIEW_SUBMITTED,
        "name": "REP course submitted for review",
        "headline_default": "Course awaiting publish review",
        "subject": "Review needed: {{ course_title|default:'a REP course' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "{{ course_title|default:'A REP course' }} has been submitted for publish review.\n\n"
            "{% if action_url %}Open the review: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p><strong>{{ course_title|default:'A REP course' }}</strong> has been submitted for publish review.</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open the review</a></p>{% endif %}"
        ),
        "action_label_default": "Open review",
    },
    {
        "verb": V.REP_COURSE_REVIEW_RETURNED,
        "name": "REP course review returned",
        "headline_default": "Your course was returned with comments",
        "subject": "Course returned for revisions: {{ course_title|default:'your course' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "{{ course_title|default:'Your course' }} was returned for revisions.\n"
            "{% if comment %}Reviewer comment:\n{{ comment }}{% endif %}\n\n"
            "{% if action_url %}Open the course: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p><strong>{{ course_title|default:'Your course' }}</strong> was returned for revisions.</p>"
            "{% if comment %}<p>Reviewer comment:</p><blockquote>{{ comment|linebreaksbr }}</blockquote>{% endif %}"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open the course</a></p>{% endif %}"
        ),
        "action_label_default": "Open course",
    },
    {
        "verb": V.REP_ASSIGNMENT_DEADLINE_EXTENDED,
        "name": "REP assignment deadline extended",
        "headline_default": "Assignment deadline extended",
        "subject": "Deadline extended: {{ assignment_title|default:'your assignment' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "The deadline for {{ assignment_title|default:'an assignment' }} "
            "in {{ course_title|default:'your course' }} has been extended to "
            "{{ new_due_at|default:'see course' }}.\n\n"
            "{% if action_url %}Open the assignment: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>The deadline for <strong>{{ assignment_title|default:'an assignment' }}</strong> "
            "in <strong>{{ course_title|default:'your course' }}</strong> has been extended to "
            "<strong>{{ new_due_at|default:'see course' }}</strong>.</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open the assignment</a></p>{% endif %}"
        ),
        "action_label_default": "Open assignment",
    },
    {
        "verb": V.REP_SCORM_ERROR,
        "name": "REP SCORM package error",
        "headline_default": "A learner hit a SCORM package error",
        "subject": "SCORM error in {{ lesson_title|default:'a lesson' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "{{ learner_email|default:'A learner' }} encountered a SCORM error "
            "in {{ lesson_title|default:'a lesson' }} "
            "({{ course_title|default:'a course' }}).\n"
            "Error code: {{ error_code|default:'unknown' }}.\n\n"
            "If this happens repeatedly, the package may be corrupt or "
            "incompatible. Re-upload the package or contact support.\n\n"
            "{% if action_url %}View submissions: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p><strong>{{ learner_email|default:'A learner' }}</strong> encountered a "
            "SCORM error in <strong>{{ lesson_title|default:'a lesson' }}</strong> "
            "({{ course_title|default:'a course' }}).</p>"
            "<p>Error code: <code>{{ error_code|default:'unknown' }}</code></p>"
            "<p>If this happens repeatedly, the package may be corrupt or "
            "incompatible. Re-upload the package or contact support.</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">View submissions</a></p>{% endif %}"
        ),
        "action_label_default": "View submissions",
    },
    # ------------------------------------------------------------------
    # RIMS Phase 3 — Application + reviewer integrity (FRFA-AM017, AM029)
    # ------------------------------------------------------------------
    {
        "verb": V.APPLICATION_READY_FOR_REVIEW,
        "name": "Application ready for review",
        "headline_default": "An application is ready for review",
        "subject": "Ready for review: {{ call_title|default:'IILMP call' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "The programme officer has cleared an application on "
            "\"{{ call_title|default:'an IILMP call' }}\" and it is now ready for reviewer scoring."
            "{% if application_reference %} Reference: {{ application_reference }}.{% endif %}\n\n"
            "Your reviewer queue lists every application assigned to you, with due dates and rubric.\n\n"
            "{% if action_url %}Open your reviewer queue: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p>The programme officer has cleared an application on "
            "<strong>\"{{ call_title|default:'an IILMP call' }}\"</strong> and it is now ready for reviewer scoring."
            "{% if application_reference %} Reference: <code>{{ application_reference }}</code>.{% endif %}</p>"
            "<p>Your reviewer queue lists every application assigned to you, with due dates and rubric.</p>"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Open your reviewer queue</a></p>{% endif %}"
        ),
        "action_label_default": "Open reviewer queue",
    },
    {
        "verb": V.REVIEWER_COI_DECLARED,
        "name": "Reviewer declared a conflict of interest",
        "headline_default": "Reviewer declared a conflict",
        "subject": "Reviewer COI on {{ call_title|default:'an IILMP application' }}",
        "body_text": (
            "Hi {{ recipient_name }},\n\n"
            "{{ reviewer_name|default:'A reviewer' }} has declared a conflict of interest on an application "
            "for \"{{ call_title|default:'an IILMP call' }}\""
            "{% if application_reference %} (reference: {{ application_reference }}){% endif %}.\n"
            "Their assignment has been blocked and the application returned to your queue for reassignment.\n"
            "{% if coi_notes %}\nDeclared reason:\n{{ coi_notes }}\n{% endif %}\n"
            "{% if action_url %}Reassign reviewers: {{ action_url }}{% endif %}"
        ),
        "body_html": (
            "<p>Hi {{ recipient_name }},</p>"
            "<p><strong>{{ reviewer_name|default:'A reviewer' }}</strong> has declared a conflict of interest on an application "
            "for <strong>\"{{ call_title|default:'an IILMP call' }}\"</strong>"
            "{% if application_reference %} (reference: <code>{{ application_reference }}</code>){% endif %}.</p>"
            "<p>Their assignment has been blocked and the application returned to your queue for reassignment.</p>"
            "{% if coi_notes %}<p>Declared reason:</p><blockquote>{{ coi_notes|linebreaksbr }}</blockquote>{% endif %}"
            "{% if action_url %}<p><a href=\"{{ action_url }}\">Reassign reviewers</a></p>{% endif %}"
        ),
        "action_label_default": "Reassign reviewers",
    },
]
