<?php

declare(strict_types=1);

final class MyronFooterVariantCompositionService
{
    /**
     * @return array<string, string>
     */
    public function variantLabels(): array
    {
        return [
            'footer.standard' => 'Standard',
            'footer.portfolio' => 'Portfolio',
            'footer.editorial' => 'Editorial',
            'footer.mega' => 'Mega',
            'footer.ecom' => 'E-commerce',
            'footer.local-business' => 'Local Business',
            'footer.conversion' => 'Conversion',
            'footer.creator' => 'Creator',
            'footer.campaign' => 'Campaign / Funnel',
            'footer.checkout' => 'Checkout',
        ];
    }

    /**
     * @return array<string, string>
     */
    public function zoneLabels(): array
    {
        return [
            'zone.brand' => 'Brand',
            'zone.nav-col' => 'Navigation Column',
            'zone.cta-band' => 'Pre-Footer CTA Band',
            'zone.newsletter' => 'Newsletter Signup',
            'zone.social' => 'Social Links',
            'zone.legal-strip' => 'Legal Strip',
            'zone.trust-signals' => 'Trust Signals',
            'zone.nap-hours' => 'NAP + Hours',
            'zone.disclaimer' => 'Disclaimer',
            'zone.payment-logos' => 'Payment Logos',
            'zone.app-badges' => 'App Store Badges',
            'zone.availability-status' => 'Availability Status',
            'zone.provider-cta' => 'Provider CTA',
        ];
    }

    /**
     * @return array<string, list<string>>
     */
    public function variantZones(): array
    {
        return [
            'footer.standard' => ['zone.brand', 'zone.nav-col', 'zone.newsletter', 'zone.social', 'zone.trust-signals', 'zone.legal-strip'],
            'footer.portfolio' => ['zone.brand', 'zone.availability-status', 'zone.nav-col', 'zone.social', 'zone.legal-strip'],
            'footer.editorial' => ['zone.brand', 'zone.newsletter', 'zone.nav-col', 'zone.social', 'zone.legal-strip'],
            'footer.mega' => ['zone.cta-band', 'zone.brand', 'zone.nav-col', 'zone.newsletter', 'zone.social', 'zone.app-badges', 'zone.trust-signals', 'zone.legal-strip'],
            'footer.ecom' => ['zone.brand', 'zone.nav-col', 'zone.newsletter', 'zone.social', 'zone.payment-logos', 'zone.trust-signals', 'zone.legal-strip'],
            'footer.local-business' => ['zone.brand', 'zone.nap-hours', 'zone.cta-band', 'zone.nav-col', 'zone.social', 'zone.trust-signals', 'zone.provider-cta', 'zone.legal-strip'],
            'footer.conversion' => ['zone.cta-band', 'zone.nav-col', 'zone.social', 'zone.legal-strip'],
            'footer.creator' => ['zone.brand', 'zone.newsletter', 'zone.nav-col', 'zone.social', 'zone.disclaimer', 'zone.legal-strip'],
            'footer.campaign' => ['zone.disclaimer', 'zone.legal-strip'],
            'footer.checkout' => ['zone.trust-signals', 'zone.legal-strip'],
        ];
    }

    /**
     * @return list<string>
     */
    public function orderedZonesFor(string $variant): array
    {
        $map = $this->variantZones();
        return $map[trim($variant)] ?? [];
    }

    public function columnCountFor(string $variant): int
    {
        return max(1, min(4, count($this->orderedZonesFor($variant))));
    }

    public function labelForVariant(string $variant): string
    {
        $labels = $this->variantLabels();
        return $labels[trim($variant)] ?? trim($variant);
    }

    public function labelForZone(string $zoneId): string
    {
        $labels = $this->zoneLabels();
        return $labels[trim($zoneId)] ?? trim($zoneId);
    }

    public function recommendedVariantForSiteType(?array $siteType): string
    {
        if (!is_array($siteType)) {
            return 'footer.standard';
        }

        $variant = trim((string) ($siteType['footerVariant'] ?? ''));
        return $variant !== '' ? $variant : 'footer.standard';
    }
}
