<?php
namespace AITheme\Elementor\Widgets;

use Elementor\Controls_Manager;

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

class Contact_Form_Left extends AI_Widget_Base {
    public function get_name() { return 'ai_contact_form_left'; }
    public function get_title() { return __('Contact Form Left', 'ai-theme'); }
    public function get_icon() { return 'eicon-form-horizontal'; }
    public function get_categories() { return array('ai-theme-contact'); }

    protected function register_controls() {
        $this->start_controls_section('content_section', ['label' => __('Content', 'ai-theme'), 'tab' => Controls_Manager::TAB_CONTENT]);
        $this->add_control('title', ['label' => __('Title', 'ai-theme'), 'type' => Controls_Manager::TEXT, 'default' => __('Get in Touch', 'ai-theme')]);
        $this->add_control('description', ['label' => __('Description', 'ai-theme'), 'type' => Controls_Manager::TEXTAREA]);
        $this->add_control('phone', ['label' => __('Phone', 'ai-theme'), 'type' => Controls_Manager::TEXT]);
        $this->add_control('email', ['label' => __('Email', 'ai-theme'), 'type' => Controls_Manager::TEXT]);
        $this->add_control('address', ['label' => __('Address', 'ai-theme'), 'type' => Controls_Manager::TEXTAREA]);
        $this->end_controls_section();
    }

    protected function render() {
        $s = $this->get_settings_for_display();
        ?>
        <section class="ai-contact ai-contact-form-left bg-white py-16">
            <div class="ai-container grid grid-cols-1 md:grid-cols-2 gap-12">
                <div class="ai-contact-form">
                    <form class="space-y-4">
                        <input type="text" placeholder="Name" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent outline-none transition">
                        <input type="email" placeholder="Email" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent outline-none transition">
                        <textarea placeholder="Message" rows="4" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent outline-none transition resize-none"></textarea>
                        <button type="submit" class="w-full bg-primary text-white py-3 rounded-lg font-semibold hover:shadow-lg transition-shadow">Send</button>
                    </form>
                </div>
                <div class="ai-contact-info">
                    <h2 class="ai-contact-title text-3xl font-bold text-gray-900 mb-4"><?php echo esc_html($s['title']); ?></h2>
                    <?php if (!empty($s['description'])) : ?><p class="text-gray-600 mb-8"><?php echo esc_html($s['description']); ?></p><?php endif; ?>
                    <div class="space-y-4">
                        <?php if (!empty($s['phone'])) : ?>
                            <div class="ai-contact-item flex items-center gap-4 p-4 bg-gray-50 rounded-lg">
                                <div class="w-10 h-10 bg-primary/10 rounded-full flex items-center justify-center"><i class="fas fa-phone text-primary"></i></div>
                                <span class="text-gray-700"><?php echo esc_html($s['phone']); ?></span>
                            </div>
                        <?php endif; ?>
                        <?php if (!empty($s['email'])) : ?>
                            <div class="ai-contact-item flex items-center gap-4 p-4 bg-gray-50 rounded-lg">
                                <div class="w-10 h-10 bg-primary/10 rounded-full flex items-center justify-center"><i class="fas fa-envelope text-primary"></i></div>
                                <span class="text-gray-700"><?php echo esc_html($s['email']); ?></span>
                            </div>
                        <?php endif; ?>
                        <?php if (!empty($s['address'])) : ?>
                            <div class="ai-contact-item flex items-center gap-4 p-4 bg-gray-50 rounded-lg">
                                <div class="w-10 h-10 bg-primary/10 rounded-full flex items-center justify-center"><i class="fas fa-map-marker-alt text-primary"></i></div>
                                <span class="text-gray-700"><?php echo esc_html($s['address']); ?></span>
                            </div>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
        </section>
        <?php
    }
}
