<?php
/**
 * Widget controls
 * @var Form $form
 * @var string $prefix
 */

use Elementor\Controls_Manager;
use Elementor\Group_Control_Border;
use ElementorPro\Modules\Forms\Widgets\Form;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

$form->start_controls_section(
	$prefix . 'form_style_tab',
	[
		'label' => esc_html__( 'Color Field', 'advanced-fields-for-elementor-forms' ),
		'tab'   => Controls_Manager::TAB_STYLE,
	]
);

$form->add_responsive_control(
	$prefix . 'width',
	[
		'label'      => esc_html__( 'Width', 'advanced-fields-for-elementor-forms' ),
		'type'       => Controls_Manager::SLIDER,
		'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
		'range'      => [
			'px' => [
				'min'  => 0,
				'max'  => 1000,
				'step' => 5,
			],
			'%'  => [
				'min' => 0,
				'max' => 100,
			],
		],
		'default'    => [
			'unit' => 'px',
			'size' => 50,
		],
		'selectors'  => [
			'{{WRAPPER}} .hulk_affef_native_color_wrap .hulk_affef_native_color_field' => 'width: {{SIZE}}{{UNIT}};',
		],
	]
);

$form->add_responsive_control(
	$prefix . 'height',
	[
		'label'      => esc_html__( 'Height', 'advanced-fields-for-elementor-forms' ),
		'type'       => Controls_Manager::SLIDER,
		'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
		'range'      => [
			'px' => [
				'min'  => 0,
				'max'  => 1000,
				'step' => 5,
			],
			'%'  => [
				'min' => 0,
				'max' => 100,
			],
		],
		'default'    => [
			'unit' => 'px',
			'size' => 50,
		],
		'selectors'  => [
			'{{WRAPPER}} .hulk_affef_native_color_wrap .hulk_affef_native_color_field' => 'height: {{SIZE}}{{UNIT}};',
		],
	]
);

$form->add_responsive_control(
	$prefix . 'padding',
	[
		'label'      => esc_html__( 'Padding', 'advanced-fields-for-elementor-forms' ),
		'type'       => Controls_Manager::DIMENSIONS,
		'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
		'selectors'  => [
			'{{WRAPPER}} .hulk_affef_native_color_wrap .hulk_affef_native_color_field' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		],
	]
);

$form->add_control(
	$prefix . 'background_color',
	[
		'label'     => esc_html__( 'Background Color', 'advanced-fields-for-elementor-forms' ),
		'type'      => Controls_Manager::COLOR,
		'selectors' => [
			'{{WRAPPER}} .hulk_affef_native_color_wrap .hulk_affef_native_color_field' => 'background-color: {{VALUE}}!important',
		],
	]
);

$form->add_group_control(
	Group_Control_Border::get_type(),
	[
		'name'     => $prefix . 'border',
		'selector' => '{{WRAPPER}} .hulk_affef_native_color_wrap .hulk_affef_native_color_field',
	]
);

$form->add_responsive_control(
	$prefix . 'border_radius',
	[
		'label'      => esc_html__( 'Border Radius', 'advanced-fields-for-elementor-forms' ),
		'type'       => Controls_Manager::DIMENSIONS,
		'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
		'selectors'  => [
			'{{WRAPPER}} .hulk_affef_native_color_wrap .hulk_affef_native_color_field' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		],
	]
);

$form->end_controls_section();
