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

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

// Content Section
$this->start_controls_section(
    'content_section',
    [
        'label' => __('Cart Settings', 'ggm-commerce'),
        'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
    ]
);

$this->add_control(
    'cart_style',
    [
        'label' => __('Cart Style', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SELECT,
        'default' => 'icon_count',
        'options' => [
            'icon_count' => __('Icon with Count', 'ggm-commerce'),
            'icon_total' => __('Icon with Total', 'ggm-commerce'),
            'icon_count_total' => __('Icon with Count & Total', 'ggm-commerce'),
            'text_only' => __('Text Only', 'ggm-commerce'),
        ],
    ]
);

$this->add_control(
    'cart_icon',
    [
        'label' => __('Cart Icon', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::ICONS,
        'default' => [
            'value' => 'fas fa-shopping-cart',
            'library' => 'fa-solid',
        ],
        'condition' => [
            'cart_style!' => 'text_only',
        ],
    ]
);

$this->add_control(
    'cart_text',
    [
        'label' => __('Cart Text', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => __('Cart', 'ggm-commerce'),
        'condition' => [
            'cart_style' => 'text_only',
        ],
    ]
);

$this->add_control(
    'show_dropdown',
    [
        'label' => __('Show Cart Dropdown', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SWITCHER,
        'label_on' => __('Yes', 'ggm-commerce'),
        'label_off' => __('No', 'ggm-commerce'),
        'return_value' => 'yes',
        'default' => 'yes',
    ]
);

$this->add_control(
    'show_product_image',
    [
        'label' => __('Show Product Image', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SWITCHER,
        'label_on' => __('Yes', 'ggm-commerce'),
        'label_off' => __('No', 'ggm-commerce'),
        'return_value' => 'yes',
        'default' => 'yes',
        'condition' => [
            'show_dropdown' => 'yes',
        ],
    ]
);

$this->add_control(
    'empty_cart_text',
    [
        'label' => __('Empty Cart Text', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => __('Your cart is empty', 'ggm-commerce'),
    ]
);

$this->add_control(
    'cart_page_url',
    [
        'label' => __('Cart Page URL', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::URL,
        'placeholder' => __('https://your-site.com/cart', 'ggm-commerce'),
        'default' => [
            'url' => get_permalink(get_option('ggm_commerce_cart_page_id')) ?: '/cart',
            'is_external' => false,
            'nofollow' => false,
        ],
        'description' => __('URL of your cart page where users can view and manage their cart', 'ggm-commerce'),
    ]
);

$this->add_control(
    'checkout_page_url',
    [
        'label' => __('Checkout Page URL', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::URL,
        'placeholder' => __('https://your-site.com/checkout', 'ggm-commerce'),
        'default' => [
            'url' => get_permalink(get_option('ggm_commerce_checkout_page_id')) ?: '/checkout',
            'is_external' => false,
            'nofollow' => false,
        ],
        'description' => __('URL of your checkout page where users can complete their purchase', 'ggm-commerce'),
    ]
);

$this->end_controls_section();
