import re

# Enhanced mobile menu CSS
mobile_menu_css = '''
    /* Mobile Menu - Enhanced */
    @media (max-width: 768px) {
      .menu-toggle {
        display: flex !important;
        z-index: 1001;
      }
      
      .menu-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
      }
      
      .menu-toggle.active span:nth-child(2) {
        opacity: 0;
      }
      
      .menu-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -7px);
      }
      
      .nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 300px;
        height: 100vh;
        background: var(--white);
        box-shadow: -5px 0 15px rgba(0,0,0,0.2);
        flex-direction: column;
        padding: 100px 20px 20px;
        transition: right 0.3s ease;
        z-index: 1000;
        overflow-y: auto;
      }
      
      .nav.active {
        right: 0;
      }
      
      .nav a {
        width: 100%;
        text-align: left;
        padding: 15px 20px;
        margin: 5px 0;
        border-radius: 8px;
        display: flex;
        align-items: center;
        gap: 10px;
      }
      
      .nav a i {
        width: 20px;
        text-align: center;
      }
      
      .nav a.btn-quote {
        margin-left: 0;
        margin-top: 10px;
      }
    }'''

pages = [
    'index.html', 'quotation.html', 'fleet.html', 'contact.html',
    'locations.html', 'sitemap-towns.html', 'q-and-a.html', 
    'privacy.html', 'terms.html',
]

for page in pages:
    try:
        with open(page, 'r', encoding='utf-8') as f:
            content = f.read()
        
        # Check if enhanced mobile menu CSS already exists
        if '.menu-toggle.active span:nth-child(1)' in content:
            print(f"ℹ️  {page} - Already has enhanced mobile menu CSS")
            continue
        
        # Add enhanced mobile menu CSS before closing </style>
        if '</style>' in content:
            content = re.sub(
                r'(\s*)(</style>)',
                mobile_menu_css + r'\n    \2',
                content,
                count=1
            )
            
            with open(page, 'w', encoding='utf-8') as f:
                f.write(content)
            print(f"✅ Enhanced mobile menu CSS added to {page}")
        else:
            print(f"⚠️  {page} - No </style> tag found")
    except Exception as e:
        print(f"❌ {page} - Error: {e}")

print("\n✅ Mobile menu CSS enhanced on all pages!")
