<?php

namespace App\Http\Controllers;

class PageController extends Controller
{
    private array $seoData = [
        'home' => [
            'title'          => 'Nexatech — Innovative Technology & Digital Solutions',
            'description'    => 'Nexatech delivers innovative technology solutions including web development, digital transformation, and creative design services to help businesses grow and succeed online.',
            'keywords'       => 'Nexatech, technology solutions, digital services, web development company, software development, IT services, digital transformation',
            'og_title'       => 'Nexatech | Innovative Technology & Digital Solutions',
            'og_description' => 'Discover Nexatech\'s cutting-edge technology services including web development, digital strategy, and business solutions designed to accelerate your digital growth.',
            'og_image'       => 'images/og-home.png',
        ],
        'about' => [
            'title'          => 'About Nexatech — Technology Experts & Digital Innovators',
            'description'    => 'Learn about Nexatech, a technology-driven company providing innovative IT services, digital solutions, and creative strategies to empower modern businesses.',
            'keywords'       => 'about Nexatech, Nexatech company, technology experts, IT solutions company, digital innovation company',
            'og_title'       => 'About Nexatech | Technology Experts & Digital Innovators',
            'og_description' => 'Get to know Nexatech\'s mission, expertise, and commitment to delivering innovative technology solutions for businesses worldwide.',
            'og_image'       => 'images/og-about.png',
            'breadcrumb'     => 'About',
        ],
        'services' => [
            'title'          => 'Nexatech Services — Web, Software & Digital Solutions',
            'description'    => 'Explore Nexatech services including web development, software solutions, digital transformation, UI/UX design, and technology consulting for modern businesses.',
            'keywords'       => 'Nexatech services, web development services, software development, IT consulting, digital solutions',
            'og_title'       => 'Nexatech Services | Web Development & Technology Solutions',
            'og_description' => 'Discover Nexatech\'s professional services including web development, custom software, UI/UX design, and digital solutions tailored for business growth.',
            'og_image'       => 'images/og-services.png',
            'breadcrumb'     => 'Services',
        ],
        'portfolio' => [
            'title'          => 'Nexatech Portfolio — Our Projects & Digital Solutions',
            'description'    => 'Explore Nexatech\'s portfolio showcasing innovative web development, software solutions, and digital projects delivered for clients across industries.',
            'keywords'       => 'Nexatech portfolio, Nexatech projects, web development portfolio, software projects',
            'og_title'       => 'Nexatech Portfolio | Innovative Digital Projects',
            'og_description' => 'Browse Nexatech\'s portfolio featuring successful web development, digital transformation, and technology solutions delivered for global clients.',
            'og_image'       => 'images/og-img.jpg',
            'breadcrumb'     => 'Portfolio',
        ],
        'insights' => [
            'title'          => 'Insights — Nexatech',
            'description'    => 'Engineering perspectives, product thinking, and industry observations from the Nexatech team.',
            'keywords'       => 'Nexatech insights, technology blog, software engineering articles, product development',
            'og_title'       => 'Nexatech Insights | Technology & Engineering Blog',
            'og_description' => 'Read engineering perspectives, product thinking, and industry observations from the Nexatech team.',
            'og_image'       => 'images/og-img.jpg',
            'breadcrumb'     => 'Insights',
        ],
        'insight-detail' => [
            'title'          => 'Why Most SaaS Architectures Fail at Scale — Nexatech Insights',
            'description'    => 'After rebuilding three production SaaS platforms, we identified the same five architectural decisions that seem reasonable at launch and catastrophic at 10x scale.',
            'keywords'       => 'SaaS architecture, scalability, backend engineering, software architecture',
            'og_title'       => 'Why Most SaaS Architectures Fail at Scale | Nexatech',
            'og_description' => 'The five architectural decisions that seem reasonable at launch and catastrophic at 10x scale — and what to do about it.',
            'og_image'       => 'images/og-img.jpg',
            'breadcrumb'     => 'Insights',
        ],
        'privacy-policy' => [
            'title'          => 'Privacy Policy — Nexatech',
            'description'    => 'Read Nexatech\'s privacy policy to understand how we collect, use, and protect your personal information.',
            'keywords'       => 'Nexatech privacy policy, data protection, privacy',
            'og_title'       => 'Privacy Policy | Nexatech',
            'og_description' => 'Nexatech\'s privacy policy — how we collect, use, and safeguard your information.',
            'breadcrumb'     => 'Privacy Policy',
        ],
    ];

    private function seo(string $page): array
    {
        $seo = $this->seoData[$page] ?? [];
        $seo['canonical'] = url()->current();
        if (isset($seo['og_image'])) {
            $seo['og_image'] = asset($seo['og_image']);
        }
        return $seo;
    }

    public function home()
    {
        return view('pages.home', ['seo' => $this->seo('home')]);
    }

    public function about()
    {
        return view('pages.about', ['seo' => $this->seo('about')]);
    }

    public function services()
    {
        return view('pages.services', ['seo' => $this->seo('services')]);
    }

    public function portfolio()
    {
        return view('pages.portfolio', ['seo' => $this->seo('portfolio')]);
    }

    public function insights()
    {
        return view('pages.insights', ['seo' => $this->seo('insights')]);
    }

    public function insightDetail(string $slug)
    {
        return view('pages.insight-detail', [
            'slug' => $slug,
            'seo'  => $this->seo('insight-detail'),
        ]);
    }

    public function privacyPolicy()
    {
        return view('pages.privacy-policy', ['seo' => $this->seo('privacy-policy')]);
    }
}
