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

// === CONTENT TAB ===
$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(
    'link_text',
    [
        'label' => __('Link Text', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => __('View Full Details →', 'ggm-commerce'),
        'placeholder' => __('View Full Details →', 'ggm-commerce'),
        'label_block' => true,
    ]
);

$this->add_control(
    'link_style',
    [
        'label' => __('Link Style', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SELECT,
        'default' => 'text',
        'options' => [
            'text' => __('Text Link', 'ggm-commerce'),
            'button' => __('Button', 'ggm-commerce'),
            'outline' => __('Outline Button', 'ggm-commerce'),
        ],
    ]
);

$this->add_control(
    'close_popup',
    [
        'label' => __('Close Popup on Click', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SWITCHER,
        'label_on' => __('Yes', 'ggm-commerce'),
        'label_off' => __('No', 'ggm-commerce'),
        'return_value' => 'yes',
        'default' => 'yes',
        'description' => __('When used in Quick View popup, close the popup when link is clicked', 'ggm-commerce'),
    ]
);

$this->add_responsive_control(
    'align',
    [
        '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' => 'left',
        'selectors' => [
            '{{WRAPPER}} .ggmc-product-details-link-wrapper' => 'text-align: {{VALUE}};',
        ],
    ]
);

$this->end_controls_section();
