import os
import re

files = [
    "welcomeEmail.html",
    "aiWebsiteSubmissionEmail.html",
    "directorySubmissionEmail.html",
    "forgetEmail.html",
    "jobSubmissionEmail.html",
    "verificationEmail.html",
    "websiteSubmissionEmail.html"
]

base_dir = r"e:\latest\Ali_Raza_Backup\Work\Webperts\Cssawwwards\cssawwwards\accounts\Backend\Backend\templates"

# Regex to find the logo image tag. 
# It looks for <img ... alt="CSSAwwwards Logo" ...> handling potential multiline or different attribute orders.
# We also handle the case where I might have left a closing > on a new line or similar.
# The previous updates used: <img src="..." alt="CSSAwwwards Logo" width="150" style="display: block;">
regex_pattern = re.compile(r'<img\s+[^>]*alt=["\']CSSAwwwards Logo["\'][^>]*>', re.IGNORECASE | re.DOTALL)

for file_name in files:
    file_path = os.path.join(base_dir, file_name)
    try:
        with open(file_path, 'r', encoding='utf-8') as f:
            content = f.read()
        
        # Check if we find the tag
        if regex_pattern.search(content):
            new_content = regex_pattern.sub('CSSAwwwards', content)
            
            with open(file_path, 'w', encoding='utf-8') as f:
                f.write(new_content)
            print(f"✅ Updated {file_name}")
        else:
            print(f"⚠️  Logo tag not found in {file_name}")
            
    except Exception as e:
        print(f"❌ Error processing {file_name}: {e}")
