<?php
namespace Sifency\Traits;

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

	protected function add_sifency_icon_list_icon_controls( $args = array() ) {
			// Section
			$this->start_controls_section(
				'section_icon_style',
				array(
					'label' => esc_html__( 'Icon', 'sifency-addons' ),
					'tab'   => Controls_Manager::TAB_STYLE,
				)
			);

			$this->add_responsive_control(
				'icon_alignment',
				array(
					'label'        => esc_html__( 'Alignment', 'sifency-addons' ),
					'type'         => Controls_Manager::CHOOSE,
					'options'      => array(
						'left'   => array(
							'title' => esc_html__( 'Left', 'sifency-addons' ),
							'icon'  => 'eicon-h-align-left',
						),
						'center' => array(
							'title' => esc_html__( 'Center', 'sifency-addons' ),
							'icon'  => 'eicon-h-align-center',
						),
						'right'  => array(
							'title' => esc_html__( 'Right', 'sifency-addons' ),
							'icon'  => 'eicon-h-align-right',
						),
					),
					'default'      => 'left',
					'prefix_class' => 'sifency-icon-align-',
					'selectors'    => array(
						'{{WRAPPER}}.sifency-icon-align-left .sifency-icon-list-icon'   => 'margin-left: 0; margin-right: auto;',
						'{{WRAPPER}}.sifency-icon-align-center .sifency-icon-list-icon' => 'margin-left: auto; margin-right: auto;',
						'{{WRAPPER}}.sifency-icon-align-right .sifency-icon-list-icon'  => 'margin-left: auto; margin-right: 0;',
					),
				)
			);

			$this->add_responsive_control(
				'icon_size',
				array(
					'label'      => esc_html__( 'Icon Size', 'sifency-addons' ),
					'type'       => Controls_Manager::SLIDER,
					'size_units' => array( 'px', 'em', 'rem' ),
					'range'      => array(
						'px' => array(
							'min' => 8,
							'max' => 160,
						),
						'em' => array(
							'min' => 0.5,
							'max' => 10,
						),
					),
					'selectors'  => array(
						'{{WRAPPER}} .sifency-icon-list-icon i, {{WRAPPER}} .sifency-icon-list-icon span, {{WRAPPER}} .sifency-icon-list-icon svg' => 'font-size: {{SIZE}}{{UNIT}}; line-height: 1;',
					),
					'default'    => array(
						'size' => 20,
						'unit' => 'px',
					),
				)
			);

			$this->add_responsive_control(
				'icon_box_size',
				array(
					'label'      => esc_html__( 'Icon Box Size', 'sifency-addons' ),
					'type'       => Controls_Manager::SLIDER,
					'size_units' => array( 'px', '%' ),
					'range'      => array(
						'px' => array(
							'min' => 0,
							'max' => 200,
						),
					),
					'selectors'  => array(
						'{{WRAPPER}} .sifency-icon-list-icon' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}}; min-width: {{SIZE}}{{UNIT}};',
					),
					'default'    => array(
						'size' => 42,
						'unit' => 'px',
					),
				)
			);

			$this->add_responsive_control(
				'icon_padding',
				array(
					'label'      => esc_html__( 'Padding', 'sifency-addons' ),
					'type'       => Controls_Manager::DIMENSIONS,
					'size_units' => array( 'px', '%', 'em' ),
					'selectors'  => array(
						'{{WRAPPER}} .sifency-icon-list-icon' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
					),
					'separator'  => 'before',
				)
			);

			$this->add_responsive_control(
				'icon_margin',
				array(
					'label'      => esc_html__( 'Margin', 'sifency-addons' ),
					'type'       => Controls_Manager::DIMENSIONS,
					'size_units' => array( 'px', '%', 'em' ),
					'selectors'  => array(
						'{{WRAPPER}} .sifency-icon-list-icon' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
					),
				)
			);

			$this->start_controls_tabs( 'icon_color_tabs' );

			$this->start_controls_tab(
				'icon_color_tab_normal',
				array( 'label' => esc_html__( 'Normal', 'sifency-addons' ) )
			);

			$this->add_control(
				'icon_color',
				array(
					'label'     => esc_html__( 'Icon Color', 'sifency-addons' ),
					'type'      => Controls_Manager::COLOR,
					'selectors' => array(
						'{{WRAPPER}} .sifency-icon-list-icon, {{WRAPPER}} .sifency-icon-list-icon i, {{WRAPPER}} .sifency-icon-list-icon svg' => 'color: {{VALUE}};',
					),
				)
			);

			$this->add_control(
				'icon_background',
				array(
					'label'     => esc_html__( 'Background', 'sifency-addons' ),
					'type'      => Controls_Manager::COLOR,
					'selectors' => array(
						'{{WRAPPER}} .sifency-icon-list-icon' => 'background-color: {{VALUE}};',
					),
				)
			);

			$this->add_control(
				'icon_opacity',
				array(
					'label'     => esc_html__( 'Opacity', 'sifency-addons' ),
					'type'      => Controls_Manager::SLIDER,
					'range'     => array(
						'px' => array(
							'min'  => 0,
							'max'  => 1,
							'step' => 0.01,
						),
					),
					'default'   => array( 'size' => 1 ),
					'selectors' => array(
						'{{WRAPPER}} .sifency-icon-list-icon' => 'opacity: {{SIZE}};',
					),
				)
			);

			$this->add_control(
				'icon_blend_mode',
				array(
					'label'     => esc_html__( 'Blend Mode', 'sifency-addons' ),
					'type'      => Controls_Manager::SELECT,
					'options'   => array(
						''         => esc_html__( 'Normal', 'sifency-addons' ),
						'multiply' => 'multiply',
						'screen'   => 'screen',
						'overlay'  => 'overlay',
						'darken'   => 'darken',
						'lighten'  => 'lighten',
					),
					'selectors' => array(
						'{{WRAPPER}} .sifency-icon-list-icon' => 'mix-blend-mode: {{VALUE}};',
					),
				)
			);

			$this->end_controls_tab();

			$this->start_controls_tab(
				'icon_color_tab_hover',
				array( 'label' => esc_html__( 'Hover', 'sifency-addons' ) )
			);

			$this->add_control(
				'icon_color_hover',
				array(
					'label'     => esc_html__( 'Icon Color (Hover)', 'sifency-addons' ),
					'type'      => Controls_Manager::COLOR,
					'selectors' => array(
						'{{WRAPPER}}:hover .sifency-icon-list-icon, {{WRAPPER}} .sifency-icon-list-item:hover .sifency-icon-list-icon' => 'color: {{VALUE}};',
						'{{WRAPPER}} .sifency-icon-list-item:hover .sifency-icon-list-icon i, {{WRAPPER}} .sifency-icon-list-item:hover .sifency-icon-list-icon svg' => 'color: {{VALUE}};',
					),
				)
			);

			$this->add_control(
				'icon_background_hover',
				array(
					'label'     => esc_html__( 'Background (Hover)', 'sifency-addons' ),
					'type'      => Controls_Manager::COLOR,
					'selectors' => array(
						'{{WRAPPER}} .sifency-icon-list-item:hover .sifency-icon-list-icon' => 'background-color: {{VALUE}};',
					),
				)
			);

			$this->add_control(
				'icon_opacity_hover',
				array(
					'label'     => esc_html__( 'Opacity (Hover)', 'sifency-addons' ),
					'type'      => Controls_Manager::SLIDER,
					'range'     => array(
						'px' => array(
							'min'  => 0,
							'max'  => 1,
							'step' => 0.01,
						),
					),
					'default'   => array( 'size' => 1 ),
					'selectors' => array(
						'{{WRAPPER}} .sifency-icon-list-item:hover .sifency-icon-list-icon' => 'opacity: {{SIZE}};',
					),
				)
			);

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

			$this->add_group_control(
				Group_Control_Border::get_type(),
				array(
					'name'     => 'icon_border',
					'selector' => '{{WRAPPER}} .sifency-icon-list-icon',
				)
			);

			$this->add_responsive_control(
				'icon_border_radius',
				array(
					'label'      => esc_html__( 'Border Radius', 'sifency-addons' ),
					'type'       => Controls_Manager::DIMENSIONS,
					'size_units' => array( 'px', '%' ),
					'selectors'  => array(
						'{{WRAPPER}} .sifency-icon-list-icon' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
					),
				)
			);

			$this->add_group_control(
				Group_Control_Box_Shadow::get_type(),
				array(
					'name'     => 'icon_box_shadow',
					'selector' => '{{WRAPPER}} .sifency-icon-list-icon',
				)
			);

			$this->add_control(
				'icon_rotate',
				array(
					'label'     => esc_html__( 'Rotate (deg)', 'sifency-addons' ),
					'type'      => Controls_Manager::SLIDER,
					'range'     => array(
						'px' => array(
							'min' => -360,
							'max' => 360,
						),
					),
					'selectors' => array(
						'{{WRAPPER}} .sifency-icon-list-icon' => 'transform: rotate({{SIZE}}deg);',
					),
				)
			);

			$this->add_control(
				'icon_transform_origin',
				array(
					'label'     => esc_html__( 'Transform Origin', 'sifency-addons' ),
					'type'      => Controls_Manager::SELECT,
					'options'   => array(
						'center center' => esc_html__( 'Center', 'sifency-addons' ),
						'top left'      => esc_html__( 'Top Left', 'sifency-addons' ),
						'top right'     => esc_html__( 'Top Right', 'sifency-addons' ),
						'bottom left'   => esc_html__( 'Bottom Left', 'sifency-addons' ),
						'bottom right'  => esc_html__( 'Bottom Right', 'sifency-addons' ),
					),
					'default'   => 'center center',
					'selectors' => array(
						'{{WRAPPER}} .sifency-icon-list-icon' => 'transform-origin: {{VALUE}};',
					),
				)
			);

			$this->add_control(
				'icon_transition_duration',
				array(
					'label'      => esc_html__( 'Transition Duration', 'sifency-addons' ),
					'type'       => Controls_Manager::SLIDER,
					'size_units' => array( 'ms', 's' ),
					'range'      => array(
						'ms' => array(
							'min' => 0,
							'max' => 2000,
						),
						's'  => array(
							'min' => 0,
							'max' => 2,
						),
					),
					'default'    => array(
						'size' => 300,
						'unit' => 'ms',
					),
					'selectors'  => array(
						'{{WRAPPER}} .sifency-icon-list-icon' => 'transition-duration: {{SIZE}}{{UNIT}};',
						'{{WRAPPER}} .sifency-icon-list-item:hover .sifency-icon-list-icon' => 'transition-duration: {{SIZE}}{{UNIT}};',
					),
				)
			);
			$this->end_controls_section();
	}
}
