<?php
declare(strict_types=1);

namespace ROITheme\Admin\CtaPost\Infrastructure\FieldMapping;

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

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

    public function getFieldMapping(): array
    {
        return [
            // Visibility
            'ctaPostEnabled' => ['group' => 'visibility', 'attribute' => 'is_enabled'],
            'ctaPostShowOnDesktop' => ['group' => 'visibility', 'attribute' => 'show_on_desktop'],
            'ctaPostShowOnMobile' => ['group' => 'visibility', 'attribute' => 'show_on_mobile'],
            'ctaPostHideForLoggedIn' => ['group' => 'visibility', 'attribute' => 'hide_for_logged_in'],

            // Page Visibility (grupo especial _page_visibility)
            'ctaPostVisibilityHome' => ['group' => '_page_visibility', 'attribute' => 'show_on_home'],
            'ctaPostVisibilityPosts' => ['group' => '_page_visibility', 'attribute' => 'show_on_posts'],
            'ctaPostVisibilityPages' => ['group' => '_page_visibility', 'attribute' => 'show_on_pages'],
            'ctaPostVisibilityArchives' => ['group' => '_page_visibility', 'attribute' => 'show_on_archives'],
            'ctaPostVisibilitySearch' => ['group' => '_page_visibility', 'attribute' => 'show_on_search'],

            // Exclusions (grupo especial _exclusions - Plan 99.11)
            'ctaPostExclusionsEnabled' => ['group' => '_exclusions', 'attribute' => 'exclusions_enabled'],
            'ctaPostExcludeCategories' => ['group' => '_exclusions', 'attribute' => 'exclude_categories', 'type' => 'json_array'],
            'ctaPostExcludePostIds' => ['group' => '_exclusions', 'attribute' => 'exclude_post_ids', 'type' => 'json_array_int'],
            'ctaPostExcludeUrlPatterns' => ['group' => '_exclusions', 'attribute' => 'exclude_url_patterns', 'type' => 'json_array_lines'],

            // Content
            'ctaPostTitle' => ['group' => 'content', 'attribute' => 'title'],
            'ctaPostDescription' => ['group' => 'content', 'attribute' => 'description'],
            'ctaPostButtonText' => ['group' => 'content', 'attribute' => 'button_text'],
            'ctaPostButtonUrl' => ['group' => 'content', 'attribute' => 'button_url'],
            'ctaPostButtonIcon' => ['group' => 'content', 'attribute' => 'button_icon'],

            // Typography
            'ctaPostTitleFontSize' => ['group' => 'typography', 'attribute' => 'title_font_size'],
            'ctaPostTitleFontWeight' => ['group' => 'typography', 'attribute' => 'title_font_weight'],
            'ctaPostDescriptionFontSize' => ['group' => 'typography', 'attribute' => 'description_font_size'],
            'ctaPostButtonFontSize' => ['group' => 'typography', 'attribute' => 'button_font_size'],

            // Colors
            'ctaPostGradientStart' => ['group' => 'colors', 'attribute' => 'gradient_start'],
            'ctaPostGradientEnd' => ['group' => 'colors', 'attribute' => 'gradient_end'],
            'ctaPostTitleColor' => ['group' => 'colors', 'attribute' => 'title_color'],
            'ctaPostDescriptionColor' => ['group' => 'colors', 'attribute' => 'description_color'],
            'ctaPostButtonBgColor' => ['group' => 'colors', 'attribute' => 'button_bg_color'],
            'ctaPostButtonTextColor' => ['group' => 'colors', 'attribute' => 'button_text_color'],
            'ctaPostButtonHoverBg' => ['group' => 'colors', 'attribute' => 'button_hover_bg'],

            // Spacing
            'ctaPostContainerMarginTop' => ['group' => 'spacing', 'attribute' => 'container_margin_top'],
            'ctaPostContainerMarginBottom' => ['group' => 'spacing', 'attribute' => 'container_margin_bottom'],
            'ctaPostContainerPadding' => ['group' => 'spacing', 'attribute' => 'container_padding'],
            'ctaPostTitleMarginBottom' => ['group' => 'spacing', 'attribute' => 'title_margin_bottom'],
            'ctaPostButtonIconMargin' => ['group' => 'spacing', 'attribute' => 'button_icon_margin'],

            // Visual Effects
            'ctaPostBorderRadius' => ['group' => 'visual_effects', 'attribute' => 'border_radius'],
            'ctaPostGradientAngle' => ['group' => 'visual_effects', 'attribute' => 'gradient_angle'],
            'ctaPostButtonBorderRadius' => ['group' => 'visual_effects', 'attribute' => 'button_border_radius'],
            'ctaPostButtonPadding' => ['group' => 'visual_effects', 'attribute' => 'button_padding'],
            'ctaPostTransitionDuration' => ['group' => 'visual_effects', 'attribute' => 'transition_duration'],
            'ctaPostBoxShadow' => ['group' => 'visual_effects', 'attribute' => 'box_shadow'],
        ];
    }
}
