<?php

namespace App\Database\Seeds;

use CodeIgniter\Database\Seeder;

class IndustrySeeder extends Seeder
{
    public function run()
    {
        $industries = [
            [
                "Real Estate",
                "real-estate",
                "property buyers",
                "trust, stature, and long-term value",
            ],
            [
                "Doctors",
                "doctors",
                "patients",
                "expertise, reassurance, and personal care",
            ],
            [
                "Hospitals",
                "hospitals",
                "patients and families",
                "clinical confidence, care, and scale",
            ],
            [
                "Hotels & Resorts",
                "hotels-resorts",
                "travellers and guests",
                "hospitality, experience, and distinction",
            ],
            [
                "Restaurants",
                "restaurants",
                "diners",
                "flavour, atmosphere, and memorability",
            ],
            [
                "Cafes",
                "cafes",
                "local customers",
                "warmth, personality, and everyday appeal",
            ],
            [
                "Dental Clinics",
                "dental-clinics",
                "patients and families",
                "comfort, cleanliness, and confidence",
            ],
            [
                "Healthcare Clinics",
                "healthcare-clinics",
                "patients",
                "professional care and reassurance",
            ],
            [
                "Pharmacies",
                "pharmacies",
                "health-conscious customers",
                "safety, accessibility, and trust",
            ],
            [
                "Law Firms",
                "law-firms",
                "clients",
                "authority, clarity, and discretion",
            ],
            [
                "Financial Services",
                "financial-services",
                "investors and customers",
                "security, credibility, and growth",
            ],
            [
                "Construction Companies",
                "construction-companies",
                "property owners and partners",
                "strength, reliability, and delivery",
            ],
            [
                "Architects",
                "architects",
                "clients and collaborators",
                "precision, vision, and modern thinking",
            ],
            [
                "Interior Designers",
                "interior-designers",
                "homeowners and businesses",
                "taste, creativity, and attention to detail",
            ],
            [
                "Schools & Education",
                "schools-education",
                "students and parents",
                "learning, opportunity, and belonging",
            ],
            [
                "Coaching Institutes",
                "coaching-institutes",
                "students and parents",
                "results, guidance, and ambition",
            ],
            [
                "Technology & SaaS",
                "technology-saas",
                "modern teams and buyers",
                "innovation, simplicity, and scale",
            ],
            [
                "E-commerce",
                "e-commerce",
                "online shoppers",
                "recognition, confidence, and conversion",
            ],
            [
                "Beauty Salons",
                "beauty-salons",
                "style-conscious customers",
                "beauty, confidence, and self-expression",
            ],
            [
                "Spas & Wellness",
                "spas-wellness",
                "wellness seekers",
                "calm, renewal, and premium care",
            ],
            [
                "Fitness & Gyms",
                "fitness-gyms",
                "active communities",
                "energy, progress, and motivation",
            ],
            [
                "Travel Agencies",
                "travel-agencies",
                "travellers",
                "discovery, reliability, and excitement",
            ],
            [
                "Automobile Businesses",
                "automobile-businesses",
                "drivers and vehicle owners",
                "performance, service, and confidence",
            ],
            [
                "Manufacturing",
                "manufacturing",
                "buyers and industry partners",
                "capability, consistency, and scale",
            ],
            [
                "Logistics",
                "logistics",
                "business customers",
                "speed, precision, and reliability",
            ],
            [
                "Food & Beverage",
                "food-beverage",
                "retail customers",
                "taste, quality, and shelf appeal",
            ],
            [
                "Fashion & Apparel",
                "fashion-apparel",
                "style-conscious shoppers",
                "individuality, relevance, and desire",
            ],
            [
                "Jewellery",
                "jewellery",
                "discerning buyers",
                "craft, elegance, and lasting value",
            ],
            [
                "NGOs & Foundations",
                "ngos-foundations",
                "supporters and communities",
                "purpose, credibility, and human impact",
            ],
            [
                "Agriculture",
                "agriculture",
                "farmers, buyers, and partners",
                "growth, dependability, and natural value",
            ],
            [
                "Consulting Firms",
                "consulting-firms",
                "business decision-makers",
                "expertise, clarity, and outcomes",
            ],
            [
                "Event Management",
                "event-management",
                "brands and hosts",
                "energy, creativity, and flawless execution",
            ],
            [
                "Photography Studios",
                "photography-studios",
                "families, couples, and brands",
                "emotion, craft, and originality",
            ],
            [
                "Home Services",
                "home-services",
                "homeowners",
                "reliability, convenience, and care",
            ],
        ];

        $rows = [];
        foreach ($industries as $index => $industry) {
            [$name, $slug, $audience, $qualities] = $industry;
            $rows[] = [
                "name" => $name,
                "slug" => $slug,
                "meta_title" =>
                    "Logo Design for " .
                    $name .
                    " | Professional Logo Designers India",
                "meta_description" =>
                    "Build a trusted " .
                    strtolower($name) .
                    " brand with a distinctive, strategic logo. Original concepts, guided revisions and complete brand-ready files from BrandSquare.",
                "hero_heading" =>
                    "Logo design for " .
                    $name .
                    " that earns attention and trust.",
                "hero_text" =>
                    "We create original visual identities that help " .
                    strtolower($name) .
                    " businesses look credible, memorable, and ready to grow—online and everywhere else.",
                "challenge_heading" =>
                    "A stronger first impression for every " .
                    strtolower($name) .
                    " brand.",
                "challenge_text" =>
                    "Your identity needs to connect with " .
                    $audience .
                    " in seconds. We translate your positioning into a clear, ownable design that communicates " .
                    $qualities .
                    ".",
                "primary_color" => $this->primaryColor($index),
                "accent_color" => $this->accentColor($index),
                "is_active" => 1,
                "sort_order" => $index + 1,
                "created_at" => date("Y-m-d H:i:s"),
                "updated_at" => date("Y-m-d H:i:s"),
            ];
        }

        $existing = $this->db
            ->table("industries")
            ->select("slug")
            ->get()
            ->getResultArray();
        $existingSlugs = array_column($existing, "slug");
        $rows = array_values(
            array_filter($rows, static function ($row) use ($existingSlugs) {
                return !in_array($row["slug"], $existingSlugs, true);
            }),
        );
        if ($rows) {
            $this->db->table("industries")->insertBatch($rows);
        }
    }

    private function primaryColor(int $index): string
    {
        $colors = ["#142522", "#17213f", "#3a1835", "#12314a", "#2d2418"];
        return $colors[$index % count($colors)];
    }

    private function accentColor(int $index): string
    {
        $colors = ["#caff62", "#7de2d1", "#ffc56e", "#a8b8ff", "#ff9f80"];
        return $colors[$index % count($colors)];
    }
}
