<?php
/**
 * Customer Account Widget - Content Controls (TAB_CONTENT)
 *
 * Included via require inside GGM_Commerce_Widget_Customer_Account::register_controls().
 * $this refers to the widget instance.
 *
 * Professional Styling Implementation:
 * - Uses add_responsive_control for spacing, dimensions, and layout controls
 * - Uses add_control for colors and non-responsive properties
 * - Follows three-layer styling architecture
 */

// If this file is called directly, abort.
if (!defined('ABSPATH')) {
    exit;
}

// Login/Register Settings
$this->start_controls_section(
    'login_register_settings',
    [
        'label' => __('Login/Register Settings', 'ggm-commerce'),
        'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
    ]
);

$this->add_control(
    'show_login',
    [
        'label' => __('Show Login Form', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SWITCHER,
        'default' => 'yes',
    ]
);

$this->add_control(
    'show_register',
    [
        'label' => __('Show Register Form', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SWITCHER,
        'default' => 'yes',
    ]
);

$this->add_control(
    'redirect_after_login',
    [
        'label' => __('Redirect After Login', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::URL,
        'placeholder' => __('https://your-site.com/my-account', 'ggm-commerce'),
        'show_external' => false,
        'default' => [
            'url' => '',
            'is_external' => false,
            'nofollow' => false,
        ],
    ]
);

$this->end_controls_section();

// Account Dashboard Settings
$this->start_controls_section(
    'dashboard_settings',
    [
        'label' => __('Dashboard Settings', 'ggm-commerce'),
        'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
    ]
);

$this->add_control(
    'orders_per_page',
    [
        'label' => __('Orders Per Page', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::NUMBER,
        'default' => 10,
        'min' => 1,
        'max' => 50,
    ]
);

$this->add_control(
    'default_tab',
    [
        'label' => __('Default Tab', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SELECT,
        'default' => 'orders',
        'options' => [
            'orders' => __('Orders', 'ggm-commerce'),
            'downloads' => __('Downloads', 'ggm-commerce'),
            'wishlists' => __('Wishlists', 'ggm-commerce'),
            'profile' => __('Profile', 'ggm-commerce'),
            'addresses' => __('Addresses', 'ggm-commerce'),
        ],
    ]
);

// Get available Elementor popups
$_ggmc_popup_templates = ['' => __('Default Modal', 'ggm-commerce')];
$_ggmc_elementor_templates = get_posts([
    'post_type' => 'elementor_library',
    'posts_per_page' => -1,
    'meta_query' => [
        [
            'key' => '_elementor_template_type',
            'value' => 'popup'
        ]
    ]
]);
foreach ($_ggmc_elementor_templates as $_ggmc_tpl) {
    $_ggmc_popup_templates[$_ggmc_tpl->ID] = $_ggmc_tpl->post_title;
}

$this->add_control(
    'address_popup_template',
    [
        'label' => __('Address Edit Popup', 'ggm-commerce'),
        'type' => \Elementor\Controls_Manager::SELECT,
        'options' => $_ggmc_popup_templates,
        'default' => get_option('ggm_commerce_address_popup_id', ''),
        'description' => __('Select an Elementor popup template for adding/editing addresses.', 'ggm-commerce'),
    ]
);

$this->end_controls_section();
