<?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\Group_Control_Background;
use Elementor\Plugin;

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

class insurance_about 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-about';
	}

	/**
	 * 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 About', '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(
            'ins_about_opt',
            [
                'label' => __( 'Insurance About', 'ximsa' ),
                'tab' => Controls_Manager::TAB_CONTENT,
            ]
        );

        $this->add_control(
			'sub_title',
			[
				'label' => esc_html__( 'Sub Title', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);

        $this->add_control(
			'title',
			[
				'label' => esc_html__( 'Title', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        $this->add_control(
			'authore_sign',
			[
				'label' => esc_html__( 'Authore Signature', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'authorename',
			[
				'label' => esc_html__( 'AUthore Name', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        $this->add_control(
			'designation',
			[
				'label' => esc_html__( 'Designation', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        $this->add_control(
			'shortbio',
			[
				'label' => esc_html__( 'Short Bio', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'button_label',
			[
				'label' => esc_html__( 'Button Label', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        $this->add_control(
			'button_link',
			[
				'label' => esc_html__( 'Button Link', 'ximsa' ),
				'type' => Controls_Manager::URL,
                'label_block' => true,
			]
		);

        $repeater = new Repeater();
		$repeater->add_control(
			'feature_img', [
				'label' => esc_html__( 'Feature Image', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::MEDIA,
				'label_block' => true,
			]
		);

		$repeater->add_control(
			'icon', [
				'label' => esc_html__( 'Icon Name', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::TEXT,
				'show_label' => true,
			]
		);
		$repeater->add_control(
			'title', [
				'label' => esc_html__( 'Title', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::TEXT,
				'show_label' => true,
			]
		);
		$repeater->add_control(
			'description', [
				'label' => esc_html__( 'Description', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::TEXTAREA,
				'show_label' => true,
			]
		);
		$repeater->add_control(
			'fs_bg_img', [
				'label' => esc_html__( 'Feature Background Image', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::MEDIA,
				'show_label' => true,
			]
		);
		$repeater->add_control(
			'btn_label', [
				'label' => esc_html__( 'Button Label', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::TEXT,
				'show_label' => false,
			]
		);
		$repeater->add_control(
			'btn_link', [
				'label' => esc_html__( 'Button Link', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::URL,
				'show_label' => false,
			]
		);


		$this->add_control(
			'features',
			[
				'label' => esc_html__( 'Features', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
				'title_field' => '{{{ title }}}',
			]
		);
		$this->add_control(
			'lowertext', [
				'label' => esc_html__( 'Lower Text', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::TEXTAREA,
				'show_label' => false,
			]
		);
		$this->end_controls_section();

        $this->start_controls_section(
            'top_info_style',
            [
                'label' => __( 'About Style Settings', 'ximsa' ),
                'tab' => Controls_Manager::TAB_STYLE,
            ]
        );

        $this->add_control(
            'sub_title_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Sub Title Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );

        $this->add_control(
            'sub_title_cl',
            [
                'label'     => esc_html__( 'Sub Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .sec-title-four .title' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'sub__typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .sec-title-four .title',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'main_title_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Title Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );

        $this->add_control(
            'main_title_cl',
            [
                'label'     => esc_html__( 'Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .sec-title-four h2' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'main_title__typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .sec-title-four h2',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'authore_title_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Authore Title Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );

        $this->add_control(
            'authore_title_cl',
            [
                'label'     => esc_html__( 'Authore Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .about-section-three .signature-box strong' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'authore_title__typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .about-section-three .signature-box strong',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'authore_designation_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Authore Designation Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );

        $this->add_control(
            'authore_designation_cl',
            [
                'label'     => esc_html__( 'Authore Designation Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .about-section-three .signature-box .box-inner' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'authore_design__typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .about-section-three .signature-box .box-inner',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'description_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Descriiption Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );

        $this->add_control(
            'description_cl',
            [
                'label'     => esc_html__( 'Description Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .sec-title-four .text' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'description_cl__typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .sec-title-four .text',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );

        $this->add_control(
            'btn_style',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Button Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );

        $this->add_control(
            'btn_color',
            [
                'label'     => esc_html__( 'Button Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .btn-style-inc-nineteen' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_control(
            'btn_bg_cl',
            [
                'label'     => esc_html__( 'Button BG Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .btn-style-inc-nineteen' => 'background-color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_control(
            'btn_bg_hv_cl',
            [
                'label'     => esc_html__( 'Button BG Hover Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .btn-style-inc-nineteen:before' => 'background-color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'btn_text_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .btn-style-inc-nineteen',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'feature_content_style',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Feature Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'feature_style',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Feature Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );

        $this->add_control(
            'feature_title_cl',
            [
                'label'     => esc_html__( 'Feature Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .service-block-two h4' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_control(
            'feature_title_hv_cl',
            [
                'label'     => esc_html__( 'Feature Title Hover Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .service-block-two h4 a' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'fs_title_cl__typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .service-block-two h4',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'feature_text_cl',
            [
                'label'     => esc_html__( 'Feature Text Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .service-block-two .text' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_control(
            'feature_text_hv_cl',
            [
                'label'     => esc_html__( 'Feature Text Hover Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .service-block-two .overlay-text' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'fs_text_cl__typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .service-block-two .text, .service-block-two .overlay-text',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'feature_icon_cl',
            [
                'label'     => esc_html__( 'Feature ICon Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .service-block-two .image .icon' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_control(
            'feature_icon_hv_cl',
            [
                'label'     => esc_html__( 'Feature Icon Hover Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .service-block-two .overlay-box .overlay-icon' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_control(
            'feature_btn_cl',
            [
                'label'     => esc_html__( 'Feature Button Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .service-block-two .quote' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_control(
            'feature_bg_cl',
            [
                'label'     => esc_html__( 'Feature BG Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .service-block-two .quote' => 'background-color: {{VALUE}} ',
                ],
            ]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'fs_bg__typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .service-block-two .quote',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'feature_box_overlay_cl',
            [
                'label'     => esc_html__( 'Feature Box Overlay Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .service-block-two .overlay-box:before' => 'background-color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_control(
            'feature_lower_style',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Feature Lower Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );

        $this->add_control(
            'feature_loaer_txt_cl',
            [
                'label'     => esc_html__( 'Feature Lower Text Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .about-section-three .lower-text' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_control(
            'feature_lower_link_cl',
            [
                'label'     => esc_html__( 'Feature Lower Link Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .about-section-three .lower-text a' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'fs_lower_cl__typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .about-section-three .lower-text',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
		$this->end_controls_section();
	}



	protected function render() {
	$settings = $this->get_settings_for_display();?>
	<!-- About Section Three -->
	<section class="about-section-three">
		<div class="auto-container">
			<!-- Sec Title Four -->
			<div class="sec-title-four clearfix">
				<div class="pull-left">
					<div class="title"><?php echo wp_kses( $settings['sub_title'], true );?></div>
					<h2><?php echo wp_kses( $settings['title'], true );?></h2>
					<!-- Signature Box -->
					<div class="signature-box">
						<div class="box-inner">
							<span class="signature">
								<img src="<?php echo esc_url($settings['authore_sign']['url']);?>" alt="" />
							</span>
							<strong><?php echo esc_html($settings['authorename']);?></strong>
							<?php echo esc_html($settings['designation']);?>
						</div>
					</div>
				</div>
				<div class="pull-right">
					<div class="text"><?php echo wp_kses( $settings['shortbio'], true )?></div>
					<div class="button-box">
						<a
                        href="<?php echo esc_url($settings['button_link']['url']);?>"
                        target="<?php echo esc_attr( $settings['button_link']['is_external'] ? '_blank' : '_self' ); ?>"
                        rel="<?php echo esc_attr( $settings['button_link']['nofollow'] ? 'nofollow' : '' ); ?>"
                        class="theme-btn btn-style-inc-nineteen clearfix">
							<span class="btn-wrap">
								<span class="text-one"><?php echo wp_kses( $settings['button_label'], true )?></span>
								<span class="text-two"><?php echo wp_kses( $settings['button_label'], true )?></span>
							</span>
							<span class="arrow fa fa-arrow-circle-right"></span>
						</a>
					</div>
				</div>
			</div>
			<?php if(!empty($settings['features'])):?>
			<div class="inner-container">
				<div class="row clearfix">
					<?php foreach($settings['features'] as $item):?>
					<!-- Service Block Two -->
					<div class="service-block-two col-lg-3 col-md-6 col-sm-12">
						<div class="inner-box wow fadeInLeft" data-wow-delay="450ms" data-wow-duration="1500ms">
							<div class="image">
								<img src="<?php echo esc_url($item['feature_img']['url']);?>" alt="" />
								<div class="icon <?php echo esc_attr($item['icon']);?>"></div>
							</div>
							<h4><?php echo wp_kses( $item['title'], true )?></h4>
							<div class="text"><?php echo wp_kses( $item['description'], true )?></div>
							<div class="overlay-box" style="background-image: url(<?php echo esc_url($item['fs_bg_img']['url']);?>)">
								<div class="overlay-inner">
									<div class="overlay-icon <?php echo esc_attr($item['icon']);?>"></div>
									<h4><a href="<?php echo esc_url($item['btn_link']['url']);?>"><?php echo wp_kses( $item['title'], true )?></a></h4>
									<div class="overlay-text"><?php echo wp_kses( $item['description'], true )?></div>
								</div>
								<a href="<?php echo esc_url($item['btn_link']['url']);?>" class="quote"><?php echo wp_kses( $item['btn_label'], true )?></a>
							</div>
						</div>
					</div>
					<?php endforeach;?>
				</div>
			</div>
			<?php endif;?>
			<!-- Lower Text -->
			<div class="lower-text"><?php echo wp_kses( $settings['lowertext'], true );?></div>

		</div>
	</section>
	<!-- End About Section Three -->
    <?php
    }

}
