import re

# Read the quotation page
with open('quotation.html', 'r', encoding='utf-8') as f:
    content = f.read()

# Fix broken HTML structure - close the logo link properly
content = re.sub(
    r'(<a href="/" class="logo">.*?<img src="/logo\.svg"[^>]*>)\s*(<button class="menu-toggle")',
    r'\1</a>\n      \2',
    content,
    flags=re.DOTALL
)

# Add nav section if missing
if '</a>\n      <button class="menu-toggle"' in content and '<nav class="nav">' not in content:
    # Add nav after menu toggle button
    nav_html = '''      </button>
      
      <nav class="nav">
        <a href="/index.html"><i class="fas fa-home"></i> Home</a>
        <a href="/quotation.html" class="active"><i class="fas fa-calculator"></i> Get Quote</a>
        <a href="/fleet.html"><i class="fas fa-car"></i> Our Fleet</a>
        <a href="/contact.html"><i class="fas fa-envelope"></i> Contact</a>
        <a href="/admin-login.html"><i class="fas fa-shield-alt"></i> Admin</a>
        <a href="/quotation.html" class="btn-quote"><i class="fas fa-calculator"></i> Live Quote</a>
      </nav>
    </div>
  </header>'''
    
    content = re.sub(
        r'(</button>\s*)\n\s*<!-- Page Header -->',
        nav_html + '\n\n  <!-- Page Header -->',
        content
    )

# Write back
with open('quotation.html', 'w', encoding='utf-8') as f:
    f.write(content)

print("✅ Fixed quotation page HTML structure")
print("✅ Added navigation menu")
print("✅ Closed logo link properly")
