<?php

namespace Gigneo\Elementor\Widgets;

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

use Elementor\Widget_Base;
use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Typography;
use Elementor\Group_Control_Text_Shadow;
use Elementor\Group_Control_Box_Shadow;

/**
 * Gigneo Elementor Forgot_Password Widget
 *
 * @since 0.0.1
 */
class Forgot_Password extends Widget_Base {


	/**
	 * Get widget unique name.
	 *
	 * @return string
	 */
	public function get_name() {
		return 'gigneo-forgot-password';
	}

	/**
	 * Get widget title.
	 *
	 * This is the name displayed in the Elementor panel.
	 *
	 * @return string
	 */
	public function get_title() {
		return esc_html__( 'Forgot Password', 'gigneo' );
	}

	/**
	 * Get widget icon.
	 *
	 * Define the icon that will appear in the Elementor panel.
	 *
	 * @return string
	 */
	public function get_icon() {
		return 'eicon-form-vertical gn-label';
	}

	/**
	 * Get widget categories.
	 *
	 * Defines the category under which the widget will be listed.
	 *
	 * @return array
	 */
	public function get_categories() {
		return array( 'gigneo-widgets' );
	}

	/**
	 * Get widget keywords.
	 *
	 * Helps users find the widget in Elementor search.
	 *
	 * @return array
	 */
	public function get_keywords() {
		return array( 'auth', 'login' );
	}

	/**
	 * Register widget controls.
	 *
	 * Adds controls/fields to the Elementor editor for this widget.
	 */
	protected function register_controls() {
		$this->start_controls_section(
			'section_general',
			array(
				'label' => esc_html__( 'General', 'gigneo' ),
			)
		);

		$this->add_control(
			'password_mode',
			array(
				'label'       => esc_html__( 'Form Type', 'gigneo' ),
				'type'        => Controls_Manager::SELECT,
				'default'     => 'reset',
				'options'     => array(
					'reset'  => esc_html__( 'Reset Password', 'gigneo' ),
					'change' => esc_html__( 'Change Password', 'gigneo' ),
				),
				'label_block' => true,
			)
		);

		/* ================= Show/Hide Title ================= */
		$this->add_control(
			'form_title',
			array(
				'label'                => esc_html__( 'Title', 'gigneo' ),
				'type'                 => Controls_Manager::SWITCHER,
				'label_on'             => esc_html__( 'Show', 'gigneo' ),
				'label_off'            => esc_html__( 'Hide', 'gigneo' ),
				'return_value'         => 'yes',
				'default'              => 'yes',
				'selectors_dictionary' => array(
					'yes' => 'block',
					''    => 'none',
				),
				'selectors'            => array(
					'{{WRAPPER}} .gn-title' => 'display: {{VALUE}};',
				),
			)
		);

		/* ================= Show/Hide Description ================= */
		$this->add_control(
			'form_description',
			array(
				'label'                => esc_html__( 'Description', 'gigneo' ),
				'type'                 => Controls_Manager::SWITCHER,
				'label_on'             => esc_html__( 'Show', 'gigneo' ),
				'label_off'            => esc_html__( 'Hide', 'gigneo' ),
				'return_value'         => 'yes',
				'default'              => 'yes',
				'selectors_dictionary' => array(
					'yes' => 'block',
					''    => 'none',
				),
				'selectors'            => array(
					'{{WRAPPER}} .gn-description' => 'display: {{VALUE}};',
				),
			)
		);

		$this->add_responsive_control(
			'title_alignment',
			array(
				'label'      => esc_html__( 'Alignment', 'gigneo' ),
				'type'       => Controls_Manager::CHOOSE,
				'options'    => array(
					'left'    => array(
						'title' => esc_html__( 'Left', 'gigneo' ),
						'icon'  => 'eicon-text-align-left',
					),
					'center'  => array(
						'title' => esc_html__( 'Center', 'gigneo' ),
						'icon'  => 'eicon-text-align-center',
					),
					'right'   => array(
						'title' => esc_html__( 'Right', 'gigneo' ),
						'icon'  => 'eicon-text-align-right',
					),
					'justify' => array(
						'title' => esc_html__( 'Justified', 'gigneo' ),
						'icon'  => 'eicon-text-align-justify',
					),
				),
				'default'    => '',
				'selectors'  => array(
					'{{WRAPPER}} .gn-title, .gn-description' => 'text-align: {{VALUE}};',
				),
				'conditions' => array(
					'relation' => 'or',
					'terms'    => array(
						array(
							'name'     => 'form_title',
							'operator' => '===',
							'value'    => 'yes',
						),
						array(
							'name'     => 'form_description',
							'operator' => '===',
							'value'    => 'yes',
						),
					),
				),
			)
		);

		/* ================= Go Back ================= */
		$this->add_control(
			'form_go_back',
			array(
				'label'                => esc_html__( 'Go Back', 'gigneo' ),
				'type'                 => Controls_Manager::SWITCHER,
				'label_on'             => esc_html__( 'Show', 'gigneo' ),
				'label_off'            => esc_html__( 'Hide', 'gigneo' ),
				'return_value'         => 'yes',
				'default'              => 'yes',
				'selectors_dictionary' => array(
					'yes' => 'block',
					''    => 'none',
				),
				'selectors'            => array(
					'{{WRAPPER}} .gn-auth-action-text' => 'display: {{VALUE}};',
				),
				'separator'            => 'before',
			)
		);

		$this->end_controls_section();

		/* ================= Title ================= */
		$this->start_controls_section(
			'title_style',
			array(
				'label'     => esc_html__( 'Title', 'gigneo' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array(
					'form_title' => 'yes',
				),
			)
		);

		$this->add_control(
			'title_color',
			array(
				'label'     => esc_html__( 'Text Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-auth-heading-area .gn-title' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'title_typography',
				'global'   => array(
					'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
				),
				'selector' => '{{WRAPPER}} .gn-auth-heading-area .gn-title',
			)
		);

		$this->add_group_control(
			Group_Control_Text_Shadow::get_type(),
			array(
				'name'     => 'title_text_shadow',
				'selector' => '{{WRAPPER}} .gn-auth-heading-area .gn-title',
			)
		);

		$this->end_controls_section();

		/* ================= Description ================= */
		$this->start_controls_section(
			'description_style',
			array(
				'label'     => esc_html__( 'Description', 'gigneo' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array(
					'form_description' => 'yes',
				),
			)
		);

		$this->add_control(
			'description_color',
			array(
				'label'     => esc_html__( 'Text Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-auth-heading-area .gn-description' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'description_typography',
				'global'   => array(
					'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
				),
				'selector' => '{{WRAPPER}} .gn-auth-heading-area .gn-description',
			)
		);

		$this->add_responsive_control(
			'description_margin',
			array(
				'label'      => esc_html__( 'Margin', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', 'em', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-auth-heading-area .gn-description' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'fields_style',
			array(
				'label' => esc_html__( 'Fields', 'gigneo' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_control(
			'fields_label_heading',
			array(
				'label'     => esc_html__( 'Label', 'gigneo' ),
				'type'      => Controls_Manager::HEADING,
				'separator' => 'before',
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'label_typography',
				'label'    => esc_html__( 'Typography', 'gigneo' ),
				'selector' => '{{WRAPPER}} .gn-form-fields .gn-form-field label',
			)
		);

		$this->add_control(
			'label_color',
			array(
				'label'     => esc_html__( 'Text Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-form-fields .gn-form-field label' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_responsive_control(
			'label_margin',
			array(
				'label'      => esc_html__( 'Margin', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', 'em', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-form-fields .gn-form-field label' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_control(
			'fields_input_heading',
			array(
				'label'     => esc_html__( 'Input', 'gigneo' ),
				'type'      => Controls_Manager::HEADING,
				'separator' => 'before',
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'input_typography',
				'label'    => esc_html__( 'Typography', 'gigneo' ),
				'selector' => '{{WRAPPER}} .gn-form-field input[type="text"], {{WRAPPER}} .gn-form-field input[type="email"], {{WRAPPER}} .gn-form-field input[type="password"]',
			)
		);

		$this->add_control(
			'input_text_color',
			array(
				'label'     => esc_html__( 'Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-form-field input' => 'color: {{VALUE}};',
					'{{WRAPPER}} .gn-form-field input:-webkit-autofill,
                     {{WRAPPER}} .gn-form-field input:-webkit-autofill:focus,
                     {{WRAPPER}} .gn-form-field input:-webkit-autofill:hover'
					=> '-webkit-text-fill-color: {{VALUE}} !important; 
                    caret-color: {{VALUE}} !important;',
				),
			)
		);

		$this->add_control(
			'input_background',
			array(
				'label'     => esc_html__( 'Background Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-form-field input' => 'background-color: {{VALUE}};',
					'{{WRAPPER}} .gn-form-field input:-webkit-autofill,
                     {{WRAPPER}} .gn-form-field input:-webkit-autofill:focus,
                     {{WRAPPER}} .gn-form-field input:-webkit-autofill:hover'
					=> '-webkit-box-shadow: 0 0 0 1000px {{VALUE}} inset !important; 
                    box-shadow: 0 0 0 1000px {{VALUE}} inset !important;',
				),
			)
		);

		$this->add_control(
			'input_placeholder_color',
			array(
				'label'     => esc_html__( 'Placeholder Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-form-field input::placeholder' => 'color: {{VALUE}}; opacity: 1;',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'box_shadow_normal',
				'selector' => '{{WRAPPER}} .gn-form-field input',
			)
		);

		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'input_border',
				'selector' => '{{WRAPPER}} .gn-form-field input',
			)
		);

		$this->add_responsive_control(
			'input_border_radius',
			array(
				'label'      => esc_html__( 'Border Radius', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-form-field input' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'input_padding',
			array(
				'label'      => esc_html__( 'Padding', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', 'em', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-form-field input' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		/* ================= Hover ================= */
		$this->start_controls_tabs( 'form_field_style_tabs' );

		$this->start_controls_tab(
			'form_field_hover',
			array( 'label' => esc_html__( 'Hover', 'gigneo' ) )
		);

		$this->add_control(
			'input_border_color_hover',
			array(
				'label'     => __( 'Border Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-form-field input:hover:not(:focus)' => 'border-color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'background_hover',
			array(
				'label'     => esc_html__( 'Background Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '',
				'selectors' => array(
					'{{WRAPPER}} .gn-form-field input:hover:not(:focus)' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'box_shadow_hover',
				'selector' => '{{WRAPPER}} .gn-form-field input:hover:not(:focus)',
			)
		);

		$this->end_controls_tab();

		/* ================= Focus ================= */
		$this->start_controls_tab(
			'form_field_focus',
			array( 'label' => esc_html__( 'Focus', 'gigneo' ) )
		);

		$this->add_control(
			'background_focus',
			array(
				'label'     => esc_html__( 'Background Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '',
				'selectors' => array(
					'{{WRAPPER}} .gn-form-field input:focus' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'input_border_color_focus',
			array(
				'label'     => __( 'Border Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-form-field input:focus' => 'border-color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'box_shadow_focus',
				'selector' => '{{WRAPPER}} .gn-form-field input:focus',
			)
		);

		$this->end_controls_tab();

		/* ================= Error ================= */
		$this->start_controls_tab(
			'form_field_error',
			array( 'label' => esc_html__( 'Error', 'gigneo' ) )
		);

		$this->add_control(
			'input_border_color_error',
			array(
				'label'     => __( 'Border Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-auth-register-continue-btn:error' => 'border-color: {{VALUE}};',
				),
			)
		);

		$this->end_controls_tab();

		$this->end_controls_tabs();

		/* ============ Eye Icon Settings ============ */
		$this->add_control(
			'eye_icon_heading',
			array(
				'label'     => esc_html__( 'Icon', 'gigneo' ),
				'type'      => Controls_Manager::HEADING,
				'separator' => 'before',
			)
		);

		$this->add_responsive_control(
			'eye_icon_size',
			array(
				'label'      => esc_html__( 'Size', 'gigneo' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%', 'em', 'rem' ),
                'range' => [
                    'px' => [
                        'min' => 10,
                        'max' => 30,
                        'step' => 1,
                    ],
                ],
				'default'    => array(
					'unit' => 'px',
					'size' => 20,
				),
				'selectors'  => array(
					'{{WRAPPER}} .gn-form-field .gn-auth-input-wrapper .gn-password-revealed' => 'font-size: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_control(
			'eye_icon_color',
			array(
				'label'     => esc_html__( 'Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-form-field .gn-auth-input-wrapper .gn-password-revealed' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_responsive_control(
			'eye_icon_margin',
			array(
				'label'      => esc_html__( 'Margin', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em', 'rem', 'vw' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-form-field .gn-auth-input-wrapper .gn-password-revealed' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'reset_password_button_style',
			array(
				'label' => esc_html__( 'Reset Button', 'gigneo' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'reset_button_typography',
				'label'    => esc_html__( 'Typography', 'gigneo' ),
				'selector' => '{{WRAPPER}} .gn-auth-action-btn',
			)
		);

		$this->start_controls_tabs( 'button_style_tabs' );

		$this->start_controls_tab(
			'button_normal',
			array( 'label' => esc_html__( 'Normal', 'gigneo' ) )
		);

		$this->add_control(
			'button_text_color',
			array(
				'label'     => esc_html__( 'Text Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-auth-action-btn' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'button_background',
			array(
				'label'     => esc_html__( 'Background Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '',
				'selectors' => array(
					'{{WRAPPER}} .gn-auth-action-btn' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'button_box_shadow',
				'label'    => esc_html__( 'Box Shadow', 'gigneo' ),
				'selector' => '{{WRAPPER}} .gn-auth-action-btn',
			)
		);

		$this->end_controls_tab();

		$this->start_controls_tab(
			'button_hover',
			array( 'label' => esc_html__( 'Hover', 'gigneo' ) )
		);

		$this->add_control(
			'reset_button_text_color_hover',
			array(
				'label'     => __( 'Text Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-auth-action-btn:hover' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'button_background_hover',
			array(
				'label'     => esc_html__( 'Background Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '',
				'selectors' => array(
					'{{WRAPPER}} .gn-auth-action-btn:hover' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'reset_button_border_color_hover',
			array(
				'label'     => __( 'Border Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-auth-action-btn:hover' => 'border-color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'button_box_shadow_hover',
				'selector' => '{{WRAPPER}} .gn-auth-action-btn:hover',
			)
		);

		$this->end_controls_tab();

		$this->start_controls_tab(
			'button_focus',
			array( 'label' => esc_html__( 'Focus', 'gigneo' ) )
		);

		$this->add_control(
			'reset_button_text_color_focus',
			array(
				'label'     => __( 'Text Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-auth-action-btn:focus' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'button_background_focus',
			array(
				'label'     => esc_html__( 'Background Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '',
				'selectors' => array(
					'{{WRAPPER}} .gn-auth-action-btn:focus' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'reset_button_border_color_focus',
			array(
				'label'     => __( 'Border Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-auth-action-btn:focus' => 'border-color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'button_box_shadow_focus',
				'selector' => '{{WRAPPER}} .gn-auth-action-btn:focus',
			)
		);

		$this->end_controls_tab();

		$this->end_controls_tabs();

		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'      => 'button_border',
				'separator' => 'before',
				'selector'  => '{{WRAPPER}} .gn-auth-action-btn',
			)
		);

		$this->add_responsive_control(
			'button_border_radius',
			array(
				'label'      => esc_html__( 'Border Radius', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-auth-action-btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'button_padding',
			array(
				'label'      => esc_html__( 'Padding', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', 'em', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-auth-action-btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'button_margin',
			array(
				'label'      => esc_html__( 'Margin', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', 'em', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-auth-action-btn' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_control(
			'loader_style',
			array(
				'label'     => esc_html__( 'Loader', 'gigneo' ),
				'type'      => Controls_Manager::HEADING,
				'separator' => 'before',
			)
		);

		$this->add_responsive_control(
			'btn_loader_size',
			array(
				'label'      => __( 'Size', 'gigneo' ),
				'type'       => \Elementor\Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%', 'em' ),
				'range'      => array(
					'px' => array(
						'min'  => 5,
						'max'  => 30,
						'step' => 1,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .gn-auth-actions .gn-loading::after' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'btn_loader_border',
				'selector' => '{{WRAPPER}} .gn-auth-actions .gn-loading::after',
			)
		);

		$this->add_control(
			'btn_loader_border_top_color',
			array(
				'label'     => __( 'Border Top Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-auth-actions .gn-loading::after' => 'border-top-color: {{VALUE}};',
				),
			)
		);

		$this->add_responsive_control(
			'btn_loader_margin',
			array(
				'label'      => esc_html__( 'Margin', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', 'em', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-auth-actions .gn-loading::after' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'go_back_style',
			array(
				'label' => esc_html__( 'Go Back', 'gigneo' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'go_back_typography',
				'label'    => esc_html__( 'Typography', 'gigneo' ),
				'selector' => '{{WRAPPER}} .gn-auth-action-text',
			)
		);

		$this->add_control(
			'go_back_text_color',
			array(
				'label'     => esc_html__( 'Text Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-auth-action-text' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_responsive_control(
			'go_back_text_padding',
			array(
				'label'      => esc_html__( 'Padding', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', 'em', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-auth-action-text' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'go_back_text_margin',
			array(
				'label'      => esc_html__( 'Margin', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', 'em', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-auth-action-text' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_control(
			'sign_in_style',
			array(
				'label'     => esc_html__( 'Sign in', 'gigneo' ),
				'type'      => Controls_Manager::HEADING,
				'separator' => 'before',
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'sign_in_typography',
				'global'   => array(
					'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
				),
				'selector' => '{{WRAPPER}} .gn-sign-in',
			)
		);

		/* ================= Hover ================= */
		$this->start_controls_tabs( 'sign_in_style_tabs' );

		$this->start_controls_tab(
			'sign_in_normal',
			array( 'label' => esc_html__( 'Normal', 'gigneo' ) )
		);

		$this->add_control(
			'sign_in_text_color',
			array(
				'label'     => esc_html__( 'Text Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-sign-in' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'sign_in_background',
			array(
				'label'     => esc_html__( 'Background Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '',
				'selectors' => array(
					'{{WRAPPER}} .gn-sign-in' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'sign_in_text_decoration',
			array(
				'label'     => esc_html__( 'Text Decoration', 'gigneo' ),
				'type'      => \Elementor\Controls_Manager::SELECT,
				'default'   => 'underline',
				'options'   => array(
					'none'         => esc_html__( 'None', 'gigneo' ),
					'underline'    => esc_html__( 'Underline', 'gigneo' ),
					'overline'     => esc_html__( 'Overline', 'gigneo' ),
					'line-through' => esc_html__( 'Line Through', 'gigneo' ),
				),
				'selectors' => array(
					'{{WRAPPER}} .gn-sign-in' => 'text-decoration: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'sign_in_box_shadow',
				'selector' => '{{WRAPPER}} .gn-sign-in',
			)
		);

		$this->end_controls_tab();

		$this->start_controls_tab(
			'sign_in_hover',
			array( 'label' => esc_html__( 'Hover', 'gigneo' ) )
		);

		$this->add_control(
			'sign_in_text_color_hover',
			array(
				'label'     => __( 'Text Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-sign-in:hover' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'sign_in_background_hover',
			array(
				'label'     => esc_html__( 'Background Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '',
				'selectors' => array(
					'{{WRAPPER}} .gn-sign-in:hover' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'sign_in_border_color_hover',
			array(
				'label'     => __( 'Border Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-sign-in:hover' => 'border-color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'sign_in_text_decoration_hover',
			array(
				'label'     => esc_html__( 'Text Decoration', 'gigneo' ),
				'type'      => \Elementor\Controls_Manager::SELECT,
				'default'   => 'underline',
				'options'   => array(
					'none'         => esc_html__( 'None', 'gigneo' ),
					'underline'    => esc_html__( 'Underline', 'gigneo' ),
					'overline'     => esc_html__( 'Overline', 'gigneo' ),
					'line-through' => esc_html__( 'Line Through', 'gigneo' ),
				),
				'selectors' => array(
					'{{WRAPPER}} .gn-sign-in:hover' => 'text-decoration: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'sign_in_box_shadow_hover',
				'selector' => '{{WRAPPER}} .gn-sign-in:hover',
			)
		);

		$this->end_controls_tab();

		$this->start_controls_tab(
			'sign_in_focus',
			array( 'label' => esc_html__( 'Focus', 'gigneo' ) )
		);

		$this->add_control(
			'sign_in_text_color_focus',
			array(
				'label'     => __( 'Text Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-sign-in:focus' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'sign_in_background_focus',
			array(
				'label'     => esc_html__( 'Background Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '',
				'selectors' => array(
					'{{WRAPPER}} .gn-sign-in:focus' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'sign_in_border_focus',
			array(
				'label'     => __( 'Border Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-auth-action-btn:focus' => 'border-color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'sign_in_box_shadow_focus',
				'selector' => '{{WRAPPER}} .gn-sign-in:focus',
			)
		);

		$this->end_controls_tab();

		$this->end_controls_tabs();

		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'      => 'sign_in_border',
				'separator' => 'before',
				'selector'  => '{{WRAPPER}} .gn-sign-in',
			)
		);

		$this->add_responsive_control(
			'sign_in_border_radius',
			array(
				'label'      => esc_html__( 'Border Radius', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-sign-in' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'sign_in_text_padding',
			array(
				'label'      => esc_html__( 'Padding', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', 'em', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-sign-in' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'sign_in_text_margin',
			array(
				'label'      => esc_html__( 'Margin', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', 'em', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-sign-in' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->end_controls_section();

		/* ================= Password Validation Hint ================= */
		$this->start_controls_section(
			'password_validation_hint_style',
			array(
				'label' => esc_html__( 'Password Validation Hint', 'gigneo' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'password_validation_hint_typography',
				'global'   => array(
					'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
				),
				'selector' => '{{WRAPPER}} .gn-password-notice li',
			)
		);

		$this->add_control(
			'password_validation_hint_text_color',
			array(
				'label'     => esc_html__( 'Text Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-password-notice li' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'password_validation_hint_background',
			array(
				'label'     => esc_html__( 'Background Color', 'gigneo' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .gn-password-notice li' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'password_validation_hint_border',
				'selector' => '{{WRAPPER}} .gn-password-notice li',
			)
		);

		$this->add_responsive_control(
			'password_validation_hint_border_radius',
			array(
				'label'      => esc_html__( 'Border Radius', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-password-notice li' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'password_validation_hint_padding',
			array(
				'label'      => esc_html__( 'Padding', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', 'em', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-password-notice li' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'password_validation_hint_margin',
			array(
				'label'      => esc_html__( 'Margin', 'gigneo' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', 'em', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .gn-password-notice li' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->end_controls_section();
	}

	/**
	 * Render widget output on the frontend.
	 *
	 * Uses a template file to separate PHP/HTML from logic.
	 */
	protected function render() {
		$settings = $this->get_settings_for_display();

		// Read the dropdown value (fallback to 'reset' if missing or invalid)
		$mode = isset( $settings['password_mode'] ) && $settings['password_mode'] === 'change' ? 'change' : 'reset';

		// Make these variables available inside the included template file
		$password_mode   = $mode;
		$widget_settings = $settings;

		$template_path = '';
		if ( $mode === 'change' ) {
			$template_path = gigneo_get_template( 'auth/change-password.php' );
		} else {
			$template_path = gigneo_get_template( 'elementor/widgets/forgot-password.php' );
		}

		if ( !empty($template_path) && file_exists( $template_path ) ) {
			include $template_path;
		}
	}
}
