<?php
declare(strict_types=1);

namespace ROITheme\Admin\Footer\Infrastructure\FieldMapping;

use ROITheme\Admin\Shared\Domain\Contracts\FieldMapperInterface;

/**
 * Field Mapper para Footer
 *
 * RESPONSABILIDAD:
 * - Mapear field IDs del formulario a atributos de BD
 * - Solo conoce sus propios campos (modularidad)
 */
final class FooterFieldMapper implements FieldMapperInterface
{
    public function getComponentName(): string
    {
        return 'footer';
    }

    public function getFieldMapping(): array
    {
        return [
            // Visibility
            'footerEnabled' => ['group' => 'visibility', 'attribute' => 'is_enabled'],
            'footerShowOnDesktop' => ['group' => 'visibility', 'attribute' => 'show_on_desktop'],
            'footerShowOnMobile' => ['group' => 'visibility', 'attribute' => 'show_on_mobile'],

            // Page Visibility (grupo especial _page_visibility)
            'footerVisibilityHome' => ['group' => '_page_visibility', 'attribute' => 'show_on_home'],
            'footerVisibilityPosts' => ['group' => '_page_visibility', 'attribute' => 'show_on_posts'],
            'footerVisibilityPages' => ['group' => '_page_visibility', 'attribute' => 'show_on_pages'],
            'footerVisibilityArchives' => ['group' => '_page_visibility', 'attribute' => 'show_on_archives'],
            'footerVisibilitySearch' => ['group' => '_page_visibility', 'attribute' => 'show_on_search'],

            // Exclusions (grupo especial _exclusions - Plan 99.11)
            'footerExclusionsEnabled' => ['group' => '_exclusions', 'attribute' => 'exclusions_enabled'],
            'footerExcludeCategories' => ['group' => '_exclusions', 'attribute' => 'exclude_categories', 'type' => 'json_array'],
            'footerExcludePostIds' => ['group' => '_exclusions', 'attribute' => 'exclude_post_ids', 'type' => 'json_array_int'],
            'footerExcludeUrlPatterns' => ['group' => '_exclusions', 'attribute' => 'exclude_url_patterns', 'type' => 'json_array_lines'],

            // Widget 1
            'footerWidget1Visible' => ['group' => 'widget_1', 'attribute' => 'widget_1_visible'],
            'footerWidget1Title' => ['group' => 'widget_1', 'attribute' => 'widget_1_title'],

            // Widget 2
            'footerWidget2Visible' => ['group' => 'widget_2', 'attribute' => 'widget_2_visible'],
            'footerWidget2Title' => ['group' => 'widget_2', 'attribute' => 'widget_2_title'],

            // Widget 3
            'footerWidget3Visible' => ['group' => 'widget_3', 'attribute' => 'widget_3_visible'],
            'footerWidget3Title' => ['group' => 'widget_3', 'attribute' => 'widget_3_title'],

            // Newsletter
            'footerNewsletterVisible' => ['group' => 'newsletter', 'attribute' => 'newsletter_visible'],
            'footerNewsletterTitle' => ['group' => 'newsletter', 'attribute' => 'newsletter_title'],
            'footerNewsletterDescription' => ['group' => 'newsletter', 'attribute' => 'newsletter_description'],
            'footerNewsletterPlaceholder' => ['group' => 'newsletter', 'attribute' => 'newsletter_email_placeholder'],
            'footerNewsletterButtonText' => ['group' => 'newsletter', 'attribute' => 'newsletter_button_text'],
            'footerNewsletterWebhookUrl' => ['group' => 'newsletter', 'attribute' => 'newsletter_webhook_url'],
            'footerNewsletterSuccessMessage' => ['group' => 'newsletter', 'attribute' => 'newsletter_success_message'],
            'footerNewsletterErrorMessage' => ['group' => 'newsletter', 'attribute' => 'newsletter_error_message'],

            // Footer Bottom
            'footerCopyrightText' => ['group' => 'footer_bottom', 'attribute' => 'copyright_text'],

            // Colors
            'footerBgColor' => ['group' => 'colors', 'attribute' => 'bg_color'],
            'footerTextColor' => ['group' => 'colors', 'attribute' => 'text_color'],
            'footerTitleColor' => ['group' => 'colors', 'attribute' => 'title_color'],
            'footerLinkColor' => ['group' => 'colors', 'attribute' => 'link_color'],
            'footerLinkHoverColor' => ['group' => 'colors', 'attribute' => 'link_hover_color'],
            'footerButtonBgColor' => ['group' => 'colors', 'attribute' => 'button_bg_color'],
            'footerButtonTextColor' => ['group' => 'colors', 'attribute' => 'button_text_color'],
            'footerButtonHoverBg' => ['group' => 'colors', 'attribute' => 'button_hover_bg'],

            // Spacing
            'footerPaddingY' => ['group' => 'spacing', 'attribute' => 'padding_y'],
            'footerMarginTop' => ['group' => 'spacing', 'attribute' => 'margin_top'],

            // Visual Effects
            'footerInputBorderRadius' => ['group' => 'visual_effects', 'attribute' => 'input_border_radius'],
            'footerButtonBorderRadius' => ['group' => 'visual_effects', 'attribute' => 'button_border_radius'],
            'footerTransitionDuration' => ['group' => 'visual_effects', 'attribute' => 'transition_duration'],
        ];
    }
}
