<?php
/**
 * Elementor Integration for Tech Repair Service
 *
 * @package Tech_Repair_Service
 */

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

/**
 * Tech_Repair_Elementor class
 */
class Tech_Repair_Elementor {

    /**
     * Instance of this class
     *
     * @var object
     */
    private static $instance = null;

    /**
     * Get instance of this class
     *
     * @return Tech_Repair_Elementor
     */
    public static function get_instance() {
        if ( null === self::$instance ) {
            self::$instance = new self();
        }
        return self::$instance;
    }

    /**
     * Constructor
     */
    public function __construct() {
        // Register widgets
        add_action( 'elementor/widgets/register', array( $this, 'register_widgets' ) );
        
        // Register widget categories
        add_action( 'elementor/elements/categories_registered', array( $this, 'add_elementor_widget_categories' ) );
        
        // Enqueue styles and scripts
        add_action( 'elementor/frontend/after_enqueue_styles', array( $this, 'enqueue_styles' ) );
        add_action( 'elementor/frontend/after_register_scripts', array( $this, 'enqueue_scripts' ) );
    }

    /**
     * Register widgets
     *
     * @param \Elementor\Widgets_Manager $widgets_manager Elementor widgets manager
     */
    public function register_widgets( $widgets_manager ) {
        // Include widget files
        require_once plugin_dir_path( __FILE__ ) . 'widgets/class-tech-repair-tabs-widget.php';
        
        // Register widgets
        $widgets_manager->register( new \Tech_Repair_Tabs_Widget() );
    }

    /**
     * Add Elementor widget categories
     *
     * @param \Elementor\Elements_Manager $elements_manager Elementor elements manager
     */
    public function add_elementor_widget_categories( $elements_manager ) {
        $elements_manager->add_category(
            'tech-repair-service',
            array(
                'title' => esc_html__( 'Tech Repair Service', 'tech-repair-service' ),
                'icon'  => 'fa fa-plug',
            )
        );
    }

    /**
     * Enqueue styles
     */
    public function enqueue_styles() {
        wp_enqueue_style( 'tech-repair-tabs' );
    }

    /**
     * Enqueue scripts
     */
    public function enqueue_scripts() {
        wp_enqueue_script( 'tech-repair-tabs' );
    }
}

// Initialize the class
Tech_Repair_Elementor::get_instance();
