<?php

namespace Layerdrops\Ostech\Widgets;


class ContactForm extends \Elementor\Widget_Base
{
    public function get_name()
    {
        return 'ostech-contact-form';
    }

    public function get_title()
    {
        return __('Contact Form', 'ostech-addon');
    }

    public function get_icon()
    {
        return 'eicon-cogs';
    }

    public function get_categories()
    {
        return ['ostech-category'];
    }

    protected function register_controls()
    {
        $this->start_controls_section(
            'layout_section',
            [
                'label' => __('Layout', 'ostech-addon'),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
            ]
        );

        $this->add_control(
            'layout_type',
            [
                'label' => __('Select Layout', 'ostech-addon'),
                'type' => \Elementor\Controls_Manager::SELECT2,
                'default' => 'layout_one',
                'options' => [
                    'layout_one' => __('Layout One', 'ostech-addon'),
                    'layout_two' => __('Layout Two', 'ostech-addon'),
                    'layout_three' => __('Layout Three', 'ostech-addon'),
                    'layout_four' => __('Layout Four', 'ostech-addon'),
                    // 'layout_five' => __('Layout Five', 'ostech-addon'),
                ]
            ]
        );

        $this->end_controls_section();

        include ostech_get_elementor_option('contact-form-one-option.php');
        include ostech_get_elementor_option('contact-form-two-option.php');
        include ostech_get_elementor_option('contact-form-three-option.php');
        include ostech_get_elementor_option('contact-form-four-option.php');
        include ostech_get_elementor_option('contact-form-five-option.php');

        //General style
        $this->start_controls_section(
            'general_style',
            [
                'label' => esc_html__('Content Style', 'ostech-addon'),
                'tab' => \Elementor\Controls_Manager::TAB_STYLE,
            ]
        );

        ostech_elementor_general_style_options($this, 'Section Title', '{{WRAPPER}} .sec-title__title,{{WRAPPER}} .sec-title-two__title', ['layout_one', 'layout_two', 'layout_three', 'layout_four', 'layout_five']);
        ostech_elementor_general_style_options($this, 'Section Sub Title', '{{WRAPPER}} .sec-title__tagline,{{WRAPPER}} .sec-title-two__tagline', ['layout_one', 'layout_two', 'layout_three', 'layout_four', 'layout_five']);
        ostech_elementor_general_style_options($this, 'Section Summary', '{{WRAPPER}} .contact-one__text', ['layout_three']);

        ostech_elementor_general_style_options($this, 'Info  Title', '{{WRAPPER}} .contact-one__info__text', ['layout_one', 'layout_three']);
        ostech_elementor_general_style_options($this, 'Info  Info', '{{WRAPPER}} .contact-one__info__title a,{{WRAPPER}} .contact-one__list__action', ['layout_one', 'layout_three']);


        $this->end_controls_section();

        //button style
        $this->start_controls_section(
            'button_style',
            [
                'label' => esc_html__('Button Style', 'ostech-addon'),
                'tab' => \Elementor\Controls_Manager::TAB_STYLE,
            ]
        );

        ostech_elementor_button_style_options($this, 'Button', '{{WRAPPER}} .ostech-btn,{{WRAPPER}} .ostech-btn::before', '{{WRAPPER}} .ostech-btn:hover,{{WRAPPER}} .ostech-btn::after', ['layout_one', 'layout_two', 'layout_three', 'layout_four']);

        $this->end_controls_section();

        //form Option style
        $this->start_controls_section(
            'form_style',
            [
                'label' => esc_html__('Form Field Style', 'ostech-addon'),
                'tab' => \Elementor\Controls_Manager::TAB_STYLE,
            ]
        );

        ostech_elementor_form_style_options($this, 'Input Text', '{{WRAPPER}} input[type="text"]', ['layout_one', 'layout_two', 'layout_three', 'layout_four', 'layout_five']);
        ostech_elementor_form_style_options($this, 'Input Email', '{{WRAPPER}} input[type="email"]', ['layout_one', 'layout_two', 'layout_three', 'layout_four', 'layout_five']);
        ostech_elementor_form_style_options($this, 'Textarea', '{{WRAPPER}}  textarea', ['layout_one', 'layout_two', 'layout_three', 'layout_four', 'layout_five']);
        ostech_elementor_form_style_options($this, 'Input Url', '{{WRAPPER}} input[type="url"]', ['layout_one', 'layout_two', 'layout_three', 'layout_four', 'layout_five']);
        ostech_elementor_form_style_options($this, 'Input Number', '{{WRAPPER}} input[type="number"]', ['layout_one', 'layout_two', 'layout_three', 'layout_four', 'layout_five']);
        ostech_elementor_form_style_options($this, 'Input Tel', '{{WRAPPER}} input[type="tel"]', ['layout_one', 'layout_two', 'layout_three', 'layout_four', 'layout_five']);

        ostech_elementor_general_style_options($this, 'Contact Form Bg', '{{WRAPPER}} .contact-one__form', ['layout_three'], 'background-color', false);

        $this->end_controls_section();
    }

    protected function render()
    {
        $settings = $this->get_settings_for_display();
        include ostech_get_template('contact-form-one.php');
        include ostech_get_template('contact-form-two.php');
        include ostech_get_template('contact-form-three.php');
        include ostech_get_template('contact-form-four.php');
        include ostech_get_template('contact-form-five.php');
    }
}
