"""
Patch the landing page.tsx to:
1. Fix all CTA button hrefs to point to /dashboard
2. Remove webflow branding from copyright footer
"""
import re

filepath = r'd:\Ai\AntiGravity\Project_1.0\gmap\leadforge\src\app\page.tsx'

with open(filepath, 'r', encoding='utf-8') as f:
    content = f.read()

original_length = len(content)

# Fix CTA hrefs - common auth/conversion pages
replacements = [
    ('href="/login"', 'href="/dashboard"'),
    ('href="/sign-up"', 'href="/dashboard"'),
    ('href="/signup"', 'href="/dashboard"'),
    ('href="/register"', 'href="/dashboard"'),
    ('href="/contact"', 'href="/dashboard"'),
    ('href="/pricing"', 'href="/dashboard"'),
    ('href="/get-started"', 'href="/dashboard"'),
    ('href="/demo"', 'href="/dashboard"'),
    ('href="/template-pages/license"', 'href="/dashboard"'),
    # Fix Webflow's own branding in footer
    ('Powered By <a href=\\"https://webflow.com/\\" target=\\"_blank\\"><span class=\\"webflow-link\\">Webflow</span></a>', ''),
    # Also handle the logo link going to home
    ('href="/" aria-current="page"', 'href="/dashboard" aria-current="page"'),
]

for old, new in replacements:
    count = content.count(old)
    if count > 0:
        print(f'Replacing {count}x: {old[:60]} -> {new[:40]}')
        content = content.replace(old, new)

# Also fix "Talk to sales" and "Book a demo" style nav links to go to /dashboard
# These are href="/contact" or href that open modals
# Use regex for any remaining dashboard-worthy CTAs
patterns = [
    (r'href="/free-trial"', 'href="/dashboard"'),
    (r'href="/trial"', 'href="/dashboard"'),
    (r'href="/start"', 'href="/dashboard"'),
]
for pattern, replacement in patterns:
    content = re.sub(pattern, replacement, content)

with open(filepath, 'w', encoding='utf-8') as f:
    f.write(content)

print(f'\nDone. File size: {original_length} -> {len(content)} bytes')
