<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit; }
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Typography;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Background;
use Elementor\Icons_Manager;
use Elementor\Repeater;
use Sifency\Traits\Sifency_Addons_Parity_Style_Controls;
use Sifency\Traits\Sifency_Addons_Animation_Controls;
use Sifency\Traits\Sifency_Addons_Animation_Manager;
use Sifency\Traits\Sifency_Addons_Master_Typography;
use Sifency\Traits\Sifency_Addons_Button_Style_Controls;
use Sifency\Traits\Sifency_Addons_Item_Style_Controls;
use Sifency\Traits\Sifency_Addons_Toggle_Style_Controls;
use Sifency\Traits\Sifency_Addons_Section_Header;
use Sifency\Traits\Sifency_Addons_Help_Controls;
use Sifency\Traits\Sifency_Addons_Flex_Controls;
use Sifency\Traits\Sifency_Addons_Custom_CSS_Controls;
use Sifency\Classes\Sifency_Addons_Widget_Base;

class Sifency_Pricing_Table extends Sifency_Addons_Widget_Base {
	use Sifency_Addons_Animation_Controls;
	use Sifency_Addons_Master_Typography;
	use Sifency_Addons_Button_Style_Controls;
	use Sifency_Addons_Item_Style_Controls;
	use Sifency_Addons_Toggle_Style_Controls;
	use Sifency_Addons_Section_Header;
	use Sifency_Addons_Flex_Controls;
	use Sifency_Addons_Custom_CSS_Controls;
	use Sifency_Addons_Help_Controls;
	public function __construct( $data = array(), $args = null ) {
		parent::__construct( $data, $args );
		$this->wg_config = array(
			'name'           => 'sifency_pricing_table',
			'title'          => 'Sifency Pricing Table',
			'icon'           => 'eicon-price-table',
			'category'       => 'sifency-business-widgets',
			'keywords'       => array( 'pricing', 'table', 'plan', 'price' ),
			'style_depends'  => array( 'sifency-pricing-style', 'sifency-typo-style', 'sifency-icons' ),
			'script_depends' => array( 'sifency-pricing-script' ),
		);}

	protected function register_controls() {
		$this->add_sifency_addons_section_header_controls();
		$this->start_controls_section(
			'section_switcher_settings',
			array( 'label' => esc_html__( 'Switcher Settings', 'sifency-addons' ) )
		);
		$this->add_control(
			'show_switcher',
			array(
				'label'   => esc_html__( 'Show Switcher?', 'sifency-addons' ),
				'type'    => Controls_Manager::SWITCHER,
				'default' => 'yes',
			)
		);

		$this->add_control(
			'label_monthly',
			array(
				'label'     => esc_html__( 'Label A (Monthly)', 'sifency-addons' ),
				'type'      => Controls_Manager::TEXT,
				'default'   => 'Monthly',
				'condition' => array( 'show_switcher' => 'yes' ),
			)
		);

		$this->add_control(
			'label_yearly',
			array(
				'label'     => esc_html__( 'Label B (Yearly)', 'sifency-addons' ),
				'type'      => Controls_Manager::TEXT,
				'default'   => 'Yearly',
				'condition' => array( 'show_switcher' => 'yes' ),
			)
		);

		$this->add_control(
			'label_badge',
			array(
				'label'     => esc_html__( 'Badge Text', 'sifency-addons' ),
				'type'      => Controls_Manager::TEXT,
				'default'   => 'Save 20%',
				'condition' => array( 'show_switcher' => 'yes' ),
			)
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'section_cards',
			array( 'label' => esc_html__( 'Pricing Cards', 'sifency-addons' ) )
		);
		$repeater = new Repeater();

		$repeater->add_control(
			'is_featured',
			array(
				'label'   => esc_html__( 'Featured?', 'sifency-addons' ),
				'type'    => Controls_Manager::SWITCHER,
				'default' => 'no',
			)
		);

		$repeater->add_control(
			'ribbon_text',
			array(
				'label'     => 'Feature Text',
				'type'      => Controls_Manager::TEXTAREA,
				'default'   => 'POPULAR',
				'condition' => array( 'is_featured' => 'yes' ),
			)
		);

		$repeater->add_control(
			'title',
			array(
				'label'   => esc_html__( 'Title', 'sifency-addons' ),
				'type'    => Controls_Manager::TEXTAREA,
				'default' => 'Standard',
			)
		);

		$repeater->add_control(
			'subtitle',
			array(
				'label'   => esc_html__( 'Subtitle', 'sifency-addons' ),
				'type'    => Controls_Manager::TEXTAREA,
				'default' => 'Description here',
			)
		);

		$repeater->add_control(
			'currency',
			array(
				'label'   => esc_html__( 'Currency', 'sifency-addons' ),
				'type'    => Controls_Manager::TEXT,
				'default' => '$',
			)
		);

		$repeater->add_control(
			'price_a',
			array(
				'label'   => esc_html__( 'Price (Monthly)', 'sifency-addons' ),
				'type'    => Controls_Manager::TEXT,
				'default' => '19',
			)
		);
		$repeater->add_control(
			'period_a',
			array(
				'label'   => esc_html__( 'Period (Monthly)', 'sifency-addons' ),
				'type'    => Controls_Manager::TEXT,
				'default' => '/mo',
			)
		);

		$repeater->add_control(
			'price_b',
			array(
				'label'   => esc_html__( 'Price (Yearly)', 'sifency-addons' ),
				'type'    => Controls_Manager::TEXT,
				'default' => '199',
			)
		);
		$repeater->add_control(
			'period_b',
			array(
				'label'   => esc_html__( 'Period (Yearly)', 'sifency-addons' ),
				'type'    => Controls_Manager::TEXT,
				'default' => '/yr',
			)
		);

		$repeater->add_control(
			'features_html',
			array(
				'label'       => esc_html__( 'Features List (Monthly)', 'sifency-addons' ),
				'type'        => Controls_Manager::TEXTAREA,
				'rows'        => 10,
				'default'     => "10GB Storage\nBandwidth Free\n!No Support",
				'description' => esc_html__( 'One feature per line. Start line with "!" to mark as excluded.', 'sifency-addons' ),
			)
		);

		$repeater->add_control(
			'features_html_yearly',
			array(
				'label'       => esc_html__( 'Features List (Yearly)', 'sifency-addons' ),
				'type'        => Controls_Manager::TEXTAREA,
				'rows'        => 10,
				'default'     => "20GB Storage\nBandwidth Free\nPremium Support\nFree Domain",
				'description' => esc_html__( 'If empty, monthly features will be used. One feature per line.', 'sifency-addons' ),
			)
		);

		$repeater->add_control(
			'btn_text',
			array(
				'label'   => esc_html__( 'Button Text', 'sifency-addons' ),
				'type'    => Controls_Manager::TEXT,
				'default' => 'Get Started',
			)
		);

		$repeater->add_control(
			'btn_link',
			array(
				'label'   => esc_html__( 'Link', 'sifency-addons' ),
				'type'    => Controls_Manager::URL,
				'default' => array( 'url' => '#' ),
			)
		);

		$this->add_control(
			'cards_list',
			array(
				'label'       => esc_html__( 'Cards', 'sifency-addons' ),
				'type'        => Controls_Manager::REPEATER,
				'fields'      => $repeater->get_controls(),
				'default'     => array(
					array(
						'title'   => 'Basic',
						'price_a' => '19',
						'price_b' => '190',
					),
					array(
						'title'       => 'Pro',
						'is_featured' => 'yes',
						'price_a'     => '49',
						'price_b'     => '490',
					),
					array(
						'title'   => 'Agency',
						'price_a' => '99',
						'price_b' => '990',
					),
				),
				'title_field' => '{{{ title }}}',
			)
		);
		$this->end_controls_section();

		$this->start_controls_section(
			'section_layout',
			array( 'label' => esc_html__( 'Layout & Grid', 'sifency-addons' ) )
		);
		$this->add_control(
			'layout_style',
			array(
				'label'   => esc_html__( 'Layout Style', 'sifency-addons' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'style-1',
				'options' => array(
					'style-1'  => esc_html__( 'Style 1 (Classic)', 'sifency-addons' ),
					'style-2'  => esc_html__( 'Style 2 (Button Middle)', 'sifency-addons' ),
					'style-3'  => esc_html__( 'Style 3 (Minimal/Clean)', 'sifency-addons' ),
					'style-4'  => esc_html__( 'Style 4 (Dark Header)', 'sifency-addons' ),
					'style-5'  => esc_html__( 'Style 5 (Bordered Header)', 'sifency-addons' ),
					'style-6'  => esc_html__( 'Style 6 (Floating Price)', 'sifency-addons' ),
					'style-7'  => esc_html__( 'Style 7 (Side Accent)', 'sifency-addons' ),
					'style-8'  => esc_html__( 'Style 8 (Compact)', 'sifency-addons' ),
					'style-9'  => esc_html__( 'Style 9 (Gradient Header)', 'sifency-addons' ),
					'style-10' => esc_html__( 'Style 10 (Boxed Features)', 'sifency-addons' ),
				),
			)
		);
		$this->add_responsive_control(
			'columns',
			array(
				'label'          => esc_html__( 'Columns', 'sifency-addons' ),
				'type'           => Controls_Manager::SELECT,
				'default'        => '3',
				'tablet_default' => '2',
				'mobile_default' => '1',
				'options'        => array(
					'1' => '1',
					'2' => '2',
					'3' => '3',
					'4' => '4',
					'5' => '5',
				),
				'selectors'      => array(
					'{{WRAPPER}} .sifency-pricing-grid' => 'grid-template-columns: repeat({{VALUE}}, 1fr);',
				),
			)
		);
		$this->add_responsive_control(
			'grid_gap',
			array(
				'label'     => esc_html__( 'Gap', 'sifency-addons' ),
				'type'      => Controls_Manager::SLIDER,
				'default'   => array( 'size' => 30 ),
				'selectors' => array(
					'{{WRAPPER}} .sifency-pricing-grid' => 'gap: {{SIZE}}px;',
				),
			)
		);
		$this->add_control(
			'show_icon',
			array(
				'label'   => 'Show Feature Icon',
				'type'    => Controls_Manager::SWITCHER,
				'default' => 'yes',
			)
		);

		$this->add_control(
			'show_button_icon',
			array(
				'label' => 'Show Button Icon',
				'type'  => Controls_Manager::SWITCHER,
			)
		);
		$this->add_control(
			'arrow_next_icon',
			array(
				'label'     => esc_html__( 'Next Icon', 'sifency-addons' ),
				'type'      => Controls_Manager::ICONS,
				'default'   => array(
					'value'   => 'icon-right-open-big',
					'library' => 'sifency-icons',
				),
				'condition' => array( 'show_button_icon' => 'yes' ),
			)
		);
		$this->add_control(
			'price_alignment',
			array(
				'label'     => esc_html__( 'Price Alignment', 'sifency-addons' ),
				'type'      => \Elementor\Controls_Manager::CHOOSE,
				'options'   => array(
					'left'   => array(
						'title' => esc_html__( 'Left', 'sifency-addons' ),
						'icon'  => 'eicon-text-align-left',
					),
					'center' => array(
						'title' => esc_html__( 'Center', 'sifency-addons' ),
						'icon'  => 'eicon-text-align-center',
					),
					'right'  => array(
						'title' => esc_html__( 'Right', 'sifency-addons' ),
						'icon'  => 'eicon-text-align-right',
					),
				),
				'toggle'    => true,
				'selectors' => array(
					'{{WRAPPER}} .sifency-price-wrap' => 'justify-content: {{VALUE}};',
				),
			)
		);
		$this->add_control(
			'feature_list_alignment',
			array(
				'label'     => esc_html__( 'Feature List Alignment', 'sifency-addons' ),
				'type'      => \Elementor\Controls_Manager::CHOOSE,
				'options'   => array(
					'left'   => array(
						'title' => esc_html__( 'Left', 'sifency-addons' ),
						'icon'  => 'eicon-text-align-left',
					),
					'center' => array(
						'title' => esc_html__( 'Center', 'sifency-addons' ),
						'icon'  => 'eicon-text-align-center',
					),
					'right'  => array(
						'title' => esc_html__( 'Right', 'sifency-addons' ),
						'icon'  => 'eicon-text-align-right',
					),
				),
				'toggle'    => true,
				'selectors' => array(
					'{{WRAPPER}} .sifency-pricing-features li' => 'justify-content: {{VALUE}};',
				),
			)
		);
		$this->add_control(
			'pricing_button_alignment',
			array(
				'label'     => esc_html__( 'Button Alignment', 'sifency-addons' ),
				'type'      => \Elementor\Controls_Manager::CHOOSE,
				'options'   => array(
					'left'   => array(
						'title' => esc_html__( 'Left', 'sifency-addons' ),
						'icon'  => 'eicon-text-align-left',
					),
					'center' => array(
						'title' => esc_html__( 'Center', 'sifency-addons' ),
						'icon'  => 'eicon-text-align-center',
					),
					'right'  => array(
						'title' => esc_html__( 'Right', 'sifency-addons' ),
						'icon'  => 'eicon-text-align-right',
					),
				),
				'toggle'    => true,
				'selectors' => array(
					'{{WRAPPER}} .sifency-pricing-footer' => 'text-align: {{VALUE}};',
				),
			)
		);
		$this->add_sifency_addons_flex_alignment_controls(
			array(
				'selector' => '.sifency-price-wrap',
				'label'    => esc_html__( 'Price Wrap Alignment', 'sifency-addons' ),
			)
		);
		$this->end_controls_section();
		$this->add_sifency_addons_help_controls();
		$this->add_sifency_addons_toggle_style_controls(
			array(
				'prefix'    => 'pricing_toggle_',
				'label'     => esc_html__( 'Toggle Switch Design', 'sifency-addons' ),
				'selector'  => '.sifency-toggle-label',
				'selectors' => array(
					'nav'          => '.sifency-toggle-container',
					'track'        => '.sifency-toggle-label',
					'thumb'        => '.sifency-toggle-label::after',
					'active_track' => '.sifency-toggle-checkbox:checked + .sifency-toggle-label',
					'active_thumb' => '.sifency-toggle-checkbox:checked + .sifency-toggle-label::after',
					'hover_track'  => '.sifency-toggle-label:hover',
					'hover_thumb'  => '.sifency-toggle-label:hover::after',
				),
			)
		);
		$this->add_sifency_addons_item_style_controls(
			array(
				'prefix'   => 'item_style',
				'label'    => 'Pricing Item',
				'selector' => '.sifency-pricing-card',
			)
		);
		$this->add_sifency_addons_item_style_controls(
			array(
				'prefix'   => 'featured_item_style',
				'label'    => 'Featured Item',
				'selector' => '.sifency-pricing-card.is-featured',
			)
		);
		$this->add_sifency_addons_item_style_controls(
			array(
				'prefix'   => 'header_style',
				'label'    => 'Header Area',
				'selector' => '.sifency-pricing-header',
				'exclude'  => array( 'tabs', 'transition' ),
			)
		);
		$this->add_sifency_addons_item_style_controls(
			array(
				'prefix'   => 'pricing_style',
				'label'    => 'Pricing Area',
				'selector' => '.sifency-price-wrap',
				'exclude'  => array( 'tabs', 'transition' ),
			)
		);
		$this->add_sifency_addons_item_style_controls(
			array(
				'prefix'   => 'feature_style',
				'label'    => 'Feature Area',
				'selector' => '.sifency-pricing-features',
				'exclude'  => array( 'tabs', 'transition' ),
			)
		);
		$this->add_sifency_addons_item_style_controls(
			array(
				'prefix'   => 'footer_style',
				'label'    => 'Footer Area',
				'selector' => '.sifency-pricing-footer',
				'exclude'  => array( 'tabs', 'transition' ),
			)
		);
		$this->add_sifency_addons_master_typography_controls(
			array(
				'prefix'   => 'label_style_',
				'label'    => 'Price',
				'selector' => '.sifency-label-style',
				'exclude'  => array( 'alignment', 'transition', 'tabs' ),
			)
		);
		$this->add_sifency_addons_master_typography_controls(
			array(
				'prefix'     => 'currency_style_',
				'label'      => 'Currency',
				'selector'   => '.sifency-price-currency',
				'color_only' => true,
				'exclude'    => array( 'alignment', 'transition', 'tabs', 'box_model', 'shadow', 'stroke' ),
			)
		);
		$this->add_sifency_addons_master_typography_controls(
			array(
				'prefix'     => 'period_style_',
				'label'      => 'Period',
				'selector'   => '.sifency-price-period',
				'color_only' => true,
				'exclude'    => array( 'alignment', 'transition', 'tabs', 'box_model', 'shadow', 'stroke' ),
			)
		);
		$this->add_sifency_addons_master_typography_controls(
			array(
				'prefix'          => 'heading_style_',
				'label'           => 'Heading',
				'selector'        => '.sifency-heading-style',
				'show_transition' => false,
				'exclude'         => array( 'transition', 'tabs', 'bg', 'radius', 'border' ),
			)
		);
		$this->add_sifency_addons_master_typography_controls(
			array(
				'prefix'     => 'meta_style_',
				'label'      => 'Subtitle (Header)',
				'selector'   => '.sifency-meta-style',
				'color_only' => true,
				'exclude'    => array( 'transition', 'tabs', 'bg', 'radius', 'border', 'stroke', 'shadow' ),
			)
		);
		$this->add_sifency_addons_master_typography_controls(
			array(
				'prefix'     => 'content_style',
				'label'      => 'Feature List',
				'selector'   => '.sifency-content-style',
				'color_only' => true,
				'exclude'    => array( 'tabs', 'shadow', 'stroke', 'alignment', 'transition' ),
			)
		);
		$this->add_sifency_addons_master_typography_controls(
			array(
				'prefix'         => 'caption_style',
				'label'          => 'Ribbon Text',
				'selector'       => '.sifency-caption-style',
				'color_only'     => true,
				'show_max_width' => true,
				'show_rotate'    => true,
				'exclude'        => array( 'alignment', 'transition', 'tabs' ),
			)
		);
		$this->add_Sifency_Addons_Button_Style_Controls(
			array(
				'prefix'         => 'button_style',
				'label'          => 'Button',
				'selector'       => '.sifency-pricing-btn',
				'hover_selector' => '.sifency-pricing-card:hover .sifency-pricing-btn',
			)
		);
		$this->add_Sifency_Addons_Button_Style_Controls(
			array(
				'prefix'   => 'featured_item_button_style',
				'label'    => 'Featured Item Button',
				'selector' => '.is-featured .sifency-pricing-btn',
				'exclude'  => array( 'dimensions', 'typography', 'shadow', 'padding', 'margin', 'transition' ),
			)
		);
		$this->add_Sifency_Addons_Button_Style_Controls(
			array(
				'prefix'    => 'yearly_save_button_style',
				'label'     => 'Yearly Benefit Button',
				'selector'  => '.sifency-benefit-style',
				'condition' => array( 'show_switcher' => 'yes' ),
			)
		);
		$this->add_sifency_addons_master_typography_controls(
			array(
				'prefix'     => 'switcher_style',
				'label'      => 'Switcher Text',
				'selector'   => '.sifency-separator-style',
				'exclude'    => array( 'alignment', 'transition', 'tabs', 'box_model', 'shadow', 'stroke' ),
				'color_only' => true,
				'condition'  => array( 'show_switcher' => 'yes' ),
			)
		);
		Sifency_Addons_Parity_Style_Controls::register( $this );
		$this->add_Sifency_Addons_Animation_Controls();
		$this->add_Sifency_Addons_Custom_CSS_Controls();
	}

	protected function render_dom( array $context ) {
		$wrapper_id = esc_attr( $context['dom_id'] );
		$settings   = $this->get_settings_for_display();
		$this->sifency_addons_render_custom_css();

		$id_unique    = $this->get_id();
		$layout_style = $settings['layout_style'];

		$wrapper_classes         = array( 'sifency-pricing-grid', $layout_style );
		$animation_manager       = new Sifency_Addons_Animation_Manager( $settings );
		$animation_wrapper_attrs = $animation_manager->get_wrapper_attributes( $wrapper_classes );
		?>
		<?php $this->render_sifency_section_header_elements( $settings ); ?>
		<?php if ( 'yes' === $settings['show_switcher'] ) : ?>
			<div id="<?php echo esc_attr( $wrapper_id ); ?>" class="sifency-toggle-container">
				<span class="sifency-toggle-text text-monthly active sifency-separator-style">
					<?php echo esc_html( $settings['label_monthly'] ); ?>
				</span>
				
				<input type="checkbox" id="sifency-switch-<?php echo esc_attr( $id_unique ); ?>" class="sifency-toggle-checkbox">
				<label for="sifency-switch-<?php echo esc_attr( $id_unique ); ?>" class="sifency-toggle-label"></label>
				
				<span class="sifency-toggle-text text-yearly">
					<span class="sifency-separator-style"><?php echo esc_html( $settings['label_yearly'] ); ?></span>
					
					<?php if ( ! empty( $settings['label_badge'] ) ) : ?>
						<span class="sifency-toggle-badge sifency-benefit-style">
							<?php echo esc_html( $settings['label_badge'] ); ?>
						</span>
					<?php endif; ?>
				</span>
			</div>
		<?php endif; ?>

		<div <?php echo wp_kses_post( $animation_wrapper_attrs ); ?> id="sifency-grid-<?php echo esc_attr( $id_unique ); ?>">
			<?php
			$post_index = 0;

			foreach ( $settings['cards_list'] as $index => $card ) :
				$post_index++;

				$card_key     = 'card_' . $index;
				$title_key    = 'title_' . $index;
				$subtitle_key = 'subtitle_' . $index;
				$price_key    = 'price_wrap_' . $index;
				$btn_key      = 'btn_' . $index;

				$parity_class = ( $post_index % 2 !== 0 ) ? 'odd-item' : 'even-item';

				$item_classes = array(
					'sifency-pricing-card',
					$parity_class,
					'elementor-repeater-item-' . $card['_id'],
				);

				if ( 'yes' === $card['is_featured'] ) {
					$item_classes[] = 'is-featured';
				}

				$animation_item_attrs = $animation_manager->get_item_attributes( $item_classes );

				$this->add_inline_editing_attributes( $title_key, 'none' );
				$this->add_inline_editing_attributes( $subtitle_key, 'none' );
				$this->add_inline_editing_attributes( $btn_key, 'none' );
				$this->add_render_attribute(
					$price_key,
					array(
						'class'         => 'sifency-price-wrap',
						'data-currency' => $card['currency'],
						'data-price-a'  => $card['price_a'],
						'data-period-a' => $card['period_a'],
						'data-price-b'  => $card['price_b'],
						'data-period-b' => $card['period_b'],
					)
				);

				$features_monthly = explode( "\n", $card['features_html'] );

				$features_yearly_raw = ! empty( $card['features_html_yearly'] ) ? $card['features_html_yearly'] : $card['features_html'];
				$features_yearly     = explode( "\n", $features_yearly_raw );
				?>
				<div <?php echo wp_kses_post( $animation_item_attrs ); ?>>
					
					<div class="sifency-pricing-header">
						<h3 class="sifency-pricing-title sifency-heading-style">
							<span <?php echo wp_kses( $this->get_render_attribute_string( $title_key ), array() ); ?>>
								<?php echo esc_html( $card['title'] ); ?>
							</span>
						</h3>
						<p class="sifency-pricing-subtitle sifency-meta-style">
							<span <?php echo wp_kses( $this->get_render_attribute_string( $subtitle_key ), array() ); ?>>
								<?php echo esc_html( $card['subtitle'] ); ?>
							</span>
						</p>

						<?php if ( 'yes' === ( $card['is_featured'] ?? '' ) && ! empty( $card['ribbon_text'] ) ) : ?>
							<div class="sifency-pricing-ribbon sifency-caption-style">
								<span><?php echo esc_html( $card['ribbon_text'] ); ?></span>
							</div>
						<?php endif; ?>

					</div>

					<div <?php echo wp_kses( $this->get_render_attribute_string( $price_key ), array() ); ?>>
						<span class="sifency-price-currency"><?php echo esc_html( $card['currency'] ); ?></span>
						<span class="sifency-price-amount sifency-label-style"><?php echo esc_html( $card['price_a'] ); ?></span>
						<span class="sifency-price-period"><?php echo esc_html( $card['period_a'] ); ?></span>
					</div>

					<div class="sifency-pricing-features">
						<ul class="sifency-pricing-features-list is-monthly">
							<?php
							foreach ( $features_monthly as $feature ) :
								$feature = trim( $feature );
								if ( empty( $feature ) ) {
									continue;
								}

								$is_excluded  = ( strpos( $feature, '!' ) === 0 );
								$feature_text = $is_excluded ? substr( $feature, 1 ) : $feature;

								$li_class   = $is_excluded ? 'excluded' : 'included';
								$icon_class = $is_excluded ? 'icon-cancel' : 'icon-check';
								?>
								<li class="sifency-content-style <?php echo esc_attr( $li_class ); ?>">
									<?php if ( 'yes' === $settings['show_icon'] ) : ?>
									<i class="<?php echo esc_attr( $icon_class ); ?>"></i>
									<?php endif; ?>
									<span><?php echo esc_html( $feature_text ); ?></span>
								</li>
							<?php endforeach; ?>
						</ul>

						<ul class="sifency-pricing-features-list is-yearly" style="display:none;">
							<?php
							foreach ( $features_yearly as $feature ) :
								$feature = trim( $feature );
								if ( empty( $feature ) ) {
									continue;
								}

								$is_excluded  = ( strpos( $feature, '!' ) === 0 );
								$feature_text = $is_excluded ? substr( $feature, 1 ) : $feature;

								$li_class   = $is_excluded ? 'excluded' : 'included';
								$icon_class = $is_excluded ? 'icon-cancel' : 'icon-check';
								?>
								<li class="sifency-content-style <?php echo esc_attr( $li_class ); ?>">
									<?php if ( 'yes' === $settings['show_icon'] ) : ?>
									<i class="<?php echo esc_attr( $icon_class ); ?>"></i>
									<?php endif; ?>
									<span><?php echo esc_html( $feature_text ); ?></span>
								</li>
							<?php endforeach; ?>
						</ul>
					</div>

					<div class="sifency-pricing-footer">
						<a href="<?php echo esc_url( $card['btn_link']['url'] ); ?>" class="sifency-pricing-btn" <?php echo wp_kses( $this->get_render_attribute_string( $btn_key ), array() ); ?>>
							<?php echo esc_html( $card['btn_text'] ); ?>
								<?php if ( 'yes' === $settings['show_button_icon'] ) : ?>
									<?php
									$next_icon = $settings['arrow_next_icon'] ?? '';
									\Elementor\Icons_Manager::render_icon( $next_icon, array( 'aria-hidden' => 'true' ) );
									?>
							<?php endif; ?>
						</a>
					</div>
				</div>
			<?php endforeach; ?>
		</div>
		<?php
	}
}
?>
