"""
Simple script to create PNG icons using PIL/Pillow
Run: pip install Pillow
Then: python scripts/create-icons-simple.py
"""

try:
    from PIL import Image, ImageDraw, ImageFont
    import os
except ImportError:
    print("❌ Pillow not installed. Install with: pip install Pillow")
    exit(1)

# Create icons directory
icons_dir = os.path.join(os.path.dirname(__file__), '..', 'icons')
os.makedirs(icons_dir, exist_ok=True)

sizes = [16, 48, 128]

print("🎨 Generating icons...")

for size in sizes:
    # Create image with rounded rectangle background
    img = Image.new('RGB', (size, size), color='#4F46E5')
    draw = ImageDraw.Draw(img)
    
    # Draw rounded rectangle
    radius = int(size * 0.2)
    draw.rounded_rectangle([(0, 0), (size, size)], radius=radius, fill='#4F46E5')
    
    # Draw text "CN"
    try:
        # Try to use a nice font
        font_size = int(size * 0.5)
        font = ImageFont.truetype("arial.ttf", font_size)
    except:
        # Fallback to default font
        font = ImageFont.load_default()
    
    text = "CN"
    bbox = draw.textbbox((0, 0), text, font=font)
    text_width = bbox[2] - bbox[0]
    text_height = bbox[3] - bbox[1]
    
    # Center text
    x = (size - text_width) // 2
    y = (size - text_height) // 2
    
    draw.text((x, y), text, fill='white', font=font)
    
    # Save
    output_path = os.path.join(icons_dir, f'icon{size}.png')
    img.save(output_path, 'PNG')
    print(f"✅ Created: icon{size}.png")

print(f"\n✅ Done! Icons saved to: {icons_dir}")

