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

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

// $this is the GGM_Commerce_Widget_Discount_Code_Input 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-discount-input-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-discount-input-wrapper',
	)
);

$this->add_group_control(
	\Elementor\Group_Control_Border::get_type(),
	array(
		'name'     => 'container_border',
		'selector' => '{{WRAPPER}} .ggmc-discount-input-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-discount-input-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,
		'condition' => array(
			'show_label' => 'yes',
		),
	)
);

$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->add_responsive_control(
	'label_margin',
	array(
		'label'      => 'Margin',
		'type'       => \Elementor\Controls_Manager::DIMENSIONS,
		'size_units' => array( 'px', 'em' ),
		'selectors'  => array(
			'{{WRAPPER}} .ggmc-discount-label' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		),
	)
);

$this->end_controls_section();

// ── Input Field ───────────────────────────────────────────────────────────────

$this->start_controls_section(
	'section_style_input',
	array(
		'label' => 'Input Field',
		'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
	)
);

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

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

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

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

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

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

$this->end_controls_section();

// ── Button ────────────────────────────────────────────────────────────────────

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

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

$this->start_controls_tabs( 'button_style_tabs' );

$this->start_controls_tab(
	'button_style_normal',
	array(
		'label' => 'Normal',
	)
);

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

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

$this->end_controls_tab();

$this->start_controls_tab(
	'button_style_hover',
	array(
		'label' => 'Hover',
	)
);

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

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

$this->end_controls_tab();

$this->end_controls_tabs();

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

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

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

$this->end_controls_section();

// ── Messages ──────────────────────────────────────────────────────────────────

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

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

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

$this->add_control(
	'error_color',
	array(
		'label'     => 'Error Color',
		'type'      => \Elementor\Controls_Manager::COLOR,
		'default'   => '#c92a2a',
		'selectors' => array(
			'{{WRAPPER}} .ggmc-discount-message.error' => 'color: {{VALUE}}; border-color: {{VALUE}};',
		),
	)
);

$this->end_controls_section();
