<?php

namespace Layerdrops\Ostech\Widgets;


class Login extends \Elementor\Widget_Base
{
    public function get_name()
    {
        return 'ostech-login';
    }

    public function get_title()
    {
        return __('Login', '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'),
                ]
            ]
        );

        $this->end_controls_section();


        $this->start_controls_section(
            'content_section',
            [
                'label' => __('Content', 'ostech-addon'),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
                'condition' => [
                    'layout_type' => 'layout_one'
                ]
            ]
        );

        $this->add_control(
            'title',
            [
                'label' => __('Title', 'ostech-addon'),
                'type' => \Elementor\Controls_Manager::TEXT,
                'default' => __('Login ', 'ostech-addon'),
                'label_block' => true,
            ]
        );

        $this->add_control(
            'user_name_placeholder',
            [
                'label' => __('Placeholder for username', 'ostech-addon'),
                'type' => \Elementor\Controls_Manager::TEXT,
                'default' => __('Username or Email Address* ', 'ostech-addon'),
                'label_block' => true,
            ]
        );

        $this->add_control(
            'password_placeholder',
            [
                'label' => __('Placeholder for Password', 'ostech-addon'),
                'type' => \Elementor\Controls_Manager::TEXT,
                'default' => __('Password* ', 'ostech-addon'),
                'label_block' => true,
            ]
        );

        $this->add_control(
            'remember_me_text',
            [
                'label' => __('Remember Me Text', 'ostech-addon'),
                'type' => \Elementor\Controls_Manager::TEXT,
                'default' => __('Remember Me?', 'ostech-addon'),
                'label_block' => true,
            ]
        );

        $this->add_control(
            'login_btn_text',
            [
                'label' => __('Login Button Text', 'ostech-addon'),
                'type' => \Elementor\Controls_Manager::TEXT,
                'default' => __('Login', 'ostech-addon'),
                'label_block' => true,
            ]
        );

        $this->add_control(
            'forget_text',
            [
                'label' => __('Forgot Password Text', 'ostech-addon'),
                'type' => \Elementor\Controls_Manager::TEXT,
                'default' => __('Forgot your Password?', 'ostech-addon'),
                'label_block' => true,
            ]
        );

        $this->add_control(
            'forget_url',
            [
                'label' => __('Forgot Password Url', 'ostech-addon'),
                'type' => \Elementor\Controls_Manager::URL,
                'placeholder' => __('#', 'ostech-addon'),
                'show_external' => false,
                'default' => [
                    'url' => '#',
                    'is_external' => false,
                    'nofollow' => true,
                ],
                'show_label' => false,
            ]
        );

        $this->end_controls_section();

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

        ostech_elementor_general_style_options($this, 'Title', '{{WRAPPER}} .login-page__wrap__title', ['layout_one']);
        ostech_elementor_general_style_options($this, 'Remember Me', '{{WRAPPER}} .login-page__form .checked-box label', ['layout_one']);
        ostech_elementor_general_style_options($this, 'Forgot Password', '{{WRAPPER}} .login-page__form-forgot-password a', ['layout_one']);
        $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:hover', ['layout_one']);

        $this->end_controls_section();
    }

    protected function render()
    {
        $settings = $this->get_settings_for_display();
        include ostech_get_template('login-one.php');
    }
}
