<?php
/**
 * Taxonomy Header Widget — TAB_CONTENT controls
 * Included via bare require inside register_controls().
 * $this refers to the widget instance.
 */

if (!defined('ABSPATH')) {
    exit;
}

// ===== CONTENT SECTION =====
$this->start_controls_section(
    'content_section',
    [
        'label' => __('Content', 'ggm-commerce'),
        'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
    ]
);

$this->add_control(
    'taxonomy_type',
    [
        'label' => __('Taxonomy Type', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SELECT,
        'default' => 'auto',
        'options' => [
            'auto' => __('Auto-detect from URL', 'ggm-commerce'),
            'category' => __('Category', 'ggm-commerce'),
            'tag' => __('Tag', 'ggm-commerce'),
        ],
    ]
);

$this->add_control(
    'show_image',
    [
        'label' => __('Show Image', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SWITCHER,
        'label_on' => __('Yes', 'ggm-commerce'),
        'label_off' => __('No', 'ggm-commerce'),
        'return_value' => 'yes',
        'default' => 'yes',
        'description' => __('Only available for categories with uploaded images', 'ggm-commerce'),
    ]
);

$this->add_control(
    'show_title',
    [
        'label' => __('Show Title', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SWITCHER,
        'label_on' => __('Yes', 'ggm-commerce'),
        'label_off' => __('No', 'ggm-commerce'),
        'return_value' => 'yes',
        'default' => 'yes',
    ]
);

$this->add_control(
    'title_prefix',
    [
        'label' => __('Title Prefix', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => '',
        'placeholder' => __('e.g., "Category: " or "Browse "', 'ggm-commerce'),
        'condition' => [
            'show_title' => 'yes',
        ],
    ]
);

$this->add_control(
    'title_tag',
    [
        'label' => __('Title HTML Tag', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SELECT,
        'default' => 'h1',
        'options' => [
            'h1' => 'H1',
            'h2' => 'H2',
            'h3' => 'H3',
            'h4' => 'H4',
            'h5' => 'H5',
            'h6' => 'H6',
            'div' => 'div',
            'span' => 'span',
            'p' => 'p',
        ],
        'condition' => [
            'show_title' => 'yes',
        ],
    ]
);

$this->add_control(
    'show_description',
    [
        'label' => __('Show Description', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SWITCHER,
        'label_on' => __('Yes', 'ggm-commerce'),
        'label_off' => __('No', 'ggm-commerce'),
        'return_value' => 'yes',
        'default' => 'yes',
    ]
);

$this->add_control(
    'show_product_count',
    [
        'label' => __('Show Product Count', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SWITCHER,
        'label_on' => __('Yes', 'ggm-commerce'),
        'label_off' => __('No', 'ggm-commerce'),
        'return_value' => 'yes',
        'default' => 'yes',
    ]
);

$this->add_control(
    'product_count_format',
    [
        'label' => __('Product Count Format', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => '{count} products',
        'description' => __('Use {count} as placeholder for the number', 'ggm-commerce'),
        'condition' => [
            'show_product_count' => 'yes',
        ],
    ]
);

$this->add_responsive_control(
    'alignment',
    [
        'label' => __('Alignment', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::CHOOSE,
        'options' => [
            'left' => [
                'title' => __('Left', 'ggm-commerce'),
                'icon' => 'eicon-text-align-left',
            ],
            'center' => [
                'title' => __('Center', 'ggm-commerce'),
                'icon' => 'eicon-text-align-center',
            ],
            'right' => [
                'title' => __('Right', 'ggm-commerce'),
                'icon' => 'eicon-text-align-right',
            ],
        ],
        'default' => 'center',
        'selectors' => [
            '{{WRAPPER}} .ggmc-taxonomy-header' => 'text-align: {{VALUE}};',
        ],
    ]
);

$this->end_controls_section();
