<?php
namespace Sifency\Traits;
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}
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 = [] ) {
            // Section
            $this->start_controls_section(
                'section_icon_style',
                [
                    'label' => esc_html__( 'Icon', 'sifency-addons' ),
                    'tab'   => Controls_Manager::TAB_STYLE,
                ]
            );

            $this->add_responsive_control(
                'icon_alignment',
                [
                    'label'       => esc_html__( 'Alignment', 'sifency-addons' ),
                    'type'        => Controls_Manager::CHOOSE,
                    'options'     => [
                        'left'   => [ 'title' => esc_html__( 'Left', 'sifency-addons' ), 'icon' => 'eicon-h-align-left' ],
                        'center' => [ 'title' => esc_html__( 'Center', 'sifency-addons' ), 'icon' => 'eicon-h-align-center' ],
                        'right'  => [ 'title' => esc_html__( 'Right', 'sifency-addons' ), 'icon' => 'eicon-h-align-right' ],
                    ],
                    'default'     => 'left',
                    'prefix_class'=> 'sifency-icon-align-',
                    'selectors'   => [
                        '{{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',
                [
                    'label'      => esc_html__( 'Icon Size', 'sifency-addons' ),
                    'type'       => Controls_Manager::SLIDER,
                    'size_units' => [ 'px', 'em', 'rem' ],
                    'range'      => [
                        'px' => [ 'min' => 8, 'max' => 160 ],
                        'em' => [ 'min' => 0.5, 'max' => 10 ],
                    ],
                    'selectors'  => [
                        '{{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'    => [ 'size' => 20, 'unit' => 'px' ],
                ]
            );

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

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

            $this->add_responsive_control(
                'icon_margin',
                [
                    'label'      => esc_html__( 'Margin', 'sifency-addons' ),
                    'type'       => Controls_Manager::DIMENSIONS,
                    'size_units' => [ 'px', '%', 'em' ],
                    'selectors'  => [
                        '{{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',
                [ 'label' => esc_html__( 'Normal', 'sifency-addons' ) ]
            );

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

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

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

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

            $this->end_controls_tab();

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

            $this->add_control(
                'icon_color_hover',
                [
                    'label'     => esc_html__( 'Icon Color (Hover)', 'sifency-addons' ),
                    'type'      => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{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',
                [
                    'label'     => esc_html__( 'Background (Hover)', 'sifency-addons' ),
                    'type'      => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .sifency-icon-list-item:hover .sifency-icon-list-icon' => 'background-color: {{VALUE}};',
                    ],
                ]
            );

            $this->add_control(
                'icon_opacity_hover',
                [
                    'label'     => esc_html__( 'Opacity (Hover)', 'sifency-addons' ),
                    'type'      => Controls_Manager::SLIDER,
                    'range'     => [ 'px' => [ 'min' => 0, 'max' => 1, 'step' => 0.01 ] ],
                    'default'   => [ 'size' => 1 ],
                    'selectors' => [
                        '{{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(),
                [
                    'name'     => 'icon_border',
                    'selector' => '{{WRAPPER}} .sifency-icon-list-icon',
                ]
            );

            $this->add_responsive_control(
                'icon_border_radius',
                [
                    'label'      => esc_html__( 'Border Radius', 'sifency-addons' ),
                    'type'       => Controls_Manager::DIMENSIONS,
                    'size_units' => [ 'px', '%' ],
                    'selectors'  => [
                        '{{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(),
                [
                    'name'     => 'icon_box_shadow',
                    'selector' => '{{WRAPPER}} .sifency-icon-list-icon',
                ]
            );

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

            $this->add_control(
                'icon_transform_origin',
                [
                    'label'     => esc_html__( 'Transform Origin', 'sifency-addons' ),
                    'type'      => Controls_Manager::SELECT,
                    'options'   => [
                        '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' => [
                        '{{WRAPPER}} .sifency-icon-list-icon' => 'transform-origin: {{VALUE}};',
                    ],
                ]
            );

            $this->add_control(
                'icon_transition_duration',
                [
                    'label'      => esc_html__( 'Transition Duration', 'sifency-addons' ),
                    'type'       => Controls_Manager::SLIDER,
                    'size_units' => [ 'ms', 's' ],
                    'range'      => [
                        'ms' => [ 'min' => 0, 'max' => 2000 ],
                        's'  => [ 'min' => 0, 'max' => 2 ],
                    ],
                    'default'    => [ 'size' => 300, 'unit' => 'ms' ],
                    'selectors'  => [
                        '{{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();
        }
    }