<?php
/**
 * Product Name Widget — TAB_STYLE controls
 * Included via bare require inside register_controls().
 * $this refers to the widget instance.
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

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

$this->add_group_control(
    \Elementor\Group_Control_Typography::get_type(),
    [
        'name' => 'typography',
        'selector' => '{{WRAPPER}} .ggmc-product-name',
        'fields_options' => [
            'typography' => [
                'default' => $this->get_conditional_default('typography_typography', ''),
            ],
            'font_family' => [
                'default' => $this->get_conditional_default('typography_font_family', ''),
            ],
            'font_size' => [
                'default' => $this->get_conditional_default('typography_font_size', ['size' => '', 'unit' => 'px']),
            ],
            'font_weight' => [
                'default' => $this->get_conditional_default('typography_font_weight', ''),
            ],
            'line_height' => [
                'default' => $this->get_conditional_default('typography_line_height', ['size' => '', 'unit' => 'em']),
            ],
            'letter_spacing' => [
                'default' => $this->get_conditional_default('typography_letter_spacing', ['size' => '', 'unit' => 'em']),
            ],
        ],
    ]
);

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

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

$this->add_control(
    'blend_mode',
    [
        'label' => __('Blend Mode', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SELECT,
        'options' => [
            '' => __('Normal', 'ggm-commerce'),
            'multiply' => 'Multiply',
            'screen' => 'Screen',
            'overlay' => 'Overlay',
            'darken' => 'Darken',
            'lighten' => 'Lighten',
            'color-dodge' => 'Color Dodge',
            'saturation' => 'Saturation',
            'color' => 'Color',
            'luminosity' => 'Luminosity',
        ],
        'selectors' => [
            '{{WRAPPER}} .ggmc-product-name' => 'mix-blend-mode: {{VALUE}}',
        ],
    ]
);

$this->end_controls_section();

// ===== HOVER STYLE SECTION =====
$this->start_controls_section(
    'hover_style_section',
    [
        'label' => __('Hover Style', 'ggm-commerce'),
        'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        'condition' => [
            'enable_link' => 'yes',
        ],
    ]
);

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

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

$this->add_control(
    'hover_transition',
    [
        'label' => __('Transition Duration', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SLIDER,
        'default' => [
            'size' => 0.3,
            'unit' => 's',
        ],
        'range' => [
            's' => [
                'min' => 0,
                'max' => 3,
                'step' => 0.1,
            ],
        ],
        'selectors' => [
            '{{WRAPPER}} .ggmc-product-name' => 'transition: all {{SIZE}}s ease;',
        ],
    ]
);

$this->end_controls_section();
