<?php

namespace ImpactAddons\ImpactWidgetsForElementor\Widgets;

use Elementor\Controls_Manager;
use Elementor\Group_Control_Background;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Group_Control_Typography;
use Elementor\Widget_Base;

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

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

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

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

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

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

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

		$this->add_control(
			'design_preset',
			array(
				'label'   => esc_html__( 'Design Preset', 'impact-widgets-for-elementor' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'clean-minimal',
				'options' => array(
					'clean-minimal'     => esc_html__( 'Clean Minimal', 'impact-widgets-for-elementor' ),
					'underline-focus'   => esc_html__( 'Dark Badge', 'impact-widgets-for-elementor' ),
					'watermark-title'   => esc_html__( 'Image Fill Title', 'impact-widgets-for-elementor' ),
					'dark-overlay'      => esc_html__( 'Dark Overlay Hero', 'impact-widgets-for-elementor' ),
					'elegant-script'    => esc_html__( 'Elegant Script', 'impact-widgets-for-elementor' ),
					'split-block'       => esc_html__( 'Split Block', 'impact-widgets-for-elementor' ),
					'blob-background'   => esc_html__( 'Blob Background', 'impact-widgets-for-elementor' ),
					'promo-hero'        => esc_html__( 'Promo Hero', 'impact-widgets-for-elementor' ),
					'wave-right'        => esc_html__( 'Wave Right', 'impact-widgets-for-elementor' ),
					'script-lines'      => esc_html__( 'Script Lines', 'impact-widgets-for-elementor' ),
					'custom'            => esc_html__( 'Custom (Style Tab)', 'impact-widgets-for-elementor' ),
				),
			)
		);

		$this->add_control(
			'title_position',
			array(
				'label'   => esc_html__( 'Title Position', 'impact-widgets-for-elementor' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'before_subtitle',
				'options' => array(
					'before_subtitle' => esc_html__( 'Title First', 'impact-widgets-for-elementor' ),
					'after_subtitle'  => esc_html__( 'After Subtitle', 'impact-widgets-for-elementor' ),
				),
				'condition' => array(
					'design_preset' => array( 'custom', 'dark-overlay' ),
				),
			)
		);

		$this->add_control(
			'script_lines_subtitle_position',
			array(
				'label'     => esc_html__( 'Subtitle Position', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'before',
				'options'   => array(
					'before' => esc_html__( 'Above Title', 'impact-widgets-for-elementor' ),
					'after'  => esc_html__( 'Below Title', 'impact-widgets-for-elementor' ),
				),
				'condition' => array(
					'design_preset' => 'script-lines',
				),
			)
		);

		$this->add_control(
			'script_lines_line_color',
			array(
				'label'     => esc_html__( 'Script Line Color', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#5f74d6',
				'selectors' => array(
					'{{WRAPPER}} .eb-advanced-heading.eb-preset-script-lines .eb-advanced-heading__title::before' => 'background-color: {{VALUE}};',
					'{{WRAPPER}} .eb-advanced-heading.eb-preset-script-lines .eb-advanced-heading__title::after' => 'background-color: {{VALUE}};',
				),
				'condition' => array(
					'design_preset' => 'script-lines',
				),
			)
		);

		$this->add_responsive_control(
			'script_lines_line_width',
			array(
				'label'      => esc_html__( 'Script Line Width', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%' ),
				'range'      => array(
					'px' => array(
						'min' => 20,
						'max' => 300,
					),
					'%' => array(
						'min' => 5,
						'max' => 50,
					),
				),
				'default'    => array(
					'size' => 120,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-heading.eb-preset-script-lines .eb-advanced-heading__title::before' => 'width: {{SIZE}}{{UNIT}};',
					'{{WRAPPER}} .eb-advanced-heading.eb-preset-script-lines .eb-advanced-heading__title::after' => 'width: {{SIZE}}{{UNIT}};',
				),
				'condition'  => array(
					'design_preset' => 'script-lines',
				),
			)
		);

		$this->add_responsive_control(
			'script_lines_line_height',
			array(
				'label'      => esc_html__( 'Script Line Height', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 10,
					),
				),
				'default'    => array(
					'size' => 2,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-heading.eb-preset-script-lines .eb-advanced-heading__title::before' => 'height: {{SIZE}}{{UNIT}};',
					'{{WRAPPER}} .eb-advanced-heading.eb-preset-script-lines .eb-advanced-heading__title::after' => 'height: {{SIZE}}{{UNIT}};',
				),
				'condition'  => array(
					'design_preset' => 'script-lines',
				),
			)
		);

		$this->add_control(
			'subtitle',
			array(
				'label'       => esc_html__( 'Subtitle', 'impact-widgets-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'default'     => esc_html__( 'Your subtitle', 'impact-widgets-for-elementor' ),
				'placeholder' => esc_html__( 'Enter subtitle', 'impact-widgets-for-elementor' ),
			)
		);

		$this->add_control(
			'elegant_left_icon',
			array(
				'label'     => esc_html__( 'Left Icon', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::MEDIA,
				'dynamic'   => array(
					'active' => true,
				),
				'default'   => array(
					'url' => IMPACT_WIDGETS_ELEMENTOR_URL . 'assets/images/elegant-icon-left.svg',
				),
				'condition' => array(
					'design_preset' => 'elegant-script',
				),
			)
		);

		$this->add_control(
			'elegant_right_icon',
			array(
				'label'     => esc_html__( 'Right Icon', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::MEDIA,
				'dynamic'   => array(
					'active' => true,
				),
				'default'   => array(
					'url' => IMPACT_WIDGETS_ELEMENTOR_URL . 'assets/images/elegant-icon-right.svg',
				),
				'condition' => array(
					'design_preset' => 'elegant-script',
				),
			)
		);

		$this->add_responsive_control(
			'elegant_icon_size',
			array(
				'label'      => esc_html__( 'Elegant Icon Size', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => 8,
						'max' => 64,
					),
				),
				'default'    => array(
					'size' => 14,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-heading__icon img' => 'width: {{SIZE}}{{UNIT}}; height: auto;',
				),
				'condition'  => array(
					'design_preset' => 'elegant-script',
				),
			)
		);

		$this->add_responsive_control(
			'elegant_left_icon_offset_y',
			array(
				'label'      => esc_html__( 'Left Icon Offset Y', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => -60,
						'max' => 60,
					),
				),
				'default'    => array(
					'size' => 0,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-heading__icon--left' => 'transform: translateY({{SIZE}}{{UNIT}});',
				),
				'condition'  => array(
					'design_preset' => 'elegant-script',
				),
			)
		);

		$this->add_responsive_control(
			'elegant_left_icon_offset_x',
			array(
				'label'      => esc_html__( 'Left Icon Offset X', '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-heading__icon--left' => 'margin-right: {{SIZE}}{{UNIT}};',
				),
				'condition'  => array(
					'design_preset' => 'elegant-script',
				),
			)
		);

		$this->add_responsive_control(
			'elegant_right_icon_offset_y',
			array(
				'label'      => esc_html__( 'Right Icon Offset Y', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => -60,
						'max' => 60,
					),
				),
				'default'    => array(
					'size' => 0,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-heading__icon--right' => 'transform: translateY({{SIZE}}{{UNIT}});',
				),
				'condition'  => array(
					'design_preset' => 'elegant-script',
				),
			)
		);

		$this->add_responsive_control(
			'elegant_right_icon_offset_x',
			array(
				'label'      => esc_html__( 'Right Icon Offset X', '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-heading__icon--right' => 'margin-left: {{SIZE}}{{UNIT}};',
				),
				'condition'  => array(
					'design_preset' => 'elegant-script',
				),
			)
		);

		$this->add_control(
			'title',
			array(
				'label'       => esc_html__( 'Title', 'impact-widgets-for-elementor' ),
				'type'        => Controls_Manager::TEXTAREA,
				'default'     => esc_html__( 'Heading title', 'impact-widgets-for-elementor' ),
				'placeholder' => esc_html__( 'Enter title', 'impact-widgets-for-elementor' ),
			)
		);

		$this->add_control(
			'title_tag',
			array(
				'label'   => esc_html__( 'Title HTML Tag', 'impact-widgets-for-elementor' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'h2',
				'options' => array(
					'h1' => 'H1',
					'h2' => 'H2',
					'h3' => 'H3',
					'h4' => 'H4',
					'h5' => 'H5',
					'h6' => 'H6',
					'div' => 'DIV',
					'p'  => 'P',
				),
			)
		);

		$this->add_control(
			'description',
			array(
				'label'       => esc_html__( 'Description', 'impact-widgets-for-elementor' ),
				'type'        => Controls_Manager::TEXTAREA,
				'rows'        => 4,
				'default'     => esc_html__( 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.', 'impact-widgets-for-elementor' ),
				'placeholder' => esc_html__( 'Enter description', 'impact-widgets-for-elementor' ),
			)
		);

		$this->add_control(
			'show_description',
			array(
				'label'        => esc_html__( 'Show Description', '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'      => 'yes',
			)
		);

		$this->add_control(
			'show_separator',
			array(
				'label'        => esc_html__( 'Show Separator', '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_preset!' => array( 'elegant-script', 'wave-right' ),
				),
			)
		);

		$this->add_control(
			'elegant_show_separator',
			array(
				'label'        => esc_html__( 'Show Separator (Elegant)', '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'      => 'no',
				'condition'    => array(
					'design_preset' => 'elegant-script',
				),
			)
		);

		$this->add_control(
			'wave_show_separator',
			array(
				'label'        => esc_html__( 'Show Separator (Wave)', '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'      => 'no',
				'condition'    => array(
					'design_preset' => 'wave-right',
				),
			)
		);

		$this->add_control(
			'wave_decor_style',
			array(
				'label'     => esc_html__( 'Wave Decoration Style', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'zigzag',
				'options'   => array(
					'zigzag'    => esc_html__( 'Zigzag', 'impact-widgets-for-elementor' ),
					'dotted'    => esc_html__( 'Dotted', 'impact-widgets-for-elementor' ),
					'gradient'  => esc_html__( 'Gradient Bar', 'impact-widgets-for-elementor' ),
					'custom'    => esc_html__( 'Custom Image', 'impact-widgets-for-elementor' ),
					'none'      => esc_html__( 'None', 'impact-widgets-for-elementor' ),
				),
				'condition' => array(
					'design_preset' => 'wave-right',
				),
			)
		);

		$this->add_control(
			'wave_decor_custom_image',
			array(
				'label'     => esc_html__( 'Wave Custom Image', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::MEDIA,
				'dynamic'   => array(
					'active' => true,
				),
				'condition' => array(
					'design_preset' => 'wave-right',
					'wave_decor_style' => 'custom',
				),
			)
		);

		$this->add_responsive_control(
			'wave_decor_width',
			array(
				'label'      => esc_html__( 'Wave Decoration Width', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%' ),
				'range'      => array(
					'px' => array(
						'min' => 60,
						'max' => 800,
					),
					'%'  => array(
						'min' => 10,
						'max' => 100,
					),
				),
				'default'    => array(
					'size' => 300,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-heading.eb-preset-wave-right .eb-advanced-heading__title::before' => 'width: {{SIZE}}{{UNIT}};',
				),
				'condition'  => array(
					'design_preset' => 'wave-right',
				),
			)
		);

		$this->add_responsive_control(
			'wave_decor_scale',
			array(
				'label'      => esc_html__( 'Wave Decoration Scale', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( '%' ),
				'range'      => array(
					'%' => array(
						'min' => 50,
						'max' => 200,
					),
				),
				'default'    => array(
					'size' => 200,
					'unit' => '%',
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-heading.eb-preset-wave-right .eb-advanced-heading__title::before' => 'background-size: {{SIZE}}% auto;',
				),
				'condition'  => array(
					'design_preset' => 'wave-right',
					'wave_decor_style!' => array( 'custom', 'none' ),
				),
			)
		);

		$this->add_responsive_control(
			'wave_decor_height',
			array(
				'label'      => esc_html__( 'Wave Decoration Height', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => 2,
						'max' => 40,
					),
				),
				'default'    => array(
					'size' => 30,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-heading.eb-preset-wave-right .eb-advanced-heading__title::before' => 'height: {{SIZE}}{{UNIT}};',
				),
				'condition'  => array(
					'design_preset' => 'wave-right',
				),
			)
		);

		$this->add_control(
			'separator_position',
			array(
				'label'     => esc_html__( 'Separator Position', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'bottom',
				'options'   => array(
					'bottom'             => esc_html__( 'Bottom', 'impact-widgets-for-elementor' ),
					'before_description' => esc_html__( 'Before Description', 'impact-widgets-for-elementor' ),
				),
				'condition' => array(
					'show_separator' => 'yes',
				),
			)
		);

		$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,
			)
		);

		$this->end_controls_section();

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

		$this->add_responsive_control(
			'wrapper_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-heading' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

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

		$this->add_group_control(
			Group_Control_Background::get_type(),
			array(
				'name'     => 'wrapper_background',
				'selector' => '{{WRAPPER}} .eb-advanced-heading',
			)
		);

		$this->add_control(
			'dark_overlay_background_image',
			array(
				'label'     => esc_html__( 'Dark Overlay Background Image', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::MEDIA,
				'dynamic'   => array(
					'active' => true,
				),
				'default'   => array(
					'url' => IMPACT_WIDGETS_ELEMENTOR_URL . 'assets/images/dark-overlay-default.svg',
				),
				'condition' => array(
					'design_preset' => 'dark-overlay',
				),
			)
		);

		$this->add_control(
			'dark_overlay_background_position',
			array(
				'label'     => esc_html__( 'Dark Overlay Background Position', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'center center',
				'options'   => array(
					'left top'      => esc_html__( 'Left Top', 'impact-widgets-for-elementor' ),
					'left center'   => esc_html__( 'Left Center', 'impact-widgets-for-elementor' ),
					'left bottom'   => esc_html__( 'Left Bottom', 'impact-widgets-for-elementor' ),
					'center top'    => esc_html__( 'Center Top', 'impact-widgets-for-elementor' ),
					'center center' => esc_html__( 'Center Center', 'impact-widgets-for-elementor' ),
					'center bottom' => esc_html__( 'Center Bottom', 'impact-widgets-for-elementor' ),
					'right top'     => esc_html__( 'Right Top', 'impact-widgets-for-elementor' ),
					'right center'  => esc_html__( 'Right Center', 'impact-widgets-for-elementor' ),
					'right bottom'  => esc_html__( 'Right Bottom', 'impact-widgets-for-elementor' ),
				),
				'condition' => array(
					'design_preset' => 'dark-overlay',
				),
			)
		);

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

		$this->add_control(
			'wrapper_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-heading' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

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

		$this->add_control(
			'promo_hero_background_image',
			array(
				'label'     => esc_html__( 'Promo Background Image', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::MEDIA,
				'dynamic'   => array(
					'active' => true,
				),
				'default'   => array(
					'url' => IMPACT_WIDGETS_ELEMENTOR_URL . 'assets/images/promo-hero-default.svg',
				),
				'condition' => array(
					'design_preset' => 'promo-hero',
				),
			)
		);

		$this->add_control(
			'promo_hero_background_position',
			array(
				'label'     => esc_html__( 'Promo Background Position', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'center center',
				'options'   => array(
					'left top'      => esc_html__( 'Left Top', 'impact-widgets-for-elementor' ),
					'left center'   => esc_html__( 'Left Center', 'impact-widgets-for-elementor' ),
					'left bottom'   => esc_html__( 'Left Bottom', 'impact-widgets-for-elementor' ),
					'center top'    => esc_html__( 'Center Top', 'impact-widgets-for-elementor' ),
					'center center' => esc_html__( 'Center Center', 'impact-widgets-for-elementor' ),
					'center bottom' => esc_html__( 'Center Bottom', 'impact-widgets-for-elementor' ),
					'right top'     => esc_html__( 'Right Top', 'impact-widgets-for-elementor' ),
					'right center'  => esc_html__( 'Right Center', 'impact-widgets-for-elementor' ),
					'right bottom'  => esc_html__( 'Right Bottom', 'impact-widgets-for-elementor' ),
				),
				'condition' => array(
					'design_preset' => 'promo-hero',
				),
			)
		);

		$this->end_controls_section();

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

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

		$this->add_control(
			'subtitle_badge_bg_color',
			array(
				'label'     => esc_html__( 'Subtitle Badge Background', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#4f72ff',
				'selectors' => array(
					'{{WRAPPER}} .eb-advanced-heading.eb-preset-underline-focus .eb-advanced-heading__subtitle' => 'background: {{VALUE}}; border-color: {{VALUE}};',
				),
				'condition' => array(
					'design_preset' => 'underline-focus',
				),
			)
		);

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

		$this->add_responsive_control(
			'subtitle_spacing',
			array(
				'label'      => esc_html__( 'Bottom Spacing', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', 'em', 'rem' ),
				'range'      => array(
					'px' => array(
						'min' => 0,
						'max' => 200,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-heading__subtitle' => 'margin-bottom: {{SIZE}}{{UNIT}};',
				),
			)
		);

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

		$this->end_controls_section();

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

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

		$this->add_control(
			'title_use_gradient',
			array(
				'label'        => esc_html__( 'Use Gradient Color', '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'      => 'yes',
			)
		);

		$this->add_control(
			'title_gradient_color_one',
			array(
				'label'     => esc_html__( 'Gradient Color 1', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#22d1a6',
				'condition' => array(
					'title_use_gradient' => 'yes',
				),
			)
		);

		$this->add_control(
			'title_gradient_color_two',
			array(
				'label'     => esc_html__( 'Gradient Color 2', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'default'   => '#3f83f8',
				'condition' => array(
					'title_use_gradient' => 'yes',
				),
			)
		);

		$this->add_control(
			'title_gradient_angle',
			array(
				'label'      => esc_html__( 'Gradient Angle', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::NUMBER,
				'default'    => 90,
				'min'        => 0,
				'max'        => 360,
				'step'       => 1,
				'condition'  => array(
					'title_use_gradient' => 'yes',
				),
			)
		);

		$this->add_control(
			'title_text_fill_image',
			array(
				'label'     => esc_html__( 'Title Text Fill Image', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::MEDIA,
				'dynamic'   => array(
					'active' => true,
				),
				'default'   => array(
					'url' => IMPACT_WIDGETS_ELEMENTOR_URL . 'assets/images/title-fill-default.svg',
				),
				'condition' => array(
					'design_preset' => 'watermark-title',
				),
			)
		);

		$this->add_control(
			'title_text_fill_image_position',
			array(
				'label'     => esc_html__( 'Image Position', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'center center',
				'options'   => array(
					'left top'      => esc_html__( 'Left Top', 'impact-widgets-for-elementor' ),
					'left center'   => esc_html__( 'Left Center', 'impact-widgets-for-elementor' ),
					'left bottom'   => esc_html__( 'Left Bottom', 'impact-widgets-for-elementor' ),
					'center top'    => esc_html__( 'Center Top', 'impact-widgets-for-elementor' ),
					'center center' => esc_html__( 'Center Center', 'impact-widgets-for-elementor' ),
					'center bottom' => esc_html__( 'Center Bottom', 'impact-widgets-for-elementor' ),
					'right top'     => esc_html__( 'Right Top', 'impact-widgets-for-elementor' ),
					'right center'  => esc_html__( 'Right Center', 'impact-widgets-for-elementor' ),
					'right bottom'  => esc_html__( 'Right Bottom', 'impact-widgets-for-elementor' ),
				),
				'condition' => array(
					'design_preset' => 'watermark-title',
				),
			)
		);

		$this->add_control(
			'blob_background_image',
			array(
				'label'     => esc_html__( 'Blob Side Image', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::MEDIA,
				'dynamic'   => array(
					'active' => true,
				),
				'default'   => array(
					'url' => IMPACT_WIDGETS_ELEMENTOR_URL . 'assets/images/blob-side-default.svg',
				),
				'condition' => array(
					'design_preset' => 'blob-background',
				),
			)
		);

		$this->add_control(
			'blob_background_image_position',
			array(
				'label'     => esc_html__( 'Blob Image Position', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'right center',
				'options'   => array(
					'left top'      => esc_html__( 'Left Top', 'impact-widgets-for-elementor' ),
					'left center'   => esc_html__( 'Left Center', 'impact-widgets-for-elementor' ),
					'left bottom'   => esc_html__( 'Left Bottom', 'impact-widgets-for-elementor' ),
					'center top'    => esc_html__( 'Center Top', 'impact-widgets-for-elementor' ),
					'center center' => esc_html__( 'Center Center', 'impact-widgets-for-elementor' ),
					'center bottom' => esc_html__( 'Center Bottom', 'impact-widgets-for-elementor' ),
					'right top'     => esc_html__( 'Right Top', 'impact-widgets-for-elementor' ),
					'right center'  => esc_html__( 'Right Center', 'impact-widgets-for-elementor' ),
					'right bottom'  => esc_html__( 'Right Bottom', 'impact-widgets-for-elementor' ),
				),
				'condition' => array(
					'design_preset' => 'blob-background',
				),
			)
		);

		$this->add_control(
			'promo_hero_title_shadow',
			array(
				'label'     => esc_html__( 'Promo Title Shadow', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::BOX_SHADOW,
				'default'   => array(
					'horizontal' => 0,
					'vertical'   => 8,
					'blur'       => 18,
					'spread'     => 0,
					'color'      => 'rgba(0,0,0,0.25)',
				),
				'selectors' => array(
					'{{WRAPPER}} .eb-advanced-heading.eb-preset-promo-hero .eb-advanced-heading__title' => 'text-shadow: {{HORIZONTAL}}px {{VERTICAL}}px {{BLUR}}px {{COLOR}};',
				),
				'condition' => array(
					'design_preset' => 'promo-hero',
				),
			)
		);

		$this->add_control(
			'promo_hero_subtitle_shadow',
			array(
				'label'     => esc_html__( 'Promo Subtitle Shadow', 'impact-widgets-for-elementor' ),
				'type'      => Controls_Manager::BOX_SHADOW,
				'default'   => array(
					'horizontal' => 0,
					'vertical'   => 6,
					'blur'       => 14,
					'spread'     => 0,
					'color'      => 'rgba(0,0,0,0.25)',
				),
				'selectors' => array(
					'{{WRAPPER}} .eb-advanced-heading.eb-preset-promo-hero .eb-advanced-heading__subtitle' => 'text-shadow: {{HORIZONTAL}}px {{VERTICAL}}px {{BLUR}}px {{COLOR}};',
				),
				'condition' => array(
					'design_preset' => 'promo-hero',
				),
			)
		);

		$this->add_responsive_control(
			'promo_hero_subtitle_offset_y',
			array(
				'label'      => esc_html__( 'Promo Subtitle Offset Y', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => -200,
						'max' => 200,
					),
				),
				'default'    => array(
					'size' => -16,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-heading.eb-preset-promo-hero .eb-advanced-heading__subtitle' => 'transform: translateY({{SIZE}}{{UNIT}});',
				),
				'condition'  => array(
					'design_preset' => 'promo-hero',
				),
			)
		);

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

		$this->add_responsive_control(
			'title_spacing',
			array(
				'label'      => esc_html__( 'Bottom Spacing', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', 'em', 'rem' ),
				'range'      => array(
					'px' => array(
						'min' => 0,
						'max' => 250,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-heading__title' => 'margin-bottom: {{SIZE}}{{UNIT}};',
				),
			)
		);

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

		$this->end_controls_section();

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

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

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

		$this->add_responsive_control(
			'description_spacing',
			array(
				'label'      => esc_html__( 'Bottom Spacing', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', 'em', 'rem' ),
				'range'      => array(
					'px' => array(
						'min' => 0,
						'max' => 250,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-heading__description' => 'margin-bottom: {{SIZE}}{{UNIT}};',
				),
			)
		);

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

		$this->end_controls_section();

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

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

		$this->add_responsive_control(
			'separator_width',
			array(
				'label'      => esc_html__( 'Width', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 600,
					),
				),
				'default'    => array(
					'size' => 72,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-heading__separator' => 'width: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'separator_height',
			array(
				'label'      => esc_html__( 'Height', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 30,
					),
				),
				'default'    => array(
					'size' => 3,
					'unit' => 'px',
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-heading__separator' => 'height: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'separator_spacing',
			array(
				'label'      => esc_html__( 'Top Spacing', 'impact-widgets-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', 'em', 'rem' ),
				'range'      => array(
					'px' => array(
						'min' => 0,
						'max' => 200,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .eb-advanced-heading__separator' => 'margin-top: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->end_controls_section();
	}

	protected function render(): void {
		$settings = $this->get_settings_for_display();
		$title_tag = ! empty( $settings['title_tag'] ) ? $settings['title_tag'] : 'h2';
		$allowed_presets = array(
			'clean-minimal',
			'underline-focus',
			'watermark-title',
			'dark-overlay',
			'elegant-script',
			'split-block',
			'blob-background',
			'promo-hero',
			'wave-right',
			'script-lines',
			'custom',
		);
		$design_preset = isset( $settings['design_preset'] ) ? $settings['design_preset'] : 'clean-minimal';
		if ( ! in_array( $design_preset, $allowed_presets, true ) ) {
			$design_preset = 'clean-minimal';
		}
		$wrapper_classes = 'eb-advanced-heading eb-preset-' . $design_preset;
		if ( 'wave-right' === $design_preset ) {
			$wave_style = isset( $settings['wave_decor_style'] ) ? $settings['wave_decor_style'] : 'zigzag';
			$allowed_wave_styles = array( 'zigzag', 'dotted', 'gradient', 'custom', 'none' );
			if ( ! in_array( $wave_style, $allowed_wave_styles, true ) ) {
				$wave_style = 'zigzag';
			}
			$wrapper_classes .= ' wave-decor-' . $wave_style;
			if ( 'custom' === $wave_style ) {
				$custom_wave = ! empty( $settings['wave_decor_custom_image']['url'] ) ? esc_url_raw( $settings['wave_decor_custom_image']['url'] ) : '';
				if ( ! empty( $custom_wave ) ) {
					$wrapper_inline_style .= sprintf(
						'--eb-wave-custom:url(%1$s);',
						esc_url( $custom_wave )
					);
				}
			}
		}
		$title_inline_style = '';
		$wrapper_inline_style = '';
		$title_position = isset( $settings['title_position'] ) ? $settings['title_position'] : 'before_subtitle';
		$show_description = ! empty( $settings['show_description'] ) && 'yes' === $settings['show_description'] && ! empty( $settings['description'] );
		if ( 'clean-minimal' === $design_preset ) {
			$show_description = false;
		}
		$show_separator = ! empty( $settings['show_separator'] ) && 'yes' === $settings['show_separator'];
		if ( empty( $settings['show_separator'] ) ) {
			$show_separator = 'script-lines' !== $design_preset;
		}
		if ( 'elegant-script' === $design_preset ) {
			$show_separator = ! empty( $settings['elegant_show_separator'] ) && 'yes' === $settings['elegant_show_separator'];
		}
		if ( 'wave-right' === $design_preset ) {
			$show_separator = ! empty( $settings['wave_show_separator'] ) && 'yes' === $settings['wave_show_separator'];
		}
		$separator_position = isset( $settings['separator_position'] ) ? $settings['separator_position'] : 'bottom';
		$alignment_desktop = isset( $settings['alignment'] ) ? $settings['alignment'] : 'center';
		$alignment_tablet = isset( $settings['alignment_tablet'] ) ? $settings['alignment_tablet'] : $alignment_desktop;
		$alignment_mobile = isset( $settings['alignment_mobile'] ) ? $settings['alignment_mobile'] : $alignment_tablet;
		if ( ! in_array( $title_position, array( 'before_subtitle', 'after_subtitle' ), true ) ) {
			$title_position = 'before_subtitle';
		}
		if ( ! in_array( $separator_position, array( 'bottom', 'before_description' ), true ) ) {
			$separator_position = 'bottom';
		}
		if ( ! in_array( $alignment_desktop, array( 'left', 'center', 'right' ), true ) ) {
			$alignment_desktop = 'center';
		}
		if ( ! in_array( $alignment_tablet, array( 'left', 'center', 'right' ), true ) ) {
			$alignment_tablet = $alignment_desktop;
		}
		if ( ! in_array( $alignment_mobile, array( 'left', 'center', 'right' ), true ) ) {
			$alignment_mobile = $alignment_tablet;
		}
		if ( 'underline-focus' === $design_preset ) {
			$alignment_desktop = 'left';
			$alignment_tablet = 'left';
			$alignment_mobile = 'left';
			$title_position = 'before_subtitle';
		}
		if ( 'split-block' === $design_preset ) {
			$alignment_desktop = 'left';
			$alignment_tablet = 'left';
			$alignment_mobile = 'left';
			$title_position = 'after_subtitle';
		}
		if ( 'elegant-script' === $design_preset ) {
			$alignment_desktop = 'center';
			$alignment_tablet = 'center';
			$alignment_mobile = 'center';
			$title_position = 'before_subtitle';
		}
		if ( 'blob-background' === $design_preset ) {
			$alignment_desktop = 'left';
			$alignment_tablet = 'left';
			$alignment_mobile = 'left';
			$title_position = 'before_subtitle';
		}
		if ( 'promo-hero' === $design_preset ) {
			$alignment_desktop = 'center';
			$alignment_tablet = 'center';
			$alignment_mobile = 'center';
			$title_position = 'before_subtitle';
		}
		if ( 'wave-right' === $design_preset ) {
			$alignment_desktop = 'right';
			$alignment_tablet = 'right';
			$alignment_mobile = 'right';
			$title_position = 'before_subtitle';
		}
		if ( 'script-lines' === $design_preset ) {
			$alignment_desktop = 'center';
			$alignment_tablet = 'center';
			$alignment_mobile = 'center';
			$title_position = ! empty( $settings['script_lines_subtitle_position'] ) && 'after' === $settings['script_lines_subtitle_position'] ? 'before_subtitle' : 'after_subtitle';
		}
		$wrapper_classes .= ' eb-title-pos-' . ( 'after_subtitle' === $title_position ? 'after' : 'before' );
		$wrapper_classes .= ' eb-separator-pos-' . ( 'before_description' === $separator_position ? 'before' : 'bottom' );
		$instance_class = 'eb-ah-' . $this->get_id();
		$wrapper_classes .= ' ' . $instance_class;
		$margin_map = array(
			'left'   => 'margin-left:0;margin-right:auto;',
			'center' => 'margin-left:auto;margin-right:auto;',
			'right'  => 'margin-left:auto;margin-right:0;',
		);
		$block_align_desktop = $margin_map[ $alignment_desktop ];
		$block_align_tablet = $margin_map[ $alignment_tablet ];
		$block_align_mobile = $margin_map[ $alignment_mobile ];

		if (
			! in_array( $design_preset, array( 'underline-focus', 'watermark-title' ), true ) &&
			! empty( $settings['title_use_gradient'] ) &&
			'yes' === $settings['title_use_gradient'] &&
			! empty( $settings['title_gradient_color_one'] ) &&
			! empty( $settings['title_gradient_color_two'] )
		) {
			$angle = isset( $settings['title_gradient_angle'] ) ? (int) $settings['title_gradient_angle'] : 90;
			$angle = max( 0, min( 360, $angle ) );
			$color_one = sanitize_text_field( $settings['title_gradient_color_one'] );
			$color_two = sanitize_text_field( $settings['title_gradient_color_two'] );
			$title_inline_style = sprintf(
				'background-image:linear-gradient(%1$ddeg,%2$s,%3$s);-webkit-background-clip:text;background-clip:text;color:transparent;-webkit-text-fill-color:transparent;',
				$angle,
				$color_one,
				$color_two
			);
		}

		if ( 'watermark-title' === $design_preset ) {
			$image_url = ! empty( $settings['title_text_fill_image']['url'] ) ? esc_url_raw( $settings['title_text_fill_image']['url'] ) : IMPACT_WIDGETS_ELEMENTOR_URL . 'assets/images/title-fill-default.svg';
			$image_position = isset( $settings['title_text_fill_image_position'] ) ? $settings['title_text_fill_image_position'] : 'center center';
			$allowed_positions = array(
				'left top',
				'left center',
				'left bottom',
				'center top',
				'center center',
				'center bottom',
				'right top',
				'right center',
				'right bottom',
			);
			if ( ! in_array( $image_position, $allowed_positions, true ) ) {
				$image_position = 'center center';
			}
			if ( ! empty( $image_url ) ) {
				$title_inline_style = sprintf(
					'background-image:url(%1$s);background-size:cover;background-position:%2$s;background-repeat:no-repeat;-webkit-background-clip:text;background-clip:text;color:transparent;-webkit-text-fill-color:transparent;',
					esc_url( $image_url )
					,
					esc_attr( $image_position )
				);
			}
		}

		if ( 'dark-overlay' === $design_preset ) {
			$bg_url = ! empty( $settings['dark_overlay_background_image']['url'] ) ? esc_url_raw( $settings['dark_overlay_background_image']['url'] ) : IMPACT_WIDGETS_ELEMENTOR_URL . 'assets/images/dark-overlay-default.svg';
			$bg_position = isset( $settings['dark_overlay_background_position'] ) ? $settings['dark_overlay_background_position'] : 'center center';
			$allowed_positions = array(
				'left top',
				'left center',
				'left bottom',
				'center top',
				'center center',
				'center bottom',
				'right top',
				'right center',
				'right bottom',
			);
			if ( ! in_array( $bg_position, $allowed_positions, true ) ) {
				$bg_position = 'center center';
			}
			if ( ! empty( $bg_url ) ) {
				$wrapper_inline_style = sprintf(
					'background-image:linear-gradient(135deg, rgba(9,16,34,0.86), rgba(17,27,55,0.82)), url(%1$s);background-size:cover;background-position:%2$s;background-repeat:no-repeat;',
					esc_url( $bg_url ),
					esc_attr( $bg_position )
				);
			}
		}

		if ( 'blob-background' === $design_preset ) {
			$blob_image = ! empty( $settings['blob_background_image']['url'] ) ? esc_url_raw( $settings['blob_background_image']['url'] ) : IMPACT_WIDGETS_ELEMENTOR_URL . 'assets/images/blob-side-default.svg';
			$blob_position = isset( $settings['blob_background_image_position'] ) ? $settings['blob_background_image_position'] : 'right center';
			$allowed_positions = array(
				'left top',
				'left center',
				'left bottom',
				'center top',
				'center center',
				'center bottom',
				'right top',
				'right center',
				'right bottom',
			);
			if ( ! in_array( $blob_position, $allowed_positions, true ) ) {
				$blob_position = 'right center';
			}
			if ( ! empty( $blob_image ) ) {
				$wrapper_inline_style .= sprintf(
					'background-image:url(%1$s);background-size:contain;background-position:%2$s;background-repeat:no-repeat;',
					esc_url( $blob_image ),
					esc_attr( $blob_position )
				);
			}
		}

		if ( 'promo-hero' === $design_preset ) {
			$promo_bg = ! empty( $settings['promo_hero_background_image']['url'] ) ? esc_url_raw( $settings['promo_hero_background_image']['url'] ) : IMPACT_WIDGETS_ELEMENTOR_URL . 'assets/images/promo-hero-default.svg';
			$promo_pos = isset( $settings['promo_hero_background_position'] ) ? $settings['promo_hero_background_position'] : 'center center';
			$allowed_positions = array(
				'left top',
				'left center',
				'left bottom',
				'center top',
				'center center',
				'center bottom',
				'right top',
				'right center',
				'right bottom',
			);
			if ( ! in_array( $promo_pos, $allowed_positions, true ) ) {
				$promo_pos = 'center center';
			}
			if ( ! empty( $promo_bg ) ) {
				$wrapper_inline_style .= sprintf(
					'background-image:url(%1$s);background-size:cover;background-position:%2$s;background-repeat:no-repeat;',
					esc_url( $promo_bg ),
					esc_attr( $promo_pos )
				);
			}
		}
		$is_elegant = 'elegant-script' === $design_preset;
		$left_icon = $is_elegant && ! empty( $settings['elegant_left_icon']['url'] ) ? esc_url( $settings['elegant_left_icon']['url'] ) : '';
		$right_icon = $is_elegant && ! empty( $settings['elegant_right_icon']['url'] ) ? esc_url( $settings['elegant_right_icon']['url'] ) : '';
		$responsive_style = sprintf(
			'.%1$s { text-align: %2$s !important; }
			.%1$s .eb-advanced-heading__title,
			.%1$s .eb-advanced-heading__subtitle,
			.%1$s .eb-advanced-heading__description,
			.%1$s .eb-advanced-heading__separator { %3$s }
			@media (max-width: 1024px) {
				.%1$s { text-align: %4$s !important; }
				.%1$s .eb-advanced-heading__title,
				.%1$s .eb-advanced-heading__subtitle,
				.%1$s .eb-advanced-heading__description,
				.%1$s .eb-advanced-heading__separator { %5$s }
			}
			@media (max-width: 767px) {
				.%1$s { text-align: %6$s !important; }
				.%1$s .eb-advanced-heading__title,
				.%1$s .eb-advanced-heading__subtitle,
				.%1$s .eb-advanced-heading__description,
				.%1$s .eb-advanced-heading__separator { %7$s }
			}',
			sanitize_html_class( $instance_class ),
			sanitize_key( $alignment_desktop ),
			$block_align_desktop,
			sanitize_key( $alignment_tablet ),
			$block_align_tablet,
			sanitize_key( $alignment_mobile ),
			$block_align_mobile
		);
		wp_add_inline_style( 'impact_widgets_elementor_advanced-heading', $responsive_style );
		?>
		<div class="<?php echo esc_attr( $wrapper_classes ); ?>"<?php echo ! empty( $wrapper_inline_style ) ? ' style="' . esc_attr( $wrapper_inline_style ) . '"' : ''; ?>>
			<?php if ( $is_elegant ) : ?>
				<?php if ( 'before_subtitle' === $title_position ) : ?>
					<?php if ( ! empty( $settings['title'] ) ) : ?>
						<div class="eb-advanced-heading__title-line">
							<?php if ( ! empty( $left_icon ) ) : ?>
								<span class="eb-advanced-heading__icon eb-advanced-heading__icon--left"><img src="<?php echo esc_url( $left_icon ); ?>" alt="" /></span>
							<?php endif; ?>
							<<?php echo esc_attr( $title_tag ); ?> class="eb-advanced-heading__title"<?php echo ! empty( $title_inline_style ) ? ' style="' . esc_attr( $title_inline_style ) . '"' : ''; ?>><?php echo esc_html( $settings['title'] ); ?></<?php echo esc_attr( $title_tag ); ?>>
						</div>
					<?php endif; ?>

					<?php if ( ! empty( $settings['subtitle'] ) ) : ?>
						<div class="eb-advanced-heading__subtitle-line">
							<div class="eb-advanced-heading__subtitle"><?php echo esc_html( $settings['subtitle'] ); ?></div>
							<?php if ( ! empty( $right_icon ) ) : ?>
								<span class="eb-advanced-heading__icon eb-advanced-heading__icon--right"><img src="<?php echo esc_url( $right_icon ); ?>" alt="" /></span>
							<?php endif; ?>
						</div>
					<?php endif; ?>
				<?php else : ?>
					<?php if ( ! empty( $settings['subtitle'] ) ) : ?>
						<div class="eb-advanced-heading__subtitle-line">
							<div class="eb-advanced-heading__subtitle"><?php echo esc_html( $settings['subtitle'] ); ?></div>
							<?php if ( ! empty( $right_icon ) ) : ?>
								<span class="eb-advanced-heading__icon eb-advanced-heading__icon--right"><img src="<?php echo esc_url( $right_icon ); ?>" alt="" /></span>
							<?php endif; ?>
						</div>
					<?php endif; ?>

					<?php if ( ! empty( $settings['title'] ) ) : ?>
						<div class="eb-advanced-heading__title-line">
							<?php if ( ! empty( $left_icon ) ) : ?>
								<span class="eb-advanced-heading__icon eb-advanced-heading__icon--left"><img src="<?php echo esc_url( $left_icon ); ?>" alt="" /></span>
							<?php endif; ?>
							<<?php echo esc_attr( $title_tag ); ?> class="eb-advanced-heading__title"<?php echo ! empty( $title_inline_style ) ? ' style="' . esc_attr( $title_inline_style ) . '"' : ''; ?>><?php echo esc_html( $settings['title'] ); ?></<?php echo esc_attr( $title_tag ); ?>>
						</div>
					<?php endif; ?>
				<?php endif; ?>
			<?php elseif ( 'before_subtitle' === $title_position ) : ?>
				<?php if ( ! empty( $settings['title'] ) ) : ?>
					<<?php echo esc_attr( $title_tag ); ?> class="eb-advanced-heading__title"<?php echo ! empty( $title_inline_style ) ? ' style="' . esc_attr( $title_inline_style ) . '"' : ''; ?>><?php echo esc_html( $settings['title'] ); ?></<?php echo esc_attr( $title_tag ); ?>>
				<?php endif; ?>

				<?php if ( ! empty( $settings['subtitle'] ) ) : ?>
					<div class="eb-advanced-heading__subtitle"><?php echo esc_html( $settings['subtitle'] ); ?></div>
				<?php endif; ?>
			<?php else : ?>
				<?php if ( ! empty( $settings['subtitle'] ) ) : ?>
					<div class="eb-advanced-heading__subtitle"><?php echo esc_html( $settings['subtitle'] ); ?></div>
				<?php endif; ?>

				<?php if ( ! empty( $settings['title'] ) ) : ?>
					<<?php echo esc_attr( $title_tag ); ?> class="eb-advanced-heading__title"<?php echo ! empty( $title_inline_style ) ? ' style="' . esc_attr( $title_inline_style ) . '"' : ''; ?>><?php echo esc_html( $settings['title'] ); ?></<?php echo esc_attr( $title_tag ); ?>>
				<?php endif; ?>
			<?php endif; ?>

			<?php if ( $show_separator && 'before_description' === $separator_position && $show_description ) : ?>
				<div class="eb-advanced-heading__separator"></div>
			<?php endif; ?>

			<?php if ( $show_description ) : ?>
				<div class="eb-advanced-heading__description"><?php echo esc_html( $settings['description'] ); ?></div>
			<?php endif; ?>

			<?php if ( $show_separator && ( 'bottom' === $separator_position || ! $show_description ) ) : ?>
				<div class="eb-advanced-heading__separator"></div>
			<?php endif; ?>
		</div>
		<?php
	}
}
