<?php
/**
 * Mini Cart Widget — Style Controls
 * Registered inside register_controls() via require — $this is the widget instance.
 *
 * @package GGM_Commerce
 */

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

$defaults = GGM_Commerce_Widget_Mini_Cart::get_static_default_styles();

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

$this->add_responsive_control(
    'cart_button_padding',
    [
        'label' => __('Padding', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' => ['px', '%', 'em'],
        'default' => $defaults['cart_button_padding'],
        'selectors' => [
            '{{WRAPPER}} .mini-cart-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
    ]
);

$this->add_group_control(
    \Elementor\Group_Control_Typography::get_type(),
    [
        'name' => 'cart_button_typography',
        'selector' => '{{WRAPPER}} .mini-cart-button',
        'fields_options' => [
            'typography' => [
                'default' => 'custom',
            ],
            'font_family' => [
                'default' => $defaults['cart_button_typography_font_family'],
            ],
            'font_size' => [
                'default' => $defaults['cart_button_typography_font_size'],
            ],
            'font_weight' => [
                'default' => $defaults['cart_button_typography_font_weight'],
            ],
        ],
    ]
);

$this->start_controls_tabs('cart_button_tabs');

$this->start_controls_tab(
    'cart_button_normal',
    [
        'label' => __('Normal', 'ggm-commerce'),
    ]
);

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

$this->add_control(
    'cart_button_background',
    [
        'label' => __('Background Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['cart_button_background'],
        'selectors' => [
            '{{WRAPPER}} .mini-cart-button' => 'background-color: {{VALUE}};',
        ],
    ]
);

$this->end_controls_tab();

$this->start_controls_tab(
    'cart_button_hover',
    [
        'label' => __('Hover', 'ggm-commerce'),
    ]
);

$this->add_control(
    'cart_button_hover_color',
    [
        'label' => __('Text Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['cart_button_hover_color'],
        'selectors' => [
            '{{WRAPPER}} .mini-cart-button:hover' => 'color: {{VALUE}};',
        ],
    ]
);

$this->add_control(
    'cart_button_hover_background',
    [
        'label' => __('Background Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['cart_button_hover_background'],
        'selectors' => [
            '{{WRAPPER}} .mini-cart-button:hover' => 'background-color: {{VALUE}};',
        ],
    ]
);

$this->end_controls_tab();

$this->end_controls_tabs();

$this->add_group_control(
    \Elementor\Group_Control_Border::get_type(),
    [
        'name' => 'cart_button_border',
        'selector' => '{{WRAPPER}} .mini-cart-button',
        'fields_options' => [
            'border' => [
                'default' => $defaults['cart_button_border_border'],
            ],
            'width' => [
                'default' => $defaults['cart_button_border_width'],
            ],
            'color' => [
                'default' => $defaults['cart_button_border_color'],
            ],
        ],
    ]
);

$this->add_control(
    'cart_button_border_radius',
    [
        'label' => __('Border Radius', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' => ['px', '%'],
        'default' => $defaults['cart_button_border_radius'],
        'selectors' => [
            '{{WRAPPER}} .mini-cart-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
    ]
);

$this->end_controls_section();

// Style Section - Cart Icon
$this->start_controls_section(
    'cart_icon_style',
    [
        'label' => __('Cart Icon', 'ggm-commerce'),
        'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        'condition' => [
            'cart_style!' => 'text_only',
        ],
    ]
);

$this->add_responsive_control(
    'icon_size',
    [
        'label' => __('Icon Size', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SLIDER,
        'size_units' => ['px', 'em'],
        'range' => [
            'px' => [
                'min' => 12,
                'max' => 60,
                'step' => 1,
            ],
            'em' => [
                'min' => 0.5,
                'max' => 4,
                'step' => 0.1,
            ],
        ],
        'default' => $defaults['icon_size'] ?? ['size' => 24, 'unit' => 'px'],
        'selectors' => [
            '{{WRAPPER}} .mini-cart-icon-wrapper i' => 'font-size: {{SIZE}}{{UNIT}};',
            '{{WRAPPER}} .mini-cart-icon-wrapper svg' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
        ],
    ]
);

$this->start_controls_tabs('icon_tabs');

$this->start_controls_tab(
    'icon_normal',
    [
        'label' => __('Normal', 'ggm-commerce'),
    ]
);

$this->add_control(
    'icon_color',
    [
        'label' => __('Icon Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['icon_color'] ?? '',
        'selectors' => [
            '{{WRAPPER}} .mini-cart-icon-wrapper' => 'color: {{VALUE}};',
            '{{WRAPPER}} .mini-cart-icon-wrapper svg' => 'fill: {{VALUE}};',
        ],
    ]
);

$this->add_control(
    'icon_background_color',
    [
        'label' => __('Background Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['icon_background_color'] ?? '',
        'selectors' => [
            '{{WRAPPER}} .mini-cart-icon-wrapper' => 'background-color: {{VALUE}};',
        ],
    ]
);

$this->end_controls_tab();

$this->start_controls_tab(
    'icon_hover',
    [
        'label' => __('Hover', 'ggm-commerce'),
    ]
);

$this->add_control(
    'icon_hover_color',
    [
        'label' => __('Icon Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['icon_hover_color'] ?? '',
        'selectors' => [
            '{{WRAPPER}} .mini-cart-button:hover .mini-cart-icon-wrapper' => 'color: {{VALUE}};',
            '{{WRAPPER}} .mini-cart-button:hover .mini-cart-icon-wrapper svg' => 'fill: {{VALUE}};',
        ],
    ]
);

$this->add_control(
    'icon_hover_background_color',
    [
        'label' => __('Background Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['icon_hover_background_color'] ?? '',
        'selectors' => [
            '{{WRAPPER}} .mini-cart-button:hover .mini-cart-icon-wrapper' => 'background-color: {{VALUE}};',
        ],
    ]
);

$this->end_controls_tab();

$this->end_controls_tabs();

$this->add_control(
    'icon_padding',
    [
        'label' => __('Padding', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' => ['px', '%', 'em'],
        'default' => $defaults['icon_padding'] ?? [
            'top' => '0',
            'right' => '0',
            'bottom' => '0',
            'left' => '0',
            'unit' => 'px',
            'isLinked' => true,
        ],
        'selectors' => [
            '{{WRAPPER}} .mini-cart-icon-wrapper' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
        'separator' => 'before',
    ]
);

$this->add_control(
    'icon_border_radius',
    [
        'label' => __('Border Radius', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' => ['px', '%'],
        'default' => $defaults['icon_border_radius'] ?? [
            'top' => '0',
            'right' => '0',
            'bottom' => '0',
            'left' => '0',
            'unit' => 'px',
            'isLinked' => true,
        ],
        'selectors' => [
            '{{WRAPPER}} .mini-cart-icon-wrapper' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
    ]
);

$this->end_controls_section();

// Style Section - Cart Count Badge
$this->start_controls_section(
    'cart_count_style',
    [
        'label' => __('Cart Count Badge', 'ggm-commerce'),
        'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        'condition' => [
            'cart_style' => ['icon_count', 'icon_count_total'],
        ],
    ]
);

$this->add_control(
    'count_background_color',
    [
        'label' => __('Background Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['count_background_color'] ?? '#dc2626',
        'selectors' => [
            '{{WRAPPER}} .cart-count' => 'background-color: {{VALUE}};',
        ],
    ]
);

$this->add_control(
    'count_text_color',
    [
        'label' => __('Text Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['count_text_color'] ?? '#ffffff',
        'selectors' => [
            '{{WRAPPER}} .cart-count' => 'color: {{VALUE}};',
        ],
    ]
);

$this->add_group_control(
    \Elementor\Group_Control_Typography::get_type(),
    [
        'name' => 'count_typography',
        'selector' => '{{WRAPPER}} .cart-count',
        'fields_options' => [
            'typography' => [
                'default' => 'custom',
            ],
            'font_size' => [
                'default' => $defaults['count_typography_font_size'] ?? ['size' => 12, 'unit' => 'px'],
            ],
            'font_weight' => [
                'default' => $defaults['count_typography_font_weight'] ?? '600',
            ],
        ],
    ]
);

$this->add_control(
    'count_size',
    [
        'label' => __('Badge Size', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SLIDER,
        'size_units' => ['px'],
        'range' => [
            'px' => [
                'min' => 16,
                'max' => 40,
                'step' => 2,
            ],
        ],
        'default' => $defaults['count_size'] ?? ['size' => 20, 'unit' => 'px'],
        'selectors' => [
            '{{WRAPPER}} .cart-count' => 'min-width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
        ],
    ]
);

$this->add_control(
    'badge_position_heading',
    [
        'label' => __('Badge Position', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::HEADING,
        'separator' => 'before',
    ]
);

$this->add_responsive_control(
    'count_position_top',
    [
        'label' => __('Top Offset', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SLIDER,
        'size_units' => ['px'],
        'range' => [
            'px' => [
                'min' => -30,
                'max' => 30,
                'step' => 1,
            ],
        ],
        'default' => $defaults['count_position_top'] ?? ['size' => -8, 'unit' => 'px'],
        'selectors' => [
            '{{WRAPPER}} .cart-count' => 'top: {{SIZE}}{{UNIT}};',
        ],
    ]
);

$this->add_responsive_control(
    'count_position_right',
    [
        'label' => __('Right Offset', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SLIDER,
        'size_units' => ['px'],
        'range' => [
            'px' => [
                'min' => -30,
                'max' => 30,
                'step' => 1,
            ],
        ],
        'default' => $defaults['count_position_right'] ?? ['size' => -8, 'unit' => 'px'],
        'selectors' => [
            '{{WRAPPER}} .cart-count' => 'right: {{SIZE}}{{UNIT}};',
        ],
    ]
);

$this->end_controls_section();

// Style Section - Dropdown Container
$this->start_controls_section(
    'dropdown_style',
    [
        'label' => __('Dropdown Container', 'ggm-commerce'),
        'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        'condition' => [
            'show_dropdown' => 'yes',
        ],
    ]
);

$this->add_control(
    'dropdown_width',
    [
        'label' => __('Dropdown Width', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SLIDER,
        'size_units' => ['px'],
        'range' => [
            'px' => [
                'min' => 250,
                'max' => 500,
                'step' => 10,
            ],
        ],
        'default' => $defaults['dropdown_width'] ?? ['size' => 320, 'unit' => 'px'],
        'selectors' => [
            '{{WRAPPER}} .mini-cart-dropdown' => 'width: {{SIZE}}{{UNIT}};',
        ],
    ]
);

$this->add_control(
    'dropdown_background',
    [
        'label' => __('Background Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['dropdown_background'] ?? '#ffffff',
        'selectors' => [
            '{{WRAPPER}} .mini-cart-dropdown' => 'background-color: {{VALUE}};',
        ],
    ]
);

$this->add_control(
    'dropdown_border_radius',
    [
        'label' => __('Border Radius', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' => ['px', '%'],
        'default' => $defaults['dropdown_border_radius'] ?? [
            'top' => '8',
            'right' => '8',
            'bottom' => '8',
            'left' => '8',
            'unit' => 'px',
            'isLinked' => true,
        ],
        'selectors' => [
            '{{WRAPPER}} .mini-cart-dropdown' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
    ]
);

$this->add_group_control(
    \Elementor\Group_Control_Border::get_type(),
    [
        'name' => 'dropdown_border',
        'selector' => '{{WRAPPER}} .mini-cart-dropdown',
        'fields_options' => [
            'border' => [
                'default' => $defaults['dropdown_border_border'] ?? 'solid',
            ],
            'width' => [
                'default' => $defaults['dropdown_border_width'] ?? [
                    'top' => '1',
                    'right' => '1',
                    'bottom' => '1',
                    'left' => '1',
                    'unit' => 'px',
                    'isLinked' => true,
                ],
            ],
            'color' => [
                'default' => $defaults['dropdown_border_color'] ?? '#e5e7eb',
            ],
        ],
    ]
);

$this->add_group_control(
    \Elementor\Group_Control_Box_Shadow::get_type(),
    [
        'name' => 'dropdown_shadow',
        'selector' => '{{WRAPPER}} .mini-cart-dropdown',
        'fields_options' => [
            'box_shadow_type' => [
                'default' => $defaults['dropdown_shadow_box_shadow_type'] ?? 'yes',
            ],
            'box_shadow' => [
                'default' => $defaults['dropdown_shadow_box_shadow'] ?? [
                    'horizontal' => 0,
                    'vertical' => 4,
                    'blur' => 12,
                    'spread' => 0,
                    'color' => 'rgba(0,0,0,0.1)',
                ],
            ],
        ],
    ]
);

$this->add_responsive_control(
    'dropdown_padding',
    [
        'label' => __('Padding', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' => ['px', '%', 'em'],
        'selectors' => [
            '{{WRAPPER}} .mini-cart-dropdown' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
    ]
);

$this->end_controls_section();

// Style Section - Dropdown Header
$this->start_controls_section(
    'dropdown_header_style',
    [
        'label' => __('Dropdown Header', 'ggm-commerce'),
        'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        'condition' => [
            'show_dropdown' => 'yes',
        ],
    ]
);

$this->add_control(
    'header_title_text',
    [
        'label' => __('Header Title', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => $defaults['header_title_text'] ?? __('Shopping Cart', 'ggm-commerce'),
        'placeholder' => __('Shopping Cart', 'ggm-commerce'),
    ]
);

$this->add_control(
    'header_background_color',
    [
        'label' => __('Background Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['header_background_color'] ?? '',
        'selectors' => [
            '{{WRAPPER}} .mini-cart-header' => 'background-color: {{VALUE}};',
        ],
    ]
);

$this->add_control(
    'header_title_color',
    [
        'label' => __('Title Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['header_title_color'] ?? '#111827',
        'selectors' => [
            '{{WRAPPER}} .mini-cart-header h4' => 'color: {{VALUE}};',
        ],
    ]
);

$this->add_group_control(
    \Elementor\Group_Control_Typography::get_type(),
    [
        'name' => 'header_title_typography',
        'selector' => '{{WRAPPER}} .mini-cart-header h4',
        'fields_options' => [
            'typography' => [
                'default' => 'custom',
            ],
            'font_size' => [
                'default' => $defaults['header_title_typography_font_size'] ?? ['size' => 18, 'unit' => 'px'],
            ],
            'font_weight' => [
                'default' => $defaults['header_title_typography_font_weight'] ?? '600',
            ],
        ],
    ]
);

$this->add_responsive_control(
    'header_padding',
    [
        'label' => __('Padding', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' => ['px', '%', 'em'],
        'default' => $defaults['header_padding'] ?? [
            'top' => '16',
            'right' => '16',
            'bottom' => '16',
            'left' => '16',
            'unit' => 'px',
            'isLinked' => true,
        ],
        'selectors' => [
            '{{WRAPPER}} .mini-cart-header' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
    ]
);

$this->add_control(
    'header_border_color',
    [
        'label' => __('Border Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['header_border_color'] ?? '#e5e7eb',
        'selectors' => [
            '{{WRAPPER}} .mini-cart-header' => 'border-bottom-color: {{VALUE}};',
        ],
    ]
);

$this->add_control(
    'close_button_heading',
    [
        'label' => __('Close Button', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::HEADING,
        'separator' => 'before',
    ]
);

$this->add_control(
    'close_button_color',
    [
        'label' => __('Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['close_button_color'] ?? '#6b7280',
        'selectors' => [
            '{{WRAPPER}} .close-mini-cart' => 'color: {{VALUE}};',
        ],
    ]
);

$this->add_control(
    'close_button_hover_color',
    [
        'label' => __('Hover Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['close_button_hover_color'] ?? '#111827',
        'selectors' => [
            '{{WRAPPER}} .close-mini-cart:hover' => 'color: {{VALUE}};',
        ],
    ]
);

$this->add_control(
    'close_button_size',
    [
        'label' => __('Size', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SLIDER,
        'size_units' => ['px'],
        'range' => [
            'px' => [
                'min' => 16,
                'max' => 40,
                'step' => 2,
            ],
        ],
        'default' => $defaults['close_button_size'] ?? ['size' => 24, 'unit' => 'px'],
        'selectors' => [
            '{{WRAPPER}} .close-mini-cart' => 'font-size: {{SIZE}}{{UNIT}}; width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
        ],
    ]
);

$this->end_controls_section();

// Style Section - Cart Items
$this->start_controls_section(
    'cart_items_style',
    [
        'label' => __('Cart Items', 'ggm-commerce'),
        'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        'condition' => [
            'show_dropdown' => 'yes',
        ],
    ]
);

$this->add_responsive_control(
    'items_padding',
    [
        'label' => __('Items Container Padding', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' => ['px', '%', 'em'],
        'default' => $defaults['items_padding'] ?? [
            'top' => '16',
            'right' => '16',
            'bottom' => '16',
            'left' => '16',
            'unit' => 'px',
            'isLinked' => true,
        ],
        'selectors' => [
            '{{WRAPPER}} .mini-cart-items' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
    ]
);

$this->add_control(
    'item_image_heading',
    [
        'label' => __('Product Image', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::HEADING,
        'separator' => 'before',
        'condition' => [
            'show_product_image' => 'yes',
        ],
    ]
);

$this->add_control(
    'item_image_size',
    [
        'label' => __('Image Size', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SLIDER,
        'size_units' => ['px'],
        'range' => [
            'px' => [
                'min' => 30,
                'max' => 100,
                'step' => 5,
            ],
        ],
        'default' => $defaults['item_image_size'] ?? ['size' => 50, 'unit' => 'px'],
        'selectors' => [
            '{{WRAPPER}} .item-image img, {{WRAPPER}} .placeholder-image' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
        ],
        'condition' => [
            'show_product_image' => 'yes',
        ],
    ]
);

$this->add_control(
    'item_image_border_radius',
    [
        'label' => __('Image Border Radius', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SLIDER,
        'size_units' => ['px', '%'],
        'range' => [
            'px' => [
                'min' => 0,
                'max' => 20,
                'step' => 1,
            ],
            '%' => [
                'min' => 0,
                'max' => 50,
                'step' => 5,
            ],
        ],
        'default' => $defaults['item_image_border_radius'] ?? ['size' => 6, 'unit' => 'px'],
        'selectors' => [
            '{{WRAPPER}} .item-image img, {{WRAPPER}} .placeholder-image' => 'border-radius: {{SIZE}}{{UNIT}};',
        ],
        'condition' => [
            'show_product_image' => 'yes',
        ],
    ]
);

$this->add_control(
    'item_name_heading',
    [
        'label' => __('Product Name', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::HEADING,
        'separator' => 'before',
    ]
);

$this->add_control(
    'item_name_color',
    [
        'label' => __('Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['item_name_color'] ?? '#111827',
        'selectors' => [
            '{{WRAPPER}} .item-details h5' => 'color: {{VALUE}};',
        ],
    ]
);

$this->add_group_control(
    \Elementor\Group_Control_Typography::get_type(),
    [
        'name' => 'item_name_typography',
        'selector' => '{{WRAPPER}} .item-details h5',
        'fields_options' => [
            'typography' => [
                'default' => 'custom',
            ],
            'font_size' => [
                'default' => $defaults['item_name_typography_font_size'] ?? ['size' => 14, 'unit' => 'px'],
            ],
            'font_weight' => [
                'default' => $defaults['item_name_typography_font_weight'] ?? '500',
            ],
        ],
    ]
);

$this->add_control(
    'item_meta_heading',
    [
        'label' => __('Price & Quantity', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::HEADING,
        'separator' => 'before',
    ]
);

$this->add_control(
    'item_meta_color',
    [
        'label' => __('Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['item_meta_color'] ?? '#6b7280',
        'selectors' => [
            '{{WRAPPER}} .item-price-qty' => 'color: {{VALUE}};',
        ],
    ]
);

$this->add_group_control(
    \Elementor\Group_Control_Typography::get_type(),
    [
        'name' => 'item_meta_typography',
        'selector' => '{{WRAPPER}} .item-price-qty',
        'fields_options' => [
            'typography' => [
                'default' => 'custom',
            ],
            'font_size' => [
                'default' => $defaults['item_meta_typography_font_size'] ?? ['size' => 12, 'unit' => 'px'],
            ],
        ],
    ]
);

$this->add_control(
    'item_divider_heading',
    [
        'label' => __('Item Divider', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::HEADING,
        'separator' => 'before',
    ]
);

$this->add_control(
    'item_divider_color',
    [
        'label' => __('Divider Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['item_divider_color'] ?? '#f3f4f6',
        'selectors' => [
            '{{WRAPPER}} .mini-cart-item' => 'border-bottom-color: {{VALUE}};',
        ],
    ]
);

$this->add_responsive_control(
    'item_spacing',
    [
        'label' => __('Item Spacing', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SLIDER,
        'size_units' => ['px'],
        'range' => [
            'px' => [
                'min' => 0,
                'max' => 30,
                'step' => 2,
            ],
        ],
        'default' => $defaults['item_spacing'] ?? ['size' => 12, 'unit' => 'px'],
        'selectors' => [
            '{{WRAPPER}} .mini-cart-item' => 'padding-top: {{SIZE}}{{UNIT}}; padding-bottom: {{SIZE}}{{UNIT}};',
        ],
    ]
);

$this->end_controls_section();

// Style Section - Remove Button
$this->start_controls_section(
    'remove_button_style',
    [
        'label' => __('Remove Item Button', 'ggm-commerce'),
        'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        'condition' => [
            'show_dropdown' => 'yes',
        ],
    ]
);

$this->add_control(
    'remove_button_color',
    [
        'label' => __('Icon Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['remove_button_color'] ?? '#dc2626',
        'selectors' => [
            '{{WRAPPER}} .remove-item' => 'color: {{VALUE}};',
        ],
    ]
);

$this->add_control(
    'remove_button_hover_color',
    [
        'label' => __('Hover Icon Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['remove_button_hover_color'] ?? '#b91c1c',
        'selectors' => [
            '{{WRAPPER}} .remove-item:hover' => 'color: {{VALUE}};',
        ],
    ]
);

$this->add_control(
    'remove_button_background',
    [
        'label' => __('Background Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['remove_button_background'] ?? '',
        'selectors' => [
            '{{WRAPPER}} .remove-item' => 'background-color: {{VALUE}};',
        ],
    ]
);

$this->add_control(
    'remove_button_hover_background',
    [
        'label' => __('Hover Background Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['remove_button_hover_background'] ?? '#fef2f2',
        'selectors' => [
            '{{WRAPPER}} .remove-item:hover' => 'background-color: {{VALUE}};',
        ],
    ]
);

$this->add_control(
    'remove_button_size',
    [
        'label' => __('Icon Size', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SLIDER,
        'size_units' => ['px'],
        'range' => [
            'px' => [
                'min' => 12,
                'max' => 30,
                'step' => 1,
            ],
        ],
        'default' => $defaults['remove_button_size'] ?? ['size' => 16, 'unit' => 'px'],
        'selectors' => [
            '{{WRAPPER}} .remove-item' => 'font-size: {{SIZE}}{{UNIT}};',
            '{{WRAPPER}} .remove-item i' => 'font-size: {{SIZE}}{{UNIT}};',
        ],
    ]
);

$this->end_controls_section();

// Style Section - Cart Footer / Total
$this->start_controls_section(
    'footer_style',
    [
        'label' => __('Cart Footer', 'ggm-commerce'),
        'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        'condition' => [
            'show_dropdown' => 'yes',
        ],
    ]
);

$this->add_control(
    'footer_background_color',
    [
        'label' => __('Background Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['footer_background_color'] ?? '',
        'selectors' => [
            '{{WRAPPER}} .mini-cart-footer' => 'background-color: {{VALUE}};',
        ],
    ]
);

$this->add_responsive_control(
    'footer_padding',
    [
        'label' => __('Padding', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' => ['px', '%', 'em'],
        'default' => $defaults['footer_padding'] ?? [
            'top' => '16',
            'right' => '16',
            'bottom' => '16',
            'left' => '16',
            'unit' => 'px',
            'isLinked' => true,
        ],
        'selectors' => [
            '{{WRAPPER}} .mini-cart-footer' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
    ]
);

$this->add_control(
    'footer_border_color',
    [
        'label' => __('Border Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['footer_border_color'] ?? '#e5e7eb',
        'selectors' => [
            '{{WRAPPER}} .mini-cart-footer' => 'border-top-color: {{VALUE}};',
        ],
    ]
);

$this->add_control(
    'total_heading',
    [
        'label' => __('Cart Total', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::HEADING,
        'separator' => 'before',
    ]
);

$this->add_control(
    'total_color',
    [
        'label' => __('Total Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['total_color'] ?? '#111827',
        'selectors' => [
            '{{WRAPPER}} .cart-total-display' => 'color: {{VALUE}};',
        ],
    ]
);

$this->add_group_control(
    \Elementor\Group_Control_Typography::get_type(),
    [
        'name' => 'total_typography',
        'selector' => '{{WRAPPER}} .cart-total-display',
        'fields_options' => [
            'typography' => [
                'default' => 'custom',
            ],
            'font_size' => [
                'default' => $defaults['total_typography_font_size'] ?? ['size' => 16, 'unit' => 'px'],
            ],
            'font_weight' => [
                'default' => $defaults['total_typography_font_weight'] ?? '600',
            ],
        ],
    ]
);

$this->end_controls_section();

// Style Section - View Cart Button
$this->start_controls_section(
    'view_cart_button_style',
    [
        'label' => __('View Cart Button', 'ggm-commerce'),
        'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        'condition' => [
            'show_dropdown' => 'yes',
        ],
    ]
);

$this->add_group_control(
    \Elementor\Group_Control_Typography::get_type(),
    [
        'name' => 'view_cart_typography',
        'selector' => '{{WRAPPER}} .view-cart-btn',
        'fields_options' => [
            'typography' => [
                'default' => 'custom',
            ],
            'font_size' => [
                'default' => $defaults['view_cart_typography_font_size'] ?? ['size' => 14, 'unit' => 'px'],
            ],
            'font_weight' => [
                'default' => $defaults['view_cart_typography_font_weight'] ?? '500',
            ],
        ],
    ]
);

$this->start_controls_tabs('view_cart_tabs');

$this->start_controls_tab(
    'view_cart_normal',
    [
        'label' => __('Normal', 'ggm-commerce'),
    ]
);

$this->add_control(
    'view_cart_color',
    [
        'label' => __('Text Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['view_cart_color'] ?? '#374151',
        'selectors' => [
            '{{WRAPPER}} .view-cart-btn' => 'color: {{VALUE}};',
        ],
    ]
);

$this->add_control(
    'view_cart_background',
    [
        'label' => __('Background Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['view_cart_background'] ?? '#f3f4f6',
        'selectors' => [
            '{{WRAPPER}} .view-cart-btn' => 'background-color: {{VALUE}};',
        ],
    ]
);

$this->add_control(
    'view_cart_border_color',
    [
        'label' => __('Border Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['view_cart_border_color'] ?? '#d1d5db',
        'selectors' => [
            '{{WRAPPER}} .view-cart-btn' => 'border-color: {{VALUE}};',
        ],
    ]
);

$this->end_controls_tab();

$this->start_controls_tab(
    'view_cart_hover',
    [
        'label' => __('Hover', 'ggm-commerce'),
    ]
);

$this->add_control(
    'view_cart_hover_color',
    [
        'label' => __('Text Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['view_cart_hover_color'] ?? '#374151',
        'selectors' => [
            '{{WRAPPER}} .view-cart-btn:hover' => 'color: {{VALUE}};',
        ],
    ]
);

$this->add_control(
    'view_cart_hover_background',
    [
        'label' => __('Background Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['view_cart_hover_background'] ?? '#e5e7eb',
        'selectors' => [
            '{{WRAPPER}} .view-cart-btn:hover' => 'background-color: {{VALUE}};',
        ],
    ]
);

$this->end_controls_tab();

$this->end_controls_tabs();

$this->add_responsive_control(
    'view_cart_padding',
    [
        'label' => __('Padding', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' => ['px', '%', 'em'],
        'default' => $defaults['view_cart_padding'] ?? [
            'top' => '8',
            'right' => '16',
            'bottom' => '8',
            'left' => '16',
            'unit' => 'px',
            'isLinked' => false,
        ],
        'selectors' => [
            '{{WRAPPER}} .view-cart-btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
        'separator' => 'before',
    ]
);

$this->add_control(
    'view_cart_border_radius',
    [
        'label' => __('Border Radius', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' => ['px', '%'],
        'default' => $defaults['view_cart_border_radius'] ?? [
            'top' => '6',
            'right' => '6',
            'bottom' => '6',
            'left' => '6',
            'unit' => 'px',
            'isLinked' => true,
        ],
        'selectors' => [
            '{{WRAPPER}} .view-cart-btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
    ]
);

$this->end_controls_section();

// Style Section - Checkout Button
$this->start_controls_section(
    'checkout_button_style',
    [
        'label' => __('Checkout Button', 'ggm-commerce'),
        'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        'condition' => [
            'show_dropdown' => 'yes',
        ],
    ]
);

$this->add_group_control(
    \Elementor\Group_Control_Typography::get_type(),
    [
        'name' => 'checkout_typography',
        'selector' => '{{WRAPPER}} .checkout-btn',
        'fields_options' => [
            'typography' => [
                'default' => 'custom',
            ],
            'font_size' => [
                'default' => $defaults['checkout_typography_font_size'] ?? ['size' => 14, 'unit' => 'px'],
            ],
            'font_weight' => [
                'default' => $defaults['checkout_typography_font_weight'] ?? '500',
            ],
        ],
    ]
);

$this->start_controls_tabs('checkout_tabs');

$this->start_controls_tab(
    'checkout_normal',
    [
        'label' => __('Normal', 'ggm-commerce'),
    ]
);

$this->add_control(
    'checkout_color',
    [
        'label' => __('Text Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['checkout_color'] ?? '#ffffff',
        'selectors' => [
            '{{WRAPPER}} .checkout-btn' => 'color: {{VALUE}};',
        ],
    ]
);

$this->add_control(
    'checkout_background',
    [
        'label' => __('Background Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['checkout_background'] ?? '#2563eb',
        'selectors' => [
            '{{WRAPPER}} .checkout-btn' => 'background-color: {{VALUE}};',
        ],
    ]
);

$this->add_control(
    'checkout_border_color',
    [
        'label' => __('Border Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['checkout_border_color'] ?? '#2563eb',
        'selectors' => [
            '{{WRAPPER}} .checkout-btn' => 'border-color: {{VALUE}};',
        ],
    ]
);

$this->end_controls_tab();

$this->start_controls_tab(
    'checkout_hover',
    [
        'label' => __('Hover', 'ggm-commerce'),
    ]
);

$this->add_control(
    'checkout_hover_color',
    [
        'label' => __('Text Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['checkout_hover_color'] ?? '#ffffff',
        'selectors' => [
            '{{WRAPPER}} .checkout-btn:hover' => 'color: {{VALUE}};',
        ],
    ]
);

$this->add_control(
    'checkout_hover_background',
    [
        'label' => __('Background Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['checkout_hover_background'] ?? '#1d4ed8',
        'selectors' => [
            '{{WRAPPER}} .checkout-btn:hover' => 'background-color: {{VALUE}};',
        ],
    ]
);

$this->end_controls_tab();

$this->end_controls_tabs();

$this->add_responsive_control(
    'checkout_padding',
    [
        'label' => __('Padding', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' => ['px', '%', 'em'],
        'default' => $defaults['checkout_padding'] ?? [
            'top' => '8',
            'right' => '16',
            'bottom' => '8',
            'left' => '16',
            'unit' => 'px',
            'isLinked' => false,
        ],
        'selectors' => [
            '{{WRAPPER}} .checkout-btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
        'separator' => 'before',
    ]
);

$this->add_control(
    'checkout_border_radius',
    [
        'label' => __('Border Radius', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' => ['px', '%'],
        'default' => $defaults['checkout_border_radius'] ?? [
            'top' => '6',
            'right' => '6',
            'bottom' => '6',
            'left' => '6',
            'unit' => 'px',
            'isLinked' => true,
        ],
        'selectors' => [
            '{{WRAPPER}} .checkout-btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
    ]
);

$this->end_controls_section();

// Style Section - Empty Cart Message
$this->start_controls_section(
    'empty_cart_style',
    [
        'label' => __('Empty Cart Message', 'ggm-commerce'),
        'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        'condition' => [
            'show_dropdown' => 'yes',
        ],
    ]
);

$this->add_control(
    'empty_cart_color',
    [
        'label' => __('Text Color', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'default' => $defaults['empty_cart_color'] ?? '#6b7280',
        'selectors' => [
            '{{WRAPPER}} .empty-cart' => 'color: {{VALUE}};',
        ],
    ]
);

$this->add_group_control(
    \Elementor\Group_Control_Typography::get_type(),
    [
        'name' => 'empty_cart_typography',
        'selector' => '{{WRAPPER}} .empty-cart',
        'fields_options' => [
            'typography' => [
                'default' => 'custom',
            ],
            'font_size' => [
                'default' => $defaults['empty_cart_typography_font_size'] ?? ['size' => 14, 'unit' => 'px'],
            ],
            'font_style' => [
                'default' => 'italic',
            ],
        ],
    ]
);

$this->add_control(
    'empty_cart_alignment',
    [
        'label' => __('Alignment', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::CHOOSE,
        'options' => [
            'left' => [
                'title' => __('Left', 'ggm-commerce'),
                'icon' => 'eicon-text-align-left',
            ],
            'center' => [
                'title' => __('Center', 'ggm-commerce'),
                'icon' => 'eicon-text-align-center',
            ],
            'right' => [
                'title' => __('Right', 'ggm-commerce'),
                'icon' => 'eicon-text-align-right',
            ],
        ],
        'default' => $defaults['empty_cart_alignment'] ?? 'center',
        'selectors' => [
            '{{WRAPPER}} .empty-cart' => 'text-align: {{VALUE}};',
        ],
    ]
);

$this->add_responsive_control(
    'empty_cart_padding',
    [
        'label' => __('Padding', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' => ['px', '%', 'em'],
        'default' => $defaults['empty_cart_padding'] ?? [
            'top' => '20',
            'right' => '0',
            'bottom' => '20',
            'left' => '0',
            'unit' => 'px',
            'isLinked' => false,
        ],
        'selectors' => [
            '{{WRAPPER}} .empty-cart' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
    ]
);

$this->end_controls_section();
