"""
Diagnostic script to check Font Awesome icon rendering issues
"""

print("=" * 60)
print("FONT AWESOME ICON DIAGNOSTIC")
print("=" * 60)

print("\n1. CHECKING BASE.HTML FOR FONT AWESOME LINK...")
try:
    with open('templates/base.html', 'r', encoding='utf-8') as f:
        content = f.read()
        if 'font-awesome' in content.lower():
            print("   ✓ Font Awesome link found in base.html")
            # Extract the link
            import re
            fa_links = re.findall(r'https://[^\s"\']+font-awesome[^\s"\']+', content)
            for link in fa_links:
                print(f"   Link: {link}")
        else:
            print("   ✗ Font Awesome link NOT found in base.html")
except Exception as e:
    print(f"   ✗ Error reading base.html: {e}")

print("\n2. CHECKING EXPENSE_ANALYTICS.HTML FOR ICON USAGE...")
try:
    with open('templates/expenses/expense_analytics.html', 'r', encoding='utf-8') as f:
        content = f.read()
        import re
        icons = re.findall(r'<i class="fas fa-[\w-]+"[^>]*>', content)
        print(f"   Found {len(icons)} Font Awesome icons")
        if icons:
            print("   Sample icons:")
            for icon in icons[:5]:
                print(f"   - {icon}")
except Exception as e:
    print(f"   ✗ Error reading expense_analytics.html: {e}")

print("\n3. POSSIBLE ISSUES AND SOLUTIONS:")
print("   Issue 1: Font Awesome not loading")
print("   Solution: Check browser console for 404 errors")
print()
print("   Issue 2: CSS conflicts with Tailwind")
print("   Solution: Use inline styles (already applied)")
print()
print("   Issue 3: Icons rendering as squares/boxes")
print("   Solution: Font file not loading - check CDN")
print()
print("   Issue 4: Icons invisible (white on white)")
print("   Solution: Add explicit color (already applied)")
print()

print("\n4. ALTERNATIVE SOLUTIONS:")
print("   A. Use Font Awesome 5.x instead of 6.x")
print("   B. Use local Font Awesome files instead of CDN")
print("   C. Use SVG icons instead of icon fonts")
print("   D. Use emoji or Unicode symbols as fallback")
print()

print("\n5. QUICK TEST:")
print("   Open test_font_awesome.html in your browser")
print("   This will show if Font Awesome works in isolation")
print()

print("=" * 60)
print("DIAGNOSTIC COMPLETE")
print("=" * 60)
