import os
import re

def process_file(filepath):
    with open(filepath, 'r') as f:
        content = f.read()

    original = content
    
    # Regex to match <section ... className="..."> etc
    # We find the className attribute inside these tags
    def replace_classes(match):
        prefix = match.group(1)
        classes = match.group(2)
        suffix = match.group(3)
        
        # Remove px-X, sm:px-X, md:px-X, lg:px-X, xl:px-X
        new_classes = re.sub(r'(?:sm:|md:|lg:|xl:)?px-[\w\[\]]+\s*', '', classes)
        
        if new_classes != classes:
            return prefix + new_classes.strip() + ' px-[100px]' + suffix
        return match.group(0)

    # Note: re.sub with a function replacing only inside the relevant tags
    new_content = re.sub(r'(<(?:section|header|footer|nav)[^>]*className=["\'])([^"\']*)(["\'])', replace_classes, content)

    if new_content != original:
        with open(filepath, 'w') as f:
            f.write(new_content)
        print('Updated', filepath)

for root, dirs, files in os.walk('.'):
    if 'node_modules' in root or '.next' in root:
        continue
    for file in files:
        if file.endswith('.tsx'):
            process_file(os.path.join(root, file))
