<?php

$this->start_controls_section(
    '_section_ea_advanced_tooltip',
    [
        'label' => __('Button Tooltip', 'endless-addons'),
        'tab'   => \Elementor\Controls_Manager::TAB_CONTENT,
        'condition' => [
            'select_button_type' => 'single'
        ]
    ]
);

$this->add_control(
    'ea_advanced_tooltip_enable',
    [
        'label' => __( 'Show/Hide Button Tooltip', 'endless-addons' ),
        'type' => \Elementor\Controls_Manager::CHOOSE,
        'options' => [
            'show' => [
                'title' => __( 'Show', 'endless-addons' ),
                'icon' => 'fa fa-check'
            ],
            'hide' => [
                'title' => __( 'Hide', 'endless-addons' ),
                'icon' => 'fa fa-close'
            ]
        ],
        'default' => 'hide',
        'toggle' => true
    ]
);

$this->start_controls_tabs('ea_tooltip_tabs');

$this->start_controls_tab('ea_tooltip_settings', [
    'label' => __('Settings', 'endless-addons'),
    'condition' => [
        'ea_advanced_tooltip_enable!' => ''
    ]
]);

$this->add_control(
    'ea_advanced_tooltip_content',
    [
        'label' => __('Content', 'endless-addons'),
        'type'      => \Elementor\Controls_Manager::TEXTAREA,
        'rows' => 5,
        'default' => __('This is tooltip', 'endless-addons'),
        'frontend_available' => true,
        'condition' => [
            'ea_advanced_tooltip_enable!' => ''
        ]
    ]
);

$this->add_responsive_control(
    'ea_advanced_tooltip_position',
    [
        'label' => __('Position', 'endless-addons'),
        'type' => \Elementor\Controls_Manager::SELECT,
        'default' => 'top',
        'options' => [
            'top' => __('Top', 'endless-addons'),
            'bottom' => __('Bottom', 'endless-addons')
        ],
        'frontend_available' => true,
        'condition' => [
            'ea_advanced_tooltip_enable!' => ''
        ]
    ]
);

$this->add_control(
    'ea_advanced_tooltip_arrow',
    [
        'label' => __('Arrow', 'endless-addons'),
        'type' => \Elementor\Controls_Manager::SWITCHER,
        'label_on' => __('Show', 'endless-addons'),
        'label_off' => __('Hide', 'endless-addons'),
        'return_value' => 'true',
        'default' => 'true',
        'frontend_available' => true,
        'condition' => [
            'ea_advanced_tooltip_enable!' => ''
        ]
    ]
);

$this->add_responsive_control(
    'ea_advanced_tooltip_distance',
    [
        'label' => __('Arrow Distance', 'endless-addons'),
        'type' => \Elementor\Controls_Manager::SLIDER,
        'range' => [
            'px' => [
                'min' => 0,
                'max' => 300,
            ],
        ],
        'selectors' => [
            '{{WRAPPER}} .ea-button-area .ea-btn-align .ea-advanced-tooltip-content.ea-btn-arrow::after' => 'left: {{SIZE}}{{UNIT}};',
        ],
        'condition' => [
            'ea_advanced_tooltip_enable!' => '',
            'ea_advanced_tooltip_arrow' => 'true'
        ]
    ]
);

$this->add_responsive_control(
    'ea_advanced_tooltip_align',
    [
        'label' => __('Text Alignment', 'endless-addons'),
        'type' => \Elementor\Controls_Manager::CHOOSE,
        'options' => [
            'left' => [
                'title' => __('Left', 'endless-addons'),
                'icon' => 'eicon-text-align-left',
            ],
            'center' => [
                'title' => __('Center', 'endless-addons'),
                'icon' => 'eicon-text-align-center',
            ],
            'right' => [
                'title' => __('Right', 'endless-addons'),
                'icon' => 'eicon-text-align-right',
            ],
        ],
        'toggle' => true,
        'selectors' => [
            '{{WRAPPER}} .ea-advanced-tooltip-content' => 'text-align: {{VALUE}};'
        ],
        'condition' => [
            'ea_advanced_tooltip_enable!' => ''
        ]
    ]
);

$this->end_controls_tab();

$this->start_controls_tab('ea_advanced_tooltip_styles', [
    'label' => __('Styles', 'endless-addons'),
    'condition' => [
        'ea_advanced_tooltip_enable!' => ''
    ]
]);

$this->add_responsive_control(
    'ea_advanced_tooltip_width',
    [
        'label' => __('Width', 'endless-addons'),
        'type' => \Elementor\Controls_Manager::SLIDER,
        'range' => [
            'px' => [
                'min' => 1,
                'max' => 800,
            ],
        ],
        'selectors' => [
            '{{WRAPPER}} .ea-advanced-tooltip-content' => 'width: {{SIZE}}{{UNIT}};',
        ],
        'condition' => [
            'ea_advanced_tooltip_enable!' => ''
        ]
    ]
);

$this->add_responsive_control(
    'ea_advanced_tooltip_arrow_size',
    [
        'label' => __('Tooltip Arrow Size (px)', 'endless-addons'),
        'type' => \Elementor\Controls_Manager::SLIDER,
        'range' => [
            'px' => [
                'min' => 1,
                'max' => 100,
            ],
        ],
        'selectors' => [
            '{{WRAPPER}} .ea-advanced-tooltip-content::after' => 'border-width: {{SIZE}}{{UNIT}};',
        ],
        'condition' => [
            'ea_advanced_tooltip_enable!' => '',
            'ea_advanced_tooltip_arrow' => 'true'
        ]
    ]
);

$this->add_group_control(
    \Elementor\Group_Control_Typography::get_type(),
    [
        'name' => 'ea_advanced_tooltip_typography',
        'separator' => 'after',
        'selector' => '{{WRAPPER}} .ea-advanced-tooltip-content',
        'condition' => [
            'ea_advanced_tooltip_enable!' => ''
        ]
    ]
);

$this->add_group_control(
    \Elementor\Group_Control_Background::get_type(),
    [
        'name'     => 'ea_advanced_tooltip_title_section_bg_color',
        'label'    => __('Background', 'endless-addons'),
        'types'    => ['classic', 'gradient'],
        'selector' => '{{WRAPPER}} .ea-advanced-tooltip-content',
        'condition' => [
            'ea_advanced_tooltip_enable!' => '',
            'ea_advanced_tooltip_arrow!' => 'true'
        ]
    ]
);

$this->add_control(
    'ea_advanced_tooltip_background_color',
    [
        'label' => __('Background Color', 'endless-addons'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'selectors' => [
            '{{WRAPPER}} .ea-advanced-tooltip-content' => 'background: {{VALUE}};',
            '{{WRAPPER}} .ea-advanced-tooltip-content::after' => '--ea-tooltip-arrow-color: {{VALUE}}',
        ],
        'condition' => [
            'ea_advanced_tooltip_enable!' => '',
            'ea_advanced_tooltip_arrow' => 'true'
        ]
    ]
);

$this->add_control(
    'ea_advanced_tooltip_color',
    [
        'label' => __('Text Color', 'endless-addons'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'selectors' => [
            '{{WRAPPER}} .ea-advanced-tooltip-content' => 'color: {{VALUE}};',
        ],
        'condition' => [
            'ea_advanced_tooltip_enable!' => ''
        ]
    ]
);

$this->add_group_control(
    \Elementor\Group_Control_Border::get_type(),
    [
        'name' => 'ea_advanced_tooltip_border',
        'label' => __('Border', 'endless-addons'),
        'selector' => '{{WRAPPER}} .ea-advanced-tooltip-content',
        'condition' => [
            'ea_advanced_tooltip_enable!' => '',
            'ea_advanced_tooltip_arrow!' => 'true'
        ]
    ]
);

$this->add_responsive_control(
    'ea_advanced_tooltip_border_radius',
    [
        'label' => __('Border Radius', 'endless-addons'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' => ['px', '%'],
        'selectors' => [
            '{{WRAPPER}} .ea-advanced-tooltip-content' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
        'condition' => [
            'ea_advanced_tooltip_enable!' => ''
        ]
    ]
);

$this->add_responsive_control(
    'ea_advanced_tooltip_padding',
    [
        'label' => __('Padding', 'endless-addons'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' => ['px', 'em', '%'],
        'selectors' => [
            '{{WRAPPER}} .ea-advanced-tooltip-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
        'condition' => [
            'ea_advanced_tooltip_enable!' => ''
        ]
    ]
);

$this->add_group_control(
    \Elementor\Group_Control_Box_Shadow::get_type(),
    [
        'name' => 'ea_advanced_tooltip_box_seadow',
        'selector' => '{{WRAPPER}} .ea-advanced-tooltip-content',
        'separator' => '',
        'condition' => [
            'ea_advanced_tooltip_enable!' => ''
        ]
    ]
);

$this->end_controls_tab();

$this->end_controls_tabs();

$this->end_controls_section();
