import re

html_files = [
    'd:\\iss\\Franciscan Society\\index.html',
    'd:\\iss\\Franciscan Society\\about.html',
    'd:\\iss\\Franciscan Society\\gallery.html'
]

youtube_btn_html = """<div onclick="window.open('https://youtube.com', '_blank')" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: transparent; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 999; transition: background 0.3s;">
                                <div style="width: 48px; height: 34px; background: #FF0000; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #fff; box-shadow: 0 4px 12px rgba(255,0,0,0.5); transition: transform 0.3s;">
                                    <svg viewBox="0 0 24 24" fill="currentColor" width="20" height="20" style="margin-left: 3px;">
                                        <path d="M8 5v14l11-7z"/>
                                    </svg>
                                </div>
                            </div>"""

for file_path in html_files:
    try:
        with open(file_path, 'r', encoding='utf-8') as f:
            content = f.read()
        
        # We need to replace the <a> tag we previously inserted
        pattern = r'<a href="https://youtube\.com"[^>]*>.*?</a>'
        content = re.sub(pattern, youtube_btn_html, content, flags=re.DOTALL)
        
        with open(file_path, 'w', encoding='utf-8') as f:
            f.write(content)
        print(f"Updated HTML in {file_path}")
    except Exception as e:
        print(f"Error in {file_path}: {e}")
