<?php
/**
 * Address Form Widget — Style Controls (TAB_STYLE)
 *
 * Included via bare require inside register_controls().
 * $this refers to the widget instance.
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

// Title Style
$this->start_controls_section(
    'title_style_section',
    [
        'label' => __( 'Title', 'ggm-commerce' ),
        'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
    ]
);

$this->add_control(
    'title_color',
    [
        'label'     => __( 'Color', 'ggm-commerce' ),
        'type'      => \Elementor\Controls_Manager::COLOR,
        'selectors' => [
            '{{WRAPPER}} .ggmc-address-form-title' => 'color: {{VALUE}};',
        ],
    ]
);

$this->add_group_control(
    \Elementor\Group_Control_Typography::get_type(),
    [
        'name'     => 'title_typography',
        'selector' => '{{WRAPPER}} .ggmc-address-form-title',
    ]
);

$this->add_responsive_control(
    'title_margin',
    [
        'label'      => __( 'Margin', 'ggm-commerce' ),
        'type'       => \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' => [ 'px', 'em', '%' ],
        'default'    => [
            'top'    => '0',
            'right'  => '0',
            'bottom' => '20',
            'left'   => '0',
            'unit'   => 'px',
        ],
        'selectors'  => [
            '{{WRAPPER}} .ggmc-address-form-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
    ]
);

$this->end_controls_section();

// Field Label Style
$this->start_controls_section(
    'label_style_section',
    [
        'label' => __( 'Field Labels', 'ggm-commerce' ),
        'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
    ]
);

$this->add_control(
    'label_color',
    [
        'label'     => __( 'Color', 'ggm-commerce' ),
        'type'      => \Elementor\Controls_Manager::COLOR,
        'selectors' => [
            '{{WRAPPER}} .ggmc-form-field label' => 'color: {{VALUE}};',
        ],
    ]
);

$this->add_group_control(
    \Elementor\Group_Control_Typography::get_type(),
    [
        'name'     => 'label_typography',
        'selector' => '{{WRAPPER}} .ggmc-form-field label',
    ]
);

$this->add_responsive_control(
    'label_spacing',
    [
        'label'      => __( 'Bottom Spacing', 'ggm-commerce' ),
        'type'       => \Elementor\Controls_Manager::SLIDER,
        'size_units' => [ 'px' ],
        'range'      => [
            'px' => [
                'min' => 0,
                'max' => 30,
            ],
        ],
        'default'    => [
            'size' => 8,
            'unit' => 'px',
        ],
        'selectors'  => [
            '{{WRAPPER}} .ggmc-form-field label' => 'margin-bottom: {{SIZE}}{{UNIT}};',
        ],
    ]
);

$this->end_controls_section();

// Input Field Style
$this->start_controls_section(
    'input_style_section',
    [
        'label' => __( 'Input Fields', 'ggm-commerce' ),
        'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
    ]
);

$this->add_control(
    'input_text_color',
    [
        'label'     => __( 'Text Color', 'ggm-commerce' ),
        'type'      => \Elementor\Controls_Manager::COLOR,
        'selectors' => [
            '{{WRAPPER}} .ggmc-form-field input, {{WRAPPER}} .ggmc-form-field select' => 'color: {{VALUE}};',
        ],
    ]
);

$this->add_control(
    'input_background_color',
    [
        'label'     => __( 'Background Color', 'ggm-commerce' ),
        'type'      => \Elementor\Controls_Manager::COLOR,
        'selectors' => [
            '{{WRAPPER}} .ggmc-form-field input, {{WRAPPER}} .ggmc-form-field select' => 'background-color: {{VALUE}};',
        ],
    ]
);

$this->add_control(
    'input_border_color',
    [
        'label'     => __( 'Border Color', 'ggm-commerce' ),
        'type'      => \Elementor\Controls_Manager::COLOR,
        'selectors' => [
            '{{WRAPPER}} .ggmc-form-field input, {{WRAPPER}} .ggmc-form-field select' => 'border-color: {{VALUE}};',
        ],
    ]
);

$this->add_responsive_control(
    'input_border_width',
    [
        'label'      => __( 'Border Width', 'ggm-commerce' ),
        'type'       => \Elementor\Controls_Manager::SLIDER,
        'size_units' => [ 'px' ],
        'range'      => [
            'px' => [
                'min' => 0,
                'max' => 10,
            ],
        ],
        'default'    => [
            'size' => 1,
            'unit' => 'px',
        ],
        'selectors'  => [
            '{{WRAPPER}} .ggmc-form-field input, {{WRAPPER}} .ggmc-form-field select' => 'border-width: {{SIZE}}{{UNIT}};',
        ],
    ]
);

$this->add_responsive_control(
    'input_border_radius',
    [
        'label'      => __( 'Border Radius', 'ggm-commerce' ),
        'type'       => \Elementor\Controls_Manager::SLIDER,
        'size_units' => [ 'px', '%' ],
        'range'      => [
            'px' => [
                'min' => 0,
                'max' => 50,
            ],
        ],
        'default'    => [
            'size' => 4,
            'unit' => 'px',
        ],
        'selectors'  => [
            '{{WRAPPER}} .ggmc-form-field input, {{WRAPPER}} .ggmc-form-field select' => 'border-radius: {{SIZE}}{{UNIT}};',
        ],
    ]
);

$this->add_responsive_control(
    'input_padding',
    [
        'label'      => __( 'Padding', 'ggm-commerce' ),
        'type'       => \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' => [ 'px', 'em' ],
        'default'    => [
            'top'    => '10',
            'right'  => '12',
            'bottom' => '10',
            'left'   => '12',
            'unit'   => 'px',
        ],
        'selectors'  => [
            '{{WRAPPER}} .ggmc-form-field input, {{WRAPPER}} .ggmc-form-field select' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
    ]
);

$this->add_responsive_control(
    'field_spacing',
    [
        'label'      => __( 'Field Spacing', 'ggm-commerce' ),
        'type'       => \Elementor\Controls_Manager::SLIDER,
        'size_units' => [ 'px' ],
        'range'      => [
            'px' => [
                'min' => 0,
                'max' => 50,
            ],
        ],
        'default'    => [
            'size' => 20,
            'unit' => 'px',
        ],
        'selectors'  => [
            '{{WRAPPER}} .ggmc-form-field' => 'margin-bottom: {{SIZE}}{{UNIT}};',
        ],
    ]
);

$this->end_controls_section();

// Button Style
$this->start_controls_section(
    'button_style_section',
    [
        'label' => __( 'Buttons', 'ggm-commerce' ),
        'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
    ]
);

$this->add_control(
    'button_text_color',
    [
        'label'     => __( 'Text Color', 'ggm-commerce' ),
        'type'      => \Elementor\Controls_Manager::COLOR,
        'selectors' => [
            '{{WRAPPER}} .ggmc-form-button' => 'color: {{VALUE}};',
        ],
    ]
);

$this->add_control(
    'button_background_color',
    [
        'label'     => __( 'Background Color', 'ggm-commerce' ),
        'type'      => \Elementor\Controls_Manager::COLOR,
        'selectors' => [
            '{{WRAPPER}} .ggmc-form-button.primary' => 'background-color: {{VALUE}};',
        ],
    ]
);

$this->add_control(
    'button_cancel_background',
    [
        'label'     => __( 'Cancel Button Background', 'ggm-commerce' ),
        'type'      => \Elementor\Controls_Manager::COLOR,
        'selectors' => [
            '{{WRAPPER}} .ggmc-form-button.secondary' => 'background-color: {{VALUE}};',
        ],
    ]
);

$this->add_control(
    'button_cancel_text_color',
    [
        'label'     => __( 'Cancel Button Text Color', 'ggm-commerce' ),
        'type'      => \Elementor\Controls_Manager::COLOR,
        'selectors' => [
            '{{WRAPPER}} .ggmc-form-button.secondary' => 'color: {{VALUE}};',
        ],
    ]
);

$this->add_responsive_control(
    'button_padding',
    [
        'label'      => __( 'Padding', 'ggm-commerce' ),
        'type'       => \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' => [ 'px', 'em' ],
        'default'    => [
            'top'    => '12',
            'right'  => '24',
            'bottom' => '12',
            'left'   => '24',
            'unit'   => 'px',
        ],
        'selectors'  => [
            '{{WRAPPER}} .ggmc-form-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
    ]
);

$this->add_responsive_control(
    'button_border_radius',
    [
        'label'      => __( 'Border Radius', 'ggm-commerce' ),
        'type'       => \Elementor\Controls_Manager::SLIDER,
        'size_units' => [ 'px', '%' ],
        'range'      => [
            'px' => [
                'min' => 0,
                'max' => 50,
            ],
        ],
        'default'    => [
            'size' => 4,
            'unit' => 'px',
        ],
        'selectors'  => [
            '{{WRAPPER}} .ggmc-form-button' => 'border-radius: {{SIZE}}{{UNIT}};',
        ],
    ]
);

$this->end_controls_section();
