<?php
namespace AITheme\Elementor\Widgets;

use Elementor\Controls_Manager;

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

class Company_Card extends AI_Widget_Base {
    public function get_name() { return 'ai_company_card'; }
    public function get_title() { return __('Company Card', 'ai-theme'); }
    public function get_icon() { return 'eicon-info-box'; }
    public function get_categories() { return array('ai-theme-company'); }

    protected function register_controls() {
        $this->start_controls_section('content_section', ['label' => __('Content', 'ai-theme'), 'tab' => Controls_Manager::TAB_CONTENT]);
        $this->add_control('logo', ['label' => __('Logo', 'ai-theme'), 'type' => Controls_Manager::MEDIA]);
        $this->add_control('name', ['label' => __('Company Name', 'ai-theme'), 'type' => Controls_Manager::TEXT]);
        $this->add_control('tagline', ['label' => __('Tagline', 'ai-theme'), 'type' => Controls_Manager::TEXT]);
        $this->add_control('description', ['label' => __('Description', 'ai-theme'), 'type' => Controls_Manager::TEXTAREA]);
        $this->add_control('founded', ['label' => __('Founded', 'ai-theme'), 'type' => Controls_Manager::TEXT]);
        $this->add_control('employees', ['label' => __('Employees', 'ai-theme'), 'type' => Controls_Manager::TEXT]);
        $this->add_control('location', ['label' => __('Location', 'ai-theme'), 'type' => Controls_Manager::TEXT]);
        $this->end_controls_section();
    }

    protected function render() {
        $s = $this->get_settings_for_display();
        ?>
        <section class="ai-company ai-company-card">
            <div class="ai-company-card-inner w-full bg-white rounded-2xl border border-gray-200 overflow-hidden hover:shadow-xl transition-shadow duration-300">
                <!-- Header with logo -->
                <div class="bg-gradient-to-br from-blue-600 to-blue-700 p-8">
                    <div class="flex items-center gap-4">
                        <?php if (!empty($s['logo']['url'])) : ?>
                        <div class="w-16 h-16 bg-white rounded-xl flex items-center justify-center overflow-hidden flex-shrink-0">
                            <img src="<?php echo esc_url($s['logo']['url']); ?>" alt="<?php echo esc_attr($s['name']); ?>" class="ai-company-logo w-full h-full object-contain">
                        </div>
                        <?php endif; ?>
                        <h3 class="text-2xl font-bold text-white"><?php echo esc_html($s['name']); ?></h3>
                    </div>
                </div>

                <!-- Content -->
                <div class="p-6">
                    <?php if (!empty($s['tagline'])) : ?><p class="ai-company-tagline text-blue-600 font-semibold mb-4"><?php echo esc_html($s['tagline']); ?></p><?php endif; ?>
                    <?php if (!empty($s['description'])) : ?><p class="ai-company-description text-gray-700 leading-relaxed mb-6"><?php echo esc_html($s['description']); ?></p><?php endif; ?>

                    <!-- Metrics -->
                    <div class="ai-company-details grid grid-cols-3 gap-4 mb-6">
                        <?php if (!empty($s['founded'])) : ?>
                        <div class="text-center">
                            <div class="text-2xl font-bold text-gray-900 mb-1"><?php echo esc_html($s['founded']); ?></div>
                            <div class="text-sm text-gray-600"><?php _e('Founded', 'ai-theme'); ?></div>
                        </div>
                        <?php endif; ?>
                        <?php if (!empty($s['employees'])) : ?>
                        <div class="text-center">
                            <div class="text-2xl font-bold text-gray-900 mb-1"><?php echo esc_html($s['employees']); ?></div>
                            <div class="text-sm text-gray-600"><?php _e('Employees', 'ai-theme'); ?></div>
                        </div>
                        <?php endif; ?>
                        <?php if (!empty($s['location'])) : ?>
                        <div class="text-center">
                            <div class="text-2xl font-bold text-gray-900 mb-1"><?php echo esc_html($s['location']); ?></div>
                            <div class="text-sm text-gray-600"><?php _e('Location', 'ai-theme'); ?></div>
                        </div>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
        </section>
        <?php
    }
}
