<?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 it_v2_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 'it_v2_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__( 'IT V2 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(
            'footer_newslater_title',
            [
                'label' => __('Footer Newslater Title', 'ximsa'),
                'type' => Controls_Manager::TEXT,
            ]
        );
        $this->add_control(
            'footer_newslater',
            [
                'label' => __('Footer Newslater Shortcode', 'ximsa'),
                'type' => Controls_Manager::TEXT,
                'label_block' => true,
            ]
        );
        $this->add_control(
            'location_title',
            [
                'label' => __('Location Title', 'ximsa'),
                'type' => Controls_Manager::TEXT,
            ]
        );
        
        $this->add_control(
            'location_nav',
            [
                'label' => __('Location Nav', 'ximsa'),
                'type' => Controls_Manager::SELECT2,
                'options' =>  ximsa_menu_selector(),
                'multiple' => false,
                'label_block' => true,
            ]
        );
        $this->add_control(
            'service_title',
            [
                'label' => __('Service Title', 'ximsa'),
                'type' => Controls_Manager::TEXT,
            ]
        );
        $this->add_control(
            'service_nav',
            [
                'label' => __('Service Menu', 'ximsa'),
                'type' => Controls_Manager::SELECT2,
                'options' =>  ximsa_menu_selector(),
                'multiple' => false,
                'label_block' => true,
            ]
        );
        
        $this->add_control(
            'quick_title',
            [
                'label' => __('Qucick Title', 'ximsa'),
                'type' => Controls_Manager::TEXT,
            ]
        );
        $this->add_control(
            'quick_nav',
            [
                'label' => __('Quick Menu', 'ximsa'),
                'type' => Controls_Manager::SELECT2,
                'options' =>  ximsa_menu_selector(),
                'multiple' => false,
                'label_block' => true,
            ]
        );
        $this->add_control(
            'fanfact_title',
            [
                'label' => __('Fanfact Title', 'ximsa'),
                'type' => Controls_Manager::TEXT,
            ]
        );
        $this->add_control(
            'fanfact_nav',
            [
                'label' => __('Fanfact Menu', 'ximsa'),
                'type' => Controls_Manager::SELECT2,
                'options' =>  ximsa_menu_selector(),
                'multiple' => false,
                'label_block' => true,
            ]
        );
        $this->add_control(
            'footer_copyright',
            [
                'label' => __('Footer Copyright', 'ximsa'),
                'type' => Controls_Manager::TEXTAREA,
                'label_block' => true,
            ]
        );
        $repeater = new \Elementor\Repeater();
        
        $repeater->add_control(
			'footer_link_text',
			[
				'label' => esc_html__( 'Link Text', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        
        $repeater->add_control(
			'link_url',
			[
				'label' => esc_html__( 'Link URL', 'ximsa' ),
				'type' => Controls_Manager::URL,
                'label_block' => true,
			]
		);
        
        $this->add_control(
			'footerlinks',
			[
				'label' => esc_html__( 'Add Footer LInk', 'ximsa' ),
				'type' => Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
			]
		);
       
        $this->end_controls_section();


        $this->start_controls_section(
            'Header_container_style',
            [
                'label' => __('Header Container Style', 'ximsa'),
                'tab' => \Elementor\Controls_Manager::TAB_STYLE,
            ]
        );
        $this->add_control(
			'container_width',
			[
				'label' => esc_html__( 'Container Width', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::SLIDER,
				'size_units' => [ 'px', '%' ],
				'range' => [
					'px' => [
						'min' => 0,
						'max' => 2000,
					],
					'%' => [
						'min' => 0,
						'max' => 100,
					],
				],
				
				'selectors' => [
					'{{WRAPPER}} .container, .container-lg, .container-md, .container-sm, .container-xl, .container-xxl' => 'max-width: {{SIZE}}{{UNIT}};',
				],
			]
		);
        $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-logo img' => 'max-width: {{SIZE}}{{UNIT}};',
                ],
            ]
        );
        $this->add_control(
            'Header_bottom_border_color_heading',
            [
                'label' => esc_html__( 'Header Bottom Border Color', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::HEADING,
                'separator' => 'before',
            ]
        );
        
        $this->add_control(
            'main_nav_color',
            [
                'label' => esc_html__( 'Main Nav Color', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-footer-menu-content .footer-menu 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}} .xis-footer-menu-content .footer-menu 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}} .xis-footer-menu-content .footer-menu a',
            ]
        );
        
        
        $this->add_control(
            'copyright_txt',
            [
                'label' => esc_html__( 'Copyright Text Color', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-footer-social-text p' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'label' => esc_html__( 'Copyright Title', 'ximsa' ),
                'name' => 'cpr_title_typography',
                'selector' => '{{WRAPPER}} .xis-footer-social-text p',
            ]
        );
        $this->add_control(
            'social_icon_clr',
            [
                'label' => esc_html__( 'Social Icon Color', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-footer-social a' => 'color: {{VALUE}}',
                ],
            ]
        );

        $this->add_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name' => 'sociL-ic_bg',
				'label' => esc_html__( 'Background', 'ximsa' ),
				'types' => [ 'gradient' ],
				'selector' => '{{WRAPPER}} .xis-footer-social a:hover',
			]
		);

        $this->add_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name' => 'con-ic_bg',
				'label' => esc_html__( 'Background', 'ximsa' ),
				'types' => [ 'gradient' ],
				'selector' => '{{WRAPPER}} .xis-dia-section-title span',
			]
		);
        $this->add_control(
			'contact_options',
			[
				'label' => esc_html__( 'Contact Form Options', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::HEADING,
				'separator' => 'before',
			]
		);
        $this->add_control(
            'cont_ttile',
            [
                'label' => esc_html__( 'Contact Title Color', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-dia-section-title h2' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'label' => esc_html__( 'Contact Title', 'ximsa' ),
                'name' => 'contact_title_typography',
                'selector' => '{{WRAPPER}} .xis-dia-section-title h2',
            ]
        );
        $this->add_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name' => 'btn-ic_bg',
				'label' => esc_html__( 'Background', 'ximsa' ),
				'types' => [ 'gradient' ],
				'selector' => '{{WRAPPER}} .xis-dia-newslatter-form button',
			]
		);
        $this->add_control(
			'contact_info_options',
			[
				'label' => esc_html__( 'Contact Info Options', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::HEADING,
				'separator' => 'before',
			]
		);
        $this->add_control(
            'con_info_title',
            [
                'label' => esc_html__( 'Contact Info Title Color', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .cta-info-item span' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_control(
            'con_info_icon',
            [
                'label' => esc_html__( 'Contact Info Icon Color', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .cta-info-item i' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'label' => esc_html__( 'Contact Info Title', 'ximsa' ),
                'name' => 'contact_inf_typography',
                'selector' => '{{WRAPPER}} .cta-info-item span',
            ]
        );
        $this->end_controls_section();
	}
		


	protected function render() {
		
		
	$settings = $this->get_settings_for_display(); ?>
    <!-- Start of Footer section
	============================================= -->
	<section id="ximsa-it-footer" class="ximsa-it-footer-section">
		<div class="ximsa-it-footer-newslatter" data-background="<?php echo esc_url($settings['footer_bg']['url']);?>">
			<div class="container">
				<div class="ximsa-it-footer-newslatter-area d-flex justify-content-between align-items-center">
					<div class="ximsa-it-section-title xis-it-main-headline pera-content">
						<h2 class="text-uppercase"><?php echo esc_html($settings['footer_newslater_title']);?></h2>
					</div>
					<div class="newslatter-form">
						<?php echo do_shortcode( $settings['footer_newslater'] );?>
					</div>
				</div>
			</div>
		</div>
		<div class="ximsa-it-footer-widget-wrapper">
			<div class="container">
				<div class="ximsa-it-footer-widget-content d-flex justify-content-between">
					<div class="ximsa-it-footer-widget ul-li-block xis-it-main-headline">
						<h3 class="widget-title text-uppercase"><?php echo esc_html($settings['location_title']);?></h3>
						<?php
                            wp_nav_menu( array(
                                'menu' => $settings['location_nav'],
                            ) );
                        ?>
					</div>
					<div class="ximsa-it-footer-widget ul-li-block xis-it-main-headline">
						<h3 class="widget-title text-uppercase"><?php echo esc_html($settings['service_title']);?></h3>
						<?php
                            wp_nav_menu( array(
                                'menu' => $settings['service_nav'],
                            ) );
                        ?>
					</div>
					<div class="ximsa-it-footer-widget ul-li-block xis-it-main-headline">
						<h3 class="widget-title text-uppercase"><?php echo esc_html($settings['quick_title']);?></h3>
						<?php
                            wp_nav_menu( array(
                                'menu' => $settings['quick_nav'],
                            ) );
                        ?>
					</div>
					<div class="ximsa-it-footer-widget ul-li-block xis-it-main-headline">
						<h3 class="widget-title text-uppercase"><?php echo esc_html($settings['fanfact_title']);?></h3>
						<?php
                            wp_nav_menu( array(
                                'menu' => $settings['fanfact_nav'],
                            ) );
                        ?>
					</div>
				</div>
			</div>
			<div class="ximsa-it-footer-copyright">
				<div class="container">
					<div class="ximsa-it-footer-copyright-content d-flex justify-content-between">
						<div class="copyright-text">
							<?php echo wp_kses( $settings['footer_copyright'], true );?>
						</div>
						<div class="copyright-menu ul-li">
							<ul>
                                <?php foreach($settings['footerlinks'] as $item):?>
								<li><a href="<?php echo esc_url($item['link_url']['url']);?>"><?php echo esc_html($item['footer_link_text']);?></a></li>
                                <?php endforeach;?>
							</ul>
						</div>
					</div>
				</div>
			</div>
		</div>
	</section>		
<!-- End of Footer section
	============================================= -->
       
    <?php  
    }
	
	

}

