<?php

namespace XIMSAPLUGIN\Element;

use Elementor\Controls_Manager;
use Elementor\Controls_Stack;
use Elementor\Group_Control_Typography;
use Elementor\Scheme_Typography;
use Elementor\Scheme_Color;
use Elementor\Group_Control_Border;
use Elementor\Repeater;
use Elementor\Widget_Base;
use Elementor\Utils;
use Elementor\Group_Control_Text_Shadow;
use Elementor\Plugin;

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

class livechat_footer extends Widget_Base {

	/**
	 * Get widget name.
	 *
	 * Retrieve Elementor widget name.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget name.
	 */
	public function get_name() {
		return 'livechat-footer';
	}

	/**
	 * Get widget title.
	 *
	 * Retrieve Elementor widget title.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget title.
	 */
	public function get_title() {
		return esc_html__( 'Livechat Footer', 'ximsa' );
	}

	/**
	 * Get widget icon.
	 *
	 * Retrieve Elementor widget icon.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget icon.
	 */
	public function get_icon() {
		return 'gl-custom-icon';
	}

	/**
	 * Get widget categories.
	 *
	 * Retrieve the list of categories the Elementor widget belongs to.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return array Widget categories.
	 */
	public function get_categories() {
		return [ 'ximsa' ];
	}

	/**
	 * Register Elementor 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->start_controls_section(
            'footer_content',
            [
                'label' => __('Footer Content', 'ximsa'),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
            ]
        );
        $this->add_control(
            'footer_bg',
            [
                'label' => __('Footer BG', 'ximsa'),
                'type' => Controls_Manager::MEDIA,
            ]
        );
       
        $this->add_control(
            'logo',
            [
                'label' => __('Choose Custom Logo', 'ximsa'),
                'type' => Controls_Manager::MEDIA,
            ]
        );
        $this->add_control(
            'about_text',
            [
                'label' => __('About Text', 'ximsa'),
                'type' => Controls_Manager::TEXTAREA,
            ]
        );
        $repeater = new \Elementor\Repeater();
        
        $repeater->add_control(
			'icons',
			[
				'label' => esc_html__( 'Icon', 'ximsa' ),
				'type' => Controls_Manager::ICONS,
                'label_block' => true,
			]
		);
        
        $repeater->add_control(
			'link_url',
			[
				'label' => esc_html__( 'Link URL', 'ximsa' ),
				'type' => Controls_Manager::URL,
                'label_block' => true,
			]
		);
        
        $this->add_control(
			'socialicons',
			[
				'label' => esc_html__( 'Social Icon', 'ximsa' ),
				'type' => Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
			]
		);
        $this->add_control(
            'address_title',
            [
                'label' => __('Address Title', 'ximsa'),
                'type' => Controls_Manager::TEXT,
            ]
        );
        
        
        $repeater = new \Elementor\Repeater();
        
        $repeater->add_control(
			'icon',
			[
				'label' => esc_html__( 'Icon', 'ximsa' ),
				'type' => Controls_Manager::ICONS,
                'label_block' => true,
			]
		);
        
        $repeater->add_control(
			'con_info',
			[
				'label' => esc_html__( 'Infos', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
                'label_block' => true,
			]
		);
        
        $this->add_control(
			'contactinfo',
			[
				'label' => esc_html__( 'Contact Info', 'ximsa' ),
				'type' => Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
			]
		);
        $this->add_control(
            'links_title',
            [
                'label' => __('Links Title', 'ximsa'),
                'type' => Controls_Manager::TEXT,
            ]
        );
        $this->add_control(
            'links_nav',
            [
                'label' => __('Links Menu', 'ximsa'),
                'type' => Controls_Manager::SELECT2,
                'options' =>  ximsa_menu_selector(),
                'multiple' => false,
                'label_block' => true,
            ]
        );
        $this->add_control(
            'links_nav2',
            [
                'label' => __('Links Nav Menu', 'ximsa'),
                'type' => Controls_Manager::SELECT2,
                'options' =>  ximsa_menu_selector(),
                'multiple' => false,
                'label_block' => true,
            ]
        );
        $this->add_control(
            'newslater_title',
            [
                'label' => __('Newslater Title', 'ximsa'),
                'type' => Controls_Manager::TEXT,
            ]
        );
        $this->add_control(
            'newslater_text',
            [
                'label' => __('Newslater Text', 'ximsa'),
                'type' => Controls_Manager::TEXTAREA,
            ]
        );
        $this->add_control(
            'newslater_form',
            [
                'label' => __('Newslater Form Shortcode', 'ximsa'),
                'type' => Controls_Manager::TEXTAREA,
            ]
        );
        
        $this->add_control(
            'newslater_lower_text',
            [
                'label' => __('Newslater Lower Text', 'ximsa'),
                'type' => Controls_Manager::TEXTAREA,
            ]
        );
        $this->add_control(
            'footer_copyright',
            [
                'label' => __('Footer Copyright', 'ximsa'),
                'type' => Controls_Manager::TEXTAREA,
                'label_block' => true,
            ]
        );
        
        $this->end_controls_section();


        $this->start_controls_section(
            'Header_container_style',
            [
                'label' => __('Header Container Style', 'ximsa'),
                'tab' => \Elementor\Controls_Manager::TAB_STYLE,
            ]
        );
        $this->add_responsive_control(
            'logo_max_width',
            [
                'label' => esc_html__( 'Logo Width', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::SLIDER,
                'size_units' => [ 'px', '%' ],
                'range' => [
                    'px' => [
                        'min' => 0,
                        'max' => 1920,
                        'step' => 1,
                    ],
                    '%' => [
                        'min' => 0,
                        'max' => 100,
                    ],
                ],
                'selectors' => [
                    '{{WRAPPER}} .footer-style-insurance .logo-widget .logo img' => 'max-width: {{SIZE}}{{UNIT}};',
                ],
            ]
        );
        
        $this->add_control(
            'main_nav_color',
            [
                'label' => esc_html__( 'Nav link Color', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .footer-widget ul li a, .footer-widget ol li a' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_control(
            'main_nav_hover_color',
            [
                'label' => esc_html__( 'Main Nav Hover Color', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .footer-widget ul li a:hover, .footer-widget ol li a:hover' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'label' => esc_html__( 'Main Nav Typo', 'ximsa' ),
                'name' => 'main_nav_typography',
                'selector' => '{{WRAPPER}} .footer-widget ul li a, .footer-widget ol li a',
            ]
        );
        
        
        $this->add_control(
            'copyright_txt',
            [
                'label' => esc_html__( 'Copyright Text Color', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .footer-style-insurance .footer-bottom .copyright' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'label' => esc_html__( 'Copyright Title', 'ximsa' ),
                'name' => 'cpr_title_typography',
                'selector' => '{{WRAPPER}} .footer-style-insurance .footer-bottom .copyright',
            ]
        );
        $this->add_control(
            'social_icon_clr',
            [
                'label' => esc_html__( 'Social Icon Color', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .footer-style-insurance .social-box li a' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_control(
            'social_icon_hover_clr',
            [
                'label' => esc_html__( 'Social Icon Hover Color', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .footer-style-insurance .social-box li a:hover' => 'color: {{VALUE}}',
                ],
            ]
        );

        $this->add_control(
            'heading_title_st',
            [
                'label' => esc_html__( 'Title Color', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .footer-style-insurance h4' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'label' => esc_html__( 'Title', 'ximsa' ),
                'name' => 'hd_title_typography',
                'selector' => '{{WRAPPER}} .footer-style-insurance h4',
            ]
        );
        $this->add_control(
            'about_txt_cl',
            [
                'label' => esc_html__( 'About Text Color', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .footer-style-insurance .logo-widget .text' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'label' => esc_html__( 'Title', 'ximsa' ),
                'name' => 'about_txt_typography',
                'selector' => '{{WRAPPER}} .footer-style-insurance .logo-widget .text',
            ]
        );
        $this->add_control(
            'contact_info_cl',
            [
                'label' => esc_html__( 'Contact Info Color', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .footer-style-insurance .list-list li' => 'color: {{VALUE}}',
                ],
            ]
        );
        
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'label' => esc_html__( 'Title', 'ximsa' ),
                'name' => 'con_txt_typography',
                'selector' => '{{WRAPPER}} .footer-style-insurance .list-list li',
            ]
        );
        $this->add_control(
            'section_bg_cl',
            [
                'label' => esc_html__( 'Section BG Color', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .footer-style-insurance' => 'background-color: {{VALUE}}',
                ],
            ]
        );
        $this->end_controls_section();
        $this->start_controls_section(
            'button__content',
            [
                'label' => __( 'Button Style', 'ximsa' ),
                'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
            ]
        );
        
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name'           => 'btn_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .footer-style-insurance .info-widget .contact-btn
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        
        $this->start_controls_tabs( '_banner_button_1' );
        $this->start_controls_tab(
            '_glow-extension_btn__banner_normal',
            [
                'label' => esc_html__( 'Normal', 'ximsa' ),
            ]
        );
        $this->add_control(
            'btn__color',
            [
                'label'     => esc_html__( 'Color', 'ximsa' ),
                'type'      => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .footer-style-insurance .info-widget .contact-btn' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Background::get_type(),
            [
                'name'     => 'btn_bg_color',
                'label'    => __( 'Background', 'ximsa' ),
                'types'    => ['classic', 'gradient'],
                'exclude'  => ['image'],
                'selector' => '
                    {{WRAPPER}} .footer-style-insurance .info-widget .contact-btn
                ',
            ]
        );
        $this->add_responsive_control(
            'btn_border_radious',
            [
                'label'      => esc_html__( 'Border Radius', 'ximsa' ),
                'type'       => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%'],
                'selectors'  => [
                    '{{WRAPPER}} .footer-style-insurance .info-widget .contact-btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );
        
        $this->end_controls_tab();
        $this->start_controls_tab(
            '_glow-extension_btn_hover',
            [
                'label' => esc_html__( 'Hover', 'ximsa' ),
            ]
        );
        $this->add_control(
            'btn__hover_color',
            [
                'label'     => esc_html__( 'Color', 'ximsa' ),
                'type'      => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .footer-style-insurance .info-widget .contact-btn:hover' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Background::get_type(),
            [
                'name'     => 'btn_hover_bg_color',
                'label'    => __( 'Background', 'ximsa' ),
                'types'    => ['classic', 'gradient'],
                'exclude'  => ['image'],
                'selector' => '
                    {{WRAPPER}} .footer-style-insurance .info-widget .contact-btn:hover
                ',
            ]
        );
        $this->add_responsive_control(
            'btn_hover_border_radious',
            [
                'label'      => esc_html__( 'Border Radius', 'ximsa' ),
                'type'       => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%'],
                'selectors'  => [
                    '{{WRAPPER}} .footer-style-insurance .info-widget .contact-btn:hover' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',                    
                ],
            ]
        );
        $this->end_controls_tab();
        $this->end_controls_tabs();
        $this->end_controls_section();
	}
		


	protected function render() {
		
		
	$settings = $this->get_settings_for_display(); ?>
        <!-- Footer Style Five -->
        <footer class="footer-style-five" style="background-image: url(<?php echo esc_url($settings['footer_bg']['url']);?>)">
            <div class="auto-container">
                <!-- Widgets Section -->
                <div class="widgets-section">
                    <div class="row clearfix">
                        
                        <!-- Column -->
                        <div class="big-column col-lg-6 col-md-12 col-sm-12">
                            <div class="row clearfix">
                            
                                <!-- Footer Column -->
                                <div class="footer-column col-lg-6 col-md-6 col-sm-12">
                                    <div class="footer-widget logo-widget">
                                        <div class="logo">
                                            <a href="<?php echo esc_url( home_url( '/' ) ); ?>"><img src="<?php echo esc_url($settings['logo']['url']);?>" alt="<?php echo esc_url($settings['logo']['alt']);?>"></a>
                                        </div>
                                        <div class="text"><?php echo wp_kses( $settings['about_text'], true )?></div>
                                        <!-- Social Box -->
                                        <ul class="social-box">
                                            <?php foreach($settings['socialicons'] as $icon):?>
                                                <li><a href="<?php echo esc_url($icon['link_url']['url']);?>"><?php \Elementor\Icons_Manager::render_icon( $icon['icons'], [ 'aria-hidden' => 'true' ] ); ?></a></li>
                                            <?php endforeach;?>	
                                        </ul>
                                    </div>
                                </div>
                                
                                <!-- Footer Column -->
                                <div class="footer-column col-lg-6 col-md-6 col-sm-12">
                                    <div class="footer-widget info-widget">
                                        <h4><?php echo wp_kses( $settings['address_title'], true )?></h4>
                                        <ul class="info-list">
                                        <?php foreach($settings['contactinfo'] as $item):?>
                                            <li><span class="icon"><?php \Elementor\Icons_Manager::render_icon( $item['icon'], [ 'aria-hidden' => 'true' ] ); ?></span> <?php echo esc_html($item['con_info']);?></li>
                                            <?php endforeach;?>
                                        </ul>
                                    </div>
                                </div>
                                
                            </div>
                        </div>
                        
                        <!-- Column -->
                        <div class="big-column col-lg-6 col-md-12 col-sm-12">
                            <div class="row clearfix">
                                
                                <!-- Footer Column -->
                                <div class="footer-column col-lg-5 col-md-6 col-sm-12">
                                    <div class="footer-widget links-widget">
                                        <h4><?php echo wp_kses( $settings['links_title'], true )?></h4>
                                        <div class="row clearfix">
                                            <!-- Column -->
                                            <div class="column col-lg-6 col-md-6 col-sm-12">
                                                <ul class="nav-list">
                                                    <?php
                                                        wp_nav_menu( array(
                                                            'menu' => $settings['links_nav'],
                                                        ) );
                                                    ?>
                                                </ul>
                                            </div>
                                            <!-- Column -->
                                            <div class="column col-lg-6 col-md-6 col-sm-12">
                                                <ul class="nav-list">
                                                    <?php
                                                        wp_nav_menu( array(
                                                            'menu' => $settings['links_nav2'],
                                                        ) );
                                                    ?>
                                                </ul>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                
                                <!-- Footer Column -->
                                <div class="footer-column col-lg-7 col-md-6 col-sm-12">
                                    <div class="footer-widget email-widget">
                                        <h4><?php echo wp_kses( $settings['newslater_title'], true )?></h4>
                                        <div class="text"><?php echo wp_kses( $settings['newslater_text'], true )?></div>
                                        <!-- Email Box -->
                                        <div class="email-box-live">
                                            <?php echo do_shortcode( $settings['newslater_form'] );?>
                                        </div>
                                        <div class="lower-text"><?php echo wp_kses( $settings['newslater_lower_text'], true )?></div>
                                    </div>
                                </div>
                                
                            </div>
                        </div>
                        
                    </div>
                </div>
                
            </div>
            
            <!-- Footer Bottom -->
            <div class="footer-bottom">
                <div class="auto-container">
                    <div class="copyright"><?php echo wp_kses( $settings['footer_copyright'], true )?></div>
                </div>
            </div>
            
        </footer>
        <!-- End Footer Style Five -->
    <?php  
    }
	
	

}

