from docx import Document
from docx.shared import Pt, RGBColor, Inches, Cm
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.enum.style import WD_STYLE_TYPE
from docx.oxml.ns import qn
from docx.oxml import OxmlElement
import copy

# ─── Colors ───
PINK   = RGBColor(0xE8, 0x19, 0x5A)
VIOLET = RGBColor(0x7C, 0x3A, 0xED)
TEAL   = RGBColor(0x08, 0x91, 0xB2)
AMBER  = RGBColor(0xD9, 0x77, 0x06)
GREEN  = RGBColor(0x05, 0x96, 0x69)
BLUE   = RGBColor(0x25, 0x63, 0xEB)
DARK   = RGBColor(0x11, 0x18, 0x27)
BODY   = RGBColor(0x37, 0x41, 0x51)
GRAY   = RGBColor(0x6B, 0x72, 0x80)
WHITE  = RGBColor(0xFF, 0xFF, 0xFF)
SOFT   = RGBColor(0xF9, 0xFA, 0xFB)
BORDER = RGBColor(0xE5, 0xE7, 0xEB)
PINK_BG = RGBColor(0xFF, 0xF0, 0xF5)

doc = Document()

# ─── Page Margins ───
for section in doc.sections:
    section.top_margin    = Cm(2.0)
    section.bottom_margin = Cm(2.0)
    section.left_margin   = Cm(2.5)
    section.right_margin  = Cm(2.5)

def set_cell_bg(cell, hex_color):
    """Set table cell background color."""
    tc = cell._tc
    tcPr = tc.get_or_add_tcPr()
    shd = OxmlElement('w:shd')
    shd.set(qn('w:val'), 'clear')
    shd.set(qn('w:color'), 'auto')
    shd.set(qn('w:fill'), hex_color)
    tcPr.append(shd)

def set_cell_borders(cell, top=None, bottom=None, left=None, right=None):
    tc = cell._tc
    tcPr = tc.get_or_add_tcPr()
    tcBorders = OxmlElement('w:tcBorders')
    for side, val in [('top', top), ('bottom', bottom), ('left', left), ('right', right)]:
        if val:
            el = OxmlElement(f'w:{side}')
            el.set(qn('w:val'), val.get('val', 'single'))
            el.set(qn('w:sz'), str(val.get('sz', 6)))
            el.set(qn('w:color'), val.get('color', 'E5E7EB'))
            tcBorders.append(el)
    tcPr.append(tcBorders)

def add_paragraph(text='', bold=False, italic=False, size=11, color=None, align=WD_ALIGN_PARAGRAPH.LEFT, space_before=0, space_after=6):
    p = doc.add_paragraph()
    p.alignment = align
    p.paragraph_format.space_before = Pt(space_before)
    p.paragraph_format.space_after  = Pt(space_after)
    if text:
        run = p.add_run(text)
        run.bold   = bold
        run.italic = italic
        run.font.size = Pt(size)
        run.font.color.rgb = color or DARK
    return p

def add_mixed(parts, align=WD_ALIGN_PARAGRAPH.LEFT, space_before=0, space_after=6):
    """parts = list of (text, bold, color, size)"""
    p = doc.add_paragraph()
    p.alignment = align
    p.paragraph_format.space_before = Pt(space_before)
    p.paragraph_format.space_after  = Pt(space_after)
    for text, bold, color, size in parts:
        run = p.add_run(text)
        run.bold = bold
        run.font.size = Pt(size)
        run.font.color.rgb = color
    return p

def add_cover_title():
    p = doc.add_paragraph()
    p.alignment = WD_ALIGN_PARAGRAPH.CENTER
    p.paragraph_format.space_before = Pt(60)
    p.paragraph_format.space_after  = Pt(4)
    r1 = p.add_run('GHL Agency\n')
    r1.bold = True
    r1.font.size = Pt(36)
    r1.font.color.rgb = DARK
    r2 = p.add_run('Starter Prompt Pack')
    r2.bold = True
    r2.font.size = Pt(36)
    r2.font.color.rgb = PINK

def add_stats_row():
    """3-column stats table."""
    table = doc.add_table(rows=1, cols=3)
    table.style = 'Table Grid'
    table.alignment = WD_ALIGN_PARAGRAPH.CENTER
    for i, (num, label) in enumerate([('50', 'PROMPTS'), ('6', 'CATEGORIES'), ('∞', 'USES')]):
        cell = table.cell(0, i)
        set_cell_bg(cell, 'FFFFFF')
        p = cell.paragraphs[0]
        p.alignment = WD_ALIGN_PARAGRAPH.CENTER
        p.paragraph_format.space_before = Pt(8)
        p.paragraph_format.space_after  = Pt(2)
        r = p.add_run(num + '\n')
        r.bold = True
        r.font.size = Pt(28)
        r.font.color.rgb = PINK
        r2 = p.add_run(label)
        r2.bold = True
        r2.font.size = Pt(9)
        r2.font.color.rgb = GRAY
    return table

def add_cat_banner(emoji, eyebrow, title, desc, bg_hex='FFF0F6'):
    table = doc.add_table(rows=1, cols=1)
    table.style = 'Table Grid'
    cell = table.cell(0, 0)
    set_cell_bg(cell, bg_hex)
    p = cell.paragraphs[0]
    p.paragraph_format.space_before = Pt(4)
    p.paragraph_format.space_after  = Pt(4)
    p.alignment = WD_ALIGN_PARAGRAPH.LEFT

    r_ey = p.add_run(eyebrow.upper() + '\n')
    r_ey.bold = True
    r_ey.font.size = Pt(8)
    r_ey.font.color.rgb = GRAY

    r_t = p.add_run(emoji + '  ' + title + '\n')
    r_t.bold = True
    r_t.font.size = Pt(16)
    r_t.font.color.rgb = DARK

    r_d = p.add_run(desc)
    r_d.font.size = Pt(10)
    r_d.font.color.rgb = BODY

    doc.add_paragraph().paragraph_format.space_after = Pt(4)
    return table

def add_prompt_card(num, title, tags, prompt_text):
    # Outer table 1-row 1-col
    table = doc.add_table(rows=1, cols=1)
    table.style = 'Table Grid'
    outer = table.cell(0, 0)
    set_cell_bg(outer, 'FFFFFF')

    p = outer.paragraphs[0]
    p.paragraph_format.space_before = Pt(2)
    p.paragraph_format.space_after  = Pt(2)

    # Number badge + title
    r_num = p.add_run(f'{num}  ')
    r_num.bold = True
    r_num.font.size = Pt(10)
    r_num.font.color.rgb = PINK

    r_t = p.add_run(title + '\n')
    r_t.bold = True
    r_t.font.size = Pt(11)
    r_t.font.color.rgb = DARK

    # Tags
    r_tags = p.add_run('  '.join([f'[{t}]' for t in tags]) + '\n')
    r_tags.font.size = Pt(8)
    r_tags.font.color.rgb = VIOLET

    # Prompt box label
    r_lbl = p.add_run('📋 Copy & Paste →\n')
    r_lbl.bold = True
    r_lbl.font.size = Pt(8)
    r_lbl.font.color.rgb = GRAY

    # Prompt text
    r_pt = p.add_run(prompt_text)
    r_pt.font.size = Pt(10)
    r_pt.font.color.rgb = BODY

    # small spacer
    sp = doc.add_paragraph()
    sp.paragraph_format.space_after = Pt(6)

def add_section_break():
    p = doc.add_paragraph('─' * 80)
    p.paragraph_format.space_before = Pt(8)
    p.paragraph_format.space_after  = Pt(8)
    run = p.runs[0]
    run.font.size = Pt(6)
    run.font.color.rgb = BORDER

def add_page_break():
    doc.add_page_break()

def add_h1(text):
    p = add_paragraph(text, bold=True, size=20, color=DARK, space_before=12, space_after=4)
    p.alignment = WD_ALIGN_PARAGRAPH.LEFT
    # Pink underline effect: just add colored run
    return p

def add_h2(text, color=PINK):
    p = doc.add_paragraph()
    p.paragraph_format.space_before = Pt(8)
    p.paragraph_format.space_after  = Pt(4)
    r = p.add_run(text)
    r.bold = True
    r.font.size = Pt(14)
    r.font.color.rgb = color
    return p

def add_tip_box(label, text):
    table = doc.add_table(rows=1, cols=1)
    table.style = 'Table Grid'
    cell = table.cell(0, 0)
    set_cell_bg(cell, 'FFF5F8')
    p = cell.paragraphs[0]
    p.paragraph_format.space_before = Pt(4)
    p.paragraph_format.space_after  = Pt(4)
    r_l = p.add_run(label + '\n')
    r_l.bold = True
    r_l.font.size = Pt(9)
    r_l.font.color.rgb = PINK
    r_t = p.add_run(text)
    r_t.font.size = Pt(10)
    r_t.font.color.rgb = BODY
    doc.add_paragraph().paragraph_format.space_after = Pt(6)

# ══════════════════════════════
# COVER PAGE
# ══════════════════════════════
add_paragraph('⚡  VOL. 1 — GHL ESSENTIALS', bold=True, size=9, color=PINK,
              align=WD_ALIGN_PARAGRAPH.CENTER, space_before=0, space_after=8)
add_paragraph('THE AGENCY OWNER\'S SHORTCUT', bold=False, size=9, color=GRAY,
              align=WD_ALIGN_PARAGRAPH.CENTER, space_before=0, space_after=8)
add_cover_title()
add_paragraph(
    '50 ready-to-use ChatGPT prompts for GHL agencies — covering lead gen, follow-up, '
    'onboarding, ad copy, client retention, and social media.',
    size=12, color=BODY, align=WD_ALIGN_PARAGRAPH.CENTER, space_before=10, space_after=20
)
add_stats_row()
add_paragraph('', space_before=14, space_after=4)
cats = ['🎯 Lead Generation', '🔄 Follow-Up Sequences', '🤝 Client Onboarding',
        '📢 Ad Copy & Funnels', '📊 Client Retention', '📱 Social Media']
add_paragraph('  ·  '.join(cats), size=10, color=GRAY,
              align=WD_ALIGN_PARAGRAPH.CENTER, space_before=8, space_after=20)
add_paragraph('MelAI ✦ HireAI  |  2026 Edition', bold=True, size=10, color=GRAY,
              align=WD_ALIGN_PARAGRAPH.CENTER, space_before=40, space_after=0)

add_page_break()

# ══════════════════════════════
# HOW TO USE
# ══════════════════════════════
add_paragraph('GETTING STARTED', bold=True, size=9, color=PINK, space_before=0, space_after=4)
add_h1('How to Use This Prompt Pack')

steps = [
    ('01  Fill In the Brackets',
     'Every prompt has [placeholders]. Replace them with your niche, client name, offer, or specific details before running the prompt.'),
    ('02  Pick Your AI Tool',
     'Works with ChatGPT GPT-4o, Claude, or Gemini. ChatGPT GPT-4o gives the best copywriting output for marketing content.'),
    ('03  Iterate & Refine',
     'After the first output follow up: "Make it shorter", "More casual", "Add urgency", or "Write 3 variations."'),
    ('04  Build Your Swipe File',
     'Save every output that works into a Google Doc. After 90 days you\'ll have a library of proven copy to reuse forever.'),
]

for title, desc in steps:
    p = doc.add_paragraph()
    p.paragraph_format.space_before = Pt(4)
    p.paragraph_format.space_after  = Pt(2)
    r1 = p.add_run(title + '\n')
    r1.bold = True
    r1.font.size = Pt(11)
    r1.font.color.rgb = DARK
    r2 = p.add_run(desc)
    r2.font.size = Pt(10)
    r2.font.color.rgb = BODY

add_paragraph('', space_after=6)
add_tip_box(
    '⚡ POWER MOVE — Add This Before Any Prompt',
    '"You are an expert GHL marketing strategist for [niche] businesses. Write in a conversational, direct '
    'tone — no corporate language, no filler, no AI-sounding phrases."'
)
add_paragraph('Paste outputs directly into GHL:', bold=True, size=10, color=DARK, space_before=4, space_after=4)
add_paragraph('✉️ Email Templates  ·  💬 SMS Workflows  ·  🔗 Funnel Pages  ·  🤖 Chatbot Flows  ·  📱 Social Planner  ·  📋 SOPs',
              size=10, color=BODY, space_before=0, space_after=8)

add_page_break()

# ══════════════════════════════
# TABLE OF CONTENTS
# ══════════════════════════════
add_paragraph('NAVIGATION', bold=True, size=9, color=PINK, space_before=0, space_after=4)
add_h1('Table of Contents')

toc = [
    ('01', '🎯 Lead Generation',              '#1–#10',  'Cold DMs, email hooks, Facebook ad hooks, database reactivation, VSL scripts'),
    ('02', '🔄 Follow-Up & Nurture Sequences','#11–#20', 'Speed-to-lead SMS, 5-day nurture, no-show recovery, objection handling'),
    ('03', '🤝 Client Onboarding',            '#21–#28', 'Welcome emails, kickoff agendas, GHL sub-account SOPs, expectation-setting'),
    ('04', '📢 Ad Copy & Sales Funnels',      '#29–#36', 'Facebook ads, landing pages, retargeting scripts, 5-email sequences'),
    ('05', '📊 Client Reporting & Retention', '#37–#43', 'Monthly reports, check-in SMS, upsell emails, handling complaints, renewals'),
    ('06', '📱 Social Media Content',         '#44–#50', 'LinkedIn posts, Instagram captions, TikTok scripts, 30-day calendar'),
]

for num, title, prompts, desc in toc:
    p = doc.add_paragraph()
    p.paragraph_format.space_before = Pt(3)
    p.paragraph_format.space_after  = Pt(3)
    r_n = p.add_run(f'{num}  ')
    r_n.bold = True
    r_n.font.size = Pt(13)
    r_n.font.color.rgb = PINK
    r_t = p.add_run(title)
    r_t.bold = True
    r_t.font.size = Pt(12)
    r_t.font.color.rgb = DARK
    r_p = p.add_run(f'  ({prompts})\n')
    r_p.font.size = Pt(9)
    r_p.font.color.rgb = GRAY
    r_d = p.add_run(f'     {desc}')
    r_d.font.size = Pt(10)
    r_d.font.color.rgb = BODY

add_paragraph('', space_after=8)
add_tip_box(
    '🚀 Quick Start — First 15 Minutes',
    'Run Prompt #1 (Cold DM), Prompt #12 (Speed-to-Lead SMS), and Prompt #21 (Welcome Email). '
    'Three working GHL assets — done.'
)

add_page_break()

# ══════════════════════════════
# ALL PROMPTS DATA
# ══════════════════════════════
categories = [
    {
        'emoji': '🎯', 'eyebrow': 'Prompts #1–#10',
        'title': 'Lead Generation',
        'desc': 'Fill your pipeline. Cold outreach, hooks, ad copy, database reactivation, and market research.',
        'bg': 'FFF0F6',
        'prompts': [
            ('#01', 'Cold Outreach DM — Instagram / Facebook',
             ['DM', '60 words max', 'Soft CTA'],
             'Write a 3-sentence cold DM for a [niche] business owner introducing my GHL-powered marketing agency. '
             'Feel human, not salesy, mention ONE pain point (slow lead response), end with a soft CTA asking if '
             'they\'re open to a quick chat. Under 60 words.'),
            ('#02', 'Cold Email Subject Lines — A/B Test Pack',
             ['Email', '10 subject lines', '3 angles'],
             'Write 10 cold email subject lines for a marketing agency targeting [niche] business owners. Make 5 curiosity-based, '
             '3 pain-point-based, and 2 results-based. Avoid spam words like "free" or "guaranteed". Goal: high open rates.'),
            ('#03', 'Lead Magnet Title Generator',
             ['Lead Magnets', '10 ideas', 'Fast results'],
             'Generate 10 irresistible lead magnet titles for [niche] business owners. Each should promise a specific, fast result. '
             'Format: [Number] + [Outcome] + [Timeframe]. Example: "5 Texts That Book Appointments in 24 Hours".'),
            ('#04', 'Facebook Ad Hook Pack',
             ['Facebook Ads', '7 hooks', '3 hook types'],
             'Write 7 scroll-stopping hooks for Facebook/Instagram ads targeting [niche] owners struggling to get leads. '
             'Mix question hooks, bold statement hooks, and story hooks. Each hook should grab attention in the first line.'),
            ('#05', 'LinkedIn Prospecting Message Sequence',
             ['LinkedIn', '3 messages', '3 days apart'],
             'Write a LinkedIn connection request + 2 follow-up messages (3 days apart each) targeting [niche] business owners. '
             'Goal: book a discovery call. Professional but conversational. No pitching in message 1.'),
            ('#06', 'VSL (Video Sales Letter) Script Outline',
             ['Video', '5 minutes', '6 sections'],
             'Create a 5-minute VSL script outline for a GHL agency targeting [niche] businesses. Include: Hook (30s), '
             'Pain Agitation (60s), Solution (60s), Social Proof (60s), Offer Breakdown (60s), CTA (30s).'),
            ('#07', 'Database Reactivation SMS Sequence',
             ['SMS', '3 messages', '160 chars each'],
             'Write a 3-message SMS sequence to reactivate cold leads in a [niche] business\'s old database. '
             'Message 1: Re-engage with curiosity. Message 2 (24hrs later): Soft offer. '
             'Message 3 (48hrs later): Final nudge with urgency. Each under 160 characters.'),
            ('#08', 'Google Business Profile Post',
             ['Google', 'Local SEO', 'Under 1500 chars'],
             'Write a Google Business Profile post for a [niche] business to attract local leads. Include a pain point, '
             'brief solution, social proof placeholder, and a CTA with a GHL booking link. Under 1500 characters. Conversational tone.'),
            ('#09', 'Referral Request Script (SMS)',
             ['SMS', 'Casual tone', 'Incentive included'],
             'Write a text message script for a [niche] business owner to send to satisfied clients asking for referrals. '
             'Casual, not pushy. Include a simple incentive mention. Should feel like a friend texting, not a corporation.'),
            ('#10', 'Niche Market Research Prompt',
             ['Research', 'Pain points', 'Messaging clarity'],
             'Act as a market researcher. For [niche] businesses in [location], identify: 1) Top 3 pain points getting clients, '
             '2) Objections to marketing services, 3) Their dream outcome, 4) The exact words they use to describe their problems.'),
        ]
    },
    {
        'emoji': '🔄', 'eyebrow': 'Prompts #11–#20',
        'title': 'Follow-Up & Nurture Sequences',
        'desc': 'Turn cold leads into booked calls. Speed-to-lead SMS, nurture emails, no-show recovery, and objection handlers.',
        'bg': 'F5F0FF',
        'prompts': [
            ('#11', '5-Day Email Nurture Sequence',
             ['Email', '5 emails', 'Post lead magnet'],
             'Write a 5-day email nurture for leads who opted into my free lead magnet for [niche] businesses. '
             'Day 1: Deliver + warm welcome. Day 2: Pain story. Day 3: Educational value. '
             'Day 4: Social proof. Day 5: Soft discovery call pitch. Conversational, short paragraphs.'),
            ('#12', 'Speed-to-Lead SMS (Fires Within 60 Seconds)',
             ['SMS', '160 chars', 'GHL auto-response'],
             'Write a GHL SMS auto-response that fires within 60 seconds of a new Facebook ad lead. '
             'Greet by first name, reference the opt-in, ask one qualifying question, hint someone will follow up. Under 160 characters.'),
            ('#13', 'No-Show Follow-Up Sequence',
             ['SMS + Email', '3 steps', 'Same day → Day 3'],
             'Write a 3-step follow-up for leads who booked but didn\'t show. Step 1 (same day): Empathetic reschedule text. '
             'Step 2 (next day): Email with value + reschedule link. Step 3 (Day 3): Final "breaking up" text with urgency. Match [niche] context.'),
            ('#14', 'Post-Discovery Call — "I Need to Think About It"',
             ['Email', 'Under 300 words', 'Objection handler'],
             'Write a follow-up email within 1 hour after a discovery call where the prospect said "I need to think about it." '
             'Recap their pain points (placeholders), reinforce ROI, address objection [objection], include soft next step. Under 300 words.'),
            ('#15', 'Appointment Reminder Sequence',
             ['SMS + Email', '3-part', '24h / 2h / 30min'],
             'Write a 3-part appointment reminder for a [niche] business: 1) 24 hours before (email + SMS), '
             '2) 2 hours before (SMS only), 3) 30 minutes before (SMS only). Keep SMS under 160 characters. Friendly, not robotic.'),
            ('#16', 'Lead Qualification Chatbot Script',
             ['GHL Chatbot', '5 questions', 'Button options'],
             'Create a 5-question chatbot flow to qualify leads for a [niche] business. Filter for: budget, timeline, '
             'problem severity, decision-maker status, location. Write 2–3 button answer options per question. '
             'Booking CTA for qualified leads; soft redirect for others.'),
            ('#17', 'Win-Back Email — Cold Leads (90+ Days)',
             ['Email', 'Re-engagement', 'Zero pressure'],
             'Write a re-engagement email for leads who went cold 90+ days ago in a [niche] GHL CRM. '
             'Include 3 subject line options. Body: brief, curious, zero pressure, one CTA. '
             'Should feel like a human checking in, not a system email.'),
            ('#18', 'Objection Handler — "Too Expensive"',
             ['Email + SMS', 'ROI reframe', 'Entry point offer'],
             'Write a follow-up (email + SMS version) for a prospect who said your services are too expensive. '
             'Reframe cost as investment with ROI placeholder, offer an alternative entry point (smaller package or payment plan). Do not be defensive.'),
            ('#19', 'Social Proof Email — Case Study Format',
             ['Email', 'Storytelling', 'Under 250 words'],
             'Write a short case study email for [niche] clients. Format: Client description → Problem → GHL solution → '
             'Results (placeholder numbers) → CTA. Under 250 words. Storytelling style, not corporate.'),
            ('#20', 'Referral Thank You + Subtle Upsell SMS',
             ['SMS', 'Under 160 chars', 'Warm + personal'],
             'Write an SMS after receiving a referral from an existing client. Thank them, mention a small reward placeholder, '
             'and subtly introduce one additional service. Warm and personal. Under 160 characters.'),
        ]
    },
    {
        'emoji': '🤝', 'eyebrow': 'Prompts #21–#28',
        'title': 'Client Onboarding',
        'desc': 'Impress from day one. Welcome emails, kickoff agendas, SOPs, questionnaires, and expectation-setting.',
        'bg': 'F0FCFF',
        'prompts': [
            ('#21', 'Welcome Email — New Client',
             ['Email', 'Under 300 words', '7-day preview'],
             'Write a warm, professional welcome email for a new client joining my GHL agency. Include: what they can expect '
             'in the first 7 days, dedicated point of contact, how to reach us, and a link to their onboarding form. '
             'Excited but confident tone. Under 300 words.'),
            ('#22', 'Client Onboarding Questionnaire',
             ['Form', 'Brand + Goals', 'Tech access'],
             'Create a comprehensive onboarding questionnaire for a new [niche] client at my GHL agency. Cover: business background, '
             'target customer, current marketing, brand voice, competitors, 30/60/90-day goals, login credentials needed, and communication preferences.'),
            ('#23', 'Kickoff Call Agenda — 60 Minutes',
             ['Agenda', '6 sections', 'Time-blocked'],
             'Write a 60-minute kickoff call agenda for a new [niche] client. Sections: intro/rapport (5 min), questionnaire review (15 min), '
             'goal alignment (10 min), tech setup walkthrough (15 min), workflow review (10 min), Q&A (5 min). Add talking points for each section.'),
            ('#24', 'SOP: GHL Sub-Account Setup',
             ['SOP', 'Team-ready', 'Step-by-step'],
             'Write a step-by-step SOP for setting up a new GHL sub-account for a [niche] client. Include: account creation, '
             'branding setup, pipeline creation, calendar/booking setup, automation triggers, and integration checklist. '
             'Written for a team member to follow without supervision.'),
            ('#25', 'Client Communication Policy Document',
             ['Document', 'Under 400 words', 'Policy'],
             'Write a "Client Communication Policy" document for new agency clients. Cover: response times, communication channels, '
             'revision policy, monthly reporting schedule, escalation process, and office hours. Firm but friendly tone. Under 400 words.'),
            ('#26', '30-Day Onboarding Checklist (Client-Facing)',
             ['Checklist', 'Week-by-week', 'Client vs Agency'],
             'Create a client-facing 30-day onboarding checklist for a GHL agency. Week 1: Setup & Access. Week 2: Campaign Launch. '
             'Week 3: First Optimization. Week 4: First Report + Review. Separate what the CLIENT does vs. what the AGENCY handles.'),
            ('#27', 'Tech Stack Access Request Email',
             ['Email', 'Access request', 'Security reassurance'],
             'Write an email requesting all tech access needed to set up a new client\'s GHL account. List what\'s needed '
             '(Facebook Ads Manager, Google Business, website access, etc.) with clear instructions for each. '
             'Reassure them about security. Friendly, confident tone.'),
            ('#28', 'Expectation-Setting Email — Week 1',
             ['Email', 'Timelines', 'Transparent'],
             'Write a "Setting Expectations" email to send after the kickoff call. Cover: realistic timelines for results, '
             'what success looks like in month 1 vs. month 3, what we need from the client to succeed, and how to avoid common pitfalls. '
             'Confident and transparent.'),
        ]
    },
    {
        'emoji': '📢', 'eyebrow': 'Prompts #29–#36',
        'title': 'Ad Copy & Sales Funnels',
        'desc': 'Turn clicks into paying clients. Facebook ads, landing pages, retargeting, email funnels, and full sales pages.',
        'bg': 'FFFBF0',
        'prompts': [
            ('#29', 'Facebook Ad Copy — 3 Angle Variations',
             ['Facebook Ads', 'PAS · Proof · Curiosity', 'Mobile-optimized'],
             'Write 3 Facebook ad variations for a [niche] business targeting [audience]. Variation A: Problem-agitation-solution. '
             'Variation B: Social proof/results. Variation C: Curiosity/question. Include headline (40 chars max), '
             'primary text (125 chars for mobile), and CTA button suggestion.'),
            ('#30', 'Landing Page Copy — Lead Gen Funnel',
             ['Funnel', 'Under 400 words', 'Conversion-focused'],
             'Write full landing page copy for a [niche] lead generation funnel. Include: hero headline + subheadline, '
             '3 benefit bullets, social proof section (placeholder), short form intro, trust signals, and footer disclaimer. '
             'Conversion-optimized. Under 400 words total.'),
            ('#31', 'Thank You Page + Low-Ticket Upsell',
             ['Funnel', '$27–$47 upsell', 'Confirm → Curiosity'],
             'Write copy for a thank-you page after a [niche] lead opts into a free offer. Confirm signup, set expectations for '
             'next steps, and introduce a low-ticket upsell at $27–$47. Create curiosity without being pushy.'),
            ('#32', 'Paid Ad Email Funnel — 5-Email Sequence',
             ['Email', '5 emails', 'Under 200 words each'],
             'Write a 5-email sequence for leads from a paid Facebook ad for a [niche] business. '
             'Email 1: Deliver lead magnet. Email 2 (Day 2): Value + story. Email 3 (Day 3): Testimonial. '
             'Email 4 (Day 4): Offer intro. Email 5 (Day 5): Urgency close. Each under 200 words.'),
            ('#33', 'Retargeting Ad Copy — 3 Objections Handled',
             ['Retargeting', '3 angles', '2–3 sentences each'],
             'Write 3 retargeting ad scripts for people who visited a [niche] landing page but didn\'t opt in. '
             'Objection 1: "I\'m not sure it works." Objection 2: "I don\'t have time." '
             'Objection 3: "I\'ve tried this before." 2–3 sentences each.'),
            ('#34', 'Full Sales Page — Agency Service',
             ['Sales Page', '6 sections', '5 FAQs included'],
             'Write a full sales page for a GHL agency offering "Done-For-You Lead Generation" to [niche] businesses '
             'at $[price]/month. Sections: Hero, Problem, Why us, What\'s included, Results/proof, FAQ (5 questions), '
             'and final CTA. Confident, direct, no fluff.'),
            ('#35', 'Abandoned Form Follow-Up Sequence',
             ['Email + SMS', 'Low-pressure', '1hr + next day'],
             'Write a 2-message sequence for leads who started a [niche] inquiry form but didn\'t finish. '
             'Message 1 (email, 1 hour later): Curious, helpful. Message 2 (SMS, next day): Short, direct. '
             'Both should make completing the form feel easy and low-pressure.'),
            ('#36', 'Webinar / Workshop Invitation Email',
             ['Email', 'Under 250 words', 'RSVP CTA'],
             'Write a free online workshop invitation email for a [niche] marketing agency. Topic: [workshop title]. '
             'Include: 3 learning bullet points, who it\'s for, date/time placeholder, and a clear RSVP CTA. '
             'Build excitement without overpromising. Under 250 words.'),
        ]
    },
    {
        'emoji': '📊', 'eyebrow': 'Prompts #37–#43',
        'title': 'Client Reporting & Retention',
        'desc': 'Keep clients happy and paying month after month. Reports, check-ins, upsells, damage control, and renewals.',
        'bg': 'F0FDF8',
        'prompts': [
            ('#37', 'Monthly Report Summary Email',
             ['Email', 'Metrics placeholders', 'Under 400 words'],
             'Write a monthly performance report email for a GHL agency. Include: month overview, key metrics '
             '(leads, calls booked, revenue — placeholders), what worked, what we\'re optimizing, and next month\'s focus. '
             'Professional but readable. Under 400 words.'),
            ('#38', 'Monthly Client Check-In SMS',
             ['SMS', 'Under 160 chars', 'Personal feel'],
             'Write a casual monthly check-in SMS from an agency to a client. Feel personal, briefly reference results, '
             'ask how they feel about progress, invite a quick call if they want to chat. Under 160 characters.'),
            ('#39', 'Handling an Unhappy Client — Email Response',
             ['Email', 'Solution-focused', 'Goodwill gesture'],
             'Write a response email to a client unhappy with their 30-day results. Acknowledge frustration, take responsibility '
             'where appropriate, explain adjustments being made, give a realistic revised timeline, and offer a goodwill gesture. '
             'Calm, confident, solution-focused.'),
            ('#40', 'Upsell Email — Introduce a New Add-On Service',
             ['Email', 'Exclusive framing', 'Under 250 words'],
             'Write an email to an existing client introducing add-on service [service name]. Frame as exclusive to current clients. '
             'Explain the benefit in terms of THEIR results, not your features. Include social proof placeholder and soft CTA. Under 250 words.'),
            ('#41', 'Contract Renewal Email — 60 Days Out',
             ['Email', 'Recap wins', 'Renewal incentive'],
             'Write a proactive retention email sent 60 days before a client\'s contract ends. Recap their wins, preview what\'s coming '
             'next quarter, and make staying feel like the obvious choice. Include a limited-time renewal incentive placeholder. '
             'Warm, confident tone.'),
            ('#42', 'Case Study / Testimonial Request Email',
             ['Email', 'Easy ask', 'Under 200 words'],
             'Write an email asking a happy client for a testimonial or case study. Make it easy — offer to write it for them based '
             'on a short call or 3 quick questions. Explain how it benefits them too (free PR, exposure). Under 200 words.'),
            ('#43', 'Graceful Offboarding Email',
             ['Email', 'Leave door open', 'No guilt-tripping'],
             'Write a graceful offboarding email for a client who\'s canceling. Thank them, offer a clean handoff, ask for honest '
             'feedback (link to a short form), leave the door open for future work, and wish them well. No guilt-tripping. Professional and warm.'),
        ]
    },
    {
        'emoji': '📱', 'eyebrow': 'Prompts #44–#50',
        'title': 'Social Media Content',
        'desc': 'Build authority and attract inbound leads. LinkedIn, Instagram, TikTok, 30-day calendar, and newsletter.',
        'bg': 'EFF6FF',
        'prompts': [
            ('#44', 'LinkedIn Thought Leadership Post',
             ['LinkedIn', '150–250 words', 'Engagement question'],
             'Write a LinkedIn post from a GHL agency owner sharing a lesson from working with [niche] businesses. '
             'Format: hook line + 3–5 short insight paragraphs + engagement question at the end. Conversational, no corporate speak. 150–250 words.'),
            ('#45', 'Instagram Caption Pack — 5 Captions',
             ['Instagram', '5 content types', 'With hashtags'],
             'Write 5 Instagram captions for a GHL marketing agency. Mix: 1) Behind-the-scenes, 2) Client result (placeholder numbers), '
             '3) Educational tip, 4) Motivational/mindset, 5) Offer/CTA post. Each with 3–5 relevant hashtag suggestions.'),
            ('#46', 'TikTok / Reels Script — 60 Seconds',
             ['TikTok', '3-sec hook', 'Comment CTA'],
             'Write a 60-second TikTok/Reels script: "3 things [niche] businesses do that kill their leads." '
             'Hook in first 3 seconds. Fast-paced, punchy sentences. End with a CTA to follow or comment a word.'),
            ('#47', '30-Day Social Media Content Calendar',
             ['Calendar', '4 posts/week', 'Table format'],
             'Create a 30-day social media calendar for a GHL agency targeting [niche] businesses. '
             '4 posts/week (Mon, Tue, Thu, Fri). Mix: 40% educational, 20% social proof, 20% personal/brand, 20% promotional. '
             'Table: Day, Content Type, Topic, Platform.'),
            ('#48', 'Instagram Story Poll / Quiz Sequence',
             ['Stories', '5 slides', 'Lead qualifying'],
             'Create a 5-slide Instagram Story sequence for a GHL agency using polls to engage followers and qualify leads. '
             'Each slide should move toward identifying a pain point and pointing to a solution. Include slide text and suggested poll options.'),
            ('#49', 'Weekly Email Newsletter Template',
             ['Email', 'Under 400 words', 'Value-first'],
             'Write a weekly email newsletter for a GHL agency subscriber list. Sections: 1 quick insight/tip (150 words), '
             '1 tool recommendation, 1 success story snippet (placeholder), and a PS with a soft CTA. '
             'Conversational, value-first. Under 400 words total.'),
            ('#50', 'Personal Brand Bio — 3 Platforms',
             ['Twitter/X', 'Instagram', 'LinkedIn'],
             'Write 3 personal brand bio versions for a GHL agency owner: 1) Twitter/X (160 chars), '
             '2) Instagram (150 words max), 3) LinkedIn headline + about section (300 words). '
             'Hook: [your name] helps [niche] businesses stop losing leads and start booking clients on autopilot.'),
        ]
    },
]

for cat in categories:
    add_cat_banner(cat['emoji'], cat['eyebrow'], cat['title'], cat['desc'], cat['bg'])
    for prompt in cat['prompts']:
        add_prompt_card(*prompt)
    add_page_break()

# ══════════════════════════════
# BONUS PAGE
# ══════════════════════════════
add_paragraph('EXCLUSIVE EXTRAS', bold=True, size=9, color=PINK, space_before=0, space_after=4)
add_h1('Bonus: Make Every Prompt Work Harder')

bonuses = [
    ('🎯  Universal Persona Primer',
     'Add this before ANY prompt:\n'
     '"You are an expert GHL marketing strategist for [niche] businesses. '
     'Write in a conversational, direct tone — no corporate language, no filler, '
     'no AI-sounding phrases. Every sentence earns its place."'),
    ('🔄  Iteration Commands',
     'After any output, follow up with:\n'
     '→ "Make it 30% shorter"\n'
     '→ "Add more urgency"\n'
     '→ "Write 3 A/B variations"\n'
     '→ "Sound more casual"\n'
     '→ "Rewrite the subject line 5 ways"\n'
     '→ "Add a P.S. line"'),
    ('🤖  Best AI Tools',
     'ChatGPT GPT-4o — Best for all-around copywriting\n'
     'Claude Sonnet — Best for SOPs & structured documents\n'
     'Gemini 1.5 Pro — Best for research-heavy prompts'),
    ('⚡  Quick Start (15 Minutes)',
     'Step 1 → Run Prompt #1 (Cold DM for your niche)\n'
     'Step 2 → Run Prompt #12 (Speed-to-Lead SMS)\n'
     'Step 3 → Run Prompt #21 (Welcome Email)\n'
     'Three working GHL assets — done.'),
]

for title, text in bonuses:
    p = doc.add_paragraph()
    p.paragraph_format.space_before = Pt(6)
    p.paragraph_format.space_after  = Pt(2)
    r1 = p.add_run(title + '\n')
    r1.bold = True
    r1.font.size = Pt(12)
    r1.font.color.rgb = DARK
    r2 = p.add_run(text)
    r2.font.size = Pt(10)
    r2.font.color.rgb = BODY

add_paragraph('', space_after=8)
add_tip_box(
    '💡 The Swipe File Strategy — Your Unfair Advantage',
    'Every time a prompt output performs — a DM gets a reply, an email gets opened, a hook stops the scroll — save it. '
    'Create a Google Doc called "Agency Swipe File." After 90 days you\'ll have a battle-tested library of proven copy '
    'you can remix and reuse forever.'
)

# ══════════════════════════════
# BACK PAGE
# ══════════════════════════════
add_page_break()
add_paragraph('', space_before=60, space_after=0)
add_paragraph('🎉  You\'re All Set', bold=True, size=10, color=PINK,
              align=WD_ALIGN_PARAGRAPH.CENTER, space_before=0, space_after=16)
p = doc.add_paragraph()
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
p.paragraph_format.space_before = Pt(0)
p.paragraph_format.space_after  = Pt(12)
r1 = p.add_run('50 Prompts Away From a\n')
r1.bold = True
r1.font.size = Pt(30)
r1.font.color.rgb = DARK
r2 = p.add_run('Fully Automated Agency')
r2.bold = True
r2.font.size = Pt(30)
r2.font.color.rgb = PINK

add_paragraph(
    'Stop writing from scratch. Fill in the blanks, run the prompts,\nand watch your GHL workflows do the heavy lifting.',
    size=13, color=BODY, align=WD_ALIGN_PARAGRAPH.CENTER, space_before=0, space_after=24
)
add_paragraph('Start With Prompt #1 →', bold=True, size=14, color=PINK,
              align=WD_ALIGN_PARAGRAPH.CENTER, space_before=0, space_after=40)
add_paragraph('Built by MelAI ✦ HireAI · 2026', bold=True, size=11, color=GRAY,
              align=WD_ALIGN_PARAGRAPH.CENTER, space_before=0, space_after=0)

# ══════════════════════════════
# SAVE
# ══════════════════════════════
out = '/home/melai/Documents/ghl-prompt-pack/GHL-Agency-Starter-Prompt-Pack.docx'
doc.save(out)
print(f'Saved: {out}')
