<?php

namespace ThemesflatAddons\Widgets;

use  Elementor\Widget_Base ;
use  Elementor\Controls_Manager ;
use  Elementor\Utils ;
use  Elementor\Scheme_Color ;
use  Elementor\Group_Control_Typography ;
use  Elementor\Scheme_Typography ;
if ( !defined( 'ABSPATH' ) ) {
    exit;
}
// Exit if accessed directly
class TFL_Box_Service_Widget extends TFL_Widget_Base
{
    public function get_name()
    {
        return 'tfl-box-service';
    }

    public function get_title()
    {
        return __( 'Box Service', 'themesflat' );
    }

    public function get_icon()
    {
        return 'tfl-icon-posts-block';
    }

    public function get_categories()
    {
        return array( 'themesflat-addons' );
    }

    public function get_script_depends()
    {
        return [ 'tfl-waypoints', 'tfl-frontend-scripts' ];
    }

    public function get_style_depends()
    {
        return [ 'tfl-animate-styles', 'tfl-frontend-styles' ];
    }

    protected function register_controls()
    {
        $this->start_controls_section( 'section_box_service', [
            'label' => __( 'Box Service', 'themesflat' ),
        ] );


        // Icon

        $this->add_control( 'icon', [
            'type'        => Controls_Manager::TEXT,
            'label'       => __( 'Icon', 'themesflat' ),
            'label_block' => true,
            'separator'   => 'before',
            'default'     => '<i class="flaticon-customer-support"></i>',
            'dynamic'     => [
                'active' => true,
            ],
        ] );

        $this->add_control( 'bg_color', [
            'label'     => __( 'BG Color', 'themesflat' ),
            'type'      => Controls_Manager::COLOR,
            'default'   => '',
            'selectors' => [
                '{{WRAPPER}} .tfl-box-service.tfl-style1' => 'background: {{VALUE}};',
            ],
        ] );

        $this->add_control( 'bg_hover_color', [
            'label'     => __( 'BG Hover Color', 'themesflat' ),
            'type'      => Controls_Manager::COLOR,
            'default'   => '',
            'selectors' => [
                '{{WRAPPER}} .tfl-box-service.tfl-style1:hover' => 'background: {{VALUE}};',
            ],
        ] );


        $this->add_control('bg_image', [
            'label' => __('BG Image', 'themesflat'),
            'type' => Controls_Manager::MEDIA,
            'default' => [
                'url' => TFL_PLG_PATH . 'assets/images/box-service-bg.png',
            ],
            'label_block' => true,
            'dynamic' => [
                'active' => true,
            ],
        ]);




        $this->add_control( 'service_title', [
            'type'        => Controls_Manager::TEXT,
            'label'       => __( 'Service Title', 'themesflat' ),
            'label_block' => true,
            'separator'   => 'before',
            'default'     => __( 'Expert Team', 'themesflat' ),
            'dynamic'     => [
                'active' => true,
            ],
        ] );




        $this->add_control( 'short_text', [
            'type'        => 'textarea',
            'label'       => __( 'Short Text', 'themesflat' ),
            'description' => __( 'Short text generally displayed below the iconbox title.', 'themesflat' ),
            'default'     => __( 'Sed ut perspiciatis undeom natus error voluptate', 'themesflat' ),
            'dynamic'     => [
                'active' => true,
            ],
        ] );

        $this->add_control( 'service_box_settings', [
            'label'     => __( 'Settings', 'themesflat' ),
            'type'      => Controls_Manager::HEADING,
            'separator' => 'before',
        ] );

        $this->add_control( 'align', [
            'label'   => __( 'Alignment', 'themesflat' ),
            'type'    => Controls_Manager::CHOOSE,
            'options' => [
                'left'    => [
                    'title' => __( 'Left', 'themesflat' ),
                    'icon'  => 'fa fa-align-left',
                ],
                'center'  => [
                    'title' => __( 'Center', 'themesflat' ),
                    'icon'  => 'fa fa-align-center',
                ],
                'right'   => [
                    'title' => __( 'Right', 'themesflat' ),
                    'icon'  => 'fa fa-align-right',
                ],
                'justify' => [
                    'title' => __( 'Justified', 'themesflat' ),
                    'icon'  => 'fa fa-align-justify',
                ],
            ],
            'default' => 'center',
        ] );
        $this->add_control( 'widget_animation', [
            "type"    => Controls_Manager::SELECT,
            "label"   => __( "Animation Type", "themesflat" ),
            'options' => tfl_get_animation_options(),
            'default' => 'none',
        ] );

        $this->end_controls_section();


//        title
        $this->start_controls_section( 'section_styling', [
            'label' => __( 'Title', 'themesflat' ),
            'tab'   => Controls_Manager::TAB_STYLE,
        ] );
            $this->add_control( 'title_tag', [
                'label'   => __( 'Title HTML Tag', 'themesflat' ),
                'type'    => Controls_Manager::SELECT,
                'options' => [
                    'h1'  => __( 'H1', 'themesflat' ),
                    'h2'  => __( 'H2', 'themesflat' ),
                    'h3'  => __( 'H3', 'themesflat' ),
                    'h4'  => __( 'H4', 'themesflat' ),
                    'h5'  => __( 'H5', 'themesflat' ),
                    'h6'  => __( 'H6', 'themesflat' ),
                    'div' => __( 'div', 'themesflat' ),
                ],
                'default' => 'h3',
            ] );
            $this->add_control( 'title_color', [
                'label'     => __( 'Title Color', 'themesflat' ),
                'type'      => Controls_Manager::COLOR,
                'default'   => '',
                'selectors' => [
                    '{{WRAPPER}} .tfl-box-service.tfl-style1 .tfl-content-wrapper .tfl-title' => 'color: {{VALUE}};',
                ],
            ] );

            $this->add_control( 'title_hover_color', [
                'label'     => __( 'Title Hover Color', 'themesflat' ),
                'type'      => Controls_Manager::COLOR,
                'default'   => '',
                'selectors' => [
                    '{{WRAPPER}} .tfl-box-service.tfl-style1:hover .tfl-content-wrapper .tfl-title' => 'color: {{VALUE}};',
                ],
            ] );

            $this->add_group_control( Group_Control_Typography::get_type(), [
                'name'     => 'title_typography',
                'label'    => __( 'Typography', 'themesflat' ),
                'selector' => '{{WRAPPER}} .tfl-box-service.tfl-style1 .tfl-content-wrapper .tfl-title',
            ] );
        $this->end_controls_section();


//short text
        $this->start_controls_section( 'section_short_text', [
            'label' => __( 'Short Text', 'themesflat' ),
            'tab'   => Controls_Manager::TAB_STYLE,
        ] );
            $this->add_control( 'shorttext_color', [
                'label'     => __( 'Color', 'themesflat' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .tfl-box-service.tfl-style1 .tfl-content-wrapper .tfl-text' => 'color: {{VALUE}};',
                ],
            ] );

            $this->add_control( 'shorttext_hover_color', [
                'label'     => __( 'Hover Color', 'themesflat' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .tfl-box-service.tfl-style1:hover .tfl-content-wrapper .tfl-text' => 'color: {{VALUE}};',
                ],
            ] );

            $this->add_group_control( Group_Control_Typography::get_type(), [
                'name'     => 'text_typography',
                'selector' => '{{WRAPPER}} .tfl-box-service.tfl-style1 .tfl-content-wrapper .tfl-text',
            ] );
        $this->end_controls_section();
    }

    protected function render()
    {
        $settings = $this->get_settings_for_display();
        $settings = apply_filters( 'tfl_box_service_v2_' . $this->get_id() . '_settings', $settings );
        $args['settings'] = $settings;
        $args['widget_instance'] = $this;
        tfl_get_template_part( "addons/box-service/style1", $args );
    }

    protected function content_template()
    {
    }

}