<?php
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(
    'display_layout',
    [
        'label' => __('Display Layout', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SELECT,
        'default' => 'inline',
        'options' => [
            'inline' => __('Inline (Horizontal)', 'ggm-commerce'),
            'list' => __('List (Vertical)', 'ggm-commerce'),
            'badges' => __('Badges/Pills', 'ggm-commerce'),
        ],
    ]
);

$this->add_control(
    'show_label',
    [
        'label' => __('Show Label', '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(
    'label_text',
    [
        'label' => __('Label Text', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => 'Categories:',
        'condition' => [
            'show_label' => 'yes',
        ],
    ]
);

$this->add_control(
    'separator',
    [
        'label' => __('Separator', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => ', ',
        'condition' => [
            'display_layout' => 'inline',
        ],
        'description' => __('Text between categories', 'ggm-commerce'),
    ]
);

$this->add_control(
    'show_image',
    [
        'label' => __('Show Category Image', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SWITCHER,
        'label_on' => __('Yes', 'ggm-commerce'),
        'label_off' => __('No', 'ggm-commerce'),
        'return_value' => 'yes',
        'default' => '',
        'condition' => [
            'display_layout!' => 'inline',
        ],
    ]
);

$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',
            ],
        ],
        'selectors' => [
            '{{WRAPPER}} .ggmc-product-categories' => 'text-align: {{VALUE}};',
        ],
    ]
);

$this->end_controls_section();
