import os
import sys
from pathlib import Path
import django

# Setup Django environment
BASE_DIR = Path(__file__).resolve().parent
sys.path.insert(0, str(BASE_DIR))
sys.path.insert(0, str(BASE_DIR / 'apps'))
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
django.setup()

from django.contrib.auth.models import User, Group
from core.models import SiteSettings, SocialLink, SEOData
from pages.models import HeroSlide, CompanyStat, WhyChooseUs
from services.models import ServiceCategory, Service
from portfolio.models import ProjectCategory, Technology, Project
from blog.models import BlogCategory, Tag, BlogPost
from careers.models import Job
from team.models import TeamMember
from testimonials.models import Testimonial
from faqs.models import FAQCategory, FAQ

def seed():
    print("[*] Starting SONICTECH Data Seeding (English)...")

    # 1. Superuser
    if not User.objects.filter(username='admin').exists():
        User.objects.create_superuser('admin', 'admin@sonictech.co.tz', 'sonictech2026!')
        print("[+] Superuser created: admin / sonictech2026!")
    else:
        print("[i] Superuser already exists.")

    # 2. Permission Groups
    groups = ['Super Admin', 'Content Manager', 'HR Manager', 'Sales & Leads']
    for grp in groups:
        Group.objects.get_or_create(name=grp)
    print("[+] User Role Groups configured.")

    # 3. Site Settings with Exact Contact Details
    settings, _ = SiteSettings.objects.get_or_create(id=1)
    settings.company_name = "SONICTECH COMPANY LIMITED"
    settings.tagline = "Engineering Next-Generation Digital & Enterprise Solutions"
    settings.phone = "+255 627 360 144"
    settings.secondary_phone = "+255 754 123 456"
    settings.email = "info@sonictech.co.tz"
    settings.support_email = "support@sonictech.co.tz"
    settings.address = "Buzuruga Kaskazini, Buzuruga, Mwanza, TZ"
    settings.working_hours = "Mon - Fri: 8:00 AM - 5:30 PM, Sat: 9:00 AM - 1:00 PM"
    settings.footer_about = "SONICTECH COMPANY LIMITED is a premier technology partner delivering cutting-edge software engineering, enterprise ERP platforms, mobile applications, and digital transformation for visionary organizations across Tanzania and East Africa."
    settings.copyright_text = "© 2026 SONICTECH COMPANY LIMITED. All Rights Reserved."
    settings.save()
    print("[+] Site Settings populated.")

    # 4. Social Links
    socials = [
        ('facebook', 'https://facebook.com/sonictechofficial', 'Facebook', 1),
        ('twitter', 'https://twitter.com/sonictechtz', 'Twitter', 2),
        ('instagram', 'https://instagram.com/sonictech.tz', 'Instagram', 3),
        ('linkedin', 'https://linkedin.com/company/sonictech-tz', 'Linkedin', 4),
        ('github', 'https://github.com/sonictech-tz', 'Github', 5),
    ]
    SocialLink.objects.all().delete()
    for platform, url, icon, order in socials:
        SocialLink.objects.create(platform=platform, url=url, icon=icon, order=order, is_active=True)
    print("[+] Social Links populated.")

    # 5. Hero Slides
    HeroSlide.objects.all().delete()
    HeroSlide.objects.create(
        badge_text="Best IT Solutions & Innovations",
        title="Quality Digital Services You Really Need!",
        highlight_word="Really Need!",
        description="SONICTECH COMPANY LIMITED provides world-class software engineering, robust enterprise platforms, and digital transformation tailored for market leaders across Tanzania and East Africa.",
        primary_btn_text="Get Started",
        primary_btn_url="/contact",
        secondary_btn_text="Our Services",
        secondary_btn_url="/services",
        image_url="https://images.unsplash.com/photo-1522071820081-009f0129c71c?auto=format&fit=crop&w=1600&q=80",
        order=1,
        is_active=True
    )
    HeroSlide.objects.create(
        badge_text="Accelerate Business Growth",
        title="Scalable Cloud & Custom Software Built For Future Scale",
        highlight_word="Future Scale",
        description="From seamless mobile money integrations (M-Pesa, Tigo Pesa) to intelligent enterprise ERP systems, we deliver secure, mission-critical technology on time.",
        primary_btn_text="Request a Quote",
        primary_btn_url="/contact",
        secondary_btn_text="View Projects",
        secondary_btn_url="/portfolio",
        image_url="https://images.unsplash.com/photo-1551434678-e076c223a692?auto=format&fit=crop&w=1600&q=80",
        order=2,
        is_active=True
    )
    print("[+] Hero Slides populated.")

    # 6. Company Stats
    CompanyStat.objects.all().delete()
    stats = [
        ("150+", "Completed Projects", "CheckCircle2", 1),
        ("99.9%", "System Reliability", "ShieldCheck", 2),
        ("50+", "Corporate Clients", "Users", 3),
        ("24/7", "Dedicated Tech Support", "Headphones", 4),
    ]
    for num, label, icon, order in stats:
        CompanyStat.objects.create(number=num, label=label, icon=icon, order=order)
    print("[+] Company Stats populated.")

    # 7. Why Choose Us
    WhyChooseUs.objects.all().delete()
    why_items = [
        ("Elite Engineering Talent", "Our certified engineers bring deep expertise in modern architectures, distributed microservices, and secure system design.", "Award", 1),
        ("FinTech & Local Ecosystem Mastery", "Native integration expertise with East African payment networks (M-Pesa, Tigo Pesa, Airtel Money, GePG, NMB, CRDB).", "Layers", 2),
        ("Zero-Compromise Security", "We follow OWASP Top 10 standards, automated security pipelines, and complete data encryption at rest and in transit.", "Lock", 3),
        ("Agile & Rapid Time-to-Market", "Transparent sprints, continuous feedback loops, and automated deployments keep your business ahead of competition.", "Zap", 4),
    ]
    for title, desc, icon, order in why_items:
        WhyChooseUs.objects.create(title=title, description=desc, icon=icon, order=order)
    print("[+] Why Choose Us populated.")

    # 8. Service Categories & Services
    ServiceCategory.objects.all().delete()
    Service.objects.all().delete()

    cat_dev = ServiceCategory.objects.create(name="Development & Engineering", slug="development-engineering", description="Bespoke software and applications")
    cat_cloud = ServiceCategory.objects.create(name="Cloud & Infrastructure", slug="cloud-infrastructure", description="Cloud hosting, DevOps, and uptime")
    cat_consult = ServiceCategory.objects.create(name="Strategy & Consulting", slug="strategy-consulting", description="IT advisory and enterprise architecture")

    services_data = [
        {
            "category": cat_dev,
            "title": "Custom Software Development",
            "slug": "custom-software-development",
            "short_description": "Tailor-made enterprise software architected to automate complex workflows, boost team productivity, and eliminate operational bottlenecks.",
            "full_description": "We engineer bespoke software tailored to your specific organizational structure. Whether automating multi-department workflows, integrating legacy databases, or architecting distributed web platforms, SONICTECH ensures rock-solid stability, audit compliance, and scalable performance.",
            "icon": "Code",
            "key_features": ["Custom Workflow Automation", "Modular Clean Architecture", "Comprehensive API Layer", "Role-Based Access Control"],
            "benefits": ["Eliminates manual human error", "Reduces operational costs by up to 40%", "Full source code ownership"],
            "technologies": "Django, Python, PostgreSQL, React, Docker, Redis",
            "order": 1,
        },
        {
            "category": cat_dev,
            "title": "Web Application Development",
            "slug": "web-application-development",
            "short_description": "High-performance, ultra-responsive web portals and SaaS platforms engineered with React and modern backend frameworks.",
            "full_description": "We build fast, secure, and intuitive web applications designed for maximum user engagement. From public-facing portals to internal management dashboards, our web apps load instantaneously, adhere strictly to SEO best practices, and deliver seamless responsive user experiences across all devices.",
            "icon": "Globe",
            "key_features": ["Progressive Web App (PWA)", "Sub-Second Page Loads", "SEO & OpenGraph Optimized", "Cross-Browser Compatibility"],
            "benefits": ["Higher customer retention", "Flawless mobile experience", "Effortless content management via CMS"],
            "technologies": "React, Tailwind CSS, Vite, Django REST Framework, Node.js",
            "order": 2,
        },
        {
            "category": cat_dev,
            "title": "Mobile App Development",
            "slug": "mobile-app-development",
            "short_description": "Native and cross-platform Android & iOS mobile applications with offline-first capabilities and lightning-fast speed.",
            "full_description": "Expand your reach into the palms of millions of consumers. We specialize in developing sleek, high-performing mobile applications using Flutter and React Native. Equipped with offline data synchronization, biometric authentication, push notifications, and local mobile money checkout.",
            "icon": "Smartphone",
            "key_features": ["iOS & Android Unified Codebase", "Biometric Authentication (FaceID/Fingerprint)", "Offline-First Data Sync", "Push Notification Automation"],
            "benefits": ["Direct consumer communication channel", "Frictionless mobile payments", "App Store & Play Store publishing included"],
            "technologies": "Flutter, React Native, Kotlin, Swift, Firebase",
            "order": 3,
        },
        {
            "category": cat_dev,
            "title": "UI/UX Product Design",
            "slug": "ui-ux-product-design",
            "short_description": "User-centric interface design, wireframing, and interactive design systems that turn complex processes into delightful experiences.",
            "full_description": "Great technology begins with intuitive human experience. Our design team conducts deep user journey mapping, wireframing, high-fidelity Figma prototypes, and usability testing to guarantee your digital product is both visually stunning and effortless to navigate.",
            "icon": "Palette",
            "key_features": ["User Journey Mapping", "Interactive Figma Prototyping", "Design System & Component Library", "Accessibility (WCAG) Compliance"],
            "benefits": ["Drastically reduced user learning curve", "Higher conversion rates", "Consistent brand identity across all touchpoints"],
            "technologies": "Figma, Adobe XD, Design Tokens, Tailwind CSS",
            "order": 4,
        },
        {
            "category": cat_cloud,
            "title": "System & FinTech Integration",
            "slug": "system-fintech-integration",
            "short_description": "Seamless API integrations with M-Pesa, Tigo Pesa, Airtel Money, national gateways (GePG, TRA), and legacy ERPs.",
            "full_description": "Eliminate digital silos. SONICTECH integrates disparate systems into unified data pipelines. We have deep production experience connecting applications with Tanzania's telecom mobile money APIs, automated reconciliation, banking gateways, CRM platforms, and government fiscal devices.",
            "icon": "Layers",
            "key_features": ["M-Pesa & Tigo Pesa Automated Webhooks", "Automated Payment Reconciliation", "Enterprise Service Bus (ESB)", "REST & GraphQL Gateway APIs"],
            "benefits": ["Zero manual payment verification", "Real-time transaction settlement", "99.99% transaction reliability"],
            "technologies": "REST APIs, GraphQL, Kafka, Celery, RabbitMQ, Webhooks",
            "order": 5,
        },
        {
            "category": cat_cloud,
            "title": "Cloud, DevOps & 24/7 Support",
            "slug": "cloud-devops-support",
            "short_description": "High-availability cloud architecture on AWS/DigitalOcean, CI/CD pipelines, automated daily backups, and proactive monitoring.",
            "full_description": "Ensure your mission-critical applications never go down. We configure scalable cloud infrastructures, automated Kubernetes/Docker deployments, SSL security certificates, daily off-site encrypted backups, and 24/7 server monitoring with guaranteed SLA response times.",
            "icon": "Cpu",
            "key_features": ["Automated CI/CD Pipelines", "Docker & Kubernetes Orchestration", "Daily Automated Off-Site Backups", "Real-Time Prometheus & Grafana Monitoring"],
            "benefits": ["Zero-downtime rolling updates", "Rapid disaster recovery guarantee", "Proactive intrusion detection"],
            "technologies": "Docker, Kubernetes, AWS, Nginx, Linux, PostgreSQL, GitHub Actions",
            "order": 6,
        },
    ]

    for s in services_data:
        Service.objects.create(**s)
    print("[+] Services populated.")

    # 9. Portfolio Projects
    ProjectCategory.objects.all().delete()
    Technology.objects.all().delete()
    Project.objects.all().delete()

    pcat_fintech = ProjectCategory.objects.create(name="FinTech & Banking", slug="fintech-banking")
    pcat_health = ProjectCategory.objects.create(name="Healthcare & ERP", slug="healthcare-erp")
    pcat_logistics = ProjectCategory.objects.create(name="Logistics & Trade", slug="logistics-trade")
    pcat_ecommerce = ProjectCategory.objects.create(name="E-Commerce & Portals", slug="ecommerce-portals")

    tech_react, _ = Technology.objects.get_or_create(name="React.js", icon="Code")
    tech_django, _ = Technology.objects.get_or_create(name="Django", icon="Server")
    tech_pg, _ = Technology.objects.get_or_create(name="PostgreSQL", icon="Database")
    tech_docker, _ = Technology.objects.get_or_create(name="Docker", icon="Box")
    tech_flutter, _ = Technology.objects.get_or_create(name="Flutter", icon="Smartphone")
    tech_mpesa, _ = Technology.objects.get_or_create(name="M-Pesa API", icon="CreditCard")

    p1 = Project.objects.create(
        title="SonicPesa Unified Payment Gateway",
        slug="sonicpesa",
        category=pcat_fintech,
        client="SonicTech Company LTD",
        industry="Financial Services",
        short_description="Centralized mobile money payment gateway handling automated collections, bulk disbursements, and instant reconciliation.",
        challenge="Client faced high transaction failure rates, delayed webhooks, and manual bank reconciliation across 4 telecom providers.",
        solution="SONICTECH architected a high-throughput async processing engine with retry queues, automated ledger balancing, and webhook idempotency.",
        results="Processed over 1.2M transactions in first quarter with 99.98% success rate and zero lost transactions.",
        featured_image_url="https://images.unsplash.com/photo-1559526324-4b87b5e36e44?auto=format&fit=crop&w=800&q=80",
        completion_date="2025",
        is_featured=True,
        order=1
    )
    p1.technologies.add(tech_django, tech_react, tech_pg, tech_mpesa, tech_docker)

    p2 = Project.objects.create(
        title="Apex Afya Hospital Information ERP",
        slug="apex-afya-hospital-information-erp",
        category=pcat_health,
        client="Apex Health Group Tanzania",
        industry="Healthcare & Medical",
        short_description="Comprehensive hospital management system connecting patient triage, electronic health records (EHR), pharmacy inventory, and billing.",
        challenge="Paper-based medical records caused patient bottlenecks, billing leakages, and delayed diagnostic test communications.",
        solution="Engineered a secure, role-restricted web portal with real-time patient queue displays, automated pharmacy stock alerts, and insurance claims processing.",
        results="Reduced average patient wait time by 65% and eradicated medication stockouts across 3 hospital branches.",
        featured_image_url="https://images.unsplash.com/photo-1576091160399-112ba8d25d1d?auto=format&fit=crop&w=800&q=80",
        completion_date="2025",
        is_featured=True,
        order=2
    )
    p2.technologies.add(tech_django, tech_react, tech_pg, tech_docker)

    p3 = Project.objects.create(
        title="Kilima Cargo Logistics & Fleet Tracker",
        slug="kilima-cargo-logistics-fleet-tracker",
        category=pcat_logistics,
        client="Kilima Express Transporters",
        industry="Logistics & Supply Chain",
        short_description="Real-time GPS vehicle tracking, electronic consignment manifests, fuel analytics, and driver performance dashboard.",
        challenge="Fleet managers struggled to track trucks across the Central Corridor with frequent signal loss.",
        solution="Built an offline-tolerant telematics gateway that buffers sensor telemetry locally and syncs automatically with central servers upon network recovery.",
        results="Fuel theft reduced by 28% and customer delivery ETA precision increased by 92%.",
        featured_image_url="https://images.unsplash.com/photo-1586528116311-ad8dd3c8310d?auto=format&fit=crop&w=800&q=80",
        completion_date="2024",
        is_featured=True,
        order=3
    )
    p3.technologies.add(tech_django, tech_flutter, tech_pg, tech_docker)

    p4 = Project.objects.create(
        title="KilimoLink Agro-Trade B2B Marketplace",
        slug="kilimolink-agro-trade-b2b-marketplace",
        category=pcat_ecommerce,
        client="Ministry of Agriculture Partnership",
        industry="Agriculture & Trade",
        short_description="B2B digital commodity trading platform connecting regional agricultural cooperatives directly with bulk food processors.",
        challenge="Smallholder farmer groups faced price exploitation by middlemen and lacked transparent market price benchmarks.",
        solution="Developed a Web-enabled commodity bidding portal with live market price tickers, escrow payment security, and transport matching.",
        results="Connected over 18,000 farmers to verified corporate buyers, generating over 4.5 Billion TZS in trade volume.",
        featured_image_url="https://images.unsplash.com/photo-1500937386664-56d1dfef3854?auto=format&fit=crop&w=800&q=80",
        completion_date="2024",
        is_featured=True,
        order=4
    )
    p4.technologies.add(tech_django, tech_react, tech_pg, tech_mpesa)

    print("[+] Projects & Portfolio populated.")

    # 10. Blog Posts
    BlogCategory.objects.all().delete()
    Tag.objects.all().delete()
    BlogPost.objects.all().delete()

    bcat_tech = BlogCategory.objects.create(name="Software Engineering", slug="software-engineering")
    bcat_fintech = BlogCategory.objects.create(name="FinTech Insights", slug="fintech-insights")
    bcat_business = BlogCategory.objects.create(name="Digital Transformation", slug="digital-transformation")

    tag_django = Tag.objects.create(name="Django", slug="django")
    tag_react = Tag.objects.create(name="React", slug="react")
    tag_security = Tag.objects.create(name="Security", slug="security")
    tag_mpesa = Tag.objects.create(name="M-Pesa", slug="mpesa")

    b1 = BlogPost.objects.create(
        title="Why Modern African Enterprises Choose Django & React for Mission-Critical Systems",
        slug="why-modern-african-enterprises-choose-django-react",
        category=bcat_tech,
        author_name="Daniel Martin",
        author_role="Lead Software Architect",
        summary="Explore why combining Django's hardened security and ORM with React's fluid interface creates the most reliable foundation for enterprise software.",
        content="""In today's fast-paced digital economy, businesses cannot afford brittle architectures. When evaluating backend systems for financial operations, inventory management, and government reporting, security and reliability must come first.

Django provides battle-tested defenses against SQL injection, cross-site scripting (XSS), and CSRF vulnerabilities right out of the box. Paired with Django REST Framework, it enables clean API decoupling.

On the client side, React provides reactive state handling, reusable component modules, and lightning-fast rendering. Together, this combination gives enterprise organizations the speed of a modern Single-Page Application without sacrificing data integrity or security compliance.""",
        image_url="https://images.unsplash.com/photo-1517245386807-bb43f82c33c4?auto=format&fit=crop&w=800&q=80",
        read_time="4 min read",
        status="published",
        is_featured=True
    )
    b1.tags.add(tag_django, tag_react)

    b2 = BlogPost.objects.create(
        title="Mastering Mobile Money Integrations: Handling Webhooks, Retries & Reconciliation",
        slug="mastering-mobile-money-integrations-webhooks-reconciliation",
        category=bcat_fintech,
        author_name="Sarah Mwamba",
        author_role="Senior Backend Engineer",
        summary="A comprehensive engineering guide on building fault-tolerant payment gateways for M-Pesa, Tigo Pesa, and Airtel Money in Tanzania.",
        content="""Integrating mobile money APIs seems straightforward until network timeouts, duplicate customer callbacks, or delayed webhooks occur in production.

To ensure your financial ledger stays 100% accurate, your integration must implement three foundational principles:
1. Idempotency Keys: Never charge a customer twice or credit an account twice for the same transaction ID.
2. Exponential Backoff & Retry Queues: Use Celery or Redis queues to process callbacks asynchronously and retry safely.
3. Daily Automated Reconciliation: Compare bank statement outputs directly with internal database records every midnight.

At SONICTECH COMPANY LIMITED, these patterns are baked directly into all our FinTech architectures.""",
        image_url="https://images.unsplash.com/photo-1559526324-4b87b5e36e44?auto=format&fit=crop&w=800&q=80",
        read_time="6 min read",
        status="published",
        is_featured=True
    )
    b2.tags.add(tag_mpesa, tag_security)

    b3 = BlogPost.objects.create(
        title="Zero-Trust Architecture: Safeguarding Corporate Data in 2026",
        slug="zero-trust-architecture-safeguarding-corporate-data-2026",
        category=bcat_business,
        author_name="Michael Kitima",
        author_role="Cybersecurity & Infrastructure Director",
        summary="Why corporate firewalls are no longer sufficient and how modern enterprises adopt Zero-Trust authentication protocols.",
        content="""The perimeter of the modern office has dissolved. With distributed teams, cloud databases, and mobile employees accessing sensitive records from across the country, assuming internal traffic is secure is a dangerous flaw.

Zero-Trust operates on a simple principle: 'Never trust, always verify.' Every single API request must be authenticated, authorized, and logged regardless of whether it originates from inside or outside the private network.

We examine practical steps companies can implement today: role-based access control, automated token rotation, encrypted database backups, and multi-factor authentication for all administrative dashboards.""",
        image_url="https://images.unsplash.com/photo-1563986768609-322da13575f3?auto=format&fit=crop&w=800&q=80",
        read_time="5 min read",
        status="published",
        is_featured=False
    )
    b3.tags.add(tag_security)

    print("[+] Blog Posts populated.")

    # 11. Careers / Jobs
    Job.objects.all().delete()
    from datetime import date, timedelta
    Job.objects.create(
        title="Senior Full-Stack Engineer (Python / React)",
        slug="senior-full-stack-engineer-python-react",
        department="Engineering",
        location="Mwanza, TZ (Hybrid)",
        employment_type="full_time",
        experience_level="Senior Level (4+ years)",
        description="We are seeking an experienced Full-Stack Engineer to architect, build, and maintain high-concurrency enterprise web platforms and client dashboards using Django and React.",
        responsibilities=[
            "Architect and implement RESTful API services using Django & DRF",
            "Develop modular, performant React UI components using modern Tailwind CSS",
            "Design normalized relational database schemas in PostgreSQL / SQLite",
            "Mentor junior and mid-level engineers through code reviews"
        ],
        requirements=[
            "4+ years of production experience in Python / Django",
            "Strong proficiency in modern JavaScript/TypeScript, React, and state management",
            "Experience with Docker, Linux server administration, and CI/CD pipelines",
            "Solid understanding of software design patterns and automated testing"
        ],
        benefits=[
            "Competitive salary and performance bonuses",
            "Comprehensive health insurance for you and your dependents",
            "Flexible hybrid work schedule and modern work hardware",
            "Continuous learning budget for certifications and conferences"
        ],
        deadline=date.today() + timedelta(days=45),
        is_active=True
    )
    Job.objects.create(
        title="Mobile Application Developer (Flutter)",
        slug="mobile-application-developer-flutter",
        department="Mobile Solutions",
        location="Mwanza, TZ (Full-time)",
        employment_type="full_time",
        experience_level="Mid Level (2+ years)",
        description="Join our mobile team to create cutting-edge iOS and Android applications integrating offline capabilities, payment gateways, and real-time communications.",
        responsibilities=[
            "Build cross-platform mobile apps for iOS and Android using Flutter",
            "Integrate RESTful backend APIs and WebSocket streams",
            "Implement biometric authentication, local SQLite caching, and push notifications",
            "Manage App Store and Google Play Store publishing and updates"
        ],
        requirements=[
            "2+ years experience building and deploying Flutter applications",
            "Demonstrated portfolio of published apps on Google Play or App Store",
            "Understanding of mobile UI/UX guidelines for Material Design and Apple HIG",
            "Experience with Git version control and collaborative workflows"
        ],
        benefits=[
            "Competitive salary package",
            "Medical insurance cover",
            "Team retreat and innovation hackathons"
        ],
        deadline=date.today() + timedelta(days=30),
        is_active=True
    )
    print("[+] Careers / Jobs populated.")

    # 12. Team Members
    TeamMember.objects.all().delete()
    team_data = [
        ("David M. Lyimo", "Managing Director & CEO", "Executive", "15+ years leading enterprise digital transformation and tech startups in East Africa.", "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?auto=format&fit=crop&w=400&q=80", 1),
        ("Sarah K. Mwamba", "Head of Engineering", "Engineering", "Specialist in distributed cloud architecture, microservices, and high-concurrency FinTech platforms.", "https://images.unsplash.com/photo-1573496359142-b8d87734a5a2?auto=format&fit=crop&w=400&q=80", 2),
        ("Daniel Martin", "Lead Systems Architect", "Engineering", "Pioneer in enterprise ERP development, database optimization, and secure API gateways.", "https://images.unsplash.com/photo-1500648767791-00dcc994a43e?auto=format&fit=crop&w=400&q=80", 3),
        ("Grace E. Tarimo", "Lead UI/UX Designer", "Product Design", "Passionate about human-centered design, accessibility, and intuitive software interfaces.", "https://images.unsplash.com/photo-1580489944761-15a19d654956?auto=format&fit=crop&w=400&q=80", 4),
    ]
    for name, role, dept, bio, photo, order in team_data:
        TeamMember.objects.create(name=name, role=role, department=dept, bio=bio, photo_url=photo, order=order, is_leadership=True)
    print("[+] Team Members populated.")

    # 13. Testimonials
    Testimonial.objects.all().delete()
    testimonials_data = [
        ("Josephat Mmari", "Chief Executive Officer", "Apex Health Group", "SONICTECH delivered our hospital ERP ahead of schedule. Their attention to security, patient privacy, and speed has transformed our daily clinic operations completely.", 5, "Apex Hospital ERP", 1),
        ("Amina Salim", "Head of Digital Operations", "SonicTech Company LTD", "The reliability of the SonicPesa payment gateway integration is remarkable. Over one million mobile money transactions processed without a hitch. Truly the top software partner in Tanzania.", 5, "SonicPesa Gateway", 2),
        ("Godfrey Kileo", "Logistics Operations Director", "Kilima Transporters", "Their fleet tracking and cargo system has completely eliminated fuel theft and delivery disputes. Outstanding support team available around the clock.", 5, "Kilima Fleet Tracker", 3),
    ]
    for name, title, comp, quote, rating, proj, order in testimonials_data:
        Testimonial.objects.create(
            client_name=name,
            client_title=title,
            company_name=comp,
            quote=quote,
            rating=rating,
            project_delivered=proj,
            order=order,
            is_featured=True,
            is_active=True
        )
    print("[+] Testimonials populated.")

    # 14. FAQs in English
    FAQCategory.objects.all().delete()
    FAQ.objects.all().delete()

    fcat_general = FAQCategory.objects.create(name="General & Getting Started", slug="general", order=1)
    fcat_dev = FAQCategory.objects.create(name="Development & Technical", slug="technical", order=2)
    fcat_pricing = FAQCategory.objects.create(name="Pricing & Support", slug="pricing-support", order=3)

    faqs_data = [
        (fcat_general, "How does the software project discovery process work at SONICTECH?", "Our engagement begins with a comprehensive Discovery Session to understand your organizational goals and workflow requirements. We then draft a detailed Technical Proposal & Architecture Roadmap. Following agreement, we initiate two-week Agile sprints with regular stakeholder demonstrations.", 1),
        (fcat_general, "Do you serve clients across different regions in Tanzania and internationally?", "Yes! While headquartered in Mwanza, TZ, SONICTECH serves enterprise clients nationwide (Dar es Salaam, Arusha, Dodoma, Zanzibar, Mbeya) and across East Africa through secure remote collaboration and on-site deployment teams.", 2),
        (fcat_dev, "Does the client retain full ownership of the system source code?", "Absolutely. Upon project completion and final milestone clearance, you receive 100% full legal ownership of the custom Source Code, Database schemas, and technical documentation with zero vendor lock-in.", 3),
        (fcat_dev, "Can you integrate our systems with M-Pesa, Tigo Pesa, Airtel Money, and GePG?", "Yes. We specialize in deep FinTech integrations with all major Tanzanian mobile network operators, government payment portals (GePG), and commercial banking APIs (CRDB, NMB, Standard Chartered, Stanbic).", 4),
        (fcat_pricing, "How are software development costs and timelines estimated?", "Costs and timelines depend on the functional scope, the number of modules required, third-party API complexities, and concurrent user concurrency demands. Contact us today for a free, transparent project proposal tailored to your budget.", 5),
        (fcat_pricing, "Do you provide post-launch maintenance and technical support (SLA)?", "Yes. Every custom software deployment includes a complimentary warranty period for bug fixes and system monitoring, followed by tailored 24/7 Service Level Agreement (SLA) maintenance contracts.", 6),
    ]

    for cat, q, a, order in faqs_data:
        FAQ.objects.create(category=cat, question=q, answer=a, order=order, is_active=True)
    print("[+] FAQs populated.")

    print("\n[SUCCESS] SONICTECH Initial Seed Data successfully populated in English!")

if __name__ == '__main__':
    seed()
