<?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 fintech_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 'fintech-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__( 'Fintech 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(
            'logo',
            [
                'label' => __('Choose Custom Logo', 'ximsa'),
                'type' => Controls_Manager::MEDIA,
            ]
        );
        
        $this->add_control(
            'about_short',
            [
                'label' => __('Short About', 'ximsa'),
                'type' => Controls_Manager::TEXTAREA,
            ]
        );

        $this->add_control(
            'app_text',
            [
                'label' => __('App Text', 'ximsa'),
                'type' => Controls_Manager::TEXT,
            ]
        );
        $this->add_control(
            'apple_img',
            [
                'label' => __('Apple Image', 'ximsa'),
                'type' => Controls_Manager::MEDIA,
            ]
        );
        $this->add_control(
            'apple_link',
            [
                'label' => __('Apple Link', 'ximsa'),
                'type' => Controls_Manager::URL,
            ]
        );
        $this->add_control(
            'play_img',
            [
                'label' => __('Play Image', 'ximsa'),
                'type' => Controls_Manager::MEDIA,
            ]
        );
        $this->add_control(
            'play_link',
            [
                'label' => __('Play Link', 'ximsa'),
                'type' => Controls_Manager::URL,
            ]
        );

        $this->add_control(
            'contact_title',
            [
                'label' => __('Contact Title', 'ximsa'),
                'type' => Controls_Manager::TEXT,
            ]
        );
        $repeater = new \Elementor\Repeater();
        
        $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(
            'time_title',
            [
                'label' => __('Time Title', 'ximsa'),
                'type' => Controls_Manager::TEXT,
            ]
        );
        $this->add_control(
            'time_text',
            [
                'label' => __('Time Details', 'ximsa'),
                'type' => Controls_Manager::TEXTAREA,
            ]
        );
        $this->add_control(
            'btn_label',
            [
                'label' => __('Button Label Title', 'ximsa'),
                'type' => Controls_Manager::TEXT,
            ]
        );
        $this->add_control(
            'btn_link',
            [
                'label' => __('Button Link', 'ximsa'),
                'type' => Controls_Manager::URL,
            ]
        );
        
        $this->add_control(
            'footer_copyright',
            [
                'label' => __('Footer Copyright', 'ximsa'),
                'type' => Controls_Manager::TEXTAREA,
                'label_block' => true,
            ]
        );
        $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->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-four .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-four .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-four .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-four .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-four .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-four 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-four h4',
            ]
        );
        $this->add_control(
            'about_txt_cl',
            [
                'label' => esc_html__( 'About Text Color', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .footer-style-four .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-four .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-four .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-four .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-four' => '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-four .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-four .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-four .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-four .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-four .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-four .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-four .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 Four -->
        <footer class="footer-style-four">
            <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-8 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_short'], true )?></div>
                                        <div class="download"><?php echo wp_kses( $settings['app_text'], true )?></div>
                                        <div class="app-btns">
                                            <?php if(!empty($settings['apple_img']['url'])):?>
                                                <a href="<?php echo esc_url($settings['apple_link']['url']);?>"><img src="<?php echo esc_url($settings['apple_img']['url']);?>" alt="" /></a>
                                            <?php endif;;?>

                                            <?php if(!empty($settings['play_img']['url'])):?>
                                                <a href="<?php echo esc_url($settings['play_link']['url']);?>"><img src="<?php echo esc_url($settings['play_img']['url']);?>" alt="" /></a>
                                            <?php endif;;?>

                                        </div>
                                    </div>
                                </div>
                                
                                <!-- Footer Column -->
                                <div class="footer-column col-lg-4 col-md-6 col-sm-12">
                                    <div class="footer-widget links-widget">
                                        <h4><?php echo wp_kses( $settings['contact_title'], true )?></h4>
                                        <ul class="list-list">
                                            <?php foreach($settings['contactinfo'] as $item):?>
                                                <li><?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-6 col-md-6 col-sm-12">
                                    <div class="footer-widget links-widget">
                                        <h4><?php echo wp_kses( $settings['links_title'], true )?></h4>
                                        <?php
                                            wp_nav_menu( array(
                                                'menu' => $settings['links_nav'],
                                            ) );
                                        ?>
                                    </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['time_title'], true )?></h4>
                                        <div class="timing"><?php echo wp_kses( $settings['time_text'], true )?></div>
                                        <a class="contact-btn" href="<?php echo esc_url($settings['btn_link']['url']);?>"><?php echo wp_kses( $settings['btn_label'], true )?> <span class="icon flaticon-chat"></span></a>
                                    </div>
                                </div>
                                
                            </div>
                        </div>
                        
                    </div>
                </div>
                
                <!-- Footer Bottom -->
                <div class="footer-bottom">
                    <div class="row clearfix">
                        <div class="column col-lg-6 col-md-12 col-sm-12">
                            <div class="copyright"><?php echo wp_kses( $settings['footer_copyright'], true )?></div>
                        </div>
                        <div class="column col-lg-6 col-md-12 col-sm-12">
                            <!-- 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>
                </div>
                
            </div>
        </footer>
        <!-- End Footer Style Four -->
    <?php  
    }
	
	

}

