<?php
declare(strict_types=1);

namespace ROITheme\Admin\CtaBoxSidebar\Infrastructure\FieldMapping;

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

/**
 * Field Mapper para CTA Box Sidebar
 *
 * RESPONSABILIDAD:
 * - Mapear field IDs del formulario a atributos de BD
 * - Solo conoce sus propios campos (modularidad)
 *
 * UBICACION:
 * - Dentro del modulo CtaBoxSidebar (autocontenido)
 * - Eliminar modulo = eliminar mapper
 */
final class CtaBoxSidebarFieldMapper implements FieldMapperInterface
{
    public function getComponentName(): string
    {
        return 'cta-box-sidebar';
    }

    public function getFieldMapping(): array
    {
        return [
            // Visibility
            'ctaEnabled' => ['group' => 'visibility', 'attribute' => 'is_enabled'],
            'ctaShowOnDesktop' => ['group' => 'visibility', 'attribute' => 'show_on_desktop'],
            'ctaShowOnMobile' => ['group' => 'visibility', 'attribute' => 'show_on_mobile'],
            'ctaHideForLoggedIn' => ['group' => 'visibility', 'attribute' => 'hide_for_logged_in'],

            // Page Visibility (grupo especial _page_visibility)
            'ctaVisibilityHome' => ['group' => '_page_visibility', 'attribute' => 'show_on_home'],
            'ctaVisibilityPosts' => ['group' => '_page_visibility', 'attribute' => 'show_on_posts'],
            'ctaVisibilityPages' => ['group' => '_page_visibility', 'attribute' => 'show_on_pages'],
            'ctaVisibilityArchives' => ['group' => '_page_visibility', 'attribute' => 'show_on_archives'],
            'ctaVisibilitySearch' => ['group' => '_page_visibility', 'attribute' => 'show_on_search'],

            // Exclusions (grupo especial _exclusions - Plan 99.11)
            'ctaExclusionsEnabled' => ['group' => '_exclusions', 'attribute' => 'exclusions_enabled'],
            'ctaExcludeCategories' => ['group' => '_exclusions', 'attribute' => 'exclude_categories', 'type' => 'json_array'],
            'ctaExcludePostIds' => ['group' => '_exclusions', 'attribute' => 'exclude_post_ids', 'type' => 'json_array_int'],
            'ctaExcludeUrlPatterns' => ['group' => '_exclusions', 'attribute' => 'exclude_url_patterns', 'type' => 'json_array_lines'],

            // Content
            'ctaTitle' => ['group' => 'content', 'attribute' => 'title'],
            'ctaDescription' => ['group' => 'content', 'attribute' => 'description'],
            'ctaButtonText' => ['group' => 'content', 'attribute' => 'button_text'],
            'ctaButtonIcon' => ['group' => 'content', 'attribute' => 'button_icon'],
            'ctaButtonAction' => ['group' => 'content', 'attribute' => 'button_action'],
            'ctaButtonLink' => ['group' => 'content', 'attribute' => 'button_link'],

            // Behavior
            'ctaTextAlign' => ['group' => 'behavior', 'attribute' => 'text_align'],

            // Typography
            'ctaTitleFontSize' => ['group' => 'typography', 'attribute' => 'title_font_size'],
            'ctaTitleFontWeight' => ['group' => 'typography', 'attribute' => 'title_font_weight'],
            'ctaDescFontSize' => ['group' => 'typography', 'attribute' => 'description_font_size'],
            'ctaButtonFontSize' => ['group' => 'typography', 'attribute' => 'button_font_size'],
            'ctaButtonFontWeight' => ['group' => 'typography', 'attribute' => 'button_font_weight'],

            // Colors
            'ctaBackgroundColor' => ['group' => 'colors', 'attribute' => 'background_color'],
            'ctaTitleColor' => ['group' => 'colors', 'attribute' => 'title_color'],
            'ctaDescriptionColor' => ['group' => 'colors', 'attribute' => 'description_color'],
            'ctaButtonBgColor' => ['group' => 'colors', 'attribute' => 'button_background_color'],
            'ctaButtonTextColor' => ['group' => 'colors', 'attribute' => 'button_text_color'],
            'ctaButtonHoverBg' => ['group' => 'colors', 'attribute' => 'button_hover_background'],
            'ctaButtonHoverText' => ['group' => 'colors', 'attribute' => 'button_hover_text_color'],

            // Spacing
            'ctaContainerPadding' => ['group' => 'spacing', 'attribute' => 'container_padding'],
            'ctaTitleMarginBottom' => ['group' => 'spacing', 'attribute' => 'title_margin_bottom'],
            'ctaDescMarginBottom' => ['group' => 'spacing', 'attribute' => 'description_margin_bottom'],
            'ctaButtonPadding' => ['group' => 'spacing', 'attribute' => 'button_padding'],
            'ctaIconMarginRight' => ['group' => 'spacing', 'attribute' => 'icon_margin_right'],

            // Visual Effects
            'ctaBorderRadius' => ['group' => 'visual_effects', 'attribute' => 'border_radius'],
            'ctaButtonBorderRadius' => ['group' => 'visual_effects', 'attribute' => 'button_border_radius'],
            'ctaBoxShadow' => ['group' => 'visual_effects', 'attribute' => 'box_shadow'],
            'ctaTransitionDuration' => ['group' => 'visual_effects', 'attribute' => 'transition_duration'],
        ];
    }
}
