#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Generate Premium Wesmart Electronics Company Profile PDF"""

from fpdf import FPDF

class PremiumPDF(FPDF):
    def __init__(self):
        super().__init__()
        self.primary_color = [26, 58, 138]
        self.accent_color = [255, 107, 53]
        self.text_color = [51, 51, 51]
        self.light_bg = [248, 249, 255]
    
    def header(self):
        self.set_fill_color(*self.light_bg)
        self.rect(0, 0, 210, 45, 'F')
        
        self.set_font('helvetica', 'B', 24)
        self.set_text_color(*self.primary_color)
        self.set_y(15)
        self.cell(0, 12, 'WESMART ELECTRONICS', new_x='LMARGIN', new_y='NEXT', align='C')
        
        self.set_font('helvetica', 'I', 11)
        self.set_text_color(100, 100, 100)
        self.cell(0, 8, 'Inventor of Bus-type Stair Light Technology', new_x='LMARGIN', new_y='NEXT', align='C')
        
        self.set_draw_color(*self.accent_color)
        self.set_line_width(1.5)
        self.line(70, 42, 140, 42)
        self.ln(15)
    
    def footer(self):
        self.set_y(-20)
        self.set_fill_color(*self.light_bg)
        self.rect(0, 277, 210, 20, 'F')
        
        self.set_font('helvetica', 'I', 9)
        self.set_text_color(128, 128, 128)
        self.set_y(-15)
        self.cell(0, 10, f'Wesmart Electronics | National High-Tech Enterprise | Page {self.page_no()}', align='C')
    
    def section_title(self, title, subtitle=''):
        self.set_font('helvetica', 'B', 16)
        self.set_text_color(*self.primary_color)
        self.cell(0, 12, title, new_x='LMARGIN', new_y='NEXT')
        
        if subtitle:
            self.set_font('helvetica', '', 10)
            self.set_text_color(100, 100, 100)
            self.cell(0, 6, subtitle, new_x='LMARGIN', new_y='NEXT')
        
        self.set_draw_color(*self.accent_color)
        self.set_line_width(0.5)
        self.line(10, self.get_y(), 60, self.get_y())
        self.ln(8)
    
    def highlight_box(self, title, content):
        self.set_fill_color(self.light_bg[0], self.light_bg[1], self.light_bg[2])
        self.set_draw_color(230, 230, 230)
        start_y = self.get_y()
        self.cell(0, 45, '', new_x='LMARGIN', new_y='NEXT', border=1, fill=True)
        
        self.set_y(start_y + 5)
        self.set_font('helvetica', 'B', 12)
        self.set_text_color(self.primary_color[0], self.primary_color[1], self.primary_color[2])
        self.cell(10)
        self.cell(0, 8, title, new_x='LMARGIN', new_y='NEXT')
        
        self.set_font('helvetica', '', 10)
        self.set_text_color(self.text_color[0], self.text_color[1], self.text_color[2])
        self.cell(10)
        self.multi_cell(185, 6, content)
        self.ln(8)
    
    def stat_box(self, number, label, x_pos):
        current_y = self.get_y()
        self.set_xy(x_pos, current_y)
        self.set_font('helvetica', 'B', 28)
        self.set_text_color(*self.accent_color)
        self.cell(40, 12, number, align='C')
        
        self.set_xy(x_pos, current_y + 12)
        self.set_font('helvetica', '', 9)
        self.set_text_color(100, 100, 100)
        self.cell(40, 6, label, align='C')
    
    def bullet_item(self, text, bold_prefix=''):
        self.set_font('helvetica', '', 10)
        self.set_text_color(*self.text_color)
        self.cell(8)
        self.set_text_color(*self.accent_color)
        self.cell(4, 6, chr(149), new_x='RIGHT', new_y='TOP')
        
        if bold_prefix:
            self.set_font('helvetica', 'B', 10)
            self.set_text_color(*self.text_color)
            self.cell(self.get_string_width(bold_prefix) + 2, 6, bold_prefix, new_x='RIGHT', new_y='TOP')
        
        self.set_font('helvetica', '', 10)
        self.set_text_color(*self.text_color)
        self.multi_cell(0, 6, text)
        self.ln(2)

def create_premium_pdf():
    pdf = PremiumPDF()
    pdf.add_page()
    pdf.set_auto_page_break(auto=True, margin=25)
    
    # Executive Summary
    pdf.section_title('COMPANY OVERVIEW', 'Pioneering Smart Lighting Solutions')
    
    pdf.set_font('helvetica', '', 11)
    pdf.set_text_color(51, 51, 51)
    pdf.multi_cell(0, 7, 
        'Wesmart Electronics is a National High-Tech Enterprise headquartered in Shenzhen, China, '
        'specializing in the research, development, and manufacturing of intelligent lighting systems. '
        'As the ORIGINAL INVENTOR of Bus-type Stair Light technology, we have revolutionized '
        'staircase lighting with our patented 2-wire solution that simultaneously handles power, '
        'communication, and sensing.')
    pdf.ln(5)
    
    # Stats row
    current_y = pdf.get_y()
    pdf.stat_box('13+', 'Years Experience', 20)
    pdf.stat_box('40+', 'Patents', 65)
    pdf.stat_box('10,000+', 'Households', 110)
    pdf.stat_box('50+', 'Countries', 155)
    pdf.set_y(current_y + 25)
    pdf.ln(10)
    
    # Brand Portfolio
    pdf.section_title('BRAND PORTFOLIO', 'Dual-Brand Strategy')
    
    pdf.highlight_box('Zhibu - China Domestic Market',
        'Premium smart lighting brand for the Chinese market. Our flagship ZM1 stair light '
        'became a category bestseller on Douyin with over 20,000 units sold. The definitive '
        'smart staircase solution recognized by industry experts.')
    
    pdf.highlight_box('Ameistor - International Market',
        'Global brand targeting international markets through Amazon and distributor channels. '
        'Products meet international standards and are compatible with Amazon Alexa, Google Home, '
        'and Tuya Smart ecosystems.')
    
    # Core Technology
    pdf.add_page()
    pdf.section_title('CORE TECHNOLOGY', 'Industry-Defining Innovation')
    
    pdf.set_font('helvetica', 'B', 13)
    pdf.set_text_color(*pdf.primary_color)
    pdf.cell(0, 10, 'Bus-Type Stair Light Technology', new_x='LMARGIN', new_y='NEXT')
    pdf.ln(2)
    
    pdf.set_font('helvetica', '', 11)
    pdf.set_text_color(*pdf.text_color)
    pdf.multi_cell(0, 7,
        'Our revolutionary 2-wire technology is the industry\'s first solution that simultaneously '
        'transmits power, data communication, and sensor signals through just two wires. '
        'This breakthrough eliminates complex wiring requirements, reduces installation time by 70%, '
        'and enables true plug-and-play smart lighting.')
    pdf.ln(5)
    
    pdf.bullet_item('Simultaneous power delivery, data transmission, and motion sensing', 'Patented: ')
    pdf.bullet_item('No additional wiring or hubs required', 'Simplicity: ')
    pdf.bullet_item('Works with existing 2-wire installations', 'Retrofit: ')
    pdf.bullet_item('Scalable from 2 to 100+ steps without signal degradation', 'Scalable: ')
    pdf.ln(5)
    
    # Advantages
    pdf.section_title('COMPETITIVE ADVANTAGES', 'What Sets Us Apart')
    
    pdf.bullet_item('National High-Tech Enterprise certification (consecutive years)', 'Recognition: ')
    pdf.bullet_item('Over 40 granted patents and software copyrights', 'IP Portfolio: ')
    pdf.bullet_item('Deep integration with Xiaomi Mi Home ecosystem', 'Partnership: ')
    pdf.bullet_item('Multi-platform: Mi Home, WeChat, Tuya, Alexa, Google Home', 'Compatible: ')
    pdf.bullet_item('Complete in-house R&D, SMT, assembly, and quality control', 'Integrated: ')
    pdf.bullet_item('Full-stack: hardware, firmware, mobile apps, cloud services', 'End-to-End: ')
    
    # Products
    pdf.add_page()
    pdf.section_title('PRODUCT PORTFOLIO', 'Award-Winning Solutions')
    
    pdf.set_font('helvetica', 'B', 12)
    pdf.set_text_color(*pdf.accent_color)
    pdf.cell(0, 10, 'FLAGSHIP: ZM1 Smart Stair Light', new_x='LMARGIN', new_y='NEXT')
    pdf.ln(2)
    
    pdf.set_font('helvetica', '', 10)
    pdf.set_text_color(*pdf.text_color)
    pdf.multi_cell(0, 6,
        'World\'s first bus-type stair light featuring patented 2-wire technology. '
        'Winner of multiple industry awards and Douyin category bestseller with 20,000+ units sold. '
        'Features intelligent motion sensing, gradient lighting effects, and smart home integration.')
    pdf.ln(5)
    
    pdf.set_font('helvetica', 'B', 12)
    pdf.set_text_color(*pdf.primary_color)
    pdf.cell(0, 10, 'Product Lines', new_x='LMARGIN', new_y='NEXT')
    pdf.ln(2)
    
    pdf.bullet_item('Smart motion-sensing night lights (20,000+ units sold)', 'Motion Lights: ')
    pdf.bullet_item('Full-color RGBW with 16-million-color palette and automation', 'RGBW Pro: ')
    pdf.bullet_item('IP65-rated professional lighting for facades and landscapes', 'Outdoor: ')
    pdf.bullet_item('Modular LED drivers and controllers for custom installations', 'Controllers: ')
    
    # Market
    pdf.add_page()
    pdf.section_title('MARKET PRESENCE', 'Global Reach')
    
    pdf.set_font('helvetica', 'B', 12)
    pdf.set_text_color(*pdf.primary_color)
    pdf.cell(0, 10, 'China Domestic Market', new_x='LMARGIN', new_y='NEXT')
    pdf.ln(2)
    
    pdf.set_font('helvetica', '', 10)
    pdf.bullet_item('Flagship stores on Douyin, Tmall, JD.com, and Pinduoduo')
    pdf.bullet_item('Showroom at Star Alliance Lighting Center, Guzhen')
    pdf.bullet_item('B2B channel partnerships nationwide')
    pdf.bullet_item('Engineering projects for residential and commercial developments')
    pdf.ln(5)
    
    pdf.set_font('helvetica', 'B', 12)
    pdf.set_text_color(*pdf.primary_color)
    pdf.cell(0, 10, 'International Markets', new_x='LMARGIN', new_y='NEXT')
    pdf.ln(2)
    
    pdf.bullet_item('Amazon Global: US, Canada, UK, Germany, France, Japan')
    pdf.bullet_item('Exported to 50+ countries across 5 continents')
    pdf.bullet_item('CE, FCC, and international safety certifications')
    pdf.bullet_item('Localized customer support and documentation')
    
    # Partnership
    pdf.add_page()
    pdf.section_title('PARTNERSHIP OPPORTUNITIES')
    
    pdf.set_font('helvetica', 'B', 13)
    pdf.set_text_color(*pdf.primary_color)
    pdf.cell(0, 10, 'OEM / ODM Services', new_x='LMARGIN', new_y='NEXT')
    pdf.ln(2)
    
    pdf.set_font('helvetica', '', 10)
    pdf.multi_cell(0, 6,
        'Full-service product development from concept to mass production. Engineering team '
        'provides industrial design, firmware development, mobile app integration, and manufacturing '
        'at our ISO-certified facility. Development cycle: 3-6 months from prototype to production.')
    pdf.ln(5)
    
    pdf.set_font('helvetica', 'B', 13)
    pdf.set_text_color(*pdf.primary_color)
    pdf.cell(0, 10, 'Technology Licensing', new_x='LMARGIN', new_y='NEXT')
    pdf.ln(2)
    
    pdf.set_font('helvetica', '', 10)
    pdf.multi_cell(0, 6,
        'License our patented bus-type stair light technology. Comprehensive technology transfer '
        'includes design documentation, firmware source code, manufacturing guidelines, and '
        'ongoing technical support.')
    pdf.ln(5)
    
    pdf.set_font('helvetica', 'B', 13)
    pdf.set_text_color(*pdf.primary_color)
    pdf.cell(0, 10, 'Distribution Partnerships', new_x='LMARGIN', new_y='NEXT')
    pdf.ln(2)
    
    pdf.set_font('helvetica', '', 10)
    pdf.multi_cell(0, 6,
        'Seeking regional distributors, e-commerce partners, and system integrators worldwide. '
        'Competitive wholesale pricing, marketing support, and exclusive territory protection.')
    
    # Contact
    pdf.add_page()
    pdf.section_title('CONTACT US', 'Let\'s Build the Future Together')
    
    pdf.set_fill_color(*pdf.light_bg)
    pdf.set_draw_color(220, 220, 220)
    pdf.rect(10, pdf.get_y(), 190, 90, 'DF')
    
    pdf.set_y(pdf.get_y() + 10)
    pdf.set_font('helvetica', 'B', 12)
    pdf.set_text_color(*pdf.primary_color)
    pdf.cell(20)
    pdf.cell(0, 10, 'WESMART ELECTRONICS CO., LTD.', new_x='LMARGIN', new_y='NEXT')
    pdf.ln(5)
    
    pdf.set_font('helvetica', '', 10)
    pdf.set_text_color(*pdf.text_color)
    pdf.cell(20)
    pdf.cell(50, 7, 'Headquarters & R&D:', new_x='RIGHT', new_y='TOP')
    pdf.cell(0, 7, "Bao'an District, Shenzhen, China", new_x='LMARGIN', new_y='NEXT')
    
    pdf.cell(20)
    pdf.cell(50, 7, 'Manufacturing:', new_x='RIGHT', new_y='TOP')
    pdf.cell(0, 7, 'Xiaolan Town, Zhongshan City, Guangdong, China', new_x='LMARGIN', new_y='NEXT')
    
    pdf.cell(20)
    pdf.cell(50, 7, 'Flagship Showroom:', new_x='RIGHT', new_y='TOP')
    pdf.cell(0, 7, '10F C06, Star Alliance, Guzhen Town, Zhongshan', new_x='LMARGIN', new_y='NEXT')
    pdf.ln(3)
    
    pdf.cell(20)
    pdf.cell(50, 7, 'Certification:', new_x='RIGHT', new_y='TOP')
    pdf.set_font('helvetica', 'B', 10)
    pdf.set_text_color(*pdf.accent_color)
    pdf.cell(0, 7, 'National High-Tech Enterprise', new_x='LMARGIN', new_y='NEXT')
    
    pdf.set_font('helvetica', '', 10)
    pdf.set_text_color(*pdf.text_color)
    pdf.cell(20)
    pdf.cell(50, 7, 'License No.:', new_x='RIGHT', new_y='TOP')
    pdf.cell(0, 7, 'Guangdong ICP No. 2020119126-1', new_x='LMARGIN', new_y='NEXT')
    
    # Closing
    pdf.set_y(250)
    pdf.set_font('helvetica', 'B', 16)
    pdf.set_text_color(*pdf.primary_color)
    pdf.cell(0, 12, 'SMART LIGHTING, EVERY STEP MATTERS.', align='C', new_x='LMARGIN', new_y='NEXT')
    
    pdf.set_font('helvetica', 'I', 10)
    pdf.set_text_color(128, 128, 128)
    pdf.cell(0, 8, 'Inventor of Bus-type Stair Light Technology | 40+ Patents | Global Smart Home Partner', align='C')
    
    # Save
    output_path = '/root/.openclaw/workspace/Wesmart_Company_Profile_Premium.pdf'
    pdf.output(output_path)
    print(f'Premium PDF generated: {output_path}')
    return output_path

if __name__ == '__main__':
    create_premium_pdf()
