<?php
namespace UltraAddons\Widget;
/**
 * Info Box
 * 
 * @author Moktadir Rahman <codeastrology.dev2@gmail.com>
 */
if ( ! defined( 'ABSPATH' ) ) exit;

use Elementor\Controls_Manager;

use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
use Elementor\Group_Control_Typography;
use Elementor\Icons_Manager;
use Elementor\Group_Control_Border;
use Elementor\Utils;
use Elementor\Group_Control_Box_Shadow;


class Info_Box extends Base {
    use \UltraAddons\Traits\Button_Helper;
    /**
     * Set Keyword for search in
     * 
     * @return type
     */
    public function get_keywords() {
            return [ 'ultraaddons-elementor-lite', 'ua','info', 'service', 'box','icon' ];
    }
    
    protected function content_infobox(){
        $this->start_controls_section(
                    'section_sliders',
                    [
                            'label' => __( 'Info Box', 'ultraaddons-elementor-lite' ),
                    ]
            );
            
            $this->add_responsive_control(
                    'infobox_align',
                    [
                            'label' => __( 'Alignment', '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-info-box-wrapper' => 'text-align: {{VALUE}};',
                            ],
                    ]
            );
            
            $this->add_control(
                    'icon_style',
                    [
                            'label'     => esc_html__( 'Select Icon Or Image', 'ultraaddons-elementor-lite' ),
                            'type'      => Controls_Manager::SELECT,
                            'options'   => [
                                'icon'      => __( 'Icon', 'ultraaddons-elementor-lite' ),
                                'image'     => __( 'Image', 'ultraaddons-elementor-lite')
                            ],
                            'default'       => 'icon',

                    ]
            );
            
            $this->add_control(
                    'add_icon',
                    [
                            'label' => __( 'Icon', 'ultraaddons-elementor-lite' ),
                            'type' => Controls_Manager::ICONS,
                            'fa4compatibility' => 'icon',
                            'default' => [
                                    'value' => 'uicon uicon-ultraaddons',
                                    'library' => 'ultraaddons-elementor-lite',
                            ],
                            'condition' => [
                                    'icon_style' => 'icon',
                            ],
                    ]
            );
            
            $this->add_control(
                    'add_image',
                    [
                            'label'     => __( 'Select Image', 'ultraaddons-elementor-lite' ),
                            'type'      => Controls_Manager::MEDIA,
                            'default'   => [
                                'url'       => Utils::get_placeholder_image_src(),
                            ],
                            'condition' => [
                                    'icon_style' => 'image',
                            ],
                    ]
            );

            $this->add_control(
                    'view',
                    [
                            'label' => __( 'View', 'ultraaddons-elementor-lite' ),
                            'type' => Controls_Manager::SELECT,
                            'options' => [
                                    'default' => __( 'Default', 'ultraaddons-elementor-lite' ),
                                    'stacked' => __( 'Stacked', 'ultraaddons-elementor-lite' ),
                                    'framed' => __( 'Framed', 'ultraaddons-elementor-lite' ),
                            ],
                            'default' => 'stacked',
                            'prefix_class' => 'elementor-view-',
                            'condition' => [
                                    'icon_style' => 'icon',
//                                    'add_icon[library]!' => 'svg',
                            ],
                    ]
            );

            $this->add_control(
                    'shape',
                    [
                            'label' => __( 'Shape', 'ultraaddons-elementor-lite' ),
                            'type' => Controls_Manager::SELECT,
                            'options' => [
                                    'circle' => __( 'Circle', 'ultraaddons-elementor-lite' ),
                                    'square' => __( 'Square', 'ultraaddons-elementor-lite' ),
                            ],
                            'default' => 'square',
                            'condition' => [
                                    'view!' => 'default',
                                    'add_icon[value]!' => '',
                                    'icon_style' => 'icon',
                            ],
                            'prefix_class' => 'elementor-shape-',
                    ]
            );

            $this->add_control(
                    'title_text',
                    [
                            'label' => __( 'Title & Description', 'ultraaddons-elementor-lite' ),
                            'type' => Controls_Manager::TEXT,
                            'dynamic' => [
                                    'active' => true,
                            ],
                            'default' => __( 'Info Box Title', 'ultraaddons-elementor-lite' ),
                            'placeholder' => __( 'Enter your title', 'ultraaddons-elementor-lite' ),
                            'label_block' => true,
                    ]
            );
            $this->add_control(
                    'count_text',
                    [
                            'label' => __( 'Count Text', 'ultraaddons-elementor-lite' ),
                            'type' => Controls_Manager::TEXT,
                            'label_block' => true,
                    ]
            );
            $this->add_control(
                    'title_size',
                    [
                            'label' => __( 'Title HTML Tag', 'ultraaddons-elementor-lite' ),
                            'type' => Controls_Manager::SELECT,
                            'options' => [
                                    'h1' => 'H1',
                                    'h2' => 'H2',
                                    'h3' => 'H3',
                                    'h4' => 'H4',
                                    'h5' => 'H5',
                                    'h6' => 'H6',
                                    'div' => 'div',
                                    'span' => 'span',
                                    'p' => 'p',
                            ],
                            'default' => 'h3',
                    ]
            );

            $this->add_control(
                    'description_text',
                    [
                            'label' => '',
                            'type' => Controls_Manager::TEXTAREA,
                            'dynamic' => [
                                    'active' => true,
                            ],
                            'default' => __( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.', 'ultraaddons-elementor-lite' ),
                            'placeholder' => __( 'Enter your description', 'ultraaddons-elementor-lite' ),
                            'rows' => 10,
                            'separator' => 'none',
                            'show_label' => false,
                    ]
            );
            
            
            $this->add_control(
                    'wrapper_link_switch',
                    [
                            'label' => __( 'Wrapper Link Switch', 'ultraaddons-elementor-lite' ),
                            'type' => Controls_Manager::SWITCHER,
                            'label_on' => __( 'Yes', 'ultraaddons-elementor-lite' ),
                            'label_off' => __( 'No', 'ultraaddons-elementor-lite' ),
                            'return_value' => 'yes',
                    ]
            );
            
            $this->add_control(
                    'wrapper_link',
                    [
                            'label' => __( 'Wrapper Link', 'ultraaddons-elementor-lite' ),
                            'type' => Controls_Manager::URL,
                            'dynamic' => [
                                    'active' => true,
                            ],
                            'placeholder' => __( 'https://your-link.com', 'ultraaddons-elementor-lite' ),
                            'default' => [
                                    'url' => '#',
                            ],
                        'condition' => [
                            'wrapper_link_switch' => 'yes',
                        ],
                    ]
            );
            
            
            
            $this->end_controls_section();
            
    }

    protected function style_infobox(){
        $this->start_controls_section(
                    'section_style_icon',
                    [
                            'label' => __( 'Icon', 'ultraaddons-elementor-lite' ),
                            'tab'   => Controls_Manager::TAB_STYLE,
                           'condition' => [
                                    'icon_style' => 'icon',
                            ],
                    ]
            );

            $this->start_controls_tabs( 'icon_colors' );

            $this->start_controls_tab(
                    'icon_colors_normal',
                    [
                            'label' => __( 'Normal', 'ultraaddons-elementor-lite' ),
                    ]
            );

            $this->add_control(
                    'primary_color',
                    [
                            'label' => __( 'Icon Color', 'ultraaddons-elementor-lite' ),
                            'type' => Controls_Manager::COLOR,
                            'global' => [
                                    'default' => Global_Colors::COLOR_PRIMARY,
                            ],
                            'default' => '#fff',
                            'selectors' => [
                                    '{{WRAPPER}}.elementor-view-stacked .elementor-icon' => 'fill: {{VALUE}}; color: {{VALUE}};',
                                    '{{WRAPPER}}.elementor-view-framed .elementor-icon, {{WRAPPER}}.elementor-view-default .elementor-icon' => 'fill: {{VALUE}}; color: {{VALUE}}; border-color: {{VALUE}};',
                            ],
                    ]
            );

            $this->add_control(
                    'secondary_color',
                    [
                            'label' => __( 'Background Color', 'ultraaddons-elementor-lite' ),
                            'type' => Controls_Manager::COLOR,
                            'default' => '#0FC392',
                            'condition' => [
                                    'view!' => 'default',
                            ],
                            'selectors' => [
                                    '{{WRAPPER}}.elementor-view-framed .elementor-icon' => 'background-color: {{VALUE}};',
                                    '{{WRAPPER}}.elementor-view-stacked .elementor-icon' => 'background-color: {{VALUE}};',
                            ],
                    ]
            );
            
            $this->add_responsive_control(
                    'icon_space',
                    [
                            'label' => __( 'Spacing', 'ultraaddons-elementor-lite' ),
                            'type' => Controls_Manager::SLIDER,
                            'default' => [
                                    'size' => 40,
                            ],
                            'range' => [
                                    'px' => [
                                            'min' => 0,
                                            'max' => 100,
                                    ],
                            ],
                            'selectors' => [
                                    '{{WRAPPER}} .ua-info-box-icon' => 'margin-bottom: {{SIZE}}{{UNIT}};',
                                    '(mobile){{WRAPPER}} .ua-info-box-icon' => 'margin-bottom: {{SIZE}}{{UNIT}};',
                            ],
                    ]
            );

            $this->add_responsive_control(
                    'icon_size',
                    [
                            'label' => __( 'Icon Size', 'ultraaddons-elementor-lite' ),
                            'type' => Controls_Manager::SLIDER,
                            'range' => [
                                    'px' => [
                                            'min' => 6,
                                            'max' => 300,
                                    ],
                            ],
                            'default' => [
                                    'size' => 30,
                            ],
                            'selectors' => [
                                    '{{WRAPPER}} .elementor-icon' => 'font-size: {{SIZE}}{{UNIT}};',
                                    '{{WRAPPER}} .infobox-svg' => 'width: {{SIZE}}{{UNIT}};',
                            ],
                    ]
            );

            $this->add_control(
                    'icon_padding',
                    [
                            'label' => __( 'Padding', 'ultraaddons-elementor-lite' ),
                            'type' => Controls_Manager::SLIDER,
                            'selectors' => [
                                    '{{WRAPPER}} .elementor-icon' => 'padding: {{SIZE}}{{UNIT}};',
                                    '{{WRAPPER}} .ua-info-box-icon.svg' => 'padding: {{SIZE}}{{UNIT}};',
                            ],
                            'range' => [
                                    'em' => [
                                            'min' => 0,
                                            'max' => 5,
                                    ],
                            ],
                            'condition' => [
                                    'view!' => 'default',
                            ],
                    ]
            );

            $this->add_control(
                    'rotate',
                    [
                            'label' => __( 'Rotate', 'ultraaddons-elementor-lite' ),
                            'type' => Controls_Manager::SLIDER,
                            'default' => [
                                    'size' => 0,
                                    'unit' => 'deg',
                            ],
                            'selectors' => [
                                    '{{WRAPPER}} .elementor-icon i' => 'transform: rotate({{SIZE}}{{UNIT}});',
                            ],
                    ]
            );

            $this->add_control(
                    'border_width',
                    [
                            'label' => __( 'Border Width', 'ultraaddons-elementor-lite' ),
                            'type' => Controls_Manager::DIMENSIONS,
                            'selectors' => [
                                    '{{WRAPPER}} .elementor-icon' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                            ],
                            'condition' => [
                                    'view' => 'framed',
                            ],
                    ]
            );

            $this->add_control(
                    'border_radius',
                    [
                            'label' => __( 'Border Radius', 'ultraaddons-elementor-lite' ),
                            'type' => Controls_Manager::DIMENSIONS,
                            'size_units' => [ 'px', '%' ],
                            'selectors' => [
                                    '{{WRAPPER}} .elementor-icon' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                            ],
                            'condition' => [
                                    'view!' => 'default',
                            ],
                    ]
            );
            $this->add_group_control(
                Group_Control_Box_Shadow::get_type(),
                [
                        'name' => '_iconshadow',
                        'label' => __( 'Icon Shadow', 'ultraaddons-elementor-lite' ),
                        'selector' => '{{WRAPPER}} .elementor-icon',
                ]
        );

            $this->end_controls_tab();

            $this->start_controls_tab(
                    'icon_colors_hover',
                    [
                            'label' => __( 'Hover', 'ultraaddons-elementor-lite' ),
                    ]
            );

            $this->add_control(
                    'hover_primary_color',
                    [
                            'label' => __( 'Icon Color', 'ultraaddons-elementor-lite' ),
                            'type' => Controls_Manager::COLOR,
                            'default' => '',
                            'selectors' => [
                                    '{{WRAPPER}}.elementor-view-stacked:hover .elementor-icon' => 'background-color: {{VALUE}};',
                                    '{{WRAPPER}}.elementor-view-framed:hover .elementor-icon, {{WRAPPER}}.elementor-view-default:hover .elementor-icon' => 'fill: {{VALUE}}; color: {{VALUE}}; border-color: {{VALUE}};',
                            ],
                    ]
            );

            $this->add_control(
                    'hover_secondary_color',
                    [
                            'label' => __( 'Background Color', 'ultraaddons-elementor-lite' ),
                            'type' => Controls_Manager::COLOR,
                            'default' => '',
                            'condition' => [
                                    'view!' => 'default',
                            ],
                            'selectors' => [
                                    '{{WRAPPER}}.elementor-view-framed:hover .elementor-icon' => 'background-color: {{VALUE}};',
                                    '{{WRAPPER}}.elementor-view-stacked:hover .elementor-icon' => 'fill: {{VALUE}}; color: {{VALUE}};',
                            ],
                    ]
            );
            
            $this->add_responsive_control(
                    'icon_space_hover',
                    [
                            'label' => __( 'Spacing', 'ultraaddons-elementor-lite' ),
                            'type' => Controls_Manager::SLIDER,

                            'range' => [
                                    'px' => [
                                            'min' => 0,
                                            'max' => 100,
                                    ],
                            ],
                            'selectors' => [
                                    '{{WRAPPER}}:hover .ua-info-box-icon' => 'margin-bottom: {{SIZE}}{{UNIT}};',
                                    '(mobile){{WRAPPER}}:hover .ua-info-box-icon' => 'margin-bottom: {{SIZE}}{{UNIT}};',
                            ],
                    ]
            );

            $this->add_responsive_control(
                    'hover_icon_size',
                    [
                            'label' => __( 'Size', 'ultraaddons-elementor-lite' ),
                            'type' => Controls_Manager::SLIDER,
                            'range' => [
                                    'px' => [
                                            'min' => 6,
                                            'max' => 300,
                                    ],
                            ],
//                            'default' => [
//                                    'size' => 30,
//                            ],
                            'selectors' => [
                                    '{{WRAPPER}}:hover .elementor-icon' => 'font-size: {{SIZE}}{{UNIT}};',
                            ],
                    ]
            );

            $this->add_control(
                    'hover_icon_padding',
                    [
                            'label' => __( 'Padding', 'ultraaddons-elementor-lite' ),
                            'type' => Controls_Manager::SLIDER,
                            'selectors' => [
                                    '{{WRAPPER}}:hover .elementor-icon' => 'padding: {{SIZE}}{{UNIT}};',
                            ],
                            'range' => [
                                    'em' => [
                                            'min' => 0,
                                            'max' => 5,
                                    ],
                            ],
                            'condition' => [
                                    'view!' => 'default',
                            ],
                    ]
            );

            $this->add_control(
                    'hover_rotate',
                    [
                            'label' => __( 'Rotate', 'ultraaddons-elementor-lite' ),
                            'type' => Controls_Manager::SLIDER,
//                            'default' => [
//                                    'size' => 0,
//                                    'unit' => 'deg',
//                            ],
                            'selectors' => [
                                    '{{WRAPPER}}:hover .elementor-icon i' => 'transform: rotate({{SIZE}}{{UNIT}});',
                            ],
                    ]
            );

            $this->add_control(
                    'hover_border_width',
                    [
                            'label' => __( 'Border Width', 'ultraaddons-elementor-lite' ),
                            'type' => Controls_Manager::DIMENSIONS,
                            'selectors' => [
                                    '{{WRAPPER}}:hover .elementor-icon' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                            ],
                            'condition' => [
                                    'view' => 'framed',
                            ],
                    ]
            );

            $this->add_control(
                    'hover_border_radius',
                    [
                            'label' => __( 'Border Radius', 'ultraaddons-elementor-lite' ),
                            'type' => Controls_Manager::DIMENSIONS,
                            'size_units' => [ 'px', '%' ],
                            'selectors' => [
                                    '{{WRAPPER}}:hover .elementor-icon' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                            ],
                            'condition' => [
                                    'view!' => 'default',
                            ],
                    ]
            );

            $this->end_controls_tab();

            $this->end_controls_tabs();

            

            $this->end_controls_section();
    }

    protected function style_content(){
        $this->start_controls_section(
                'section_style_content',
                [
                        'label' => __( 'Content', 'ultraaddons-elementor-lite' ),
                        'tab'   => Controls_Manager::TAB_STYLE,
                ]
        );

        $this->start_controls_tabs( 'content_tabs' );

        $this->start_controls_tab(
                'style_content_normal',
                [
                        'label' => __( 'Normal', 'ultraaddons-elementor-lite' ),
                ]
        );
        
        
        
        $this->add_control(
                'heading_title',
                [
                        'label' => __( 'Title', 'ultraaddons-elementor-lite' ),
                        'type' => Controls_Manager::HEADING,
                        'separator' => 'before',
                ]
        );

        $this->add_responsive_control(
                'title_bottom_space',
                [
                        'label' => __( 'Spacing', 'ultraaddons-elementor-lite' ),
                        'type' => Controls_Manager::SLIDER,
                        'range' => [
                                'px' => [
                                        'min' => 0,
                                        'max' => 100,
                                ],
                        ],
                        'selectors' => [
                                '{{WRAPPER}} .elementor-icon-box-title' => 'margin-bottom: {{SIZE}}{{UNIT}};',
                        ],
                ]
        );

        $this->add_control(
                'title_color',
                [
                        'label' => __( 'Color', 'ultraaddons-elementor-lite' ),
                        'type' => Controls_Manager::COLOR,
                        'default' => '#21272c',
                        'selectors' => [
                                '{{WRAPPER}} .ua-info-box-content .elementor-icon-box-title' => 'color: {{VALUE}};',
                                '{{WRAPPER}} .ua-info-box-content .elementor-icon-box-title a' => 'color: {{VALUE}};',
                        ],
                        'global' => [
                                'default' => Global_Colors::COLOR_PRIMARY,
                        ],
                ]
        );

        $this->add_group_control(
                Group_Control_Typography::get_type(),
                [
                        'name' => 'title_typography',
                        'selector' => '{{WRAPPER}} .ua-info-box-content .elementor-icon-box-title, {{WRAPPER}} .ua-info-box-content .elementor-icon-box-title a',
                        'global' => [
                                'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
                        ],

                ]
        );
        $this->add_responsive_control(
                'title_padding',
                [
                        'label' => __( 'Title Padding', 'ultraaddons-elementor-lite' ),
                        'type' => Controls_Manager::DIMENSIONS,
                        'size_units' => [ 'px'],
                        'selectors' => [
                                '{{WRAPPER}} .elementor-icon-box-title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                        ],
                ]
        );

        $this->add_control(
                'heading_description',
                [
                        'label' => __( 'Description', 'ultraaddons-elementor-lite' ),
                        'type' => Controls_Manager::HEADING,
                        'separator' => 'before',
                ]
        );
        
        $this->add_responsive_control(
                'description_bottom_space',
                [
                        'label' => __( 'Spacing', 'ultraaddons-elementor-lite' ),
                        'type' => Controls_Manager::SLIDER,
                        'range' => [
                                'px' => [
                                        'min' => 0,
                                        'max' => 100,
                                ],
                        ],
                        'selectors' => [
                                '{{WRAPPER}} .elementor-icon-box-description' => 'margin-bottom: {{SIZE}}{{UNIT}};',
                        ],
                ]
        );


        $this->add_control(
                'description_color',
                [
                        'label' => __( 'Color', 'ultraaddons-elementor-lite' ),
                        'type' => Controls_Manager::COLOR,
                        'default' => '',
                        'selectors' => [
                                '{{WRAPPER}} .ua-info-box-content .elementor-icon-box-description' => 'color: {{VALUE}};',
                        ],
                        'global' => [
                                'default' => Global_Colors::COLOR_TEXT,
                        ],
                ]
        );

        $this->add_group_control(
                Group_Control_Typography::get_type(),
                [
                        'name' => 'description_typography',
                        'selector' => '{{WRAPPER}} .ua-info-box-content .elementor-icon-box-description',
                        'global' => [
                                'default' => Global_Typography::TYPOGRAPHY_TEXT,
                        ],
                ]
        );
       
        $this->add_responsive_control(
                'description_padding',
                [
                        'label' => __( 'Description Padding', 'ultraaddons-elementor-lite' ),
                        'type' => Controls_Manager::DIMENSIONS,
                        'size_units' => [ 'px'],
                        'selectors' => [
                                '{{WRAPPER}} .elementor-icon-box-description'=> 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                        ],
                ]
        );
        $this->end_controls_tab();
        
        
        
        $this->start_controls_tab(
                'style_content_normal_hover',
                [
                        'label' => __( 'Hover', 'ultraaddons-elementor-lite' ),
                ]
        );
        
        
        $this->add_control(
                'heading_title_hover',
                [
                        'label' => __( 'Title', 'ultraaddons-elementor-lite' ),
                        'type' => Controls_Manager::HEADING,
                        'separator' => 'before',
                ]
        );

        $this->add_responsive_control(
                'title_bottom_space_hover',
                [
                        'label' => __( 'Spacing', 'ultraaddons-elementor-lite' ),
                        'type' => Controls_Manager::SLIDER,
                        'range' => [
                                'px' => [
                                        'min' => 0,
                                        'max' => 100,
                                ],
                        ],
                        'selectors' => [
                                '{{WRAPPER}}:hover .elementor-icon-box-title' => 'margin-bottom: {{SIZE}}{{UNIT}};',
                        ],
                ]
        );

        $this->add_control(
                'title_color_hover',
                [
                        'label' => __( 'Color', 'ultraaddons-elementor-lite' ),
                        'type' => Controls_Manager::COLOR,
//                        'default' => '#21272c',
                        'selectors' => [
                                '{{WRAPPER}}:hover .ua-info-box-content .elementor-icon-box-title' => 'color: {{VALUE}};',
                                '{{WRAPPER}}:hover .ua-info-box-content .elementor-icon-box-title a' => 'color: {{VALUE}};',
                        ],
                        'global' => [
                                'default' => Global_Colors::COLOR_PRIMARY,
                        ],
                ]
        );

        $this->add_group_control(
                Group_Control_Typography::get_type(),
                [
                        'name' => 'title_typography_hover',
                        'selector' => '{{WRAPPER}} .ua-info-box-content .elementor-icon-box-title, {{WRAPPER}} .ua-info-box-content .elementor-icon-box-title a',
                        'global' => [
                                'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
                        ],

                ]
        );

        $this->add_control(
                'heading_description_hover',
                [
                        'label' => __( 'Description', 'ultraaddons-elementor-lite' ),
                        'type' => Controls_Manager::HEADING,
                        'separator' => 'before',
                ]
        );

        $this->add_responsive_control(
                'description_bottom_space_hover',
                [
                        'label' => __( 'Spacing', 'ultraaddons-elementor-lite' ),
                        'type' => Controls_Manager::SLIDER,
                        'range' => [
                                'px' => [
                                        'min' => 0,
                                        'max' => 100,
                                ],
                        ],
                        'selectors' => [
                                '{{WRAPPER}}:hover .elementor-icon-box-description' => 'margin-bottom: {{SIZE}}{{UNIT}};',
                        ],
                ]
        );
        
        $this->add_control(
                'description_color_hover',
                [
                        'label' => __( 'Color', 'ultraaddons-elementor-lite' ),
                        'type' => Controls_Manager::COLOR,
                        'default' => '',
                        'selectors' => [
                                '{{WRAPPER}}:hover .ua-info-box-content .elementor-icon-box-description' => 'color: {{VALUE}};',
                        ],
                        'global' => [
                                'default' => Global_Colors::COLOR_TEXT,
                        ],
                ]
        );

        $this->add_group_control(
                Group_Control_Typography::get_type(),
                [
                        'name' => 'description_typography_hover',
                        'selector' => '{{WRAPPER}}:hover .ua-info-box-content .elementor-icon-box-description',
                        'global' => [
                                'default' => Global_Typography::TYPOGRAPHY_TEXT,
                        ],
                ]
        );

        $this->end_controls_tab();
        
        
        $this->end_controls_tabs();

        $this->end_controls_section();

    }
    /**
     * @author B M Rafiul Alam
     * email: bmrafiul.alam@gamil.
     * @since 1.1.0.11
     */
        protected function style_box(){

                        $this->start_controls_section(
                                'box_section',
                                [
                                        'label' => esc_html__( 'Box', 'ultraaddons-elementor-lite' ),
                                        'tab' => Controls_Manager::TAB_STYLE,
                                ]
                        );
                $this->add_responsive_control(
                        'wrapper_link_padding',
                        [
                                'label' => __( 'Padding', 'ultraaddons-elementor-lite' ),
                                'type' => Controls_Manager::DIMENSIONS,
                                'description' => __( 'For setting wrapper link padding, Please set zero padding for main box from Advance Tab.', 'ultraaddons-elementor-lite' ),
                                'size_units' => [ 'px', '%' ],
                                'default'   => [
                                        'top' => 30,
                                        'left' => 15,
                                        'right' => 15,
                                        'bottom' => 30,
                                        'unit' => 'px',
                                ],
                                'selectors' => [
                                        '{{WRAPPER}} .elementor-widget-container' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                                ],
                        ]
                );
                $this->add_responsive_control(
                        'wrapper_border_radius',
                        [
                                'label' => __( 'Radius', 'ultraaddons-elementor-lite' ),
                                'type' => Controls_Manager::DIMENSIONS,
                                'size_units' => [ 'px', '%' ],
                                'selectors' => [
                                        '{{WRAPPER}} .elementor-widget-container' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                                ],
                        ]
                );
        
        
                $this->add_group_control(
                        Group_Control_Box_Shadow::get_type(),
                        [
                                'name' => 'box_shadow',
                                'label' => esc_html__( 'Box Shadow', 'ultraaddons-elementor-lite' ),
                                'selector' => '{{WRAPPER}} .elementor-widget-container',
                        ]
                );


                        $this->end_controls_section();
        }
         protected function style_image(){

                $this->start_controls_section(
                        'image_section',
                        [
                                'label' => esc_html__( 'Image', 'ultraaddons-elementor-lite' ),
                                'tab' => Controls_Manager::TAB_STYLE,
                                'condition' => [
                                    'icon_style' => 'image',
                                ],
                        ]
                );
                $this->add_responsive_control(
                    'image_size',
                    [
                            'label' => __( 'Image Size', 'ultraaddons-elementor-lite' ),
                            'type' => Controls_Manager::SLIDER,
                            'size_units' => [ 'px', '%' ],
                            'default' => [
                                    'size' => 40,
                            ],
                            'range' => [
                                    'px' => [
                                            'min' => 0,
                                            'max' => 1000,
                                    ],
                                    '%' => [
                                            'min' => 0,
                                            'max' => 100,
                                    ],
                            ],
                            'selectors' => [
                                    '{{WRAPPER}} .infobox-image' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
                            ],
                    ]
                );
                $this->add_control(
                'image_margin',
                [
                        'label' => __( 'Image Margin', 'ultraaddons-elementor-lite' ),
                        'type' => Controls_Manager::DIMENSIONS,
                        'size_units' => [ 'px', '%' ],
                        'selectors' => [
                                '{{WRAPPER}} .infobox-image' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                        ],
                ]
        );
         $this->add_control(
                'image_radius',
                [
                        'label' => __( 'Image Radius', 'ultraaddons-elementor-lite' ),
                        'type' => Controls_Manager::DIMENSIONS,
                        'size_units' => [ 'px', '%' ],
                        'selectors' => [
                                '{{WRAPPER}} .infobox-image' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                        ],
                ]
        );

                $this->end_controls_section();
        }
        
    protected function style_count(){

        $this->start_controls_section(
                'counter_section',
                [
                        'label' => esc_html__( 'Counter', 'ultraaddons-elementor-lite' ),
                        'tab' => Controls_Manager::TAB_STYLE,
                ]
        );

        $this->add_control(
                'count_alignment',
                [
                        'type' => Controls_Manager::CHOOSE,
                        'label' => esc_html__( 'Horizontal Position', 'ultraaddons-elementor-lite' ),
                        'options' => [
                                'left' => [
                                        'title' => esc_html__( 'Left', 'ultraaddons-elementor-lite' ),
                                        'icon' => 'eicon-arrow-left',
                                ],
                                'right' => [
                                        'title' => esc_html__( 'Right', 'ultraaddons-elementor-lite' ),
                                        'icon' => 'eicon-arrow-right',
                                ],
                        ],
                        'default' => 'right',
                        
                ]
	);
         $this->add_control(
                'count_position',
                [
                        'type' => Controls_Manager::CHOOSE,
                        'label' => esc_html__( 'Vertical Position', 'ultraaddons-elementor-lite' ),
                        'options' => [
                                'top' => [
                                        'title' => esc_html__( 'Top', 'ultraaddons-elementor-lite' ),
                                        'icon' => 'eicon-arrow-up',
                                ],
                                'bottom' => [
                                        'title' => esc_html__( 'Bottom', 'ultraaddons-elementor-lite' ),
                                        'icon' => 'eicon-arrow-down',
                                ],
                               
                        ],
                        'toggle' => true,
                        'default' => 'top',
                ]
	);
        $this->add_group_control(
                Group_Control_Typography::get_type(),
                [
                        'name' => 'counter_typography',
                        'selector' => '{{WRAPPER}} .count-text',
                ]
        );
        $this->add_control(
                'counter_color',
                [
                        'label' => __( 'Text Color', 'ultraaddons-elementor-lite' ),
                        'type' => Controls_Manager::COLOR,
                        'default' => '#222',
                        'selectors' => [
                                '{{WRAPPER}} .count-text' => 'color: {{VALUE}};',
                        ],
                ]
        );
        $this->add_control(
                'counter_bg',
                [
                        'label' => __( 'Background Color', 'ultraaddons-elementor-lite' ),
                        'type' => Controls_Manager::COLOR,
                        'default' => '#ddd',
                        'selectors' => [
                                '{{WRAPPER}} .count-text' => 'background-color: {{VALUE}};',
                        ],
                ]
        );
        $this->add_control(
                'count_radius',
                [
                        'label' => __( 'Border Radius', 'ultraaddons-elementor-lite' ),
                        'type' => Controls_Manager::DIMENSIONS,
                        'size_units' => [ 'px', '%' ],
                        'selectors' => [
                                '{{WRAPPER}} .count-text' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                        ],
                ]
        );
        
         $this->add_control(
                'count_padding',
                [
                        'label' => __( 'Padding', 'ultraaddons-elementor-lite' ),
                        'type' => Controls_Manager::DIMENSIONS,
                        'size_units' => [ 'px', '%' ],
                        'selectors' => [
                                '{{WRAPPER}} .count-text' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                        ],
                ]
        );
        $this->add_responsive_control(
                'counter_size',
                [
                        'label' => __( 'Size', 'ultraaddons-elementor-lite' ),
                        'type' => Controls_Manager::SLIDER,
                        'default' => [
                                'size' => 40,
                        ],
                        'range' => [
                                'px' => [
                                        'min' => 40,
                                        'max' => 100,
                                ],
                        ],
                        'selectors' => [
                                '{{WRAPPER}} .count-text' => 'height:{{SIZE}}{{UNIT}}; width:{{SIZE}}{{UNIT}};', 
                        ],
                ]
        );
       
        $this->add_group_control(
                Group_Control_Box_Shadow::get_type(),
                [
                        'name' => 'count_shadow',
                        'label' => esc_html__( 'Box Shadow', 'ultraaddons-elementor-lite' ),
                        'selector' => '{{WRAPPER}} .count-text',
                ]
        );

        $this->end_controls_section();
            

    }
        /**
     * Register 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->btn_border_color = '#e2ebf1';
        
        $this->content_infobox();
        
        $this->style_infobox();

        $this->style_image();
        
        $this->style_content();
            
        /**
         * Button Control Load using Trait
         * from Button Helper Trait
         */
        $this->button_register_controls();

        $this->style_box();

        $this->style_count();
    }
    
    
    
    /**
     * Get Image Icon.
     * 
     * @access protected
     * 
     * @since 1.0.0
     */
    public function get_image_icon(){
        $settings   = $this->get_settings_for_display();
        $this->add_render_attribute( 'icon', 'class', [ 'elementor-icon' ] );
        $this->add_render_attribute( 'icon_wrapper', 'class', 'ua-info-box-icon' );

        $icon_tag = 'span';

        if ( ! isset( $settings['add_icon'] ) && ! Icons_Manager::is_migration_allowed() ) {
                // add old default
                $settings['add_icon'] = 'uicon uicon-ultraaddons';
        }

        $has_icon = ! empty( $settings['add_icon'] );

        if ( $has_icon ) {
            if( is_string( $settings['add_icon']['value'] ) ){
                $this->add_render_attribute( 'i', 'class', $settings['add_icon'] );
            }
                
                $this->add_render_attribute( 'i', 'aria-hidden', 'true' );
        }
        $svg_library_bool = false;
        $add_icon= isset($settings['add_icon']['library'] );
        if($add_icon == 'svg'){
            $svg_library_bool = true;
        }
        

        $icon_attributes = $this->get_render_attribute_string( 'icon' );


        if ( ! $has_icon && ! empty( $settings['add_icon']['value'] ) ) {
                $has_icon = true;
        }
        $migrated = isset( $settings['__fa4_migrated']['add_icon'] );
        $is_new = ! isset( $settings['add_icon'] ) && Icons_Manager::is_migration_allowed();
        
        $icon_style = isset( $settings['icon_style'] ) ? $settings['icon_style'] : 'icon';
        $add_image  = isset( $settings['add_image']['url'] ) ? $settings['add_image']['url'] : '';
        $add_icon   = !empty( $settings['add_icon']['value'] ) && is_string( $settings['add_icon']['value'] ) ? $settings['add_icon']['value'] : false;
        $svg        = !empty( $settings['add_icon']['value']['url'] ) && is_string( $settings['add_icon']['value']['url'] ) ? $settings['add_icon']['value']['url'] : false;

        if ( $has_icon || 'image' == $icon_style ) { ?>
        <div <?php echo esc_attr( $this->get_render_attribute_string( 'icon_wrapper' ) ); ?>>
            <?php if( 'icon' == $icon_style ) { ?>
                <<?php echo esc_attr( implode( ' ', [ $icon_tag, $icon_attributes ] ) ); ?>>
                    <?php
                    if ( $is_new || $svg_library_bool ) {
                            Icons_Manager::render_icon( $settings['add_icon'], [ 'aria-hidden' => 'true' ] );
                    } elseif ( ! empty( $settings['add_icon'] ) ) {?>
                            <i <?php echo esc_attr( $this->get_render_attribute_string( 'i' ) ); ?>></i>
                    <?php } ?>
                </<?php echo esc_attr( $icon_tag ); ?>>
            <?php } elseif( 'image' == $icon_style ) { ?>
                    <img class="infobox-image" src="<?php echo esc_url( $add_image );?>" alt="" />
            <?php } ?>
            <?php if(!empty($settings['count_text'])): ?>
                <div class="count-text count-<?php echo esc_attr( $settings['count_alignment']);?> count-<?php echo esc_attr( $settings['count_position']);?> ">
                        <?php echo esc_html( $settings['count_text'] ); ?>
                </div>
             <?php endif;?>
        </div>
        <?php 
        }
    }

    /**
     * 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() {
            $settings = $this->get_settings_for_display();
            $icon_tag = 'span';
            $this->add_render_attribute( 'wrapper-tag', 'class', 'ua-info-box-wrapper' );
            $this->add_render_attribute( 'description_text', 'class', 'elementor-icon-box-description' );
            $this->add_inline_editing_attributes( 'title_text', 'none' );
            $this->add_inline_editing_attributes( 'description_text' );
            
        
        $wrapper_link_switch = !empty( $settings['wrapper_link_switch'] ) ? true : false;
        $button_show = true;
        $wrapper_tag = 'div';
        
        if( $wrapper_link_switch & ! empty( $settings['btn_link']['url'] ) ){
            $wrapper_tag = 'a';
            $this->add_link_attributes( 'wrapper-tag', $settings['wrapper_link'] );
            $button_show = false;
        }
        
    ?>
    <<?php echo esc_attr( $wrapper_tag ); ?> <?php echo esc_attr( $this->get_render_attribute_string( 'wrapper-tag' ) ); ?>>
        <?php $this->get_image_icon(); ?>
        <div class="ua-info-box-content">
            <<?php echo esc_attr( $settings['title_size'] ); ?> class="elementor-icon-box-title">
                    <<?php echo esc_attr( $icon_tag ); ?><?php echo esc_attr( $this->get_render_attribute_string( 'title_text' ) ); ?>><?php echo esc_html( $settings['title_text'] ); ?></<?php echo esc_attr( $icon_tag ); ?>>
            </<?php echo esc_attr( $settings['title_size'] ); ?>>
            <?php if ( ! ultraaddons_widget_data_is_empty( $settings['description_text'] ) ) : ?>
            <p <?php echo esc_attr( $this->get_render_attribute_string( 'description_text' ) ); ?>><?php echo esc_html( $settings['description_text'] ); ?></p>
            <?php endif; ?>
        </div>
        <?php 
        if( $button_show ){
            $this->button_render();
        }
        ?>
    </<?php echo esc_attr( $wrapper_tag ); ?>>
    <?php
        
    }

}
