import glob

# 1. Update CSS to move widget to the left
with open('css/bible-widget.css', 'r', encoding='utf-8') as f:
    css = f.read()

css = css.replace('right: 30px;', 'left: 30px;\n    right: auto;')
css = css.replace('background: linear-gradient(135deg, #e6c888, #b8924b);', 'background: transparent;')
css = css.replace('border: 3px solid #fff;', 'border: none;')
css = css.replace('box-shadow: 0 10px 25px rgba(0,0,0,0.3);', 'box-shadow: none;')

with open('css/bible-widget.css', 'w', encoding='utf-8') as f:
    f.write(css)

# 2. Update HTML files to replace SVG with Lottie
old_svg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M21 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h14a1 1 0 0 0 1-1V5a1 1 0 0 0-1-1zm-1 13H7V6h13v11zM5 18H4V6H3v13a2 2 0 0 0 2 2h16v-1H5a1 1 0 0 1 0-2z"/><rect x="10" y="8" width="8" height="2"/><rect x="10" y="11" width="8" height="2"/><rect x="10" y="14" width="5" height="2"/></svg>'
new_lottie = '''<script src="https://unpkg.com/@lottiefiles/dotlottie-wc@0.9.4/dist/dotlottie-wc.js" type="module"></script>
        <dotlottie-wc src="https://lottie.host/7b2916b3-0215-48d7-9027-9b00d77f098b/QkgT0kRT6F.json" style="width: 80px;height: 80px; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));" autoplay loop></dotlottie-wc>'''

for filepath in glob.glob('*.html'):
    with open(filepath, 'r', encoding='utf-8') as f:
        content = f.read()
    
    if old_svg in content:
        content = content.replace(old_svg, new_lottie)
        with open(filepath, 'w', encoding='utf-8') as f:
            f.write(content)

print("Moved widget and updated to Lottie animation.")
