<?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 insurence_company 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-company';
	}

	/**
	 * 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 Company', '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_company_opt',
            [
                'label' => __( 'Insurance Company', 'ximsa' ),
                'tab' => Controls_Manager::TAB_CONTENT,
            ]
        );
        $this->add_control(
			'company_bg',
			[
				'label' => esc_html__( 'Company BG', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);

        $this->add_control(
			'companys',
			[
				'label' => esc_html__( 'Company Gallery', 'ximsa' ),
				'type' => Controls_Manager::GALLERY,
                'label_block' => true,
			]
		);

        $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(
			'description',
			[
				'label' => esc_html__( 'Description', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
                'label_block' => true,
			]
		);

		$this->add_control(
			'button_label', [
				'label' => esc_html__( 'Button Label', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::TEXT,
				'show_label' => false,
			]
		);
		$this->add_control(
			'button_link', [
				'label' => esc_html__( 'Button Link', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::URL,
				'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-five .title' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'sub__typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .sec-title-five .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-five 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-five h2',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'main_txt_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Text Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );

        $this->add_control(
            'main_text_cl',
            [
                'label'     => esc_html__( 'Text Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .sec-title-five .text' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'main_txt__typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .sec-title-five .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_cl',
            [
                '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_hv_bg_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___typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .btn-style-inc-nineteen',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'shape_bg_style',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Shape BG Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );

        $this->add_control(
            'shape_bg_cl',
            [
                'label'     => esc_html__( 'Shape BG 1 Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .company-section .image-column .image:before' => 'background-color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_control(
            'shape_bg2_cl',
            [
                'label'     => esc_html__( 'Shape BG 2 Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .company-section .image-column .image:after' => 'background-color: {{VALUE}} ',
                ],
            ]
        );


		$this->end_controls_section();
	}



	protected function render() {
	$settings = $this->get_settings_for_display();?>
        <!-- Company Section -->
        <section class="company-section">
            <div class="image-layer" style="background-image: url(<?php echo esc_url($settings['company_bg']['url'])?>)"></div>
            <div class="auto-container">
                <div class="row clearfix">

                    <!-- Image Column -->
                    <div class="image-column col-lg-5 col-md-12 col-sm-12">
                        <div class="inner-column">
                            <div class="single-item-carousel owl-carousel owl-theme">
                                <?php foreach($settings['companys'] as $gall):?>
                                <div class="image">
                                    <img src="<?php echo esc_url($gall['url'])?>" alt="" />
                                </div>
                                <?php endforeach;?>
                            </div>
                        </div>
                    </div>

                    <!-- Content Column -->
                    <div class="content-column col-lg-7 col-md-12 col-sm-12">
                        <div class="inner-column">
                            <div class="sec-title-five light">
                                <div class="title"><?php echo esc_html($settings['sub_title']);?></div>
                                <h2><?php echo wp_kses( $settings['title'], true );?></h2>
                                <div class="text"><?php echo wp_kses( $settings['description'], true );?> </div>
                            </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>

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

}
