from docx import Document
from docx.shared import Inches, Pt, RGBColor
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.enum.style import WD_STYLE_TYPE
import os

# Unicode narrow no-break space in macOS screenshot filenames
NBSP = "\u202f"

BASE = "/home/usr1/code2/temp"
doc = Document()

# --- Styles ---
style = doc.styles['Normal']
font = style.font
font.name = 'Calibri'
font.size = Pt(11)
font.color.rgb = RGBColor(0x22, 0x22, 0x22)
style.paragraph_format.space_after = Pt(6)
style.paragraph_format.line_spacing = 1.4

# Heading styles
for level in [1, 2, 3]:
    hs = doc.styles[f'Heading {level}']
    hs.font.name = 'Calibri'
    hs.font.color.rgb = RGBColor(0x22, 0x22, 0x22)
    hs.font.bold = True
    if level == 1:
        hs.font.size = Pt(22)
    elif level == 2:
        hs.font.size = Pt(16)
    else:
        hs.font.size = Pt(13)


def add_image(doc, filename, caption):
    """Add image with caption. Images are embedded directly."""
    path = os.path.join(BASE, filename)
    if os.path.exists(path):
        doc.add_picture(path, width=Inches(5.8))
        last = doc.paragraphs[-1]
        last.alignment = WD_ALIGN_PARAGRAPH.CENTER
        cap = doc.add_paragraph()
        cap.alignment = WD_ALIGN_PARAGRAPH.CENTER
        run = cap.add_run(caption)
        run.font.size = Pt(9)
        run.font.italic = True
        run.font.color.rgb = RGBColor(0x88, 0x88, 0x88)
    else:
        doc.add_paragraph(f"[Image not found: {filename}]")


def add_field(doc, name, detail, mandatory=False):
    p = doc.add_paragraph()
    p.paragraph_format.space_before = Pt(2)
    p.paragraph_format.space_after = Pt(2)
    run = p.add_run(f"  {name}:  ")
    run.bold = True
    run.font.size = Pt(11)
    p.add_run(detail).font.size = Pt(11)
    if mandatory:
        m = p.add_run("  [Mandatory]")
        m.font.size = Pt(9)
        m.font.bold = True
        m.font.color.rgb = RGBColor(0xCC, 0x00, 0x00)


def add_bullet(doc, text):
    doc.add_paragraph(text, style='List Bullet')


def add_section_break(doc):
    p = doc.add_paragraph()
    p.paragraph_format.space_before = Pt(4)
    p.paragraph_format.space_after = Pt(4)
    # thin line
    run = p.add_run("_" * 80)
    run.font.size = Pt(6)
    run.font.color.rgb = RGBColor(0xCC, 0xCC, 0xCC)


# ===========================
# COVER PAGE
# ===========================
for _ in range(6):
    doc.add_paragraph()

p = doc.add_paragraph()
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
run = p.add_run("Data Pool Management")
run.font.size = Pt(28)
run.bold = True

p = doc.add_paragraph()
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
run = p.add_run("Requirement Document")
run.font.size = Pt(18)
run.font.color.rgb = RGBColor(0x55, 0x55, 0x55)

doc.add_paragraph()

for line in [
    "Module: Enterprise Self-Service Portal",
    "Version: 1.0",
    "Date: 13 April 2026",
    "Status: Draft",
]:
    p = doc.add_paragraph()
    p.alignment = WD_ALIGN_PARAGRAPH.CENTER
    run = p.add_run(line)
    run.font.size = Pt(11)
    run.font.color.rgb = RGBColor(0x66, 0x66, 0x66)

doc.add_page_break()

# ===========================
# TABLE OF CONTENTS (manual)
# ===========================
doc.add_heading("Contents", level=1)
toc_items = [
    "Step 1 — Manage Services: Data Pool Section",
    "Step 2 — Buy Data Pool Plan: Choose Master Number",
    "Step 3 — Select Data Plan",
    "Step 4 — Plan Confirmation & Security Deposit Prompt",
    "Step 5 — Payment Gateway",
    "Step 6 — Payment: PIN Entry, Success & Failure",
    "Step 7 — Payment Success Confirmation",
    "Step 8 — Security Deposit Service Request (Alternate Path)",
    "Step 9 — Add / Remove Dependents (Individual & Bulk)",
    "Step 10 — Data Pool Deactivation",
    "Step 11 — Service Request Detail Page",
]
for item in toc_items:
    p = doc.add_paragraph(item)
    p.paragraph_format.space_after = Pt(3)

doc.add_page_break()

# ===========================
# STEP 1
# ===========================
doc.add_heading("Step 1 — Manage Services: Data Pool Section", level=1)

add_image(doc, f"Screenshot 2026-04-13 at 12.57.34{NBSP}PM.png",
          "Manage Services page with Data Pool tab selected")

doc.add_heading("Description", level=2)
doc.add_paragraph(
    "The user logs into the Enterprise Portal and navigates to Manage Services from the top navigation. "
    "The page shows the enterprise account context (company name, user name, IT account number) and two panels: "
    "Account Self Service (with action tiles like Activate New Line, Buy Product, etc.) and Account Service Request."
)
doc.add_paragraph(
    "Below the account-level panels, a tab bar provides access to: Mobile, M2M, Fixed Line, and Data Pool. "
    "The user clicks the Data Pool tab."
)
doc.add_paragraph("Under the Data Pool tab, two sections appear:")
add_bullet(doc, "Self Service — action tiles: Buy Plan, Add Dependent, Remove Dependent")
add_bullet(doc, "Service Request — for raising Data Pool specific SRs")
doc.add_paragraph(
    "Below these, four history tabs are shown: OPEN SRs (count), CLOSED SRs (count), SELF SERVICE HISTORY, "
    "and TRANSACTION HISTORY, with a search bar and date-range filter."
)

doc.add_heading("Fields", level=2)
add_field(doc, "Enterprise Name", 'Displayed in header. Example: "ABC Enterprise Ltd"')
add_field(doc, "User Name & MSISDN", 'Logged-in user. Example: "Nitin Kumar (9500038660)"')
add_field(doc, "IT Account Number", 'Unique account ID. Example: "4585959474 9"')
add_field(doc, "Search (History)", "Text input to filter history records")
add_field(doc, "Date Range Filter", 'Date picker. Example: "21/9/2020 - 10/10/2020"')

doc.add_heading("Validations", level=2)
add_bullet(doc, "User must be authenticated and linked to an enterprise IT account to access this page.")
add_bullet(doc, "Data Pool tab should only appear if the enterprise account has Data Pool feature enabled.")
add_bullet(doc, "SR counts (Open/Closed) must reflect real-time data.")

add_section_break(doc)
doc.add_page_break()

# ===========================
# STEP 2
# ===========================
doc.add_heading("Step 2 — Buy Data Pool Plan: Choose Master Number", level=1)

add_image(doc, f"Screenshot 2026-04-13 at 12.57.48{NBSP}PM.png",
          "Step 1 of Buy Data Pool Plan — Master Number selection with type-ahead search")

doc.add_heading("Description", level=2)
doc.add_paragraph(
    'User clicks "Buy Plan" from the Data Pool self-service section. The system opens the "Buy Data Pool Plan" page. '
    "The first step asks the user to choose a Master Number."
)
doc.add_paragraph(
    "As the user types in the search field, matching master numbers appear in a dropdown (type-ahead). "
    'After selecting a number and clicking "Continue", the "YOUR SELECTION" panel on the right updates to show the selected master mobile number.'
)

doc.add_heading("Fields", level=2)
add_field(doc, "Choose Master Number", "Search/input field with type-ahead dropdown.", mandatory=True)
add_field(doc, "YOUR SELECTION Panel", 'Right-side summary. Initially shows "You have not selected any service yet.", then updates with selected master number.')
add_field(doc, "Continue Button", "Proceeds to Step 2 (plan selection)")

doc.add_heading("Validations", level=2)
add_bullet(doc, "Master Number is mandatory. Continue button stays disabled until a valid number is selected.")
add_bullet(doc, "Only master numbers belonging to the logged-in enterprise account should appear in the dropdown.")
add_bullet(doc, "If a master number already has an active data pool, the system should indicate this or restrict re-purchase.")

add_section_break(doc)
doc.add_page_break()

# ===========================
# STEP 3
# ===========================
doc.add_heading("Step 3 — Select Data Plan", level=1)

add_image(doc, f"Screenshot 2026-04-13 at 12.57.59{NBSP}PM.png",
          "Available plans displayed with plan code, name, price, description, and validity")

add_image(doc, f"Screenshot 2026-04-13 at 12.58.22{NBSP}PM.png",
          "Plan selected (Super Plus 350) — YOUR SELECTION panel updated with product details")

doc.add_heading("Description", level=2)
doc.add_paragraph(
    "After selecting the master number, Step 2 loads a list of available data plans. Each plan shows its Plan Code, "
    "Plan Name with price, Plan Description (data, SMS, voice details), and Validity period. "
    "The user can select only one plan at a time via radio buttons."
)
doc.add_paragraph(
    "On selecting a plan, the YOUR SELECTION panel updates to show the Master Mobile Number and Product Details "
    "(plan name, price, description, validity)."
)
doc.add_paragraph(
    'Pagination is available if plans exceed the page size (e.g., "Showing 1 to 10 of 30 rows" with Prev/Next controls).'
)

doc.add_heading("Fields", level=2)
add_field(doc, "Plan Code", 'Unique identifier. Example: "PC_0012"')
add_field(doc, "Plan Name", 'Display name with price. Example: "Super Plus 350 — KES 350"')
add_field(doc, "Plan Description", 'Data volume, SMS count, voice details. Example: "10GB Data, 500 SMS, Unlimited Voice Call"')
add_field(doc, "Validity", 'Plan duration. Example: "30 Days", "60 Days"')
add_field(doc, "Radio Button (per row)", "Single-select. Only one plan active at a time.", mandatory=True)
add_field(doc, "YOUR SELECTION Panel", "Updates with: Master Mobile Number, Plan Name, Price, Description, Validity")
add_field(doc, "Pagination Controls", "Rows per page selector, Prev/Next, page numbers")

doc.add_heading("Validations", level=2)
add_bullet(doc, "Only one plan can be selected at a time.")
add_bullet(doc, "Continue button is enabled only after a plan is selected.")
add_bullet(doc, 'Plans with long descriptions should show a "read more" expandable link.')
add_bullet(doc, "If no plans are available, show an appropriate message.")

add_section_break(doc)
doc.add_page_break()

# ===========================
# STEP 4
# ===========================
doc.add_heading("Step 4 — Plan Confirmation & Security Deposit Prompt", level=1)

add_image(doc, f"Screenshot 2026-04-13 at 12.58.34{NBSP}PM.png",
          "Plan Selected modal — shows plan details, security deposit amount, and payment/waiver options")

doc.add_heading("Description", level=2)
doc.add_paragraph(
    'After selecting a plan and clicking Continue, a confirmation modal appears titled "Plan Selected". '
    "It displays the plan name, plan details (data, validity, price), and the Security deposit requirement amount."
)
doc.add_paragraph("The user has two paths from here:")
add_bullet(doc, 'Pay Now — Click the "Pay KES XXX" button to proceed to the payment gateway.')
add_bullet(doc, 'Request Waiver — Click "Don\'t want to pay security deposit. Contact our customer support team" to raise a Security Deposit Service Request instead (see Step 8).')
doc.add_paragraph('Clicking "Cancel" returns the user to the plan selection screen.')

doc.add_heading("Fields", level=2)
add_field(doc, "Plan Name", 'Selected plan. Example: "Super Plus 350"')
add_field(doc, "Plan Details", 'Data, validity, price. Example: "(20 GB data, 1 month validity, price KES 350)"')
add_field(doc, "Security Deposit Requirement", 'Amount calculated by backend. Example: "KES 350"')
add_field(doc, "Pay Button", '"Pay KES 350" — proceeds to payment gateway')
add_field(doc, "Cancel Button", "Returns to plan selection")
add_field(doc, "Waiver Link", '"Don\'t want to pay security deposit. Contact our customer support team" — opens Security Deposit SR form')

doc.add_heading("Validations", level=2)
add_bullet(doc, "Security deposit amount is calculated by backend based on account outstanding, overdue amount, and plan price.")
add_bullet(doc, "Pay button must clearly show the exact amount to be charged.")
add_bullet(doc, "Modal should not be dismissible by clicking outside (only via Cancel or Pay).")

add_section_break(doc)
doc.add_page_break()

# ===========================
# STEP 5
# ===========================
doc.add_heading("Step 5 — Payment Gateway", level=1)

add_image(doc, f"Screenshot 2026-04-13 at 12.59.29{NBSP}PM.png",
          "Payment page — Smartcash selected, plan purchase summary on right")

doc.add_heading("Description", level=2)
doc.add_paragraph(
    'User is redirected to the Airtel payment gateway. The page title is "How will you pay". '
    "Payment methods are listed as tabs on the left: Smartcash, Credit / Debit Card."
)
doc.add_paragraph(
    "For Smartcash, the user provides their email (for receipt) and phone number (pre-filled, used for OTP). "
    "A Plan Purchase summary on the right shows the plan name, description, and total amount."
)
doc.add_paragraph('The user clicks "PROCEED" to initiate payment or "CANCEL" to go back.')

doc.add_heading("Fields", level=2)
add_field(doc, "Payment Method Tabs", "Smartcash, Credit / Debit Card")
add_field(doc, "Email ID", "For sending payment receipt.", mandatory=True)
add_field(doc, "Phone Number", "Pre-filled. OTP sent to this number.", mandatory=True)
add_field(doc, "Plan Purchase Summary", 'Plan name, description, total amount (e.g., "KES 350")')
add_field(doc, "PROCEED Button", "Initiates payment processing")
add_field(doc, "CANCEL Button", "Returns to previous screen")

doc.add_heading("Validations", level=2)
add_bullet(doc, "Email must be a valid email format.")
add_bullet(doc, "Phone number must be pre-filled and non-editable (or editable with valid Airtel number validation).")
add_bullet(doc, '"Please ensure sufficient balance to avoid failure" warning must be displayed.')
add_bullet(doc, "All payment data must be transmitted over HTTPS/TLS.")
add_bullet(doc, "PROCEED button should be disabled until all mandatory fields are filled.")

add_section_break(doc)
doc.add_page_break()

# ===========================
# STEP 6
# ===========================
doc.add_heading("Step 6 — Payment: PIN Entry, Success & Failure", level=1)

add_image(doc, f"Screenshot 2026-04-13 at 12.59.45{NBSP}PM.png",
          "SmartCash PIN entry modal — leads to successful or unsuccessful transaction")

doc.add_heading("Description", level=2)
doc.add_paragraph(
    'After clicking PROCEED with Smartcash, a PIN entry modal appears titled "Enter SmartCash PIN". '
    "The user enters their 4-digit PIN in masked input fields."
)
doc.add_paragraph("Two outcomes:")
add_bullet(doc, "Successful transaction — redirects to the Payment Success page (Step 7).")
add_bullet(doc, "Unsuccessful transaction — displays an error. The user can retry or return to the Data Pool section.")

doc.add_heading("Fields", level=2)
add_field(doc, "SmartCash PIN", "4-digit masked input fields.", mandatory=True)

doc.add_heading("Validations", level=2)
add_bullet(doc, "PIN input must be masked (dots/asterisks) for security.")
add_bullet(doc, "PIN must be exactly 4 digits.")
add_bullet(doc, "On failure, a clear error message must be shown with retry option.")
add_bullet(doc, "Maximum retry attempts should be enforced (backend-driven).")
add_bullet(doc, "Session timeout should apply if PIN entry is left idle.")

add_section_break(doc)
doc.add_page_break()

# ===========================
# STEP 7
# ===========================
doc.add_heading("Step 7 — Payment Success Confirmation", level=1)

add_image(doc, f"Screenshot 2026-04-13 at 12.59.50{NBSP}PM.png",
          "Payment Successful page with transaction summary and provisioning indicator")

doc.add_heading("Description", level=2)
doc.add_paragraph("On successful payment, the user sees a confirmation page with:")
add_bullet(doc, '"Thank You / Payment Successful!" message.')
add_bullet(doc, '"We have received your payment, please wait till we provision the plan for your account." with a loading spinner.')
add_bullet(doc, "A Payment Summary panel showing the transaction confirmation for the MSISDN, Transaction ID, and date/time.")
add_bullet(doc, 'A "BACK TO DATA POOL" link to return to the Data Pool section.')
doc.add_paragraph("After successful payment and provisioning, the user can proceed to add dependents.")

doc.add_heading("Fields", level=2)
add_field(doc, "Transaction Status", '"Successful" (displayed in green)')
add_field(doc, "Transaction ID", 'Unique reference. Example: "TR-100001221323401O"')
add_field(doc, "Date & Time", 'Timestamp. Example: "17/02/2026, 2:23 PM"')
add_field(doc, "MSISDN", 'Master number. Example: "9971698631"')
add_field(doc, "BACK TO DATA POOL", "Navigation back to Data Pool section")

doc.add_heading("Validations", level=2)
add_bullet(doc, "Transaction ID must be generated and displayed immediately upon payment confirmation.")
add_bullet(doc, "Provisioning spinner should remain until backend confirms plan activation (or timeout with message).")
add_bullet(doc, "Transaction must be logged in the Transaction History tab.")

add_section_break(doc)
doc.add_page_break()

# ===========================
# STEP 8
# ===========================
doc.add_heading("Step 8 — Security Deposit Service Request (Alternate Path)", level=1)

add_image(doc, f"Screenshot 2026-04-13 at 12.58.55{NBSP}PM.png",
          "Security Deposit SR form — pre-filled account and plan details with waiver reason input")

doc.add_heading("Description", level=2)
doc.add_paragraph(
    "If the user does not want to pay the security deposit upfront, they click the "
    '"Contact our customer support team" link from the Plan Confirmation modal (Step 4). '
    "This opens a Security Deposit service request form."
)
doc.add_paragraph(
    "Most fields are pre-filled and read-only. The user only needs to provide the "
    '"Reason for security deposit waiver" and click Submit. '
    'A Service Request is created with status "Pending" and can be tracked on the SR detail page (Step 11).'
)

doc.add_heading("Fields", level=2)
add_field(doc, "Account Number", 'Pre-filled, read-only. Example: "4585959474 9"', mandatory=True)
add_field(doc, "Outstanding Amount", 'Pre-filled, read-only. Example: "KES 100000"', mandatory=True)
add_field(doc, "Overdue Amount", 'Pre-filled, read-only. Example: "KES 50000"', mandatory=True)
add_field(doc, "Plan Details", 'Pre-filled, read-only. Example: "Smart plan 1000 (20 GB data, 1 month validity, price KES 350)"', mandatory=True)
add_field(doc, "Security Deposit Required", 'Pre-filled, read-only. Example: "KES 120000"', mandatory=True)
add_field(doc, "Contact Person", 'Pre-filled, read-only. Example: "9971698631 / Cyrac Francis"', mandatory=True)
add_field(doc, "Reason for security deposit waiver", "Textarea. User must enter justification.", mandatory=True)

doc.add_heading("Validations", level=2)
add_bullet(doc, '"Reason for security deposit waiver" is mandatory. Submit button disabled if empty.')
add_bullet(doc, "All pre-filled fields must be read-only and not editable.")
add_bullet(doc, 'On Submit, SR is created with SR Type = "Security deposit" and status = "Pending".')
add_bullet(doc, "User should receive confirmation with SR number after submission.")
add_bullet(doc, "Cancel button closes the form without creating an SR.")

add_section_break(doc)
doc.add_page_break()

# ===========================
# STEP 9
# ===========================
doc.add_heading("Step 9 — Add / Remove Dependents (Individual & Bulk)", level=1)

doc.add_heading("Description", level=2)
doc.add_paragraph(
    "Once a Data Pool plan is active, the user can manage dependent numbers from the Data Pool section. "
    "Two actions are available: Add Dependent and Remove Dependent. Each supports individual and bulk operations."
)

doc.add_heading("9a. Add Dependent — Individual", level=3)
doc.add_paragraph('User clicks "Add Dependent" and enters a single mobile number to add to the data pool.')

doc.add_heading("9b. Add Dependent — Bulk Upload", level=3)
doc.add_paragraph(
    'Visible as "Add Dependents Number/Upload Bulk" in the Buy Plan flow. '
    "User uploads a file (CSV/Excel) containing multiple dependent numbers."
)

doc.add_heading("9c. Remove Dependent — Individual", level=3)
doc.add_paragraph(
    'User clicks "Remove Dependent" and selects a number currently in the pool to remove. '
    "A confirmation dialog appears before execution."
)

doc.add_heading("9d. Remove Dependent — Bulk", level=3)
doc.add_paragraph("User uploads a file (CSV/Excel) of numbers to remove in bulk.")

doc.add_heading("Fields", level=2)
add_field(doc, "Dependent Mobile Number (Individual)", "Input field for single number entry.", mandatory=True)
add_field(doc, "Bulk Upload File", "File input accepting CSV or Excel format.", mandatory=True)
add_field(doc, "Confirmation Dialog (Remove)", "Confirm/Cancel prompt before removing a dependent")

doc.add_heading("Validations", level=2)
add_bullet(doc, "Dependent number must be a valid Airtel number.")
add_bullet(doc, "Dependent must not already belong to another active data pool (for add).")
add_bullet(doc, "Maximum dependent limit per pool (e.g., 50). Block with message if reached.")
add_bullet(doc, "Bulk upload must validate all numbers and report success/failure count.")
add_bullet(doc, "Bulk file must be CSV or Excel format. Reject other formats with error.")
add_bullet(doc, "Removal requires a confirmation prompt before execution.")
add_bullet(doc, "All add/remove operations must be logged in the Self Service History tab.")

add_section_break(doc)
doc.add_page_break()

# ===========================
# STEP 10
# ===========================
doc.add_heading("Step 10 — Data Pool Deactivation", level=1)

add_image(doc, f"Screenshot 2026-04-13 at 1.05.21{NBSP}PM.png",
          "Deactivation request raised — confirmation with SR number, from the Actions menu")

doc.add_heading("Description", level=2)
doc.add_paragraph(
    "On the Data Pool listing page, each active pool entry shows the master number, line type (Postpaid), "
    "status (Active), plan details, data usage, expiry information, and dependent count (e.g., '10/50 numbers added')."
)
doc.add_paragraph(
    "An Actions menu (three-dot icon) is available per entry with options: Buy Plan, Add Dependents, "
    "Remove Dependents, and Deactivate Data Pool."
)
doc.add_paragraph(
    'Clicking "Deactivate Data Pool" immediately raises a Service Request. A confirmation dialog appears showing:'
)
add_bullet(doc, '"Deactivation request raised" with a green checkmark.')
add_bullet(doc, '"Your request to deactivate data pool master line has been submitted."')
add_bullet(doc, 'The assigned SR Number (e.g., "SR No: 12340513").')
add_bullet(doc, 'A "Close" button to dismiss the dialog.')
doc.add_paragraph(
    'A "Download Dependents" button is also available to export the current list of dependent numbers.'
)

doc.add_heading("Fields", level=2)
add_field(doc, "Master Number", 'Highlighted. Example: "9971698631"')
add_field(doc, "Line Type", 'Example: "Postpaid"')
add_field(doc, "Status", '"Active"')
add_field(doc, "Plan Details", 'Plan name, data, price, dependent limit')
add_field(doc, "Data Usage", 'Consumed vs total. Example: "5 GB data used"')
add_field(doc, "Expiry", 'Plan expiry date')
add_field(doc, "Dependent Count", 'Added vs limit. Example: "10/50 numbers added"')
add_field(doc, "Actions Menu", "Buy Plan, Add Dependents, Remove Dependents, Deactivate Data Pool")
add_field(doc, "SR Number (confirmation)", 'Auto-generated. Example: "12340513"')

doc.add_heading("Validations", level=2)
add_bullet(doc, "Deactivation is not immediate — it always creates a Service Request for back-office processing.")
add_bullet(doc, "SR number must be generated and shown in the confirmation dialog.")
add_bullet(doc, "Deactivation SR must appear in the Open SRs tab and be trackable on the SR detail page.")
add_bullet(doc, 'Only active data pools should show the "Deactivate Data Pool" option.')

add_section_break(doc)
doc.add_page_break()

# ===========================
# STEP 11
# ===========================
doc.add_heading("Step 11 — Service Request Detail Page", level=1)

add_image(doc, f"Screenshot 2026-04-13 at 1.07.30{NBSP}PM.png",
          "Service Request detail page — Security Deposit SR with status, creator, remarks, and attachments")

doc.add_heading("Description", level=2)
doc.add_paragraph(
    "The user can view details of any Service Request (Security Deposit, Deactivation, etc.) by clicking "
    "the SR from the Open SRs or Closed SRs tab. The SR detail page shows all relevant information."
)
doc.add_paragraph("Breadcrumb navigation: Dashboard > Manage Services > Contact Us.")

doc.add_heading("Fields", level=2)
add_field(doc, "SR Type", 'Type of request. Example: "Security deposit"')
add_field(doc, "SR No", 'Unique identifier. Example: "12009340"')
add_field(doc, "Account Number", 'Enterprise IT account. Example: "4585959474 9"')
add_field(doc, "Status", 'Current status with badge. Example: "Pending" (orange)')
add_field(doc, "Expected Closure Date", 'Target resolution date. Example: "20/02/2026"')
add_field(doc, "Created By", 'User + timestamp. Example: "Mohit Kumar, 18/02/2026, 03:08 AM"')
add_field(doc, "Remarks", "Free-text notes about the SR")
add_field(doc, "Attachment", 'Attached files with name and size. Example: "screenshot.png, 5 Kb". Downloadable.')

doc.add_heading("Validations", level=2)
add_bullet(doc, "All fields are read-only on the SR detail page.")
add_bullet(doc, "Status badge color should reflect state (orange=Pending, green=Resolved, red=Rejected).")
add_bullet(doc, "Attachments must be downloadable.")
add_bullet(doc, "Breadcrumb navigation must be functional.")
add_bullet(doc, "SR detail page must be accessible from both Open SRs and Closed SRs tabs.")

# --- Footer ---
doc.add_paragraph()
p = doc.add_paragraph()
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
run = p.add_run("— End of Document —")
run.font.size = Pt(10)
run.font.color.rgb = RGBColor(0x99, 0x99, 0x99)
p = doc.add_paragraph()
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
run = p.add_run("Data Pool Management — Requirement Document — Version 1.0 — 13 April 2026")
run.font.size = Pt(9)
run.font.color.rgb = RGBColor(0x99, 0x99, 0x99)

# Save
output_path = os.path.join(BASE, "Data_Pool_Management_Requirements.docx")
doc.save(output_path)
print(f"Document saved: {output_path}")
