<?php
declare(strict_types=1);

namespace ROITheme\Admin\TableOfContents\Infrastructure\FieldMapping;

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

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

    public function getFieldMapping(): array
    {
        return [
            // Visibility
            'tocEnabled' => ['group' => 'visibility', 'attribute' => 'is_enabled'],
            'tocShowOnDesktop' => ['group' => 'visibility', 'attribute' => 'show_on_desktop'],
            'tocShowOnMobile' => ['group' => 'visibility', 'attribute' => 'show_on_mobile'],

            // Page Visibility (grupo especial _page_visibility)
            'tocVisibilityHome' => ['group' => '_page_visibility', 'attribute' => 'show_on_home'],
            'tocVisibilityPosts' => ['group' => '_page_visibility', 'attribute' => 'show_on_posts'],
            'tocVisibilityPages' => ['group' => '_page_visibility', 'attribute' => 'show_on_pages'],
            'tocVisibilityArchives' => ['group' => '_page_visibility', 'attribute' => 'show_on_archives'],
            'tocVisibilitySearch' => ['group' => '_page_visibility', 'attribute' => 'show_on_search'],

            // Exclusions (grupo especial _exclusions - Plan 99.11)
            'tocExclusionsEnabled' => ['group' => '_exclusions', 'attribute' => 'exclusions_enabled'],
            'tocExcludeCategories' => ['group' => '_exclusions', 'attribute' => 'exclude_categories', 'type' => 'json_array'],
            'tocExcludePostIds' => ['group' => '_exclusions', 'attribute' => 'exclude_post_ids', 'type' => 'json_array_int'],
            'tocExcludeUrlPatterns' => ['group' => '_exclusions', 'attribute' => 'exclude_url_patterns', 'type' => 'json_array_lines'],

            // Content
            'tocTitle' => ['group' => 'content', 'attribute' => 'title'],
            'tocAutoGenerate' => ['group' => 'content', 'attribute' => 'auto_generate'],
            'tocHeadingLevels' => ['group' => 'content', 'attribute' => 'heading_levels'],
            'tocSmoothScroll' => ['group' => 'content', 'attribute' => 'smooth_scroll'],

            // Typography
            'tocTitleFontSize' => ['group' => 'typography', 'attribute' => 'title_font_size'],
            'tocTitleFontWeight' => ['group' => 'typography', 'attribute' => 'title_font_weight'],
            'tocLinkFontSize' => ['group' => 'typography', 'attribute' => 'link_font_size'],
            'tocLinkLineHeight' => ['group' => 'typography', 'attribute' => 'link_line_height'],
            'tocLevelThreeFontSize' => ['group' => 'typography', 'attribute' => 'level_three_font_size'],
            'tocLevelFourFontSize' => ['group' => 'typography', 'attribute' => 'level_four_font_size'],

            // Colors
            'tocBackgroundColor' => ['group' => 'colors', 'attribute' => 'background_color'],
            'tocBorderColor' => ['group' => 'colors', 'attribute' => 'border_color'],
            'tocTitleColor' => ['group' => 'colors', 'attribute' => 'title_color'],
            'tocTitleBorderColor' => ['group' => 'colors', 'attribute' => 'title_border_color'],
            'tocLinkColor' => ['group' => 'colors', 'attribute' => 'link_color'],
            'tocLinkHoverColor' => ['group' => 'colors', 'attribute' => 'link_hover_color'],
            'tocLinkHoverBackground' => ['group' => 'colors', 'attribute' => 'link_hover_background'],
            'tocActiveBorderColor' => ['group' => 'colors', 'attribute' => 'active_border_color'],
            'tocActiveBackgroundColor' => ['group' => 'colors', 'attribute' => 'active_background_color'],
            'tocActiveTextColor' => ['group' => 'colors', 'attribute' => 'active_text_color'],
            'tocScrollbarTrackColor' => ['group' => 'colors', 'attribute' => 'scrollbar_track_color'],
            'tocScrollbarThumbColor' => ['group' => 'colors', 'attribute' => 'scrollbar_thumb_color'],

            // Spacing
            'tocContainerPadding' => ['group' => 'spacing', 'attribute' => 'container_padding'],
            'tocMarginBottom' => ['group' => 'spacing', 'attribute' => 'margin_bottom'],
            'tocTitlePaddingBottom' => ['group' => 'spacing', 'attribute' => 'title_padding_bottom'],
            'tocTitleMarginBottom' => ['group' => 'spacing', 'attribute' => 'title_margin_bottom'],
            'tocItemMarginBottom' => ['group' => 'spacing', 'attribute' => 'item_margin_bottom'],
            'tocLinkPadding' => ['group' => 'spacing', 'attribute' => 'link_padding'],
            'tocLevelThreePaddingLeft' => ['group' => 'spacing', 'attribute' => 'level_three_padding_left'],
            'tocLevelFourPaddingLeft' => ['group' => 'spacing', 'attribute' => 'level_four_padding_left'],
            'tocScrollbarWidth' => ['group' => 'spacing', 'attribute' => 'scrollbar_width'],

            // Visual Effects
            'tocBorderRadius' => ['group' => 'visual_effects', 'attribute' => 'border_radius'],
            'tocBoxShadow' => ['group' => 'visual_effects', 'attribute' => 'box_shadow'],
            'tocBorderWidth' => ['group' => 'visual_effects', 'attribute' => 'border_width'],
            'tocLinkBorderRadius' => ['group' => 'visual_effects', 'attribute' => 'link_border_radius'],
            'tocActiveBorderLeftWidth' => ['group' => 'visual_effects', 'attribute' => 'active_border_left_width'],
            'tocTransitionDuration' => ['group' => 'visual_effects', 'attribute' => 'transition_duration'],
            'tocScrollbarBorderRadius' => ['group' => 'visual_effects', 'attribute' => 'scrollbar_border_radius'],

            // Behavior
            'tocIsSticky' => ['group' => 'behavior', 'attribute' => 'is_sticky'],
            'tocScrollOffset' => ['group' => 'behavior', 'attribute' => 'scroll_offset'],
            'tocMaxHeight' => ['group' => 'behavior', 'attribute' => 'max_height'],
        ];
    }
}
