<?php
namespace Sifency\Traits;
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}
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 = [] ) {
    $this->start_controls_section(
        'section_content',
        [ 'label' => __('Mailchimp Form', 'sifency-addons') ]
    );
    $this->add_control(
        'mc4wp_form_id',
        [
            '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',
        [ 'label' => esc_html__('Input Fields', 'sifency-addons'), 'tab' => Controls_Manager::TAB_STYLE ]
    );

    // Typography
    $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
            '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');

    // Normal
    $this->start_controls_tab('fields_normal', ['label' => esc_html__('Normal', 'sifency-addons')]);
    $this->add_control('field_color', [
        'label' => __('Text Color', 'sifency-addons'),
        'type' => Controls_Manager::COLOR,
        'selectors' => ['{{WRAPPER}} .sifency-mc4wp-form form input:not([type=submit]), {{WRAPPER}} .sifency-mc4wp-form form textarea' => 'color: {{VALUE}};']
    ]);
    $this->add_control('Label_color', [
        'label' => __('Label Color', 'sifency-addons'),
        'type' => Controls_Manager::COLOR,
        'selectors' => ['{{WRAPPER}} .sifency-mc4wp-form form label' => 'color: {{VALUE}};']
    ]);
    $this->add_control('field_placeholder_color', [
        'label' => __('Placeholder Color', 'sifency-addons'),
        'type' => Controls_Manager::COLOR,
        'selectors' => ['{{WRAPPER}} .sifency-mc4wp-form form ::placeholder' => 'color: {{VALUE}};']
    ]);
    $this->add_control('field_bg_color', [
        'label' => __('Background', 'sifency-addons'),
        'type' => Controls_Manager::COLOR,
        'selectors' => ['{{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(),
        [
            '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', [
        'label' => __('Border Radius', 'sifency-addons'),
        'type' => Controls_Manager::DIMENSIONS,
        'selectors' => [
            '{{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(),
        [
            'name' => 'field_shadow',
            'selector' => '{{WRAPPER}} .sifency-mc4wp-form form input:not([type=submit]), {{WRAPPER}} .sifency-mc4wp-form form textarea',
        ]
    );
    $this->end_controls_tab();

    // Focus
    $this->start_controls_tab('fields_focus', ['label' => esc_html__('Focus', 'sifency-addons')]);
    $this->add_control('field_focus_border_color', [
        'label' => __('Border Color', 'sifency-addons'),
        'type' => Controls_Manager::COLOR,
        'selectors' => ['{{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', [
        'label' => __('Background', 'sifency-addons'),
        'type' => Controls_Manager::COLOR,
        'selectors' => ['{{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();

    // Padding & Spacing
    $this->add_responsive_control('field_padding', [
        'label' => __('Padding', 'sifency-addons'),
        'type' => Controls_Manager::DIMENSIONS,
        'selectors' => [
            '{{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', [
        'label' => __('Margin', 'sifency-addons'),
        'type' => Controls_Manager::DIMENSIONS,
        'selectors' => [
            '{{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_button_style',
        [ 'label' => esc_html__('Button', 'sifency-addons'), 'tab' => Controls_Manager::TAB_STYLE ]
    );

    $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
            'name' => 'button_typography',
            'selector' => '{{WRAPPER}} .sifency-mc4wp-form form input[type="submit"]',
        ]
    );

    $this->start_controls_tabs('button_states');

    // Normal
    $this->start_controls_tab('btn_normal', ['label' => __('Normal', 'sifency-addons')]);
    $this->add_control('button_bg', [
        'label' => __('Background', 'sifency-addons'),
        'type' => Controls_Manager::COLOR,
        'selectors' => ['{{WRAPPER}} .sifency-mc4wp-form form input[type="submit"]' => 'background-color: {{VALUE}};']
    ]);
    $this->add_control('button_color', [
        'label' => __('Text Color', 'sifency-addons'),
        'type' => Controls_Manager::COLOR,
        'selectors' => ['{{WRAPPER}} .sifency-mc4wp-form form input[type="submit"]' => 'color: {{VALUE}};']
    ]);
    $this->add_group_control(
        \Elementor\Group_Control_Border::get_type(),
        [
            'name' => 'button_border',
            'selector' => '{{WRAPPER}} .sifency-mc4wp-form form input[type="submit"]',
        ]
    );
    $this->add_control('button_radius', [
        'label' => __('Border Radius', 'sifency-addons'),
        'type' => Controls_Manager::SLIDER,
        'selectors' => ['{{WRAPPER}} .sifency-mc4wp-form form input[type="submit"]' => 'border-radius: {{SIZE}}px;'],
    ]);
    $this->end_controls_tab();

    // Hover
    $this->start_controls_tab('btn_hover', ['label' => __('Hover', 'sifency-addons')]);
    $this->add_control('button_hover_bg', [
        'label' => __('Background', 'sifency-addons'),
        'type' => Controls_Manager::COLOR,
        'selectors' => ['{{WRAPPER}} .sifency-mc4wp-form form input[type="submit"]:hover' => 'background-color: {{VALUE}};']
    ]);
    $this->add_control('button_hover_color', [
        'label' => __('Text Color', 'sifency-addons'),
        'type' => Controls_Manager::COLOR,
        'selectors' => ['{{WRAPPER}} .sifency-mc4wp-form form input[type="submit"]:hover' => 'color: {{VALUE}};']
    ]);
    $this->add_control('button_hover_border_color', [
        'label' => __('Border Color', 'sifency-addons'),
        'type' => Controls_Manager::COLOR,
        'selectors' => ['{{WRAPPER}} .sifency-mc4wp-form form input[type="submit"]:hover' => 'border-color: {{VALUE}};']
    ]);
    $this->end_controls_tab();

    $this->end_controls_tabs();

    // Button Spacing
    $this->add_responsive_control('button_padding', [
        'label' => __('Padding', 'sifency-addons'),
        'type' => Controls_Manager::DIMENSIONS,
        'selectors' => ['{{WRAPPER}} .sifency-mc4wp-form form input[type="submit"]' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'],
    ]);
    $this->add_group_control(
        \Elementor\Group_Control_Box_Shadow::get_type(),
        [
            'name' => 'button_shadow',
            'selector' => '{{WRAPPER}} .sifency-mc4wp-form form input[type="submit"]',
        ]
    );

    $this->end_controls_section();

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