"""Generate a .docx version of the ResolutionFlow landing page content."""
from docx import Document
from docx.shared import Pt, RGBColor
from docx.enum.text import WD_ALIGN_PARAGRAPH
import os

doc = Document()

style = doc.styles['Normal']
style.font.name = 'Calibri'
style.font.size = Pt(11)
style.font.color.rgb = RGBColor(0x33, 0x33, 0x33)

for level in range(1, 4):
    hs = doc.styles[f'Heading {level}']
    hs.font.color.rgb = RGBColor(0x10, 0x11, 0x14)

# ── Title ──
title = doc.add_heading('ResolutionFlow', level=0)
title.alignment = WD_ALIGN_PARAGRAPH.CENTER
subtitle = doc.add_paragraph('From Issue to Resolution, Documented')
subtitle.alignment = WD_ALIGN_PARAGRAPH.CENTER
subtitle.runs[0].font.size = Pt(14)
subtitle.runs[0].font.color.rgb = RGBColor(0x06, 0xB6, 0xD4)

doc.add_paragraph('AI-guided decision trees that walk your engineers through troubleshooting and automatically document every step.').alignment = WD_ALIGN_PARAGRAPH.CENTER
doc.add_paragraph('')

# ── Hero ──
doc.add_heading('Stop writing ticket notes. Start generating them.', level=1)
doc.add_paragraph(
    'AI-guided decision trees that walk your engineers through troubleshooting — '
    'and automatically document every step, ready for your PSA ticket.'
)

# ── Social Proof ──
doc.add_paragraph('')
p = doc.add_paragraph()
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
run = p.add_run('Built by MSP engineers, for MSP engineers')
run.bold = True
run.font.size = Pt(12)

stats = doc.add_table(rows=1, cols=3)
stats.alignment = WD_ALIGN_PARAGRAPH.CENTER
for i, (num, label) in enumerate([
    ('15+', 'Years MSP Experience'),
    ('70%', 'Less Time on Documentation'),
    ('0', 'Ticket Notes Written by Hand'),
]):
    cell = stats.cell(0, i)
    p = cell.paragraphs[0]
    p.alignment = WD_ALIGN_PARAGRAPH.CENTER
    run = p.add_run(num)
    run.bold = True
    run.font.size = Pt(16)
    run.font.color.rgb = RGBColor(0x06, 0xB6, 0xD4)
    p.add_run('\n' + label).font.size = Pt(9)

doc.add_paragraph('')

# ── The Problem ──
doc.add_heading('The Problem', level=1)
doc.add_paragraph('Documentation is broken. Everyone knows it.')
doc.add_paragraph(
    "Engineers don't want to write it. Managers hate chasing it. "
    "Clients never see it. The same issues get solved from scratch every time."
)

problems = [
    ('15-25 min lost per ticket',
     'Engineers spend more time documenting what they did than actually doing it. '
     'After a complex issue, writing notes is the last thing anyone wants to do.'),
    ('Vague, useless notes',
     '"Fixed Outlook" tells you nothing. Documentation written under pressure tends '
     'toward generalities that help nobody the second time around.'),
    ('Knowledge walks out the door',
     'When a senior engineer leaves, years of tribal knowledge disappear overnight. '
     'New hires spend months building up what was never captured.'),
    ('Context switching kills speed',
     'Jumping between the issue, documentation tools, PSA tickets, and knowledge bases '
     'fragments focus and slows resolution.'),
]
for title_text, desc in problems:
    p = doc.add_paragraph()
    run = p.add_run(title_text)
    run.bold = True
    p.add_run(f'  --  {desc}')

doc.add_paragraph('')

# ── The Answer ──
doc.add_heading('The Answer', level=1)
p = doc.add_paragraph()
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
run = p.add_run('Resolution + Documentation - Time = ResolutionFlow')
run.bold = True
run.font.size = Pt(14)
run.font.color.rgb = RGBColor(0x06, 0xB6, 0xD4)

doc.add_paragraph(
    'What if documentation was a byproduct of solving the issue -- not a separate task? '
    'What if your engineers never had to write another ticket note?'
)

doc.add_paragraph('')

# ── How It Works ──
doc.add_heading('How It Works', level=1)
doc.add_paragraph('Three steps. Zero note-writing.')
doc.add_paragraph('Build once, run forever. Every session generates documentation automatically.')

steps = [
    ('1. Build a Flow',
     'Use the visual Flow Editor to create branching decision trees for any troubleshooting scenario. '
     'Drag, connect, and enrich steps with commands, notes, and AI suggestions.'),
    ('2. Run a Session',
     'An engineer launches the flow on a live ticket. FlowPilot -- your AI copilot -- acts as a virtual '
     'senior engineer, guiding decisions and capturing every action in real time.'),
    ('3. Export to Ticket',
     'When the session ends, full documentation is generated -- formatted for your PSA. Paste it directly '
     'into ConnectWise, Atera, or Syncro. Done.'),
]
for step_title, step_desc in steps:
    doc.add_heading(step_title, level=2)
    doc.add_paragraph(step_desc)

doc.add_paragraph('')

# ── Features ──
doc.add_heading('Features', level=1)
doc.add_paragraph('Everything your team needs to resolve faster and document better.')

features = [
    ('FlowPilot -- Your AI Copilot',
     'Like having a senior engineer on every call. FlowPilot suggests next steps, provides context-aware '
     'guidance, and automatically captures documentation as a byproduct of the troubleshooting session.'),
    ('Visual Flow Editor',
     'Build branching decision trees with a drag-and-drop canvas. Add steps, conditions, commands, and notes -- no code required.'),
    ('Auto-Documentation',
     'Every session generates timestamped, detailed notes -- formatted for your PSA. Engineers never write another ticket note.'),
    ('Team Knowledge Sharing',
     'Share flows across your team. When one engineer solves a new problem, the whole team benefits from that path -- instantly.'),
    ('Session History & Analytics',
     'Track which flows are used most, identify bottlenecks, and see how your team resolves issues over time.'),
    ('PSA Integration',
     'Connect directly to ConnectWise, Atera, and Syncro. Export session docs straight to tickets -- no copy-paste needed.'),
]
for feat_title, feat_desc in features:
    p = doc.add_paragraph()
    run = p.add_run(feat_title)
    run.bold = True
    p.add_run(f'  --  {feat_desc}')

doc.add_paragraph('')

# ── Pricing ──
doc.add_heading('Pricing', level=1)
doc.add_paragraph('Simple pricing. No surprises. Start free. Upgrade when your team is ready.')

pricing_table = doc.add_table(rows=9, cols=4)
pricing_table.style = 'Light Grid Accent 1'

headers = ['', 'Free', 'Pro', 'Team']
for i, h in enumerate(headers):
    cell = pricing_table.cell(0, i)
    cell.text = h
    for run in cell.paragraphs[0].runs:
        run.bold = True

rows_data = [
    ['Target', 'Individual techs evaluating', 'Small MSPs (1-5 techs)', 'Growing MSPs (5-25 techs)'],
    ['Price', '$0 -- Free forever', '$15/user/mo', '$25/user/mo'],
    ['Decision Trees', '3', 'Unlimited', 'Unlimited'],
    ['Sessions', '20/month', 'Unlimited', 'Unlimited'],
    ['FlowPilot AI', '--', 'Included', 'Included'],
    ['Exports', 'MD, TXT', 'All formats', 'All formats'],
    ['PSA Integration', '--', '--', 'ConnectWise, Atera, Syncro'],
    ['Support', 'Community', 'Priority', 'Dedicated'],
]
for row_idx, row_data in enumerate(rows_data):
    for col_idx, val in enumerate(row_data):
        pricing_table.cell(row_idx + 1, col_idx).text = val

doc.add_paragraph('')
p = doc.add_paragraph('Need Enterprise (25+ techs, SSO, custom branding)? Contact us at ')
run = p.add_run('hello@resolutionflow.com')
run.font.color.rgb = RGBColor(0x06, 0xB6, 0xD4)

doc.add_paragraph('')

# ── Testimonial ──
doc.add_heading('What People Are Saying', level=1)
p = doc.add_paragraph()
run = p.add_run(
    '"We used to spend more time writing ticket notes than solving the actual issue. '
    'Now it just... happens. The documentation writes itself while we work."'
)
run.italic = True
run.font.size = Pt(12)
doc.add_paragraph('-- Beta Tester, MSP Engineer, Southeast US')

doc.add_paragraph('')

# ── CTA ──
doc.add_heading('Ready to stop writing ticket notes?', level=1)
doc.add_paragraph(
    'Join the beta and see what happens when documentation becomes automatic.\n'
    'Free to start. No credit card required.'
)
p = doc.add_paragraph()
run = p.add_run('Sign up at resolutionflow.com')
run.bold = True
run.font.color.rgb = RGBColor(0x06, 0xB6, 0xD4)

doc.add_paragraph('')

# ── Footer ──
p = doc.add_paragraph()
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
run = p.add_run('\u00a9 2026 ResolutionFlow. All rights reserved.')
run.font.size = Pt(9)
run.font.color.rgb = RGBColor(0x88, 0x91, 0xA0)

# Save
out_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'ResolutionFlow-Landing-Page.docx')
doc.save(out_path)
print(f'Saved to {out_path}')
