<?php

namespace Lknwp\CrowdfundingExtension\Includes\elementorFields;

use Elementor\Widget_Base;
use Elementor\Controls_Manager;

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

class LknwpCrowdfundingTemplateBiography extends Widget_Base
{
    public function get_name()
    {
        return 'lkn-wp-crowdfunding-author-biography';
    }

    public function get_title()
    {
        return __('Author Biography', 'link-nacional-wp-crowdfunding-extension');
    }

    public function get_icon()
    {
        return 'eicon-post-content';
    }

    public function get_categories()
    {
        return ['lkn-wp-crowdfunding-extension'];
    }

    protected function _register_controls()
    {
        $this->start_controls_section(
            'section_bio_content',
            [
                'label' => __('Biography Content', 'link-nacional-wp-crowdfunding-extension'),
            ]
        );

        // Controle para o Nome
        $this->add_control(
            'show_name',
            [
                'label' => __('Show Name', 'link-nacional-wp-crowdfunding-extension'),
                'type' => Controls_Manager::SWITCHER,
                'label_on' => __('Yes', 'link-nacional-wp-crowdfunding-extension'),
                'label_off' => __('No', 'link-nacional-wp-crowdfunding-extension'),
                'return_value' => 'yes',
                'default' => 'yes',
            ]
        );

        // Controle para a Contagem de Campanhas
        $this->add_control(
            'show_campaign_count',
            [
                'label' => __('Show Campaign Count', 'link-nacional-wp-crowdfunding-extension'),
                'type' => Controls_Manager::SWITCHER,
                'label_on' => __('Yes', 'link-nacional-wp-crowdfunding-extension'),
                'label_off' => __('No', 'link-nacional-wp-crowdfunding-extension'),
                'return_value' => 'yes',
                'default' => 'yes',
            ]
        );

        // Controle para o Email
        $this->add_control(
            'show_email',
            [
                'label' => __('Show Email', 'link-nacional-wp-crowdfunding-extension'),
                'type' => Controls_Manager::SWITCHER,
                'label_on' => __('Yes', 'link-nacional-wp-crowdfunding-extension'),
                'label_off' => __('No', 'link-nacional-wp-crowdfunding-extension'),
                'return_value' => 'yes',
                'default' => 'yes',
            ]
        );

        // Controle para a Cidade
        $this->add_control(
            'show_city',
            [
                'label' => __('Show City', 'link-nacional-wp-crowdfunding-extension'),
                'type' => Controls_Manager::SWITCHER,
                'label_on' => __('Yes', 'link-nacional-wp-crowdfunding-extension'),
                'label_off' => __('No', 'link-nacional-wp-crowdfunding-extension'),
                'return_value' => 'yes',
                'default' => 'yes',
            ]
        );

        // Controle para o Estado
        $this->add_control(
            'show_state',
            [
                'label' => __('Show State', 'link-nacional-wp-crowdfunding-extension'),
                'type' => Controls_Manager::SWITCHER,
                'label_on' => __('Yes', 'link-nacional-wp-crowdfunding-extension'),
                'label_off' => __('No', 'link-nacional-wp-crowdfunding-extension'),
                'return_value' => 'yes',
                'default' => 'yes',
            ]
        );

        // Controle para o País
        $this->add_control(
            'show_country',
            [
                'label' => __('Show Country', 'link-nacional-wp-crowdfunding-extension'),
                'type' => Controls_Manager::SWITCHER,
                'label_on' => __('Yes', 'link-nacional-wp-crowdfunding-extension'),
                'label_off' => __('No', 'link-nacional-wp-crowdfunding-extension'),
                'return_value' => 'yes',
                'default' => 'yes',
            ]
        );

        // Controle para a Data de Registro
        $this->add_control(
            'show_registration_date',
            [
                'label' => __('Show Registration Date', 'link-nacional-wp-crowdfunding-extension'),
                'type' => Controls_Manager::SWITCHER,
                'label_on' => __('Yes', 'link-nacional-wp-crowdfunding-extension'),
                'label_off' => __('No', 'link-nacional-wp-crowdfunding-extension'),
                'return_value' => 'yes',
                'default' => 'yes',
            ]
        );

        $this->end_controls_section();

        $this->start_controls_section(
            'style_section',
            [
                'label' => __('Style', 'link-nacional-wp-crowdfunding-extension'),
                'tab' => Controls_Manager::TAB_STYLE,
            ]
        );

        // Controle para a cor do título
        $this->add_control(
            'bio_title_color',
            [
                'label' => __('Title Color', 'link-nacional-wp-crowdfunding-extension'),
                'type' => Controls_Manager::COLOR,
                'default' => '#00A859',  // Cor padrão
                'selectors' => [
                    '{{WRAPPER}} .lkn-bio-modal-header h2' => 'color: {{VALUE}}',
                ],
            ]
        );

        // Controle para a cor do link
        $this->add_control(
            'bio_link_color',
            [
                'label' => __('Link Color', 'link-nacional-wp-crowdfunding-extension'),
                'type' => Controls_Manager::COLOR,
                'default' => '#0073aa',  // Cor padrão
                'selectors' => [
                    '{{WRAPPER}} .lkn-open-bio-modal' => 'color: {{VALUE}}',
                ],
            ]
        );

        $this->end_controls_section();
    }

    protected function render()
    {
        require LKNWP_CROWDFUNDING_EXTENSION_DIR . 'Includes/elementorFields/views/LknwpCrowdfundingBiographyView.php';
        require LKNWP_CROWDFUNDING_EXTENSION_DIR . 'Includes/elementorFields/views/LknwpCrowdfundingBiographyModal.php';
    }
}
