<?php
namespace Sifency\Traits;

if ( ! defined( 'ABSPATH' ) ) {
	exit;  }
use Elementor\Controls_Manager;
use Elementor\Group_Control_Typography;
use Elementor\Group_Control_Border;
trait Sifency_Newsletter_Controls {

	protected function add_sifency_newsletter_controls( $args = array() ) {
		$this->start_controls_section(
			'section_content',
			array( 'label' => __( 'Mailchimp Form', 'sifency-addons' ) )
		);
		$this->add_control(
			'mc4wp_form_id',
			array(
				'label'   => __( 'Select Form', 'sifency-addons' ),
				'type'    => Controls_Manager::SELECT,
				'options' => sifency_addons_get_mailchimp_forms(),
			)
		);
		$this->end_controls_section();

		$this->start_controls_section(
			'form_fields_style',
			array(
				'label' => esc_html__( 'Input Fields', 'sifency-addons' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_group_control(
			\Elementor\Group_Control_Typography::get_type(),
			array(
				'name'     => 'fields_typography',
				'selector' => '{{WRAPPER}} .sifency-mc4wp-form form input:not([type=submit]), {{WRAPPER}} .sifency-mc4wp-form form textarea',
			)
		);
		$this->start_controls_tabs( 'fields_states' );

		$this->start_controls_tab( 'fields_normal', array( 'label' => esc_html__( 'Normal', 'sifency-addons' ) ) );
		$this->add_control(
			'field_color',
			array(
				'label'     => __( 'Text Color', 'sifency-addons' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array( '{{WRAPPER}} .sifency-mc4wp-form form input:not([type=submit]), {{WRAPPER}} .sifency-mc4wp-form form textarea' => 'color: {{VALUE}};' ),
			)
		);
		$this->add_control(
			'Label_color',
			array(
				'label'     => __( 'Label Color', 'sifency-addons' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array( '{{WRAPPER}} .sifency-mc4wp-form form label' => 'color: {{VALUE}};' ),
			)
		);
		$this->add_control(
			'field_placeholder_color',
			array(
				'label'     => __( 'Placeholder Color', 'sifency-addons' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array( '{{WRAPPER}} .sifency-mc4wp-form form ::placeholder' => 'color: {{VALUE}};' ),
			)
		);
		$this->add_control(
			'field_bg_color',
			array(
				'label'     => __( 'Background', 'sifency-addons' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array( '{{WRAPPER}} .sifency-mc4wp-form form input:not([type=submit]), {{WRAPPER}} .sifency-mc4wp-form form textarea' => 'background-color: {{VALUE}};' ),
			)
		);
		$this->add_group_control(
			\Elementor\Group_Control_Border::get_type(),
			array(
				'name'     => 'field_border',
				'selector' => '{{WRAPPER}} .sifency-mc4wp-form form input:not([type=submit]), {{WRAPPER}} .sifency-mc4wp-form form textarea',
			)
		);
		$this->add_responsive_control(
			'field_radius',
			array(
				'label'     => __( 'Border Radius', 'sifency-addons' ),
				'type'      => Controls_Manager::DIMENSIONS,
				'selectors' => array(
					'{{WRAPPER}} .sifency-mc4wp-form form input:not([type=submit]), {{WRAPPER}} .sifency-mc4wp-form form textarea' =>
					'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			\Elementor\Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'field_shadow',
				'selector' => '{{WRAPPER}} .sifency-mc4wp-form form input:not([type=submit]), {{WRAPPER}} .sifency-mc4wp-form form textarea',
			)
		);
		$this->end_controls_tab();

		$this->start_controls_tab( 'fields_focus', array( 'label' => esc_html__( 'Focus', 'sifency-addons' ) ) );
		$this->add_control(
			'field_focus_border_color',
			array(
				'label'     => __( 'Border Color', 'sifency-addons' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array( '{{WRAPPER}} .sifency-mc4wp-form form input:not([type=submit]):focus, {{WRAPPER}} .sifency-mc4wp-form form textarea:focus' => 'border-color: {{VALUE}};' ),
			)
		);
		$this->add_control(
			'field_focus_bg_color',
			array(
				'label'     => __( 'Background', 'sifency-addons' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array( '{{WRAPPER}} .sifency-mc4wp-form form input:not([type=submit]):focus, {{WRAPPER}} .sifency-mc4wp-form form textarea:focus' => 'background-color: {{VALUE}};' ),
			)
		);
		$this->end_controls_tab();
		$this->end_controls_tabs();

		$this->add_responsive_control(
			'field_padding',
			array(
				'label'     => __( 'Padding', 'sifency-addons' ),
				'type'      => Controls_Manager::DIMENSIONS,
				'selectors' => array(
					'{{WRAPPER}} .sifency-mc4wp-form form input:not([type=submit]), {{WRAPPER}} .sifency-mc4wp-form form textarea' =>
					'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'field_margin',
			array(
				'label'     => __( 'Margin', 'sifency-addons' ),
				'type'      => Controls_Manager::DIMENSIONS,
				'selectors' => array(
					'{{WRAPPER}} .sifency-mc4wp-form form input:not([type=submit]), {{WRAPPER}} .sifency-mc4wp-form form textarea' =>
					'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->end_controls_section();
		$this->start_controls_section(
			'form_message_style',
			array(
				'label' => esc_html__( 'Messages', 'sifency-addons' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);
		$this->add_control(
			'success_color',
			array(
				'label'     => __( 'Success Message Color', 'sifency-addons' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array( '{{WRAPPER}} .sifency-mc4wp-form .mc4wp-success' => 'color: {{VALUE}};' ),
			)
		);
		$this->add_control(
			'error_color',
			array(
				'label'     => __( 'Error Message Color', 'sifency-addons' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array( '{{WRAPPER}} .sifency-mc4wp-form .mc4wp-error' => 'color: {{VALUE}};' ),
			)
		);
		$this->end_controls_section();
	}
}
