with open("public_html/supercerebro/api/proposals.php", "r") as f:
    content = f.read()

# ── PATCH 1: Strengthen NON-NEGOTIABLE RULES with conversion + accessibility ──
old_rules = """━━━ NON-NEGOTIABLE RULES ━━━
1. Generate COMPLETE HTML from <!DOCTYPE html> all the way to </html> — NEVER stop before finishing
2. ZERO Lorem Ipsum — every word of content must come from the business brief below
3. Navigation menu items must be REAL sections of this specific business (not generic "Home, About, Services, Contact")
4. Use ONLY these exact brand colors — never use generic blues, greens, or purple from defaults
5. Every service/product mentioned in the brief must appear by name
6. All 3 testimonials must sound like real clients of THIS business (reference the actual service they used)
7. Stats/numbers must be believable for this industry (use brief data or industry-realistic figures)
8. The hero H1 must communicate the UNIQUE value proposition — not a generic tagline"""

new_rules = """━━━ NON-NEGOTIABLE RULES ━━━
1. Generate COMPLETE HTML from <!DOCTYPE html> all the way to </html> — NEVER stop before finishing
2. ZERO Lorem Ipsum — every word of content must come from the business brief below
3. Navigation menu items must be REAL sections of this specific business (not generic "Home, About, Services, Contact")
4. Use ONLY these exact brand colors — never use generic blues, greens, or purple from defaults
5. Every service/product mentioned in the brief must appear by name
6. All 3 testimonials must sound like real clients of THIS business (reference the actual service they used)
7. Stats/numbers must be believable for this industry (use brief data or industry-realistic figures)
8. The hero H1 must communicate the UNIQUE value proposition — not a generic tagline
9. Every section (services, about, portfolio, pricing) must end with a CTA button — never leave a section without a next step
10. Include at minimum 3 trust signals: years in business badge, client count, certifications, awards, or media mentions
11. Every img tag must have a descriptive alt attribute (never alt="" for content images)
12. All interactive elements (buttons, links, inputs) must have :focus-visible styles for accessibility
13. Mobile must be fully usable: tap targets minimum 44px, no horizontal scroll, readable font sizes (min 16px body)"""

if old_rules in content:
    content = content.replace(old_rules, new_rules, 1)
    print("OK patch 1: rules strengthened")
else:
    print("ERROR patch 1: rules anchor not found")

# ── PATCH 2: Add SEO + Performance + Conversion sections before OUTPUT FORMAT ──
old_output = """━━━ OUTPUT FORMAT ━━━
- Return ONLY the complete HTML — no explanations, no markdown, no code fences
- Start with: <!DOCTYPE html>
- End with: </html>
- The file must be self-contained (all CSS in <style>, all JS in <script> before </body>)
- DO NOT truncate or summarize any section — write every section fully"""

new_output = """━━━ SEO — MANDATORY IN <head> ━━━
Include ALL of these in the <head> (use real data from the brief):
- <title> tag: business name + main service + city if local (max 60 chars)
- <meta name="description"> (150-160 chars, include main keyword + CTA)
- Open Graph: og:title, og:description, og:image (use IMG1 URL), og:type="website"
- Twitter Card: twitter:card="summary_large_image", twitter:title, twitter:description
- <link rel="canonical"> with placeholder URL structure
- Structured Data JSON-LD: use schema.org/LocalBusiness or schema.org/Organization
  Include: name, description, url, telephone, address (from brief), sameAs (social links from brief)
- <meta name="robots" content="index, follow">
- <html lang="es"> (or detected language from brief)

━━━ PERFORMANCE — MANDATORY ━━━
- Google Fonts: use <link rel="preconnect" href="https://fonts.googleapis.com"> BEFORE the @import
- Add <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> as well
- font-display: swap on ALL @font-face declarations
- Hero image (IMG1): add fetchpriority="high" loading="eager" — it is the LCP element, NOT lazy
- All other images: loading="lazy" (already required)
- All <script> tags: use defer attribute
- CSS: avoid @import inside <style> — use <link> tags in <head> for external CSS
- Add will-change: transform only on animated elements (cards on hover, not all elements)

━━━ CONVERSION ARCHITECTURE ━━━
Structure the page as a conversion funnel:
1. Hero: attention + single primary CTA (WhatsApp or contact form) — above the fold
2. After services section: CTA "¿Listo para empezar?" with button + optional phone number
3. After testimonials: CTA with urgency ("Lugares disponibles este mes" or similar believable scarcity)
4. Sticky header: after scroll, show a compact CTA button in the navigation bar (right side)
5. Floating WhatsApp button: always visible bottom-right (#25D366)
6. Exit-intent or last section: "¿Tienes preguntas?" with a short contact form (name, phone, message)
The primary action should always be ONE click away regardless of scroll position.

━━━ OUTPUT FORMAT ━━━
- Return ONLY the complete HTML — no explanations, no markdown, no code fences
- Start with: <!DOCTYPE html>
- End with: </html>
- The file must be self-contained (all CSS in <style>, all JS in <script> before </body>)
- DO NOT truncate or summarize any section — write every section fully"""

if old_output in content:
    content = content.replace(old_output, new_output, 1)
    print("OK patch 2: SEO + Performance + Conversion sections added")
else:
    print("ERROR patch 2: OUTPUT FORMAT anchor not found")

with open("public_html/supercerebro/api/proposals.php", "w") as f:
    f.write(content)
print("File saved")
