<?php
/**
 * Advanced Button widget.
 *
 * @package IMPACT_WIDGETS_ELEMENTOR
 */

namespace ImpactAddons\ImpactWidgetsForElementor\Widgets;

use Elementor\Controls_Manager;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Group_Control_Typography;
use Elementor\Icons_Manager;
use Elementor\Widget_Base;
use ImpactAddons\ImpactWidgetsForElementor\Config\Advanced_Button_Config;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class Advanced_Button extends Widget_Base {
	public function get_name(): string {
		return 'impact_widgets_elementor_advanced-button';
	}

	public function get_title(): string {
		return esc_html__( 'Advanced Button', 'impact-widgets-for-elementor' );
	}

	public function get_icon(): string {
		return 'eicon-button';
	}

	public function get_categories(): array {
		return array( 'impact-widgets-elementor' );
	}

	public function get_style_depends(): array {
		return array( 'impact_widgets_elementor_advanced-button' );
	}

	protected function register_controls(): void {
		$this->start_controls_section(
			'section_content',
			array(
				'label' => esc_html__( 'Content', 'impact-widgets-for-elementor' ),
			)
		);

		$this->add_control(
			'design_style',
			array(
				'label'   => esc_html__( 'Button Style', 'impact-widgets-for-elementor' ),
				'type'    => Controls_Manager::SELECT,
				'default' => Advanced_Button_Config::get_default_style(),
				'options' => Advanced_Button_Config::get_style_options(),
			)
		);

		$this->add_control(
			'button_text',
			array(
				'label'       => esc_html__( 'Text', 'impact-widgets-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'default'     => esc_html__( 'Read More', 'impact-widgets-for-elementor' ),
				'placeholder' => esc_html__( 'Enter button text', 'impact-widgets-for-elementor' ),
			)
		);

		$this->add_control(
			'button_link',
			array(
				'label'         => esc_html__( 'Link', 'impact-widgets-for-elementor' ),
				'type'          => Controls_Manager::URL,
				'placeholder'   => esc_html__( 'https://your-link.com', 'impact-widgets-for-elementor' ),
				'show_external' => true,
				'default'       => array(
					'url' => '#',
				),
			)
		);

		$this->add_responsive_control(
			'alignment',
			array(
				'label'     => esc_html__( 'Alignment', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::CHOOSE,
				'options'   => array(
					'left' => array(
						'title' => esc_html__( 'Left', 'impact-widgets-for-elementor' ),
						'icon'  => 'eicon-text-align-left',
					),
					'center' => array(
						'title' => esc_html__( 'Center', 'impact-widgets-for-elementor' ),
						'icon'  => 'eicon-text-align-center',
					),
					'right' => array(
						'title' => esc_html__( 'Right', 'impact-widgets-for-elementor' ),
						'icon'  => 'eicon-text-align-right',
					),
				),
				'default'   => 'center',
				'toggle'    => true,
				'selectors' => array(
					'{{WRAPPER}} .eb-advanced-button' => 'text-align: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'accent_overlay_shape',
			array(
				'label'     => esc_html__( 'Accent Shape', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'circle',
				'options'   => array(
					'circle'  => esc_html__( 'Circle', 'impact-widgets-for-elementor' ),
					'rounded' => esc_html__( 'Rounded Box', 'impact-widgets-for-elementor' ),
				),
				'condition' => array(
					'design_style' => 'accent-overlay',
				),
			)
		);

		$this->add_control(
			'ribbon_tag_text',
			array(
				'label'       => esc_html__( 'Ribbon Text', 'impact-widgets-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'default'     => esc_html__( 'AVAILABLE FOR WORK', 'impact-widgets-for-elementor' ),
				'placeholder' => esc_html__( 'Enter ribbon text', 'impact-widgets-for-elementor' ),
				'condition'   => array(
					'design_style' => 'ribbon-tag',
				),
			)
		);

		$this->add_control(
			'ribbon_tag_fill',
			array(
				'label'     => esc_html__( 'Fill Type', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'bordered',
				'options'   => array(
					'bordered'   => esc_html__( 'Bordered', 'impact-widgets-for-elementor' ),
					'background' => esc_html__( 'Background', 'impact-widgets-for-elementor' ),
				),
				'condition' => array(
					'design_style' => 'ribbon-tag',
				),
			)
		);

		$this->add_control(
			'ribbon_tag_position',
			array(
				'label'     => esc_html__( 'Ribbon Position', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'center',
				'options'   => array(
					'left'   => esc_html__( 'Left', 'impact-widgets-for-elementor' ),
					'center' => esc_html__( 'Center', 'impact-widgets-for-elementor' ),
					'right'  => esc_html__( 'Right', 'impact-widgets-for-elementor' ),
				),
				'condition' => array(
					'design_style' => 'ribbon-tag',
				),
			)
		);

		$this->add_control(
			'ribbon_tag_button_shape',
			array(
				'label'     => esc_html__( 'Button Shape', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'pill',
				'options'   => array(
					'pill'      => esc_html__( 'Pill', 'impact-widgets-for-elementor' ),
					'rectangle' => esc_html__( 'Rectangle', 'impact-widgets-for-elementor' ),
				),
				'condition' => array(
					'design_style' => 'ribbon-tag',
				),
			)
		);


		$this->add_control(
			'offer_note_content_type',
			array(
				'label'     => esc_html__( 'Badge Content Type', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'text',
				'options'   => array(
					'text'  => esc_html__( 'Text', 'impact-widgets-for-elementor' ),
					'icon'  => esc_html__( 'Icon', 'impact-widgets-for-elementor' ),
					'image' => esc_html__( 'Image', 'impact-widgets-for-elementor' ),
				),
				'condition' => array(
					'design_style' => 'offer-note',
				),
			)
		);

		$this->add_control(
			'offer_note_text',
			array(
				'label'       => esc_html__( 'Badge Text', 'impact-widgets-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'default'     => esc_html__( 'get flat 50% off', 'impact-widgets-for-elementor' ),
				'placeholder' => esc_html__( 'Enter offer text', 'impact-widgets-for-elementor' ),
				'condition'   => array(
					'design_style' => 'offer-note',
					'offer_note_content_type' => 'text',
				),
			)
		);

		$this->add_control(
			'offer_note_icon',
			array(
				'label'            => esc_html__( 'Badge Icon', 'impact-widgets-for-elementor' ),
				'type'             => Controls_Manager::ICONS,
				'default'          => array(
					'value'   => 'fas fa-hand-point-down',
					'library' => 'fa-solid',
				),
				'fa4compatibility' => 'offer_note_icon_fa4',
				'condition'        => array(
					'design_style' => 'offer-note',
					'offer_note_content_type' => 'icon',
				),
			)
		);

		$this->add_control(
			'offer_note_image',
			array(
				'label'     => esc_html__( 'Badge Image', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::MEDIA,
				'dynamic'   => array(
					'active' => true,
				),
				'condition' => array(
					'design_style' => 'offer-note',
					'offer_note_content_type' => 'image',
				),
			)
		);

		$this->add_control(
			'offer_note_repeat',
			array(
				'label'     => esc_html__( 'Badge Repeat Count', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::NUMBER,
				'min'       => 1,
				'max'       => 8,
				'step'      => 1,
				'default'   => 1,
				'condition' => array(
					'design_style' => 'offer-note',
					'offer_note_content_type!' => 'text',
				),
			)
		);

		$this->add_responsive_control(
			'offer_note_visual_size',
			array(
				'label'      => esc_html__( 'Badge Icon/Image Size', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => 8,
						'max' => 120,
					),
				),
				'default'    => array(
					'size' => 26,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-button--offer-note' => '--eb-offer-icon-size: {{SIZE}}{{UNIT}};',
				),
				'condition'  => array(
					'design_style' => 'offer-note',
					'offer_note_content_type!' => 'text',
				),
			)
		);

		$this->add_responsive_control(
			'offer_note_item_gap',
			array(
				'label'      => esc_html__( 'Badge Item Gap', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => 0,
						'max' => 60,
					),
				),
				'default'    => array(
					'size' => 10,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-button--offer-note' => '--eb-offer-item-gap: {{SIZE}}{{UNIT}};',
				),
				'condition'  => array(
					'design_style' => 'offer-note',
				),
			)
		);

		$this->add_control(
			'offer_note_fill',
			array(
				'label'     => esc_html__( 'Fill Type', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'bordered',
				'options'   => array(
					'bordered'   => esc_html__( 'Bordered', 'impact-widgets-for-elementor' ),
					'background' => esc_html__( 'Background', 'impact-widgets-for-elementor' ),
				),
				'condition' => array(
					'design_style' => 'offer-note',
				),
			)
		);

		$this->add_control(
			'offer_note_position',
			array(
				'label'     => esc_html__( 'Badge Position', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'bottom',
				'options'   => array(
					'top'    => esc_html__( 'Top', 'impact-widgets-for-elementor' ),
					'right'  => esc_html__( 'Right', 'impact-widgets-for-elementor' ),
					'bottom' => esc_html__( 'Bottom', 'impact-widgets-for-elementor' ),
					'left'   => esc_html__( 'Left', 'impact-widgets-for-elementor' ),
				),
				'condition' => array(
					'design_style' => 'offer-note',
				),
			)
		);

		$this->add_control(
			'offer_note_color',
			array(
				'label'     => esc_html__( 'Badge Accent Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#ea3c78',
				'selectors' => array(
					'{{WRAPPER}} .eb-advanced-button--offer-note' => '--eb-offer-color: {{VALUE}};',
				),
				'condition' => array(
					'design_style' => 'offer-note',
				),
			)
		);

		$this->add_control(
			'accent_overlay_fill',
			array(
				'label'     => esc_html__( 'Accent Fill', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'outline',
				'options'   => array(
					'outline' => esc_html__( 'Outline', 'impact-widgets-for-elementor' ),
					'solid'   => esc_html__( 'Solid', 'impact-widgets-for-elementor' ),
				),
				'condition' => array(
					'design_style' => 'accent-overlay',
				),
			)
		);

		$this->add_responsive_control(
			'accent_overlay_size',
			array(
				'label'      => esc_html__( 'Accent Size', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => 24,
						'max' => 220,
					),
				),
				'default'    => array(
					'size' => 78,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-button--accent-overlay .eb-advanced-button__link' => '--eb-accent-size: {{SIZE}}{{UNIT}};',
				),
				'condition'  => array(
					'design_style' => 'accent-overlay',
				),
			)
		);

		$this->add_responsive_control(
			'accent_overlay_offset_x',
			array(
				'label'      => esc_html__( 'Accent Offset X', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => -200,
						'max' => 200,
					),
				),
				'default'    => array(
					'size' => 20,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-button--accent-overlay .eb-advanced-button__link' => '--eb-accent-x: {{SIZE}}{{UNIT}};',
				),
				'condition'  => array(
					'design_style' => 'accent-overlay',
				),
			)
		);

		$this->add_responsive_control(
			'accent_overlay_offset_y',
			array(
				'label'      => esc_html__( 'Accent Offset Y', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => -120,
						'max' => 120,
					),
				),
				'default'    => array(
					'size' => 0,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-button--accent-overlay .eb-advanced-button__link' => '--eb-accent-y: {{SIZE}}{{UNIT}};',
				),
				'condition'  => array(
					'design_style' => 'accent-overlay',
				),
			)
		);

		$this->add_control(
			'accent_overlay_color',
			array(
				'label'     => esc_html__( 'Accent Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#7c6ef4',
				'selectors' => array(
					'{{WRAPPER}} .eb-advanced-button--accent-overlay .eb-advanced-button__link' => '--eb-accent-color: {{VALUE}};',
				),
				'condition' => array(
					'design_style' => 'accent-overlay',
				),
			)
		);

		$this->add_control(
			'accent_overlay_opacity',
			array(
				'label'     => esc_html__( 'Accent Opacity', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::NUMBER,
				'min'       => 0,
				'max'       => 1,
				'step'      => 0.1,
				'default'   => 0.4,
				'selectors' => array(
					'{{WRAPPER}} .eb-advanced-button--accent-overlay .eb-advanced-button__link' => '--eb-accent-opacity: {{VALUE}};',
				),
				'condition' => array(
					'design_style' => 'accent-overlay',
				),
			)
		);

		$this->add_responsive_control(
			'accent_overlay_stroke_width',
			array(
				'label'      => esc_html__( 'Accent Stroke Width', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 12,
					),
				),
				'default'    => array(
					'size' => 2,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-button--accent-overlay .eb-advanced-button__link' => '--eb-accent-stroke: {{SIZE}}{{UNIT}};',
				),
				'condition'  => array(
					'design_style' => 'accent-overlay',
				),
			)
		);

		$this->add_control(
			'downloadable_variant',
			array(
				'label'     => esc_html__( 'Download Layout', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'solid-split',
				'options'   => array(
					'solid-split'      => esc_html__( 'Solid Split', 'impact-widgets-for-elementor' ),
					'text-underline'   => esc_html__( 'Text Underline', 'impact-widgets-for-elementor' ),
					'circle-icon-text' => esc_html__( 'Circle Icon + Text', 'impact-widgets-for-elementor' ),
					'text-arrow-line'  => esc_html__( 'Text + Arrow Line', 'impact-widgets-for-elementor' ),
					'icon-only-circle' => esc_html__( 'Icon Only Circle', 'impact-widgets-for-elementor' ),
					'file-card'        => esc_html__( 'File Card', 'impact-widgets-for-elementor' ),
					'text-icon-square' => esc_html__( 'Text + Square Icon', 'impact-widgets-for-elementor' ),
					'store-badge'      => esc_html__( 'Store Badge', 'impact-widgets-for-elementor' ),
				),
				'condition' => array(
					'design_style' => 'downloadable',
				),
			)
		);

		$this->add_control(
			'downloadable_fill',
			array(
				'label'     => esc_html__( 'Fill Type', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'background',
				'options'   => array(
					'background' => esc_html__( 'Background', 'impact-widgets-for-elementor' ),
					'bordered'   => esc_html__( 'Bordered', 'impact-widgets-for-elementor' ),
				),
				'condition' => array(
					'design_style' => 'downloadable',
				),
			)
		);

		$this->add_control(
			'downloadable_icon',
			array(
				'label'            => esc_html__( 'Download Icon', 'impact-widgets-for-elementor' ),
				'type'             => Controls_Manager::ICONS,
				'default'          => array(
					'value'   => 'fas fa-download',
					'library' => 'fa-solid',
				),
				'fa4compatibility' => 'downloadable_icon_fa4',
				'condition'        => array(
					'design_style' => 'downloadable',
					'downloadable_variant!' => 'text-arrow-line',
				),
			)
		);

		$this->add_control(
			'downloadable_icon_position',
			array(
				'label'     => esc_html__( 'Icon Position', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'right',
				'options'   => array(
					'left'  => esc_html__( 'Left', 'impact-widgets-for-elementor' ),
					'right' => esc_html__( 'Right', 'impact-widgets-for-elementor' ),
				),
				'condition' => array(
					'design_style' => 'downloadable',
				),
			)
		);

		$this->add_control(
			'downloadable_arrow_icon',
			array(
				'label'            => esc_html__( 'Arrow Icon', 'impact-widgets-for-elementor' ),
				'type'             => Controls_Manager::ICONS,
				'default'          => array(
					'value'   => 'fas fa-arrow-right',
					'library' => 'fa-solid',
				),
				'fa4compatibility' => 'downloadable_arrow_icon_fa4',
				'condition'        => array(
					'design_style' => 'downloadable',
					'downloadable_variant' => 'text-arrow-line',
				),
			)
		);

		$this->add_control(
			'downloadable_file_tag',
			array(
				'label'       => esc_html__( 'File Tag Text', 'impact-widgets-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'default'     => esc_html__( 'pdf', 'impact-widgets-for-elementor' ),
				'placeholder' => esc_html__( 'pdf, word, zip', 'impact-widgets-for-elementor' ),
				'condition'   => array(
					'design_style' => 'downloadable',
					'downloadable_variant' => 'file-card',
				),
			)
		);

		$this->add_control(
			'downloadable_store_subtext',
			array(
				'label'       => esc_html__( 'Badge Top Text', 'impact-widgets-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'default'     => esc_html__( 'GET IT ON', 'impact-widgets-for-elementor' ),
				'placeholder' => esc_html__( 'GET IT ON', 'impact-widgets-for-elementor' ),
				'condition'   => array(
					'design_style' => 'downloadable',
					'downloadable_variant' => 'store-badge',
				),
			)
		);

		$this->add_control(
			'downloadable_enable_download_attr',
			array(
				'label'        => esc_html__( 'Force Download', 'impact-widgets-for-elementor' ),
				'type'         => Controls_Manager::SWITCHER,
				'label_on'     => esc_html__( 'Yes', 'impact-widgets-for-elementor' ),
				'label_off'    => esc_html__( 'No', 'impact-widgets-for-elementor' ),
				'return_value' => 'yes',
				'default'      => '',
				'condition'    => array(
					'design_style' => 'downloadable',
				),
			)
		);

		$this->add_control(
			'downloadable_filename',
			array(
				'label'       => esc_html__( 'Download File Name', 'impact-widgets-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'placeholder' => esc_html__( 'example.pdf', 'impact-widgets-for-elementor' ),
				'description' => esc_html__( 'Used when Force Download is enabled.', 'impact-widgets-for-elementor' ),
				'condition'   => array(
					'design_style' => 'downloadable',
				),
			)
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'section_style_button',
			array(
				'label' => esc_html__( 'Button', 'impact-widgets-for-elementor' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'button_typography',
				'selector' => '{{WRAPPER}} .eb-advanced-button__link',
			)
		);

		$this->add_responsive_control(
			'button_padding',
			array(
				'label'      => esc_html__( 'Padding', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', 'em', 'rem' ),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-button__link' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'button_min_width',
			array(
				'label'      => esc_html__( 'Minimum Width', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%' ),
				'range'      => array(
					'px' => array(
						'min' => 20,
						'max' => 500,
					),
					'%' => array(
						'min' => 5,
						'max' => 100,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-button__link' => 'min-width: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->start_controls_tabs( 'button_style_tabs' );

		$this->start_controls_tab(
			'button_style_normal',
			array(
				'label' => esc_html__( 'Normal', 'impact-widgets-for-elementor' ),
			)
		);

		$this->add_control(
			'button_text_color',
			array(
				'label'     => esc_html__( 'Text Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eb-advanced-button__link' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'button_background_color',
			array(
				'label'     => esc_html__( 'Background Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eb-advanced-button__link' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'button_border',
				'selector' => '{{WRAPPER}} .eb-advanced-button__link',
			)
		);

		$this->add_control(
			'button_border_radius',
			array(
				'label'      => esc_html__( 'Border Radius', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-button__link' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'button_box_shadow',
				'selector' => '{{WRAPPER}} .eb-advanced-button__link',
			)
		);

		$this->end_controls_tab();

		$this->start_controls_tab(
			'button_style_hover',
			array(
				'label' => esc_html__( 'Hover', 'impact-widgets-for-elementor' ),
			)
		);

		$this->add_control(
			'button_hover_text_color',
			array(
				'label'     => esc_html__( 'Text Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eb-advanced-button__link:hover' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'button_hover_background_color',
			array(
				'label'     => esc_html__( 'Background Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eb-advanced-button__link:hover' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'button_hover_border_color',
			array(
				'label'     => esc_html__( 'Border Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eb-advanced-button__link:hover' => 'border-color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'button_hover_box_shadow',
				'selector' => '{{WRAPPER}} .eb-advanced-button__link:hover',
			)
		);

		$this->add_control(
			'button_hover_transform_y',
			array(
				'label'      => esc_html__( 'Hover Move Y', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => -20,
						'max' => 20,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-button__link:hover' => 'transform: translateY({{SIZE}}{{UNIT}});',
				),
			)
		);

		$this->end_controls_tab();
		$this->end_controls_tabs();

		$this->add_control(
			'button_transition_duration',
			array(
				'label'      => esc_html__( 'Transition Duration (ms)', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::NUMBER,
				'default'    => 280,
				'min'        => 0,
				'max'        => 3000,
				'step'       => 10,
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-button__link' => 'transition-duration: {{VALUE}}ms;',
				),
			)
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'section_style_ribbon',
			array(
				'label'     => esc_html__( 'Ribbon Settings', 'impact-widgets-for-elementor' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array(
					'design_style' => 'ribbon-tag',
				),
			)
		);

		$this->add_control(
			'ribbon_tag_shape_style',
			array(
				'label'   => esc_html__( 'Ribbon Shape', 'impact-widgets-for-elementor' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'current',
				'options' => array(
					'current'     => esc_html__( 'Current', 'impact-widgets-for-elementor' ),
					'circular'    => esc_html__( 'Circular', 'impact-widgets-for-elementor' ),
					'rectangular' => esc_html__( 'Rectangular', 'impact-widgets-for-elementor' ),
				),
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'ribbon_tag_typography',
				'selector' => '{{WRAPPER}} .eb-advanced-button--ribbon-tag .eb-advanced-button__ribbon-text',
			)
		);

		$this->add_control(
			'ribbon_tag_primary_color',
			array(
				'label'     => esc_html__( 'Primary Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#a93dff',
				'selectors' => array(
					'{{WRAPPER}} .eb-advanced-button--ribbon-tag' => '--eb-ribbon-primary: {{VALUE}};',
				),
			)
		);

		$this->add_responsive_control(
			'ribbon_tag_padding',
			array(
				'label'      => esc_html__( 'Ribbon Padding', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', 'em', 'rem' ),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-button--ribbon-tag .eb-advanced-button__ribbon' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'ribbon_tag_border',
				'selector' => '{{WRAPPER}} .eb-advanced-button--ribbon-tag .eb-advanced-button__ribbon',
			)
		);

		$this->add_responsive_control(
			'ribbon_tag_border_radius',
			array(
				'label'      => esc_html__( 'Ribbon Border Radius', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-button--ribbon-tag .eb-advanced-button__ribbon' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'ribbon_tag_skew_angle',
			array(
				'label'      => esc_html__( 'Ribbon Skew Angle', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'deg' ),
				'range'      => array(
					'deg' => array(
						'min' => -60,
						'max' => 60,
					),
				),
				'default'    => array(
					'size' => -18,
					'unit' => 'deg',
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-button--ribbon-tag' => '--eb-ribbon-skew-angle: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'ribbon_tag_text_skew_angle',
			array(
				'label'      => esc_html__( 'Ribbon Text Skew Angle', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'deg' ),
				'range'      => array(
					'deg' => array(
						'min' => -60,
						'max' => 60,
					),
				),
				'default'    => array(
					'size' => 18,
					'unit' => 'deg',
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-button--ribbon-tag' => '--eb-ribbon-text-skew-angle: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_control(
			'ribbon_tag_secondary_color',
			array(
				'label'     => esc_html__( 'Secondary Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#f6b833',
				'selectors' => array(
					'{{WRAPPER}} .eb-advanced-button--ribbon-tag' => '--eb-ribbon-secondary: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'ribbon_tag_label_text_color',
			array(
				'label'     => esc_html__( 'Ribbon Text Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#ffffff',
				'selectors' => array(
					'{{WRAPPER}} .eb-advanced-button--ribbon-tag' => '--eb-ribbon-label-text: {{VALUE}};',
				),
			)
		);

		$this->add_responsive_control(
			'ribbon_tag_offset_x',
			array(
				'label'      => esc_html__( 'Ribbon Offset X', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => -240,
						'max' => 240,
					),
				),
				'default'    => array(
					'size' => 0,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-button--ribbon-tag' => '--eb-ribbon-offset-x: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'ribbon_tag_offset_y',
			array(
				'label'      => esc_html__( 'Ribbon Offset Y', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => -240,
						'max' => 240,
					),
				),
				'default'    => array(
					'size' => 0,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-button--ribbon-tag' => '--eb-ribbon-offset-y: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'section_style_downloadable',
			array(
				'label'     => esc_html__( 'Downloadable Settings', 'impact-widgets-for-elementor' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array(
					'design_style' => 'downloadable',
				),
			)
		);

		$this->add_control(
			'downloadable_primary_color',
			array(
				'label'     => esc_html__( 'Primary Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#5b63ff',
				'selectors' => array(
					'{{WRAPPER}} .eb-advanced-button--downloadable' => '--eb-download-primary: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'downloadable_secondary_color',
			array(
				'label'     => esc_html__( 'Secondary Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#8a53f7',
				'selectors' => array(
					'{{WRAPPER}} .eb-advanced-button--downloadable' => '--eb-download-secondary: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'downloadable_text_color',
			array(
				'label'     => esc_html__( 'Text Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#ffffff',
				'selectors' => array(
					'{{WRAPPER}} .eb-advanced-button--downloadable' => '--eb-download-text: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'downloadable_muted_color',
			array(
				'label'     => esc_html__( 'Muted/Panel Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#eef1ff',
				'selectors' => array(
					'{{WRAPPER}} .eb-advanced-button--downloadable' => '--eb-download-muted: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'downloadable_line_color',
			array(
				'label'     => esc_html__( 'Line Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#5b63ff',
				'selectors' => array(
					'{{WRAPPER}} .eb-advanced-button--downloadable' => '--eb-download-line: {{VALUE}};',
				),
			)
		);

		$this->add_responsive_control(
			'downloadable_icon_size',
			array(
				'label'      => esc_html__( 'Icon Size', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => 8,
						'max' => 80,
					),
				),
				'default'    => array(
					'size' => 18,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-button--downloadable' => '--eb-download-icon-size: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'downloadable_icon_box_size',
			array(
				'label'      => esc_html__( 'Icon Box Size', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => 24,
						'max' => 140,
					),
				),
				'default'    => array(
					'size' => 44,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-button--downloadable' => '--eb-download-icon-box-size: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'downloadable_split_size',
			array(
				'label'      => esc_html__( 'Split Area Width', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%' ),
				'range'      => array(
					'px' => array(
						'min' => 28,
						'max' => 180,
					),
					'%' => array(
						'min' => 10,
						'max' => 60,
					),
				),
				'default'    => array(
					'size' => 56,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-button--downloadable' => '--eb-download-split-size: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'downloadable_line_thickness',
			array(
				'label'      => esc_html__( 'Line Thickness', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 12,
					),
				),
				'default'    => array(
					'size' => 2,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-button--downloadable' => '--eb-download-line-size: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'downloadable_line_width',
			array(
				'label'      => esc_html__( 'Line Width', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%' ),
				'range'      => array(
					'px' => array(
						'min' => 30,
						'max' => 420,
					),
					'%' => array(
						'min' => 20,
						'max' => 100,
					),
				),
				'default'    => array(
					'size' => 140,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-button--downloadable' => '--eb-download-line-width: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'downloadable_card_size',
			array(
				'label'      => esc_html__( 'Card Size', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => 60,
						'max' => 280,
					),
				),
				'default'    => array(
					'size' => 120,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-button--downloadable' => '--eb-download-card-size: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'downloadable_typography',
				'selector' => '{{WRAPPER}} .eb-advanced-button--downloadable .eb-advanced-button__label',
			)
		);

		$this->add_responsive_control(
			'downloadable_inner_gap',
			array(
				'label'      => esc_html__( 'Item Gap', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => 0,
						'max' => 80,
					),
				),
				'default'    => array(
					'size' => 12,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-button--downloadable' => '--eb-download-gap: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_control(
			'downloadable_store_subtext_color',
			array(
				'label'     => esc_html__( 'Badge Top Text Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => 'rgba(255, 255, 255, 0.82)',
				'selectors' => array(
					'{{WRAPPER}} .eb-advanced-button--downloadable' => '--eb-download-store-subtext-color: {{VALUE}};',
				),
				'condition' => array(
					'design_style' => 'downloadable',
					'downloadable_variant' => 'store-badge',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'      => 'downloadable_store_subtext_typography',
				'selector'  => '{{WRAPPER}} .eb-advanced-button--downloadable .eb-advanced-button__download-store-subtext',
				'condition' => array(
					'design_style' => 'downloadable',
					'downloadable_variant' => 'store-badge',
				),
			)
		);

		$this->end_controls_section();
	}

	protected function render(): void {
		$settings = $this->get_settings_for_display();

		$design_style = isset( $settings['design_style'] ) ? Advanced_Button_Config::sanitize_style( $settings['design_style'] ) : Advanced_Button_Config::get_default_style();
		$text = ! empty( $settings['button_text'] ) ? $settings['button_text'] : esc_html__( 'Read More', 'impact-widgets-for-elementor' );
		$link = ! empty( $settings['button_link']['url'] ) ? $settings['button_link']['url'] : '#';
		$offer_text = '';
		$offer_content_type = 'text';
		$offer_repeat = 1;
		$show_offer_note = false;
		$ribbon_tag_text = '';
		$show_ribbon_tag = false;
		$downloadable_variant = 'solid-split';
		$downloadable_icon_position = 'right';
		$downloadable_file_tag = '';
		$downloadable_store_subtext = '';
		$show_downloadable_icon = false;
		$downloadable_uses_split_icon = false;
		$downloadable_icon_settings = array();

		$this->add_render_attribute( 'wrapper', 'class', array( 'eb-advanced-button', 'eb-advanced-button--' . $design_style ) );

		if ( 'accent-overlay' === $design_style ) {
			$accent_shape = isset( $settings['accent_overlay_shape'] ) ? $settings['accent_overlay_shape'] : 'circle';
			$accent_fill = isset( $settings['accent_overlay_fill'] ) ? $settings['accent_overlay_fill'] : 'outline';

			if ( ! in_array( $accent_shape, array( 'circle', 'rounded' ), true ) ) {
				$accent_shape = 'circle';
			}

			if ( ! in_array( $accent_fill, array( 'outline', 'solid' ), true ) ) {
				$accent_fill = 'outline';
			}

			$this->add_render_attribute(
				'wrapper',
				'class',
				array(
					'eb-advanced-button--accent-shape-' . $accent_shape,
					'eb-advanced-button--accent-fill-' . $accent_fill,
				)
			);
		}

		if ( 'offer-note' === $design_style ) {
			$offer_fill = isset( $settings['offer_note_fill'] ) ? $settings['offer_note_fill'] : 'bordered';
			$offer_position = isset( $settings['offer_note_position'] ) ? $settings['offer_note_position'] : 'bottom';
			$offer_text = ! empty( $settings['offer_note_text'] ) ? $settings['offer_note_text'] : '';
			$offer_content_type = isset( $settings['offer_note_content_type'] ) ? $settings['offer_note_content_type'] : 'text';
			$offer_repeat = isset( $settings['offer_note_repeat'] ) ? (int) $settings['offer_note_repeat'] : 1;
			$offer_repeat = max( 1, min( 8, $offer_repeat ) );

			if ( ! in_array( $offer_fill, array( 'bordered', 'background' ), true ) ) {
				$offer_fill = 'bordered';
			}

			if ( ! in_array( $offer_position, array( 'top', 'right', 'bottom', 'left' ), true ) ) {
				$offer_position = 'bottom';
			}

			if ( ! in_array( $offer_content_type, array( 'text', 'icon', 'image' ), true ) ) {
				$offer_content_type = 'text';
			}

			if ( 'text' === $offer_content_type ) {
				$show_offer_note = '' !== $offer_text;
			} elseif ( 'icon' === $offer_content_type ) {
				$show_offer_note = ! empty( $settings['offer_note_icon']['value'] );
			} elseif ( 'image' === $offer_content_type ) {
				$show_offer_note = ! empty( $settings['offer_note_image']['url'] );
			}

			$this->add_render_attribute(
				'wrapper',
				'class',
				array(
					'eb-advanced-button--offer-fill-' . $offer_fill,
					'eb-advanced-button--offer-position-' . $offer_position,
					'eb-advanced-button--offer-content-' . $offer_content_type,
				)
			);
		}

		if ( 'ribbon-tag' === $design_style ) {
			$ribbon_fill = isset( $settings['ribbon_tag_fill'] ) ? $settings['ribbon_tag_fill'] : 'bordered';
			$ribbon_position = isset( $settings['ribbon_tag_position'] ) ? $settings['ribbon_tag_position'] : 'center';
			$ribbon_shape = isset( $settings['ribbon_tag_button_shape'] ) ? $settings['ribbon_tag_button_shape'] : 'pill';
			$ribbon_shape_style = isset( $settings['ribbon_tag_shape_style'] ) ? $settings['ribbon_tag_shape_style'] : 'current';
			$ribbon_tag_text = ! empty( $settings['ribbon_tag_text'] ) ? $settings['ribbon_tag_text'] : '';
			$show_ribbon_tag = '' !== $ribbon_tag_text;

			if ( ! in_array( $ribbon_fill, array( 'bordered', 'background' ), true ) ) {
				$ribbon_fill = 'bordered';
			}
			if ( ! in_array( $ribbon_position, array( 'left', 'center', 'right' ), true ) ) {
				$ribbon_position = 'center';
			}
			if ( ! in_array( $ribbon_shape, array( 'pill', 'rectangle' ), true ) ) {
				$ribbon_shape = 'pill';
			}
			if ( ! in_array( $ribbon_shape_style, array( 'current', 'circular', 'rectangular' ), true ) ) {
				$ribbon_shape_style = 'current';
			}

			$this->add_render_attribute(
				'wrapper',
				'class',
				array(
					'eb-advanced-button--ribbon-fill-' . $ribbon_fill,
					'eb-advanced-button--ribbon-position-' . $ribbon_position,
					'eb-advanced-button--ribbon-shape-' . $ribbon_shape,
					'eb-advanced-button--ribbon-style-' . $ribbon_shape_style,
				)
			);
		}

		if ( 'downloadable' === $design_style ) {
			$downloadable_variant = isset( $settings['downloadable_variant'] ) ? $settings['downloadable_variant'] : 'solid-split';
			$downloadable_fill = isset( $settings['downloadable_fill'] ) ? $settings['downloadable_fill'] : 'background';
			$downloadable_icon_position = isset( $settings['downloadable_icon_position'] ) ? $settings['downloadable_icon_position'] : 'right';
			$downloadable_file_tag = ! empty( $settings['downloadable_file_tag'] ) ? $settings['downloadable_file_tag'] : '';
			$downloadable_store_subtext = ! empty( $settings['downloadable_store_subtext'] ) ? $settings['downloadable_store_subtext'] : '';
			$downloadable_icon_settings = ! empty( $settings['downloadable_icon']['value'] ) ? $settings['downloadable_icon'] : array();

			if ( 'text-arrow-line' === $downloadable_variant && ! empty( $settings['downloadable_arrow_icon']['value'] ) ) {
				$downloadable_icon_settings = $settings['downloadable_arrow_icon'];
			}
			$show_downloadable_icon = ! empty( $downloadable_icon_settings['value'] );

			if ( ! in_array( $downloadable_variant, array( 'solid-split', 'text-underline', 'circle-icon-text', 'text-arrow-line', 'icon-only-circle', 'file-card', 'text-icon-square', 'store-badge' ), true ) ) {
				$downloadable_variant = 'solid-split';
			}

			if ( ! in_array( $downloadable_fill, array( 'background', 'bordered' ), true ) ) {
				$downloadable_fill = 'background';
			}

			if ( ! in_array( $downloadable_icon_position, array( 'left', 'right' ), true ) ) {
				$downloadable_icon_position = 'right';
			}

			$downloadable_uses_split_icon = in_array( $downloadable_variant, array( 'solid-split', 'text-icon-square' ), true );

			$this->add_render_attribute(
				'wrapper',
				'class',
				array(
					'eb-advanced-button--download-fill-' . $downloadable_fill,
					'eb-advanced-button--download-variant-' . $downloadable_variant,
					'eb-advanced-button--download-icon-' . $downloadable_icon_position,
				)
			);
		}

		$this->add_render_attribute( 'button', 'class', 'eb-advanced-button__link' );
		$this->add_render_attribute( 'button', 'href', esc_url( $link ) );

		if ( ! empty( $settings['button_link']['is_external'] ) ) {
			$this->add_render_attribute( 'button', 'target', '_blank' );
			$this->add_render_attribute( 'button', 'rel', 'noopener' );
		}

		if ( ! empty( $settings['button_link']['nofollow'] ) ) {
			$this->add_render_attribute( 'button', 'rel', 'nofollow' );
		}

		if ( 'downloadable' === $design_style ) {
			$downloadable_filename = ! empty( $settings['downloadable_filename'] ) ? sanitize_file_name( $settings['downloadable_filename'] ) : '';
			$enable_download_attr = ! empty( $settings['downloadable_enable_download_attr'] ) && 'yes' === $settings['downloadable_enable_download_attr'];

			if ( '' !== $downloadable_filename ) {
				$this->add_render_attribute( 'button', 'download', $downloadable_filename );
			} elseif ( $enable_download_attr ) {
				$this->add_render_attribute( 'button', 'download', 'download' );
			}
		}
		?>
		<div <?php $this->print_render_attribute_string( 'wrapper' ); ?>>
			<div class="eb-advanced-button__inner">
				<a <?php $this->print_render_attribute_string( 'button' ); ?>>
					<?php if ( 'downloadable' === $design_style && $show_downloadable_icon && ! $downloadable_uses_split_icon && 'left' === $downloadable_icon_position ) : ?>
						<span class="eb-advanced-button__download-icon eb-advanced-button__download-icon--left" aria-hidden="true">
							<?php Icons_Manager::render_icon( $downloadable_icon_settings, array( 'aria-hidden' => 'true' ) ); ?>
						</span>
					<?php endif; ?>
					<?php if ( 'downloadable' === $design_style && 'store-badge' === $downloadable_variant ) : ?>
						<span class="eb-advanced-button__download-store-text">
							<?php if ( '' !== $downloadable_store_subtext ) : ?>
								<span class="eb-advanced-button__download-store-subtext"><?php echo esc_html( $downloadable_store_subtext ); ?></span>
							<?php endif; ?>
							<span class="eb-advanced-button__label"><?php echo esc_html( $text ); ?></span>
						</span>
					<?php else : ?>
						<span class="eb-advanced-button__label"><?php echo esc_html( $text ); ?></span>
					<?php endif; ?>
					<?php if ( 'downloadable' === $design_style && $show_downloadable_icon && ! $downloadable_uses_split_icon && 'right' === $downloadable_icon_position ) : ?>
						<span class="eb-advanced-button__download-icon eb-advanced-button__download-icon--right" aria-hidden="true">
							<?php Icons_Manager::render_icon( $downloadable_icon_settings, array( 'aria-hidden' => 'true' ) ); ?>
						</span>
					<?php endif; ?>

					<?php if ( 'downloadable' === $design_style && $downloadable_uses_split_icon && $show_downloadable_icon ) : ?>
						<span class="eb-advanced-button__download-split" aria-hidden="true">
							<span class="eb-advanced-button__download-split-icon">
								<?php Icons_Manager::render_icon( $downloadable_icon_settings, array( 'aria-hidden' => 'true' ) ); ?>
							</span>
						</span>
					<?php endif; ?>

					<?php if ( 'downloadable' === $design_style && 'file-card' === $downloadable_variant ) : ?>
						<span class="eb-advanced-button__download-file-card" aria-hidden="true">
							<span class="eb-advanced-button__download-file-icon">
								<?php if ( $show_downloadable_icon ) : ?>
									<?php Icons_Manager::render_icon( $downloadable_icon_settings, array( 'aria-hidden' => 'true' ) ); ?>
								<?php endif; ?>
							</span>
							<?php if ( '' !== $downloadable_file_tag ) : ?>
								<span class="eb-advanced-button__download-file-tag"><?php echo esc_html( $downloadable_file_tag ); ?></span>
							<?php endif; ?>
						</span>
					<?php endif; ?>

					<?php if ( 'downloadable' === $design_style && in_array( $downloadable_variant, array( 'text-underline', 'text-arrow-line' ), true ) ) : ?>
						<span class="eb-advanced-button__download-line" aria-hidden="true"></span>
					<?php endif; ?>
				</a>
				<?php if ( $show_ribbon_tag ) : ?>
					<span class="eb-advanced-button__ribbon">
						<span class="eb-advanced-button__ribbon-text"><?php echo esc_html( $ribbon_tag_text ); ?></span>
					</span>
				<?php endif; ?>
				<?php if ( $show_offer_note ) : ?>
					<span class="eb-advanced-button__offer">
						<?php if ( 'text' === $offer_content_type ) : ?>
							<?php echo esc_html( $offer_text ); ?>
						<?php elseif ( 'icon' === $offer_content_type ) : ?>
							<?php for ( $i = 0; $i < $offer_repeat; $i++ ) : ?>
								<span class="eb-advanced-button__offer-icon">
									<?php Icons_Manager::render_icon( $settings['offer_note_icon'], array( 'aria-hidden' => 'true' ) ); ?>
								</span>
							<?php endfor; ?>
						<?php elseif ( ! empty( $settings['offer_note_image']['url'] ) ) : ?>
							<?php for ( $i = 0; $i < $offer_repeat; $i++ ) : ?>
								<span class="eb-advanced-button__offer-image-wrap">
									<img class="eb-advanced-button__offer-image" src="<?php echo esc_url( $settings['offer_note_image']['url'] ); ?>" alt="" />
								</span>
							<?php endfor; ?>
						<?php endif; ?>
					</span>
				<?php endif; ?>
			</div>
		</div>
		<?php
	}
}
