<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
use App\Models\User;
use App\Models\SiteSetting;
use App\Models\Product;
use App\Models\ProductFeature;
use App\Models\Solution;
use App\Models\CaseStudy;
use App\Models\ResourceCategory;
use App\Models\Resource;
use App\Models\Job;
use App\Models\HeroSlide;
use App\Models\ProcessStep;
use App\Models\WhyUsPoint;
use App\Models\AboutSection;

class DatabaseSeeder extends Seeder
{
    public function run(): void
    {
        // ── Admin User ──────────────────────────────────────
        User::create([
            'name'     => 'Admin',
            'email'    => 'admin@muvrlabs.com',
            'password' => Hash::make('Admin@1234'),
            'role'     => 'admin',
        ]);

        // ── Site Settings ────────────────────────────────────
        $settings = [
            'site_name'        => 'MUVR Labs',
            'footer_tagline'   => 'Engineering-driven solutions built for real-world performance.',
            'contact_email'    => 'info@muvrlabs.com',
            'contact_phone'    => '',
            'address'          => '',
            'google_maps_embed'=> '',
            'meta_title'       => 'MUVR Labs — Custom Test Rigs & Engineering Solutions',
            'meta_description' => 'MUVR Labs builds automated test systems, standards-compliant rigs, and project-based engineering solutions for industrial, research, and advanced technology applications.',
        ];
        foreach ($settings as $key => $value) {
            SiteSetting::create(['key' => $key, 'value' => $value]);
        }

        // ── Hero Slide ───────────────────────────────────────
        HeroSlide::create([
            'eyebrow'             => 'Engineering · Testing · Automation',
            'heading'             => 'Custom Test Rigs and Engineering Development for Demanding Applications',
            'subheading'          => 'MUVR Labs builds automated test systems, standards-compliant rigs, and project-based engineering solutions for industrial, research, and advanced technology applications.',
            'support_line'        => 'From concept to commissioning — engineered for performance, precision, and real-world deployment.',
            'primary_btn_text'    => 'Explore Products',
            'primary_btn_url'     => '/products',
            'secondary_btn_text'  => 'Discuss Your Requirement',
            'secondary_btn_url'   => '/contact',
            'is_active'           => 1,
            'sort_order'          => 0,
        ]);

        // ── Products ─────────────────────────────────────────
        $p1 = Product::create([
            'name'              => 'AERONIX A100',
            'slug'              => 'aeronix-a100',
            'subtitle'          => 'Universal Gas Phase Test Rig — EN14387 Compliant',
            'standard_badge'    => 'EN14387',
            'short_description' => 'AERONIX A100 is a gas phase filter test rig developed for EN14387-standard testing, capable of evaluating both carbon bed modules and mask canister testing configurations.',
            'full_description'  => '<p>The AERONIX A100 is a fully automated gas phase filter test rig developed in compliance with EN14387 standards. Designed for use in compliance testing laboratories, research facilities, and industrial quality assurance environments, the A100 delivers precise, repeatable test execution with automated data capture.</p><p>The system supports both carbon bed module testing and mask canister evaluation within a single platform. The modular design allows configuration changes without additional hardware. Built for demanding environments, the A100 provides stable and controlled gas exposure profiles, real-time monitoring, and automated data logging that integrates with standard reporting workflows.</p>',
            'sort_order'        => 1,
            'is_active'         => 1,
        ]);
        foreach (['Gas phase exposure control','Carbon bed module testing','Mask canister evaluation','Automated data logging','EN14387 compliance','Repeatable test execution'] as $i => $f) {
            ProductFeature::create(['product_id' => $p1->id, 'feature' => $f, 'sort_order' => $i]);
        }

        $p2 = Product::create([
            'name'              => 'ASTM D6646 Test Rig',
            'slug'              => 'astm-d6646-test-rig',
            'subtitle'          => 'Automated Breakthrough Test System — ASTM D6646 Compliant',
            'standard_badge'    => 'ASTM D6646',
            'short_description' => 'An automated test rig developed in compliance with ASTM D6646 for evaluating gas phase adsorption performance and breakthrough characteristics under controlled test conditions.',
            'full_description'  => '<p>The ASTM D6646 Test Rig is an automated test system specifically designed and built to meet the requirements of ASTM D6646 for evaluating gas phase adsorption and breakthrough performance. Designed for precision, repeatability, and dependable data logging, this system is used in industrial testing, research, and compliance verification environments.</p><p>The automated controls ensure consistent test conditions across multiple runs, while the data acquisition system captures all critical parameters in real time.</p>',
            'sort_order'        => 2,
            'is_active'         => 1,
        ]);
        foreach (['Breakthrough characteristic testing','Gas adsorption evaluation','Precision flow control','ASTM D6646 compliance','High-repeatability design','Data logging system'] as $i => $f) {
            ProductFeature::create(['product_id' => $p2->id, 'feature' => $f, 'sort_order' => $i]);
        }

        // ── Solutions ────────────────────────────────────────
        $solutions = [
            ['title'=>'Custom Test Rig Development','slug'=>'custom-test-rig-development','short_description'=>'Bespoke automated test systems engineered to your specification and standards requirements.','full_description'=>'<p>We design and build fully bespoke automated test systems tailored to your exact specification. From requirements capture through to commissioning, we manage the full engineering lifecycle. Our test rig development capability spans mechanical design, control systems, instrumentation, software, and validation.</p>','icon_svg'=>'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="3" y1="9" x2="21" y2="9"/></svg>','sort_order'=>1],
            ['title'=>'Automation & Instrumentation Systems','slug'=>'automation-instrumentation','short_description'=>'Integrated automation solutions with precision instrumentation for industrial and research use.','full_description'=>'<p>We deliver integrated automation solutions for industrial and research applications. Our capabilities span PLC-based control systems, sensor integration, HMI development, and data acquisition system design.</p>','icon_svg'=>'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M12 1v4M12 19v4M4.22 4.22l2.83 2.83M16.95 16.95l2.83 2.83M1 12h4M19 12h4M4.22 19.78l2.83-2.83M16.95 7.05l2.83-2.83"/></svg>','sort_order'=>2],
            ['title'=>'Medical Technology Development','slug'=>'medical-technology','short_description'=>'Engineering support for medical device development, testing validation, and compliance projects.','full_description'=>'<p>We provide engineering development support for medical technology companies, covering device development, testing validation, and compliance-oriented engineering programs.</p>','icon_svg'=>'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M22 12h-4l-3 9L9 3l-3 9H2"/></svg>','sort_order'=>3],
            ['title'=>'Advanced Engineering & Deep-Tech Projects','slug'=>'advanced-engineering','short_description'=>'Complex technical programs from concept through to deployment for specialized applications.','full_description'=>'<p>We take on complex, multi-disciplinary engineering programs that sit at the boundary of what is technically feasible. Our deep-tech engineering capability covers concept development, systems engineering, hardware and software integration, and deployment support.</p>','icon_svg'=>'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>','sort_order'=>4],
        ];
        foreach ($solutions as $s) {
            Solution::create(array_merge($s, ['is_active' => 1]));
        }

        // ── Case Studies ─────────────────────────────────────
        CaseStudy::create(['title'=>'EN14387 Test Rig Development and Deployment','slug'=>'en14387-test-rig-development','tab_label'=>'EN14387 Case','summary'=>'Development and commissioning of a complete EN14387 gas phase filter test rig for a compliance-testing laboratory.','full_content'=>'<h4>Project Overview</h4><p>MUVR Labs was engaged to develop and commission a complete EN14387-compliant gas phase filter test rig. The project scope covered full system design, mechanical build, control system integration, calibration, and on-site deployment.</p><h4>Outcome</h4><p>The client achieved compliance with EN14387 testing requirements and has been using the system for ongoing product qualification and compliance verification.</p>','category'=>'Products','sort_order'=>1,'is_active'=>1]);
        CaseStudy::create(['title'=>'ASTM D6646 Test System Development','slug'=>'astm-d6646-test-system','tab_label'=>'ASTM Case','summary'=>'Full development of an automated ASTM D6646 breakthrough test system for an industrial client.','full_content'=>'<h4>Project Overview</h4><p>A full development project to build an automated ASTM D6646 breakthrough test system. The project included mechanical design, control system development, data acquisition, and software interface.</p><h4>Outcome</h4><p>The client now runs automated ASTM D6646 tests with consistent results and significantly reduced manual intervention.</p>','category'=>'Products','sort_order'=>2,'is_active'=>1]);
        CaseStudy::create(['title'=>'Custom Engineering and Development Projects','slug'=>'custom-engineering-projects','tab_label'=>'Engineering Projects','summary'=>'Custom engineering programs including automation builds, product development support, and specialized technical programs.','full_content'=>'<h4>Overview</h4><p>This case study represents a selection of custom engineering programs delivered by MUVR Labs for industrial and technology clients.</p><h4>Engineering Approach</h4><p>In each case, we start with a thorough requirements review, produce a design proposal, and execute through to delivery and commissioning with full documentation.</p>','category'=>'Engineering','sort_order'=>3,'is_active'=>1]);

        // ── Resource Categories & Resources ──────────────────
        $catBrochures = ResourceCategory::create(['name'=>'Product Brochures','slug'=>'product-brochures','sort_order'=>1]);
        $catStandards = ResourceCategory::create(['name'=>'Standards & References','slug'=>'standards-references','sort_order'=>2]);
        $catVideos    = ResourceCategory::create(['name'=>'Videos & Media','slug'=>'videos-media','sort_order'=>3]);
        $catArticles  = ResourceCategory::create(['name'=>'Insights & Articles','slug'=>'insights-articles','sort_order'=>4]);

        Resource::create(['category_id'=>$catBrochures->id,'title'=>'AERONIX A100 Brochure','description'=>'Technical specifications, applications, and compliance details for the A100 gas phase test rig.','resource_type'=>'pdf','sort_order'=>1,'is_active'=>1]);
        Resource::create(['category_id'=>$catBrochures->id,'title'=>'ASTM D6646 Rig Brochure','description'=>'Full product documentation for the automated ASTM D6646 breakthrough test system.','resource_type'=>'pdf','sort_order'=>2,'is_active'=>1]);
        Resource::create(['category_id'=>$catBrochures->id,'title'=>'Company Profile','description'=>'Overview of MUVR Labs capabilities, portfolio, and engineering approach.','resource_type'=>'pdf','sort_order'=>3,'is_active'=>1]);
        Resource::create(['category_id'=>$catStandards->id,'title'=>'EN14387 Standard','description'=>'Respiratory protective devices — Gas filters and combined filters.','resource_type'=>'link','external_url'=>'https://www.en-standard.eu/','sort_order'=>1,'is_active'=>1]);
        Resource::create(['category_id'=>$catStandards->id,'title'=>'ASTM D6646','description'=>'Standard Test Method for Determination of the Accelerated Hydrogen Sulfide Breakthrough Capacity.','resource_type'=>'link','external_url'=>'https://www.astm.org/','sort_order'=>2,'is_active'=>1]);
        Resource::create(['category_id'=>$catVideos->id,'title'=>'AERONIX A100 Demo','description'=>'Product demonstration video for the AERONIX A100 gas phase test rig.','resource_type'=>'video','sort_order'=>1,'is_active'=>1]);
        Resource::create(['category_id'=>$catVideos->id,'title'=>'ASTM D6646 Rig Demo','description'=>'Product demonstration video for the ASTM D6646 automated test system.','resource_type'=>'video','sort_order'=>2,'is_active'=>1]);
        Resource::create(['category_id'=>$catArticles->id,'title'=>'Understanding EN14387 Gas Phase Filter Testing','description'=>'An overview of EN14387 gas phase filter testing requirements, methodology, and system considerations.','resource_type'=>'article','sort_order'=>1,'is_active'=>1]);
        Resource::create(['category_id'=>$catArticles->id,'title'=>'Breakthrough Testing and ASTM D6646 Explained','description'=>'A technical overview of breakthrough testing for activated carbon and the ASTM D6646 test method.','resource_type'=>'article','sort_order'=>2,'is_active'=>1]);

        // ── Process Steps ─────────────────────────────────────
        $steps = [
            [1,'Requirement Understanding','We start with your technical brief'],
            [2,'System Design','Engineering design and architecture'],
            [3,'Build & Integration','Fabrication and system assembly'],
            [4,'Testing & Validation','Performance verification and QA'],
            [5,'Deployment & Support','Commissioning and ongoing support'],
        ];
        foreach ($steps as $i => [$num, $title, $desc]) {
            ProcessStep::create(['step_number'=>$num,'title'=>$title,'description'=>$desc,'sort_order'=>$i,'is_active'=>1]);
        }

        // ── Why Us Points ─────────────────────────────────────
        $points = [
            ['Focused Engineering Expertise','Deep domain knowledge in test systems, automation, and precision instrumentation.'],
            ['Product + Project Capability','We deliver both off-the-shelf compliant products and fully custom engineering programs.'],
            ['Built for Real Applications','Every system is designed and validated for real-world performance, not just lab conditions.'],
            ['From Design to Commissioning','End-to-end support from requirement definition through installation and support.'],
        ];
        foreach ($points as $i => [$heading, $description]) {
            WhyUsPoint::create(['heading'=>$heading,'description'=>$description,'sort_order'=>$i,'is_active'=>1]);
        }

        // ── About Sections ────────────────────────────────────
        AboutSection::create(['section_key'=>'overview','heading'=>'Company Overview','subheading'=>'About MUVR Labs','content'=>'MUVR Labs is an engineering company focused on building automated test systems, standards-compliant rigs, and custom engineering solutions for industrial, research, and advanced technology applications. We combine rigorous engineering methodology with practical system-building capability to deliver products and projects that perform reliably in real-world environments.','sort_order'=>1]);
        AboutSection::create(['section_key'=>'mission','heading'=>'Mission','subheading'=>'Engineering that performs','content'=>'To build automated test systems and engineering solutions that meet real technical demands — designed for precision, reliability, and compliance from concept to commissioning.','sort_order'=>2]);
        AboutSection::create(['section_key'=>'vision','heading'=>'Vision','subheading'=>'A trusted engineering partner','content'=>'To be the go-to engineering development partner for organizations needing standards-compliant testing systems and technically complex product development support.','sort_order'=>3]);

        // ── Jobs ──────────────────────────────────────────────
        Job::create(['title'=>'Mechanical Design Engineer','department'=>'Engineering','location'=>'On-site','job_type'=>'Full-time','description'=>'Design and develop mechanical components and assemblies for test rigs and automation systems.','requirements'=>'Degree in Mechanical Engineering. Proficiency in SolidWorks or similar CAD tools.','sort_order'=>1,'is_active'=>1]);
        Job::create(['title'=>'Controls & Automation Engineer','department'=>'Engineering','location'=>'On-site','job_type'=>'Full-time','description'=>'Develop PLC-based control systems, instrumentation integration, and HMI software.','requirements'=>'Degree in Electrical/Electronic/Controls Engineering. Experience with PLC programming.','sort_order'=>2,'is_active'=>1]);
    }
}
