<?php
namespace Sifency\Traits;

if ( ! defined( 'ABSPATH' ) ) {
	exit;  }
use \Elementor\Controls_Manager;
use Elementor\Utils;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;

trait Sifency_Iconbox_Controls {
	/**
	 * Registers the main content controls for the Icon Box widget.
	 */
	protected function add_sifency_iconbox_controls() {
		$this->start_controls_section(
			'section_content',
			array(
				'label' => esc_html__( 'Icon Box', 'sifency-addons' ),
			)
		);
		$this->add_control(
			'icon_type',
			array(
				'label'   => esc_html__( 'Media Type', 'sifency-addons' ),
				'type'    => Controls_Manager::CHOOSE,
				'options' => array(
					'icon'  => array(
						'title' => esc_html__( 'Icon', 'sifency-addons' ),
						'icon'  => 'eicon-star',
					),
					'image' => array(
						'title' => esc_html__( 'Image', 'sifency-addons' ),
						'icon'  => 'eicon-image-bold',
					),
				),
				'default' => 'icon',
			)
		);
		$this->add_control(
			'icon',
			array(
				'label'     => esc_html__( 'Icon', 'sifency-addons' ),
				'type'      => Controls_Manager::ICONS,
				'default'   => array(
					'value'   => 'icon-heart-empty',
					'library' => 'sifency-icons',
				),
				'condition' => array(
					'icon_type' => 'icon',
				),
			)
		);
		$this->add_control(
			'image',
			array(
				'label'     => esc_html__( 'Choose Image', 'sifency-addons' ),
				'type'      => Controls_Manager::MEDIA,
				'default'   => array(
					'url' => Utils::get_placeholder_image_src(),
				),
				'condition' => array(
					'icon_type' => 'image',
				),
			)
		);
		$this->add_control(
			'title_text',
			array(
				'label'   => esc_html__( 'Title', 'sifency-addons' ),
				'type'    => Controls_Manager::TEXTAREA,
				'default' => esc_html__( 'Icon Box Title', 'sifency-addons' ),
				'dynamic' => array( 'active' => true ),
			)
		);
		$this->add_control(
			'description_text',
			array(
				'label'   => esc_html__( 'Description', 'sifency-addons' ),
				'type'    => Controls_Manager::TEXTAREA,
				'default' => esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 'sifency-addons' ),
				'dynamic' => array( 'active' => true ),
			)
		);
		$this->add_control(
			'show_read_more',
			array(
				'label'     => esc_html__( 'Show Read More', 'sifency-addons' ),
				'type'      => Controls_Manager::SWITCHER,
				'default'   => 'yes',
				'separator' => 'before',
			)
		);
		$this->add_control(
			'read_more_text',
			array(
				'label'     => esc_html__( 'Read More Text', 'sifency-addons' ),
				'type'      => Controls_Manager::TEXT,
				'default'   => esc_html__( 'Read More', 'sifency-addons' ),
				'condition' => array( 'show_read_more' => 'yes' ),
			)
		);
		$this->add_control(
			'read_more_icon',
			array(
				'label'     => esc_html__( 'Read More Icon', 'sifency-addons' ),
				'type'      => Controls_Manager::ICONS,
				'default'   => array(
					'value'   => 'icon-right',
					'library' => 'sifency-icons',
				),
				'condition' => array( 'show_read_more' => 'yes' ),
			)
		);
		$this->add_control(
			'read_more_icon_position',
			array(
				'label'     => esc_html__( 'Icon Position', 'sifency-addons' ),
				'type'      => Controls_Manager::SELECT,
				'options'   => array(
					'before' => esc_html__( 'Before', 'sifency-addons' ),
					'after'  => esc_html__( 'After', 'sifency-addons' ),
				),
				'default'   => 'after',
				'condition' => array(
					'show_read_more'         => 'yes',
					'read_more_icon[value]!' => '',
				),
			)
		);

		$this->add_control(
			'link',
			array(
				'label'       => esc_html__( 'Link', 'sifency-addons' ),
				'type'        => Controls_Manager::URL,
				'placeholder' => esc_html__( 'https://your-link.com', 'sifency-addons' ),
				'dynamic'     => array( 'active' => true ),
			)
		);
		$this->add_control(
			'position',
			array(
				'label'        => esc_html__( 'Icon Position', 'sifency-addons' ),
				'type'         => Controls_Manager::CHOOSE,
				'options'      => array(
					'left'  => array(
						'title' => esc_html__( 'Left', 'sifency-addons' ),
						'icon'  => 'eicon-h-align-left',
					),
					'top'   => array(
						'title' => esc_html__( 'Top', 'sifency-addons' ),
						'icon'  => 'eicon-v-align-top',
					),
					'right' => array(
						'title' => esc_html__( 'Right', 'sifency-addons' ),
						'icon'  => 'eicon-h-align-right',
					),
				),
				'default'      => 'top',
				'prefix_class' => 'sifency-iconbox-position-',
			)
		);
		$this->add_control(
			'title_html_tag',
			array(
				'label'   => esc_html__( 'Title HTML Tag', 'sifency-addons' ),
				'type'    => Controls_Manager::SELECT,
				'options' => array(
					'h1'   => 'H1',
					'h2'   => 'H2',
					'h3'   => 'H3',
					'h4'   => 'H4',
					'h5'   => 'H5',
					'h6'   => 'H6',
					'div'  => 'div',
					'span' => 'span',
					'p'    => 'p',
				),
				'default' => 'h3',
			)
		);
		$this->end_controls_section();
	}

}
