<?php
/**
 * Applied Discount Widget - Style Controls
 *
 * @package GGM_Commerce
 */

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

// $this is the GGM_Commerce_Widget_Applied_Discount instance.

// ── Container ─────────────────────────────────────────────────────────────────

$this->start_controls_section(
	'section_style_container',
	array(
		'label' => 'Container',
		'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
	)
);

$this->add_responsive_control(
	'container_padding',
	array(
		'label'      => 'Padding',
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => array( 'px', 'em' ),
		'selectors'  => array(
			'{{WRAPPER}} .ggmc-applied-discount-wrapper' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		),
	)
);

$this->add_group_control(
	\Elementor\Group_Control_Background::get_type(),
	array(
		'name'     => 'container_background',
		'selector' => '{{WRAPPER}} .ggmc-applied-discount-wrapper',
	)
);

$this->add_group_control(
	\Elementor\Group_Control_Border::get_type(),
	array(
		'name'     => 'container_border',
		'selector' => '{{WRAPPER}} .ggmc-applied-discount-wrapper',
	)
);

$this->add_control(
	'container_border_radius',
	array(
		'label'      => 'Border Radius',
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => array( 'px', 'em' ),
		'selectors'  => array(
			'{{WRAPPER}} .ggmc-applied-discount-wrapper' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		),
	)
);

$this->end_controls_section();

// ── Label ─────────────────────────────────────────────────────────────────────

$this->start_controls_section(
	'section_style_label',
	array(
		'label' => 'Label',
		'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
	)
);

$this->add_group_control(
	\Elementor\Group_Control_Typography::get_type(),
	array(
		'name'     => 'label_typography',
		'selector' => '{{WRAPPER}} .ggmc-discount-label',
	)
);

$this->add_control(
	'label_color',
	array(
		'label'     => 'Color',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => array(
			'{{WRAPPER}} .ggmc-discount-label' => 'color: {{VALUE}};',
		),
	)
);

$this->end_controls_section();

// ── Discount Code ─────────────────────────────────────────────────────────────

$this->start_controls_section(
	'section_style_code',
	array(
		'label' => 'Discount Code',
		'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
	)
);

$this->add_group_control(
	\Elementor\Group_Control_Typography::get_type(),
	array(
		'name'     => 'code_typography',
		'selector' => '{{WRAPPER}} .ggmc-discount-code-badge',
	)
);

$this->add_control(
	'code_text_color',
	array(
		'label'     => 'Text Color',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'selectors' => array(
			'{{WRAPPER}} .ggmc-discount-code-badge' => 'color: {{VALUE}};',
		),
	)
);

$this->add_control(
	'code_background_color',
	array(
		'label'     => 'Background Color',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'default'   => '#d3f9d8',
		'selectors' => array(
			'{{WRAPPER}} .ggmc-discount-code-badge' => 'background-color: {{VALUE}};',
		),
	)
);

$this->add_responsive_control(
	'code_padding',
	array(
		'label'      => 'Padding',
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => array( 'px', 'em' ),
		'selectors'  => array(
			'{{WRAPPER}} .ggmc-discount-code-badge' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		),
	)
);

$this->add_control(
	'code_border_radius',
	array(
		'label'      => 'Border Radius',
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => array( 'px', 'em' ),
		'selectors'  => array(
			'{{WRAPPER}} .ggmc-discount-code-badge' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		),
	)
);

$this->end_controls_section();

// ── Discount Amount ───────────────────────────────────────────────────────────

$this->start_controls_section(
	'section_style_amount',
	array(
		'label' => 'Discount Amount',
		'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
	)
);

$this->add_group_control(
	\Elementor\Group_Control_Typography::get_type(),
	array(
		'name'     => 'amount_typography',
		'selector' => '{{WRAPPER}} .ggmc-discount-amount',
	)
);

$this->add_control(
	'amount_color',
	array(
		'label'     => 'Color',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'default'   => '#2f9e44',
		'selectors' => array(
			'{{WRAPPER}} .ggmc-discount-amount' => 'color: {{VALUE}};',
		),
	)
);

$this->end_controls_section();
