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

// === STYLE TAB ===
$this->start_controls_section(
    'style_section',
    [
        'label' => __('Link Style', 'ggm-commerce'),
        'tab' => \Elementor\Controls_Manager::TAB_STYLE,
    ]
);

$this->add_group_control(
    \Elementor\Group_Control_Typography::get_type(),
    [
        'name' => 'link_typography',
        'selector' => '{{WRAPPER}} .ggmc-product-details-link',
    ]
);

$this->start_controls_tabs('link_colors');

$this->start_controls_tab(
    'link_normal',
    [
        'label' => __('Normal', 'ggm-commerce'),
    ]
);

$this->add_control(
    'link_color',
    [
        'label' => __('Text Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'selectors' => [
            '{{WRAPPER}} .ggmc-product-details-link' => 'color: {{VALUE}};',
        ],
    ]
);

$this->add_control(
    'link_background_color',
    [
        'label' => __('Background Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'selectors' => [
            '{{WRAPPER}} .ggmc-product-details-link' => 'background-color: {{VALUE}};',
        ],
        'condition' => [
            'link_style!' => 'text',
        ],
    ]
);

$this->end_controls_tab();

$this->start_controls_tab(
    'link_hover',
    [
        'label' => __('Hover', 'ggm-commerce'),
    ]
);

$this->add_control(
    'link_hover_color',
    [
        'label' => __('Text Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'selectors' => [
            '{{WRAPPER}} .ggmc-product-details-link:hover' => 'color: {{VALUE}};',
        ],
    ]
);

$this->add_control(
    'link_hover_background_color',
    [
        'label' => __('Background Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'selectors' => [
            '{{WRAPPER}} .ggmc-product-details-link:hover' => 'background-color: {{VALUE}};',
        ],
        'condition' => [
            'link_style!' => 'text',
        ],
    ]
);

$this->end_controls_tab();

$this->end_controls_tabs();

$this->add_group_control(
    \Elementor\Group_Control_Border::get_type(),
    [
        'name' => 'link_border',
        'selector' => '{{WRAPPER}} .ggmc-product-details-link',
        'separator' => 'before',
        'condition' => [
            'link_style!' => 'text',
        ],
    ]
);

$this->add_control(
    'link_border_radius',
    [
        'label' => __('Border Radius', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' => ['px', '%'],
        'selectors' => [
            '{{WRAPPER}} .ggmc-product-details-link' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
        'condition' => [
            'link_style!' => 'text',
        ],
    ]
);

$this->add_responsive_control(
    'link_padding',
    [
        'label' => __('Padding', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' => ['px', 'em', '%'],
        'selectors' => [
            '{{WRAPPER}} .ggmc-product-details-link' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
        'condition' => [
            'link_style!' => 'text',
        ],
    ]
);

$this->add_responsive_control(
    'link_margin',
    [
        'label' => __('Margin', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' => ['px', 'em', '%'],
        'selectors' => [
            '{{WRAPPER}} .ggmc-product-details-link-wrapper' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
    ]
);

$this->end_controls_section();
