<?php
// If this file is called directly, abort.
if (! defined('ABSPATH')) {
    exit;
}

// === CONTENT TAB ===
$this->start_controls_section(
    'content_section',
    [
        'label' => __('Description Settings', '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(
    'description_type',
    [
        'label' => __('Description Type', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SELECT,
        'default' => 'full',
        'options' => [
            'full' => __('Full Description', 'ggm-commerce'),
            'short' => __('Short Description', 'ggm-commerce'),
            'excerpt' => __('Auto Excerpt', 'ggm-commerce'),
        ],
    ]
);

$this->add_control(
    'excerpt_length',
    [
        'label' => __('Excerpt Length (words)', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::NUMBER,
        'default' => 25,
        'min' => 5,
        'max' => 100,
        'condition' => [
            'description_type' => 'excerpt',
        ],
    ]
);

$this->add_control(
    'show_read_more',
    [
        'label' => __('Show Read More', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SWITCHER,
        'label_on' => __('Show', 'ggm-commerce'),
        'label_off' => __('Hide', 'ggm-commerce'),
        'return_value' => 'yes',
        'default' => 'no',
        'condition' => [
            'description_type' => 'excerpt',
        ],
    ]
);

$this->add_control(
    'read_more_text',
    [
        'label' => __('Read More Text', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => __('Read More', 'ggm-commerce'),
        'condition' => [
            'description_type' => 'excerpt',
            'show_read_more' => 'yes',
        ],
    ]
);

$this->add_control(
    'read_less_text',
    [
        'label' => __('Read Less Text', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => __('Read Less', 'ggm-commerce'),
        'condition' => [
            'description_type' => 'excerpt',
            'show_read_more' => 'yes',
        ],
    ]
);

$this->end_controls_section();
