<?php
/**
 * Product Name 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(
    'product_source',
    [
        'label' => __('Product Source', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SELECT,
        'default' => 'current',
        'options' => [
            'current' => __('Current Product (Auto-detect)', 'ggm-commerce'),
            'custom' => __('Select Product', 'ggm-commerce'),
        ],
    ]
);

$this->add_control(
    'product_id',
    [
        'label' => __('Product', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::NUMBER,
        'default' => '',
        'condition' => [
            'product_source' => 'custom',
        ],
        'description' => __('Start typing product name to search', 'ggm-commerce'),
    ]
);

$this->add_control(
    'html_tag',
    [
        'label' => __('HTML Tag', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SELECT,
        'options' => [
            'h1' => 'H1',
            'h2' => 'H2',
            'h3' => 'H3',
            'h4' => 'H4',
            'h5' => 'H5',
            'h6' => 'H6',
            'div' => 'div',
            'span' => 'span',
            'p' => 'p'
        ],
        'default' => 'h2',
        'description' => __('Choose the HTML tag for the product name', 'ggm-commerce'),
    ]
);

$this->add_control(
    'enable_link',
    [
        'label' => __('Enable Link', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SWITCHER,
        'label_on' => __('Yes', 'ggm-commerce'),
        'label_off' => __('No', 'ggm-commerce'),
        'return_value' => 'yes',
        'default' => '',
        'description' => __('Make the product name clickable', 'ggm-commerce'),
    ]
);

$this->add_control(
    'link',
    [
        'label' => __('Link', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::URL,
        'placeholder' => __('https://your-link.com', 'ggm-commerce'),
        'dynamic' => [
            'active' => true,
        ],
        'default' => [
            'url' => '',
            'is_external' => false,
            'nofollow' => false,
        ],
        'condition' => [
            'enable_link' => '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',
            ],
            'justify' => [
                'title' => __('Justified', 'ggm-commerce'),
                'icon' => 'eicon-text-align-justify',
            ],
        ],
        'selectors' => [
            '{{WRAPPER}}' => 'text-align: {{VALUE}};',
        ],
    ]
);

$this->end_controls_section();
