<?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 insurance_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 'insurance-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__( 'Insurance 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(
            'top_title',
            [
                'label' => __('Top Title', 'ximsa'),
                'type' => Controls_Manager::TEXT,
            ]
        );
        $this->add_control(
            'top_btn',
            [
                'label' => __('Top Button', 'ximsa'),
                'type' => Controls_Manager::TEXT,
            ]
        );
        $this->add_control(
            'top_btn_link',
            [
                'label' => __('Top Button', 'ximsa'),
                'type' => Controls_Manager::URL,
            ]
        );
        $this->add_control(
            'logo',
            [
                'label' => __('Choose Custom Logo', 'ximsa'),
                'type' => Controls_Manager::MEDIA,
            ]
        );

        $this->add_control(
            'about_title',
            [
                'label' => __('About Title', 'ximsa'),
                'type' => Controls_Manager::TEXT,
            ]
        );

        $this->add_control(
            'about_short',
            [
                'label' => __('Short About', 'ximsa'),
                'type' => Controls_Manager::TEXTAREA,
            ]
        );

        $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(
            'gallery_title',
            [
                'label' => __('Gallery Title', 'ximsa'),
                'type' => Controls_Manager::TEXT,
            ]
        );
        $this->add_control(
            'gallery',
            [
                'label' => __('Gallery', 'ximsa'),
                'type' => Controls_Manager::GALLERY,
            ]
        );
        $this->add_control(
            'footer_menu',
            [
                'label' => __('Footer 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(
			'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(),
			]
		);
        $repeater = new \Elementor\Repeater();

        $repeater->add_control(
			'title',
			[
				'label' => esc_html__( 'Title', '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(
			'policy_item',
			[
				'label' => esc_html__( 'Policy Item', '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-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 Four -->
        <footer class="footer-style-insurance" style="background-image: url(<?php echo esc_url($settings['footer_bg']['url']);?>)">
            <div class="auto-container">
                <!-- Upper Box -->
                <div class="upper-box">
                    <div class="row clearfix">

                        <!-- Title Column -->
                        <div class="title-column col-lg-6 col-md-12 col-sm-12">
                            <h3><?php echo esc_html($settings['top_title']);?></h3>
                        </div>

                        <!-- Button Column -->
                        <div class="button-column col-lg-6 col-md-12 col-sm-12">
                            <div class="button-box">
                                <a
                                href="<?php echo esc_url($settings['top_btn_link']['url']);?>"
                                target="<?php echo esc_attr( $settings['top_btn_link']['is_external'] ? '_blank' : '_self' ); ?>"
                                rel="<?php echo esc_attr( $settings['top_btn_link']['nofollow'] ? 'nofollow' : '' ); ?>"
                                class="theme-btn btn-style-inc-nineteen clearfix">
                                    <span class="btn-wrap">
                                        <span class="text-one"><?php echo esc_html($settings['top_btn']);?></span>
                                        <span class="text-two"><?php echo esc_html($settings['top_btn']);?></span>
                                    </span>
                                    <span class="arrow fa fa-arrow-circle-right"></span>
                                </a>
                            </div>
                        </div>

                    </div>
                </div>

                <!-- Widgets Section -->
                <div class="widgets-section">
                    <div class="row clearfix">

                        <!-- Footer Column -->
                        <div class="footer-column col-lg-4 col-md-6 col-sm-12">
                            <div class="footer-widget about-widget">
                                <h5><?php echo esc_html($settings['about_title']);?></h5>
                                <div class="text"><?php echo esc_html($settings['about_short']);?></div>
                                <ul class="list-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>

                        <!-- Footer Column -->
                        <div class="footer-column col-lg-4 col-md-6 col-sm-12">
                            <div class="footer-widget links-widget">
                                <h5><?php echo esc_html($settings['links_title']);?></h5>
                                <div class="row clearfix">
                                    <div class="col-lg-6 col-md-6 col-sm-12">
                                        <ul class="nav-list">
                                            <?php
                                                wp_nav_menu( array(
                                                    'menu' => $settings['links_nav'],
                                                ) );
                                            ?>
                                        </ul>
                                    </div>
                                    <div class="col-lg-6 col-md-6 col-sm-12">
                                        <ul class="nav-list">
                                            <?php
                                                wp_nav_menu( array(
                                                    'menu' => $settings['links_nav'],
                                                ) );
                                            ?>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- Footer Column -->
                        <div class="footer-column col-lg-4 col-md-6 col-sm-12">
                            <div class="footer-widget instagram-widget">
                                <h5><?php echo esc_html($settings['gallery_title']);?></h5>
                                <div class="widget-content">
                                    <div class="images-outer clearfix">
                                        <!--Image Box-->
                                        <?php foreach($settings['gallery'] as $item):?>
                                        <figure class="image-box"><a class="lightbox-image" href="<?php echo esc_url($item['url']);?>"><img src="<?php echo esc_url($item['url']);?>" alt=""></a></figure>
                                        <?php endforeach;?>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>

                <!-- Lower Box -->
                <div class="lower-box">
                    <div class="row clearfix">

                        <!-- Logo Column -->
                        <div class="logo-column col-lg-3 col-md-6 col-sm-12">
                            <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>

                        <!-- Nav Column -->
                        <div class="nav-column col-lg-6 col-md-12 col-sm-12">
                            <ul class="menu-list">
                                <?php
                                    wp_nav_menu( array(
                                        'menu' => $settings['footer_menu'],
                                    ) );
                                ?>
                            </ul>
                        </div>

                        <!-- Social Column -->
                        <div class="social-column col-lg-3 col-md-6 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>

            <div class="footer-bottom">
                <div class="auto-container clearfix">
                    <div class="pull-left">
                        <div class="copyright"><?php echo wp_kses( $settings['footer_copyright'], true );?></div>
                    </div>
                    <div class="pull-right">
                        <ul class="footer-nav">
                            <li><a href="#">Privacy Policy</a></li>
                            <li><a href="#">Terms Of Use</a></li>
                        </ul>
                    </div>
                </div>
            </div>

        </footer>
        <!-- End Footer Style Two -->
    <?php
    }



}
