<?php
namespace UltraAddons\Widget;


use Elementor\Controls_Manager;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Typography;
use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
use Elementor\Group_Control_Box_Shadow;

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

class Formidable_Form extends Base{
       
        public function get_keywords() {
                return [ 'ultraaddons-elementor-lite', 'appointment', 'contact', 'quote', 'form', 'schedule', 'formidable', 'contact form', ];
        }

         /**
         * Register oEmbed widget controls.
         *
         * Adds different input fields to allow the user to change and customize the widget settings.
         *
         * @since 1.0.0
         * @access protected
         */
        
        protected function register_controls() {
                $this->register_content_controls();

                $this->container_style();
                $this->title_style();
                $this->label_style();
                $this->input_style();
                $this->button_style();
                $this->placeholder_style();
                
        }

        protected function register_content_controls(){
                
                $this->start_controls_section(
                        '_section_frm',
                        [
                                'label' =>  __( 'Contact Form', 'ultraaddons-elementor-lite' ) ,
                                'tab' => Controls_Manager::TAB_CONTENT,
                        ]
                );
                if( class_exists( 'FrmForm' ) ){
                        $this->add_control(
                                'form_id',
                                array(
                                'label'   => __( 'Form', 'ultraaddons-elementor-lite' ),
                                'type'    => Controls_Manager::SELECT2,
                                'options' => ultraaddons_get_formidable_forms(),
                                )
                        );
                        $this->add_basic_switcher_control( 'title', __( 'Show Form Title', 'ultraaddons-elementor-lite' ) );
                        $this->add_basic_switcher_control( 'description', __( 'Show Form Description', 'ultraaddons-elementor-lite' ) );
                        $this->add_basic_switcher_control( 'minimize', __( 'Minimize HTML', 'ultraaddons-elementor-lite' ) );
                }else{
                        $this->add_control(
                                'form_error',[
                                    'type'            => Controls_Manager::RAW_HTML,
                                    /* translators: %s: Plugin installation URL */
                                    'raw'             => sprintf( __( '<strong>Please install or activate Formidable Forms.</strong><br>Go to the <a href="%s" target="_blank" style="color:#93003c">Plugin page</a> to actions.', 'ultraaddons-elementor-lite' ), admin_url( 'plugin-install.php?s=formidable&tab=search&type=term' ) ),
                                    'separator'       => 'after',
                                    'content_classes' => 'elementor-panel-alert elementor-panel-alert-warning',
                                ]
                            );
                }

                $this->end_controls_section();
        }
        protected function container_style(){
                $this->start_controls_section(
                        'container_style',
                        [
                            'label'                 => __('Form Container', 'ultraaddons-elementor-lite'),
                            'tab'                   => Controls_Manager::TAB_STYLE,
                            'condition' => [
                                'form_id!' => '',
                                ]
                        ]
                    );
                
                    $this->add_control(
                        'ua_contact_form_background',
                        [
                            'label' => esc_html__('Form Background Color', 'ultraaddons-elementor-lite'),
                            'type' => Controls_Manager::COLOR,
                            'selectors' => [
                                '{{WRAPPER}} .ua-form.formidable' => 'background: {{VALUE}};',
                            ],
                        ]
                    );
                
                    $this->add_responsive_control(
                        'ua_contact_form_max_width',
                        [
                            'label' => esc_html__('Form Max Width', 'ultraaddons-elementor-lite'),
                            'type' => Controls_Manager::SLIDER,
                            'size_units' => ['px', 'em', '%'],
                            'range' => [
                                'px' => [
                                    'min' => 10,
                                    'max' => 1500,
                                ],
                                'em' => [
                                    'min' => 1,
                                    'max' => 80,
                                ],
                            ],
                            'selectors' => [
                                '{{WRAPPER}} .ua-form.formidable' => 'max-width: {{SIZE}}{{UNIT}};',
                            ],
                        ]
                    );
                
                
                    $this->add_responsive_control(
                        'ua_contact_form_margin',
                        [
                            'label' => esc_html__('Form Margin', 'ultraaddons-elementor-lite'),
                            'type' => Controls_Manager::DIMENSIONS,
                            'size_units' => ['px', 'em', '%'],
                            'selectors' => [
                                '{{WRAPPER}} .ua-form.formidable' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                            ],
                        ]
                    );
                
                    $this->add_responsive_control(
                        'ua_contact_form_padding',
                        [
                            'label' => esc_html__('Form Padding', 'ultraaddons-elementor-lite'),
                            'type' => Controls_Manager::DIMENSIONS,
                            'size_units' => ['px', 'em', '%'],
                            'selectors' => [
                                '{{WRAPPER}} .ua-form.formidable' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                            ],
                        ]
                    );
                
                
                    $this->add_control(
                        'ua_contact_form_border_radius',
                        [
                            'label' => esc_html__('Border Radius', 'ultraaddons-elementor-lite'),
                            'type' => Controls_Manager::DIMENSIONS,
                            'separator' => 'before',
                            'size_units' => ['px'],
                            'selectors' => [
                                '{{WRAPPER}} .ua-form.formidable' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                            ],
                        ]
                    );
                
                
                    $this->add_group_control(
                        Group_Control_Border::get_type(),
                        [
                            'name' => 'ua_contact_form_border',
                            'selector' => '{{WRAPPER}} .ua-form.formidable',
                        ]
                    );
                
                
                    $this->add_group_control(
                        Group_Control_Box_Shadow::get_type(),
                        [
                            'name' => 'ua_contact_form_box_shadow',
                            'selector' => '{{WRAPPER}} .ua-form.formidable',
                        ]
                    );
                
               
                $this->end_controls_section();
        }
        protected function title_style(){
                
                $this->start_controls_section(
                        'from_style',
                        [
                                'label' =>  __( 'Title & Description', 'ultraaddons-elementor-lite' ) ,
                                'tab' => Controls_Manager::TAB_STYLE,
                                'condition' => [
                                        'form_id!' => '',
                                ]
                        ]
                );
                $this->add_control(
                        'title_text_align',
                            [
                                'label'         => esc_html__( 'Align', 'ultraaddons-elementor-lite' ),
                                'type'          => Controls_Manager::CHOOSE,
                                'options' => [
                                        'left' => [
                                                'title' => __( 'Left', 'ultraaddons-elementor-lite' ),
                                                'icon' => 'eicon-text-align-left',
                                        ],
                                        'center' => [
                                                'title' => __( 'Center', 'ultraaddons-elementor-lite' ),
                                                'icon' => 'eicon-text-align-center',
                                        ],
                                        'right' => [
                                                'title' => __( 'Right', 'ultraaddons-elementor-lite' ),
                                                'icon' => 'eicon-text-align-right',
                                        ],
                                ],
                                'default' => 'left',
                                'selectors' => [
                                        '{{WRAPPER}} .ua-form .frm_form_title, .ua-form .frm_description p' => 'text-align:{{VALUE}} !important;',
                                ],
                               
                            ]
                );
                
                $this->add_group_control(
                        Group_Control_Typography::get_type(),
                        [
                                'name' => 'title_typography',
                                'label' => 'Title Typography',
                                'selector' => '{{WRAPPER}} .ua-form .frm_form_title',
                                'global' => [
                                        'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
                                ],
                        ]
                );
                $this->add_control(
                        'title_color',
                        [
                                'label' => __( 'Title Color', 'ultraaddons-elementor-lite' ),
                                'type' => Controls_Manager::COLOR,
                                'selectors' => [
                                        '{{WRAPPER}} .ua-form .frm_form_title' => 'color: {{VALUE}};',
                                ],
                        ]
                );
                $this->add_responsive_control(
			'title_margin',
			[
				'label'       => esc_html__( 'Title Margin', 'ultraaddons-elementor-lite' ),
				'type'        => Controls_Manager::DIMENSIONS,
				'size_units'  => [ 'px', '%' ],
				'placeholder' => [
					'top'    => '',
					'right'  => '',
					'bottom' => '',
					'left'   => '',
				],
				'selectors'   => [
					'{{WRAPPER}} .ua-form .frm_form_title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				],
                                'separator'=>'after',
			]
		);
                $this->add_group_control(
                        Group_Control_Typography::get_type(),
                        [
                                'name' => 'desc_typography',
                                'label' => 'Description Typography',
                                'selector' => '{{WRAPPER}} .ua-form .frm_description p',
                                'global' => [
                                        'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
                                ],
        
                        ]
                );

                $this->add_control(
                        'desc_color',
                        [
                                'label' => __( 'Deccription Color', 'ultraaddons-elementor-lite' ),
                                'type' => Controls_Manager::COLOR,
                                'selectors' => [
                                        '{{WRAPPER}} .ua-form .frm_description p' => 'color: {{VALUE}};',
                                ],
                        ]
                );
                $this->add_responsive_control(
			'desc_margin',
			[
				'label'       => esc_html__( 'Description Margin', 'ultraaddons-elementor-lite' ),
				'type'        => Controls_Manager::DIMENSIONS,
				'size_units'  => [ 'px', '%' ],
				'placeholder' => [
					'top'    => '',
					'right'  => '',
					'bottom' => '',
					'left'   => '',
				],
				'selectors'   => [
					'{{WRAPPER}} .ua-form .frm_description p' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				],
                                'separator'=>'after',
			]
		);
               

                $this->end_controls_section();
        }
        protected function label_style(){
                
                $this->start_controls_section(
                        'label_style',
                        [
                                'label' =>  __( 'Label & Sub Label', 'ultraaddons-elementor-lite' ) ,
                                'tab' => Controls_Manager::TAB_STYLE,
                                'condition' => [
                                        'form_id!' => '',
                                ]
                        ]
                );
                $this->add_group_control(
                        Group_Control_Typography::get_type(),
                        [
                                'name' => 'label_typography',
                                'label' => 'Label Typography',
                                'global' => [
                                        'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
                                ],
                                'selector' => '{{WRAPPER}} .ua-form .frm_fields_container label',
        
                        ]
                );
                $this->add_control(
                        'label_color',
                        [
                                'label' => __( 'Form Label Color', 'ultraaddons-elementor-lite' ),
                                'type' => Controls_Manager::COLOR,
                                'selectors' => [
                                        '{{WRAPPER}} .ua-form .frm_fields_container label' => 'color: {{VALUE}};',
                                ],
                        ]
                );
                $this->add_responsive_control(
			'label_margin',
			[
				'label'       => esc_html__( 'Label Margin', 'ultraaddons-elementor-lite' ),
				'type'        => Controls_Manager::DIMENSIONS,
				'size_units'  => [ 'px', '%' ],
				'placeholder' => [
					'top'    => '',
					'right'  => '',
					'bottom' => '',
					'left'   => '',
				],
				'selectors'   => [
					'{{WRAPPER}} .ua-form .frm_fields_container label' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				],
                                'separator'=>'after',
			]
		);
                $this->add_group_control(
                        Group_Control_Typography::get_type(),
                        [
                                'name' => 'sub_label_typography',
                                'label' => 'Sub Label Typography',
                                'global' => [
                                        'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
                                ],
                                'selector' => '{{WRAPPER}} .ua-form .frm_description',
                        ]
                );
                $this->add_control(
                        'sub_label_color',
                        [
                                'label' => __( 'Sub Label Color', 'ultraaddons-elementor-lite' ),
                                'type' => Controls_Manager::COLOR,
                                'separator'=>'after',
                                'selectors' => [
                                        '{{WRAPPER}} .ua-form .frm_description' => 'color: {{VALUE}};',
                                       
                                ],
                        ]
                );
                $this->end_controls_section();
        }              
        protected function input_style(){
                
                $this->start_controls_section(
                        'input_style',
                        [
                                'label' =>  __( 'Input & Textarea', 'ultraaddons-elementor-lite' ) ,
                                'tab' => Controls_Manager::TAB_STYLE,
                                'condition' => [
                                        'form_id!' => '',
                                ]
                        ]
                );
                $this->add_control(
			'input_radius',
			[
				'label' => __( 'Border Radius', 'ultraaddons-elementor-lite' ),
				'type' => Controls_Manager::DIMENSIONS,
				'size_units' => [ 'px', '%' ],
				'selectors' => [
				'{{WRAPPER}} .with_frm_style input[type=text], 
                                {{WRAPPER}} .with_frm_style input[type=password], 
                                {{WRAPPER}} .with_frm_style input[type=email], 
                                {{WRAPPER}} .with_frm_style input[type=number], 
                                {{WRAPPER}} .with_frm_style input[type=url], 
                                {{WRAPPER}} .with_frm_style input[type=tel],
                                {{WRAPPER}} .with_frm_style input[type=file], 
                                {{WRAPPER}} .with_frm_style input[type=search], 
                                {{WRAPPER}} .with_frm_style select, 
                                {{WRAPPER}} .with_frm_style .frm-card-element.StripeElement, 
                                {{WRAPPER}} .with_frm_style .frm_form_field textarea' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				],
			]
		);
                $this->add_control(
			'input_bg_color',
			[
				'label' => __( 'Background Color', 'ultraaddons-elementor-lite' ),
				'type' => Controls_Manager::COLOR,
				'default' => '',
				'selectors' => [
				'{{WRAPPER}} .with_frm_style input[type=text], 
                                {{WRAPPER}} .with_frm_style input[type=password], 
                                {{WRAPPER}} .with_frm_style input[type=email], 
                                {{WRAPPER}} .with_frm_style input[type=number], 
                                {{WRAPPER}} .with_frm_style input[type=url], 
                                {{WRAPPER}} .with_frm_style input[type=tel],
                                {{WRAPPER}} .with_frm_style input[type=file], 
                                {{WRAPPER}} .with_frm_style input[type=search], 
                                {{WRAPPER}} .with_frm_style select, 
                                {{WRAPPER}} .with_frm_style .frm-card-element.StripeElement, 
                                {{WRAPPER}} .with_frm_style .frm_form_field textarea' => 'background-color: {{VALUE}};',
				],
			]
		);
                $this->add_group_control(
			Group_Control_Border::get_type(),
			[
				'name' => 'input_border',
				'label' => esc_html__( 'Button Border', 'ultraaddons-elementor-lite' ),
				'selector' => '{{WRAPPER}} .with_frm_style input[type=text], 
                                {{WRAPPER}} .with_frm_style input[type=password], 
                                {{WRAPPER}} .with_frm_style input[type=email], 
                                {{WRAPPER}} .with_frm_style input[type=number], 
                                {{WRAPPER}} .with_frm_style input[type=url], 
                                {{WRAPPER}} .with_frm_style input[type=tel],
                                {{WRAPPER}} .with_frm_style input[type=file], 
                                {{WRAPPER}} .with_frm_style input[type=search], 
                                {{WRAPPER}} .with_frm_style select, 
                                {{WRAPPER}} .with_frm_style .frm-card-element.StripeElement, 
                                {{WRAPPER}} .with_frm_style .frm_form_field textarea',
			]
		);
                $this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			[
				'name' => 'input_shadow',
				'label' => __( 'Input Shadow', 'ultraaddons-elementor-lite' ),
				'selector' => '{{WRAPPER}} .with_frm_style input[type=text], 
                                {{WRAPPER}} .with_frm_style input[type=password], 
                                {{WRAPPER}} .with_frm_style input[type=email], 
                                {{WRAPPER}} .with_frm_style input[type=number], 
                                {{WRAPPER}} .with_frm_style input[type=url], 
                                {{WRAPPER}} .with_frm_style input[type=tel],
                                {{WRAPPER}} .with_frm_style input[type=file], 
                                {{WRAPPER}} .with_frm_style input[type=search], 
                                {{WRAPPER}} .with_frm_style select, 
                                {{WRAPPER}} .with_frm_style .frm-card-element.StripeElement, 
                                {{WRAPPER}} .with_frm_style .frm_form_field textarea',
			]
		);
		$this->add_group_control(
			Group_Control_Typography::get_type(),
			[
				'name' => 'input_typography',
				'selector' => '{{WRAPPER}} .with_frm_style input[type=text], 
                                {{WRAPPER}} .with_frm_style input[type=password], 
                                {{WRAPPER}} .with_frm_style input[type=email], 
                                {{WRAPPER}} .with_frm_style input[type=number], 
                                {{WRAPPER}} .with_frm_style input[type=url], 
                                {{WRAPPER}} .with_frm_style input[type=tel],
                                {{WRAPPER}} .with_frm_style input[type=file], 
                                {{WRAPPER}} .with_frm_style input[type=search], 
                                {{WRAPPER}} .with_frm_style select, 
                                {{WRAPPER}} .with_frm_style .frm-card-element.StripeElement, 
                                {{WRAPPER}} .with_frm_style .frm_form_field textarea',
			]
		);
		$this->add_control(
			'text_height',
			[
				'label' => esc_html__( 'Input Text Height', 'ultraaddons-elementor-lite' ),
				'type' => Controls_Manager::SLIDER,
				'size_units' => [ 'px' ],
				'range' => [
					'px' => [
						'min' => 20,
						'max' => 100,
						'step' => 5,
					],
				],
				'default' => [
					'size' => 40,
				],
				'selectors' => [
					'{{WRAPPER}} .with_frm_style input[type=text], .with_frm_style input[type=password], .with_frm_style input[type=email], .with_frm_style input[type=number], .with_frm_style input[type=url], .with_frm_style input[type=tel], .with_frm_style input[type=file], .with_frm_style input[type=search], .with_frm_style select, .with_frm_style .frm-card-element.StripeElement' => 'height: {{SIZE}}{{UNIT}};',
				],
			]
		);

                $this->add_control(
			'textarea_height',
			[
				'label' => esc_html__( 'Textarea Height', 'ultraaddons-elementor-lite' ),
				'type' => Controls_Manager::SLIDER,
				'size_units' => [ 'px' ],
				'range' => [
					'px' => [
						'min' => 150,
						'max' => 500,
						'step' => 10,
					],
				],
				'default' => [
					'size' => 150,
				],
				'selectors' => [
					'{{WRAPPER}} .ua-form .frm_fields_container .frm_form_field textarea' => 'height: {{SIZE}}{{UNIT}};',
				],
			]
		);
                $this->end_controls_section();
        }

        protected function button_style(){
                
                $this->start_controls_section(
                        'button_style',
                        [
                                'label' =>  __( 'Submit Button', 'ultraaddons-elementor-lite' ) ,
                                'tab' => Controls_Manager::TAB_STYLE,
                                'condition' => [
                                        'form_id!' => '',
                                ]
                        ]
                );
                $this->add_responsive_control(
                        'submit_btn_alignment',
                        [
                            'label' => esc_html__('Button Alignment', 'ultraaddons-elementor-lite'),
                            'type' => Controls_Manager::CHOOSE,
                            'label_block' => false,
                            'options' => [
                                'default' => [
                                    'title' => __('Default', 'ultraaddons-elementor-lite'),
                                    'icon' => ' eicon-ban',
                                ],
                                'left' => [
                                    'title' => esc_html__('Left', 'ultraaddons-elementor-lite'),
                                    'icon' => 'eicon-text-align-left',
                                ],
                                'center' => [
                                    'title' => esc_html__('Center', 'ultraaddons-elementor-lite'),
                                    'icon' => 'eicon-text-align-center',
                                ],
                                'right' => [
                                    'title' => esc_html__('Right', 'ultraaddons-elementor-lite'),
                                    'icon' => 'eicon-text-align-right',
                                ],
                            ],
                            'default' => 'left',
                            'selectors' => [
                                '{{WRAPPER}} .with_frm_style .frm_submit' => 'text-align: {{VALUE}};',
                            ],

                        ]
                    );
                $this->add_control(
			'btn_block',
			[
				'label' => esc_html__( 'Button Block', 'ultraaddons-elementor-lite' ),
				'type' => Controls_Manager::SWITCHER,
				'label_on' => esc_html__( 'Block', 'ultraaddons-elementor-lite' ),
				'label_off' => esc_html__( 'Inline', 'ultraaddons-elementor-lite' ),
				'return_value' => 'yes',
				'default' => 'no',
			]
		);

                $this->start_controls_tabs(
			'style_tabs'
		);
                //Normal Tab
                $this->start_controls_tab(
                        'btn_normal_tab',
                        [
                                'label' => esc_html__( 'Normal', 'ultraaddons-elementor-lite' ),
                        ]
                );
                $this->add_control(
                        '_btn_bg_color', [
                                'label' => __( 'Button Background', 'ultraaddons-elementor-lite' ),
                                'type'      => Controls_Manager::COLOR,
                                'selectors' => [
                                        '{{WRAPPER}} .ua-form .frm_fields_container .frm_button_submit' => 'background-color: {{VALUE}};',
                                ],
                        ]
                );
                 $this->add_group_control(
                        Group_Control_Border::get_type(),
                        [
                            'name' => '_btn_border',
                            'selector' => '{{WRAPPER}} .ua-form .frm_fields_container .frm_button_submit',
                        ]
                );
                $this->add_control(
                        '_btn_text_color', [
                                'label' => __( 'Button Text Color', 'ultraaddons-elementor-lite' ),
                                'type'      => Controls_Manager::COLOR,
                                'selectors' => [
                                                '{{WRAPPER}} .ua-form .frm_fields_container .frm_button_submit' => 'color: {{VALUE}};',
                                ],
                        ]
                );
        
                $this->add_group_control(
                        Group_Control_Typography::get_type(),
                        [
                                        'name' => 'btn_typography',
                                        'label' => 'Button Typography',
                                        'selector' => '{{WRAPPER}} .ua-form .frm_fields_container .frm_button_submit',

                        ]
                );
                $this->add_responsive_control(
                        '_btn_padding',
                        [
                                'label'       => esc_html__( 'Button Padding', 'ultraaddons-elementor-lite' ),
                                'type'        => Controls_Manager::DIMENSIONS,
                                'size_units'  => [ '%', 'px' ],
                                'placeholder' => [
                                        'top'    => '',
                                        'right'  => '',
                                        'bottom' => '',
                                        'left'   => '',
                                ],
                                'selectors'   => [
                                        '{{WRAPPER}} .ua-form .frm_fields_container .frm_button_submit' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                                ],
                        ]
                        );
                $this->add_responsive_control(
                        '_btn_radius',
                        [
                                'label'       => esc_html__( 'Button Radius', 'ultraaddons-elementor-lite' ),
                                'type'        => Controls_Manager::DIMENSIONS,
                                'size_units'  => [ '%', 'px' ],
                                'placeholder' => [
                                        'top'    => '',
                                        'right'  => '',
                                        'bottom' => '',
                                        'left'   => '',
                                ],
                                'separator' =>'after',
                                'selectors'   => [
                                        '{{WRAPPER}} .ua-form .frm_fields_container .frm_button_submit' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                                ],
                        ]
                        );
                $this->end_controls_tab();

                //Hover Tab
                $this->start_controls_tab(
                        'btn_hover_tab',
                        [
                                'label' => esc_html__( 'Hover', 'ultraaddons-elementor-lite' ),
                        ]
                );
                $this->add_control(
                        '_btn_bg_hover_bg', [
                                'label' => __( 'Hover Background', 'ultraaddons-elementor-lite' ),
                                'type'      => Controls_Manager::COLOR,
                                'selectors' => [
                                        '{{WRAPPER}} .ua-form .frm_fields_container .frm_button_submit:hover' => 'background: {{VALUE}};',
                                ],
                        ]
                );
                 $this->add_group_control(
                        Group_Control_Border::get_type(),
                        [
                            'name' => '_btn_hover_border',
                            'selector' => '{{WRAPPER}} .ua-form .frm_fields_container .frm_button_submit:hover',
                        ]
                );
                $this->add_control(
                        '_btn_text_hover_color', [
                                'label' => __( 'Button Text Color', 'ultraaddons-elementor-lite' ),
                                'type'      => Controls_Manager::COLOR,
                                'selectors' => [
                                        '{{WRAPPER}} .ua-form .frm_fields_container .frm_button_submit:hover' => 'color: {{VALUE}};',
                                ],
                                'default' =>'#333'
                        ]
                );
                $this->end_controls_tab();
                $this->end_controls_tabs();

                $this->end_controls_section();
        }
         //Placeholder Style Tabs
         protected function placeholder_style(){
                $this->start_controls_section(
                        'placeholder_section',
                        [
                                'label' =>  __( 'Placeholder', 'ultraaddons-elementor-lite' ) ,
                                'tab' => Controls_Manager::TAB_STYLE,
                                'condition' => [
                                        'form_id!' => '',
                                ]
                        ]
                );
                $this->add_control(
                        'placeholder_color',
                                [
                                'label' => esc_html__('Placeholder Color', 'ultraaddons-elementor-lite'),
                                'type' => Controls_Manager::COLOR,
                                'selectors' => [
                                        '{{WRAPPER}} .frm_forms input::placeholder, textarea::placeholder, select::placeholder' => 'color: {{VALUE}};',
                                ],
                                ]
                        );
                        $this->add_group_control(
                                Group_Control_Typography::get_type(),
                                [
                                    'name'                  => 'placeholder_typography',
                                    'label'                 => __('Typography', 'ultraaddons-elementor-lite'),
                                    'selector'              => '{{WRAPPER}} .frm_forms input::placeholder, textarea::placeholder, select::placeholder',
                                ]
                            );
               
            $this->end_controls_section();
            }

        private function add_basic_switcher_control( $ultraaddons_key, $title ) {
                $this->add_control(
                        $ultraaddons_key,
                        array(
                                'label' => $title,
                                'type'  => Controls_Manager::SWITCHER,
                        )
                );
        }
        /**
         * Render widget output on the frontend.
         *
         * Written in PHP and used to generate the final HTML.
         *
         * @since 1.0.0
         * @access protected
         */
        protected function render() {
                if( ! class_exists( 'FrmForm' ) )
                return;
                
                $settings    = $this->get_settings_for_display();

                $form_id     = isset( $settings['form_id'] ) ? absint( $settings['form_id'] ) : 0;
                $title       = isset( $settings['title'] ) && 'yes' === $settings['title'];
                $description = isset( $settings['description'] ) && 'yes' === $settings['description'];
                $minimize    = isset( $settings['minimize'] ) && 'yes' === $settings['minimize'];
                $btn_block    = ($settings['btn_block'] =='yes' ) ? 'btn_block' : '';

                $alert_class = (!empty($form_id)) ? '' : 'ua-alert';

                $this->add_render_attribute(
			'ua_form_class',
			[
				'class' => 'ua-form formidable ' . $btn_block . $alert_class,
			]
		);
        ?>
        <div <?php echo esc_attr( $this->get_render_attribute_string( 'ua_form_class' ) );?>>
                <?php
                echo do_shortcode(
                        '[formidable 
                        id="'. $form_id .'" 
                        title="'. $title .'" 
                        description= "'. $description .'" 
                        minimize= "' . $minimize .'" 
                        ]'
                );
                ?>
        </div>
        <?php
        }
}
