<?php
/**
 * Assets handler for Product Display.
 *
 * @package Product_Display
 */

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

/**
 * Class PRODDISP_Assets.
 *
 * This class handles the registration and enqueuing of scripts and styles for the plugin.
 */
class PRODDISP_Assets {
	/**
	 * The single instance of the class.
	 */
	protected static $_instance = null;

	/**
	 * Asset definitions.
	 */
	private $assets = [];

	/**
	 * Main Instance.
	 */
	public static function get_instance() {
		if ( is_null(self::$_instance) ) {
			self::$_instance = new self();
		}
		return self::$_instance;
	}

	/**
	 * Constructor.
	 */
	public function __construct() {
		$this->init_assets();
		add_action('admin_enqueue_scripts', array( $this, 'register_admin_assets' ));
		add_action('wp_enqueue_scripts', array( $this, 'register_frontend_assets' ));
		add_action('admin_head', array( $this, 'add_admin_menu_styles' ));
		// Always output custom CSS in <head> on frontend, priority 999 = last stylesheet.
		add_action('wp_head', array( $this, 'output_custom_css_in_head' ), 999);
	}

	/**
	 * Initialize asset definitions.
	 */
	private function init_assets() {
		$this->assets = [
			'styles' => [
				'wcps-admin-styles' => [
					'src'  => PRODDISP_PLUGIN_URL . 'assets/build/css/react-admin.min.css',
					'deps' => [],
				],
				'wcps-admin-styles-2' => [
					'src'  => PRODDISP_PLUGIN_URL . 'assets/build/css/wcps-admin-style-2.min.css',
					'deps' => [],
				],
				'wcps-get-started' => [
					'src'  => PRODDISP_PLUGIN_URL . 'assets/build/css/wcps-get-started.min.css',
					'deps' => [],
				],
				'wcps-styles' => [
					'src'  => PRODDISP_PLUGIN_URL . 'assets/build/css/wcps-styles.min.css',
					'deps' => [],
				],
				'wcps-style-caption' => [
					'src'  => PRODDISP_PLUGIN_URL . 'assets/build/css/wcps-style-caption.min.css',
					'deps' => [],
				],
				'wcps-style-slider' => [
					'src'  => PRODDISP_PLUGIN_URL . 'assets/build/css/wcps-style-slider.min.css',
					'deps' => [],
				],
				'wcps-style-table' => [
					'src'  => PRODDISP_PLUGIN_URL . 'assets/build/css/wcps-style-table.min.css',
					'deps' => [],
				],
				'wcps-style-flip' => [
					'src'  => PRODDISP_PLUGIN_URL . 'assets/build/css/wcps-style-flip.min.css',
					'deps' => [],
				],
				'wcps-style-card' => [
					'src'  => PRODDISP_PLUGIN_URL . 'assets/build/css/wcps-style-card.min.css',
					'deps' => [],
				],
				'wcps-style-cta' => [
					'src'  => PRODDISP_PLUGIN_URL . 'assets/build/css/wcps-style-cta.min.css',
					'deps' => [],
				],
				'wcps-style-list' => [
					'src'  => PRODDISP_PLUGIN_URL . 'assets/build/css/wcps-style-list.min.css',
					'deps' => [],
				],
				'wcps-style-grid' => [
					'src'  => PRODDISP_PLUGIN_URL . 'assets/build/css/wcps-style-grid.min.css',
					'deps' => [],
				],
				'wcps-style-showcase' => [
					'src'  => PRODDISP_PLUGIN_URL . 'assets/build/css/wcps-style-showcase.min.css',
					'deps' => [],
				],
				'wcps-style-masonry' => [
					'src'  => PRODDISP_PLUGIN_URL . 'assets/build/css/wcps-style-masonry.min.css',
					'deps' => [],
				],
				'wcps-style-gallery' => [
					'src'  => PRODDISP_PLUGIN_URL . 'assets/build/css/wcps-style-gallery.min.css',
					'deps' => [],
				],
				'wcps-style-category-tabs' => [
					'src'  => PRODDISP_PLUGIN_URL . 'assets/build/css/wcps-style-category-tabs.min.css',
					'deps' => [],
				],

				'wcps-slick' => [
					'src'  => PRODDISP_PLUGIN_URL . 'assets/library/slick.css',
					'deps' => [],
				],
				'wcps-font-awesome' => [
					/*
					 'src'  => 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css',
					'deps' => [], */
					'src'  => PRODDISP_PLUGIN_URL . 'assets/library/all.min.css',
					'deps' => [],
				],
				'wcps-shop-integration' => [
					'src'  => PRODDISP_PLUGIN_URL . 'assets/css/shop-integration-frontend.css',
					'deps' => [],
				],
			],
			'scripts' => [
				'wcps-admin-styles' => [
					'src'    => PRODDISP_PLUGIN_URL . 'assets/build/js/react-admin.min.js',
					'deps'   => [ 'wp-element', 'jquery', 'wp-color-picker', 'jquery-ui-sortable', 'wp-util' ],
					'footer' => true,
				],
				'wcps-scripts' => [
					'src'    => PRODDISP_PLUGIN_URL . 'assets/build/js/wcps-scripts.min.js', // Frontend scripts for shortcode display
					'deps'   => [ 'jquery' ],
					'footer' => true,
				],

				'wcps-slick' => [
					'src'    => PRODDISP_PLUGIN_URL . 'assets/library/slick.min.js',
					'deps'   => [ 'jquery' ],
					'footer' => true,
				],
				'wcps-imagesloaded' => [
					'src'    => PRODDISP_PLUGIN_URL . 'assets/library/imagesloaded.pkgd.min.js',
					'deps'   => [ 'jquery' ],
					'footer' => true,
				],
				'wcps-masonry' => [
					'src'    => PRODDISP_PLUGIN_URL . 'assets/library/masonry.min.js',
					'deps'   => [ 'jquery' ],
					'footer' => true,
				],
				'wcps-features' => [
					'src'    => PRODDISP_PLUGIN_URL . 'assets/build/js/wcps-features.min.js',
					'deps'   => [ 'jquery' ],
					'footer' => true,
				],

				'wcps-isotope' => [
					'src'    => PRODDISP_PLUGIN_URL . 'assets/library/isotope.pkgd.min.js',
					'deps'   => [ 'jquery' ],
					'footer' => true,
				],
				'toastmaster' => [
					'src'    => PRODDISP_PLUGIN_URL . 'assets/library/toastmaster.min.js',
					'deps'   => [ 'jquery' ],
					'footer' => true,
				],
			],
		];
	}

	/**
	 * Register admin scripts and styles.
	 */
	public function register_admin_assets( $hook ) {

		// Define allowed hooks for this plugin
		$allowed_hooks = array(
			'toplevel_page_product-display',
		);

		// Remove admin notices on our pages for cleaner interface
		if ( in_array( $hook, $allowed_hooks ) ) {
			remove_all_actions( 'admin_notices' );
			remove_all_actions( 'all_admin_notices' );
		}

		// Only load on plugin pages
		if ( ! in_array( $hook, $allowed_hooks ) ) {
			return;
		}

		remove_all_actions( 'admin_notices' );
		remove_all_actions( 'all_admin_notices' );

		// React Admin CSS and JS
		$this->register_style('wcps-admin-styles');
		$this->register_script('wcps-admin-styles');

		// Frontend styles for preview in admin
		$this->register_style('wcps-styles');
		$this->register_style('wcps-style-caption');
		$this->register_style('wcps-slick');
		$this->register_style('wcps-font-awesome');
		
		// Load all layout-specific styles for admin preview and layout selection
		$this->register_style('wcps-style-slider');
		$this->register_style('wcps-style-table');
		$this->register_style('wcps-style-flip');
		$this->register_style('wcps-style-card');
		$this->register_style('wcps-style-cta');
		$this->register_style('wcps-style-list');
		$this->register_style('wcps-style-grid');
		$this->register_style('wcps-style-showcase');
		$this->register_style('wcps-style-masonry');
		$this->register_style('wcps-style-gallery');
		$this->register_style('wcps-style-category-tabs');

		// Frontend scripts for preview functionality
		$this->register_script('wcps-scripts');
		$this->register_script('wcps-slick'); // Add Slick.js for slider previews
		$this->register_script('wcps-features');
		$this->register_script('toastmaster');

		// Localize React admin script
		wp_localize_script('wcps-admin-styles', 'proddispAdmin', array(
			'ajaxUrl' => admin_url('admin-ajax.php'),
			'adminUrl' => admin_url(),
			'siteUrl'     => get_site_url(),
			'nonce' => wp_create_nonce('proddisp_admin_nonce'),
			'pluginUrl' => PRODDISP_PLUGIN_URL,
			'restUrl' => rest_url('wp/v2/'),
			'restNonce' => wp_create_nonce('wp_rest'),
			'isProActive' => PRODDISP_Loader::is_pro_active(),
			'fontAwesome' => array(
				'version' => '6.4.0',
				'loaded' => true,
				'icons' => $this->get_fontawesome_icons(),
			),
		));
	}

	/**
	 * Register frontend scripts and styles.
	 */
	public function register_frontend_assets() {
		// Register all frontend assets without enqueuing
		foreach ( $this->assets['styles'] as $handle => $style ) {
			if ( $handle !== 'wcps-admin-styles' ) {
				$this->register_style($handle, false);
			}
		}

		foreach ( $this->assets['scripts'] as $handle => $script ) {
			if ( $handle !== 'wcps-admin-styles' ) {
				$this->register_script($handle, false);
			}
		}

		// Localize frontend scripts with proper nonce and parameters
		wp_localize_script('wcps-scripts', 'proddisp_params', array(
			'ajax_url' => admin_url('admin-ajax.php'),
			'nonce' => wp_create_nonce('wcps-nonce'),
			'i18n' => array(
				'empty_wishlist' => __('Your wishlist is empty', 'product-display'),
				'added_to_cart' => __('Product added to cart!', 'product-display'),
				'error_occurred' => __('An error occurred. Please try again.', 'product-display'),
			),
		));

		wp_localize_script('wcps-features', 'proddisp_params', array(
			'ajax_url' => admin_url('admin-ajax.php'),
			'nonce' => wp_create_nonce('wcps-nonce'),
			'cart_url' => function_exists('wc_get_cart_url') ? wc_get_cart_url() : home_url('/cart/'),
			'i18n' => array(
				'empty_wishlist' => __('Your wishlist is empty', 'product-display'),
				'added_to_cart' => __('Product added to cart!', 'product-display'),
				'error_occurred' => __('An error occurred. Please try again.', 'product-display'),
			),
		));
	}

	/**
	 * Helper to register a style.
	 */
	private function register_style( $handle, $enqueue = true ) {
		if ( isset($this->assets['styles'][ $handle ]) ) {
			$style = $this->assets['styles'][ $handle ];
			wp_register_style(
				$handle,
				$style['src'],
				$style['deps'],
				PRODDISP_VERSION
			);

			if ( $enqueue ) {
				wp_enqueue_style($handle);
			}
		}
	}

	/**
	 * Helper to register a script.
	 */
	private function register_script( $handle, $enqueue = true ) {
		if ( isset($this->assets['scripts'][ $handle ]) ) {
			$script = $this->assets['scripts'][ $handle ];
			wp_register_script(
				$handle,
				$script['src'],
				$script['deps'],
				PRODDISP_VERSION,
				$script['footer']
			);

			if ( $enqueue ) {
				wp_enqueue_script($handle);
			}
		}
	}

	/**
	 * Enqueue frontend assets for shortcode display.
	 */
	public function enqueue_frontend_assets() {
		wp_enqueue_style('wcps-styles');
		wp_enqueue_style('wcps-style-caption');
		wp_enqueue_script('wcps-scripts');
		wp_enqueue_script('wcps-features');

		wp_enqueue_script('wcps-imagesloaded');
		wp_enqueue_script('wcps-masonry');
		wp_enqueue_style('wcps-slick');
		wp_enqueue_script('wcps-slick');

		wp_enqueue_script('toastmaster');

		// Enqueue shop integration styles if on shop pages
		if ( $this->is_shop_page() ) {
			wp_enqueue_style('wcps-shop-integration');
		}
	}

	/**
	 * Output all saved per-showcase custom CSS into <head> at priority 999.
	 * Fires after every enqueued stylesheet, so any selector — even with low
	 * specificity — wins without needing !important.
	 */
	public function output_custom_css_in_head() {
		$all_css = get_option( 'proddisp_custom_css', array() );

		if ( empty( $all_css ) || ! is_array( $all_css ) ) {
			return;
		}

		// Only output CSS for showcases that still exist
		$existing_showcases = get_option( 'proddisp_saved_showcases', array() );

		$combined = '';
		foreach ( $all_css as $showcase_id => $css ) {
			$showcase_id = absint( $showcase_id );
			$css         = trim( $css );
			if ( $showcase_id && $css && isset( $existing_showcases[ $showcase_id ] ) ) {
				$combined .= "\n/* PD — #" . $showcase_id . " */\n" . $css . "\n";
			}
		}

		if ( $combined ) {
			// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- CSS is stored by admin-only AJAX handler; HTML tags are stripped with preg_replace on save.
			echo "<style id=\"product-display-custom-style\">\n" . $combined . "\n</style>\n";
		}
	}

	/**
	 * Conditionally enqueue FontAwesome based on shortcode settings.
	 * 
	 * @param array $settings Shortcode settings to check for features that need FontAwesome.
	 */
	public function maybe_enqueue_fontawesome_for_shortcode( $settings ) {
		$needs_fontawesome = false;

		// Check if any features that need FontAwesome are enabled
		if ( isset($settings['show_compare']) && $settings['show_compare'] === 'yes' ) {
			$needs_fontawesome = true;
		}
		
		if ( isset($settings['show_quickview']) && $settings['show_quickview'] === 'yes' ) {
			$needs_fontawesome = true;
		}
		
		if ( isset($settings['show_wishlist']) && $settings['show_wishlist'] === 'yes' ) {
			$needs_fontawesome = true;
		}

		// Load FontAwesome only if needed
		if ( $needs_fontawesome ) {
			wp_enqueue_style('wcps-font-awesome');
		}
	}

	/**
	 * Check if current page is a shop-related page
	 */
	private function is_shop_page() {
		return is_shop() || is_product_category() || is_product_tag() || is_product_taxonomy();
	}

	/**
	 * Enqueue shop integration assets
	 */
	public function enqueue_shop_integration_assets() {
		wp_enqueue_style('wcps-shop-integration');
	}

	/**
	 * Enqueue feature assets for advanced layouts.
	 */
	public function enqueue_feature_assets() {
		wp_enqueue_script('wcps-features');
	}

	/**
	 * Enqueue slider assets for slider layouts.
	 */
	public function enqueue_slider_assets() {
		wp_enqueue_style('wcps-slick');
		wp_enqueue_script('wcps-slick');
	}

	/**
	 * Enqueue masonry assets for masonry layouts.
	 */
	public function enqueue_masonry_assets() {
		wp_enqueue_script('wcps-imagesloaded');
		wp_enqueue_script('wcps-masonry');
	}

	/**
	 * Enqueue isotope assets for filtering.
	 */
	public function enqueue_isotope_assets() {
		wp_enqueue_script('wcps-isotope');
	}

	/**
	 * Enqueue caption assets for caption layouts.
	 */
	public function enqueue_caption_assets() {
		wp_enqueue_style('wcps-style-caption');
	}

	/**
	 * Enqueue slider assets for slider layouts.
	 */
	public function enqueue_slider_style_assets() {
		wp_enqueue_style('wcps-style-slider');
	}

	/**
	 * Enqueue table assets for table layouts.
	 */
	public function enqueue_table_style_assets() {
		wp_enqueue_style('wcps-style-table');
	}

	/**
	 * Enqueue flip assets for flip layouts.
	 */
	public function enqueue_flip_style_assets() {
		wp_enqueue_style('wcps-style-flip');
	}

	/**
	 * Enqueue card assets for card layouts.
	 */
	public function enqueue_card_style_assets() {
		wp_enqueue_style('wcps-style-card');
	}

	/**
	 * Enqueue cta assets for cta layouts.
	 */
	public function enqueue_cta_style_assets() {
		wp_enqueue_style('wcps-style-cta');
	}

	/**
	 * Enqueue list assets for list layouts.
	 */
	public function enqueue_list_style_assets() {
		wp_enqueue_style('wcps-style-list');
	}

	/**
	 * Enqueue grid assets for grid layouts.
	 */
	public function enqueue_grid_style_assets() {
		wp_enqueue_style('wcps-style-grid');
	}

	/**
	 * Enqueue showcase assets for showcase layouts.
	 */
	public function enqueue_showcase_style_assets() {
		wp_enqueue_style('wcps-style-showcase');
	}

	/**
	 * Enqueue masonry assets for masonry layouts.
	 */
	public function enqueue_masonry_style_assets() {
		wp_enqueue_style('wcps-style-masonry');
	}

	/**
	 * Enqueue gallery assets for gallery layouts.
	 */
	public function enqueue_gallery_style_assets() {
		wp_enqueue_style('wcps-style-gallery');
	}

	/**
	 * Enqueue category tabs assets for category tabs layouts.
	 */
	public function enqueue_category_tabs_style_assets() {
		wp_enqueue_style('wcps-style-category-tabs');
	}

	/**
	 * Get Font Awesome icon classes for use in JavaScript
	 * Returns comprehensive FontAwesome 6.4.0 icon library organized by categories
	 */
	private function get_fontawesome_icons() {
		return array(
			'Shopping & E-commerce' => array(
				'fas fa-shopping-cart' => 'Shopping Cart',
				'fas fa-shopping-bag' => 'Shopping Bag',
				'fas fa-shopping-basket' => 'Shopping Basket',
				'fas fa-cart-plus' => 'Add to Cart',
				'fas fa-cart-arrow-down' => 'Cart Download',
				'fas fa-credit-card' => 'Credit Card',
				'far fa-credit-card' => 'Credit Card Outline',
				'fas fa-money-bill' => 'Money Bill',
				'fas fa-money-bill-wave' => 'Money Bill Wave',
				'fas fa-coins' => 'Coins',
				'fas fa-dollar-sign' => 'Dollar Sign',
				'fas fa-euro-sign' => 'Euro Sign',
				'fas fa-pound-sign' => 'Pound Sign',
				'fas fa-yen-sign' => 'Yen Sign',
				'fas fa-store' => 'Store',
				'fas fa-store-alt' => 'Store Alt',
				'fas fa-cash-register' => 'Cash Register',
				'fas fa-receipt' => 'Receipt',
				'fas fa-tag' => 'Tag',
				'fas fa-tags' => 'Tags',
				'fas fa-gift' => 'Gift',
				'fas fa-percent' => 'Percent',
				'fas fa-percentage' => 'Percentage',
				'fas fa-wallet' => 'Wallet',
				'fas fa-piggy-bank' => 'Piggy Bank',
				'fas fa-hand-holding-usd' => 'Hand Holding USD',
			),
			'Actions & Interactions' => array(
				'fas fa-heart' => 'Heart',
				'far fa-heart' => 'Heart Outline',
				'fas fa-heart-broken' => 'Heart Broken',
				'fas fa-eye' => 'Eye',
				'far fa-eye' => 'Eye Outline',
				'fas fa-eye-slash' => 'Eye Slash',
				'far fa-eye-slash' => 'Eye Slash Outline',
				'fas fa-balance-scale' => 'Balance Scale',
				'fas fa-balance-scale-left' => 'Balance Scale Left',
				'fas fa-balance-scale-right' => 'Balance Scale Right',
				'fas fa-plus' => 'Plus',
				'fas fa-plus-circle' => 'Plus Circle',
				'far fa-plus-square' => 'Plus Square',
				'fas fa-minus' => 'Minus',
				'fas fa-minus-circle' => 'Minus Circle',
				'far fa-minus-square' => 'Minus Square',
				'fas fa-times' => 'Times',
				'fas fa-times-circle' => 'Times Circle',
				'far fa-times-circle' => 'Times Circle Outline',
				'fas fa-check' => 'Check',
				'fas fa-check-circle' => 'Check Circle',
				'far fa-check-circle' => 'Check Circle Outline',
				'fas fa-check-square' => 'Check Square',
				'far fa-check-square' => 'Check Square Outline',
				'fas fa-thumbs-up' => 'Thumbs Up',
				'far fa-thumbs-up' => 'Thumbs Up Outline',
				'fas fa-thumbs-down' => 'Thumbs Down',
				'far fa-thumbs-down' => 'Thumbs Down Outline',
				'fas fa-star' => 'Star',
				'far fa-star' => 'Star Outline',
				'fas fa-star-half-alt' => 'Star Half',
				'far fa-star-half' => 'Star Half Outline',
				'fas fa-bookmark' => 'Bookmark',
				'far fa-bookmark' => 'Bookmark Outline',
				'fas fa-flag' => 'Flag',
				'far fa-flag' => 'Flag Outline',
			),
			'Navigation & Arrows' => array(
				'fas fa-arrow-right' => 'Arrow Right',
				'fas fa-arrow-left' => 'Arrow Left',
				'fas fa-arrow-up' => 'Arrow Up',
				'fas fa-arrow-down' => 'Arrow Down',
				'fas fa-arrow-circle-right' => 'Arrow Circle Right',
				'fas fa-arrow-circle-left' => 'Arrow Circle Left',
				'fas fa-arrow-circle-up' => 'Arrow Circle Up',
				'fas fa-arrow-circle-down' => 'Arrow Circle Down',
				'far fa-arrow-alt-circle-right' => 'Arrow Alt Circle Right',
				'far fa-arrow-alt-circle-left' => 'Arrow Alt Circle Left',
				'far fa-arrow-alt-circle-up' => 'Arrow Alt Circle Up',
				'far fa-arrow-alt-circle-down' => 'Arrow Alt Circle Down',
				'fas fa-chevron-right' => 'Chevron Right',
				'fas fa-chevron-left' => 'Chevron Left',
				'fas fa-chevron-up' => 'Chevron Up',
				'fas fa-chevron-down' => 'Chevron Down',
				'fas fa-chevron-circle-right' => 'Chevron Circle Right',
				'fas fa-chevron-circle-left' => 'Chevron Circle Left',
				'fas fa-chevron-circle-up' => 'Chevron Circle Up',
				'fas fa-chevron-circle-down' => 'Chevron Circle Down',
				'fas fa-angle-right' => 'Angle Right',
				'fas fa-angle-left' => 'Angle Left',
				'fas fa-angle-up' => 'Angle Up',
				'fas fa-angle-down' => 'Angle Down',
				'fas fa-angle-double-right' => 'Angle Double Right',
				'fas fa-angle-double-left' => 'Angle Double Left',
				'fas fa-angle-double-up' => 'Angle Double Up',
				'fas fa-angle-double-down' => 'Angle Double Down',
				'fas fa-caret-right' => 'Caret Right',
				'fas fa-caret-left' => 'Caret Left',
				'fas fa-caret-up' => 'Caret Up',
				'fas fa-caret-down' => 'Caret Down',
				'fas fa-caret-square-right' => 'Caret Square Right',
				'far fa-caret-square-right' => 'Caret Square Right Outline',
				'fas fa-caret-square-left' => 'Caret Square Left',
				'far fa-caret-square-left' => 'Caret Square Left Outline',
				'fas fa-caret-square-up' => 'Caret Square Up',
				'far fa-caret-square-up' => 'Caret Square Up Outline',
				'fas fa-caret-square-down' => 'Caret Square Down',
				'far fa-caret-square-down' => 'Caret Square Down Outline',
			),
			'Interface & Controls' => array(
				'fas fa-search' => 'Search',
				'fas fa-search-plus' => 'Search Plus',
				'fas fa-search-minus' => 'Search Minus',
				'fas fa-filter' => 'Filter',
				'fas fa-sort' => 'Sort',
				'fas fa-sort-up' => 'Sort Up',
				'fas fa-sort-down' => 'Sort Down',
				'fas fa-sort-alpha-down' => 'Sort Alpha Down',
				'fas fa-sort-alpha-up' => 'Sort Alpha Up',
				'fas fa-sort-amount-down' => 'Sort Amount Down',
				'fas fa-sort-amount-up' => 'Sort Amount Up',
				'fas fa-sort-numeric-down' => 'Sort Numeric Down',
				'fas fa-sort-numeric-up' => 'Sort Numeric Up',
				'fas fa-list' => 'List',
				'fas fa-list-ul' => 'List Unordered',
				'fas fa-list-ol' => 'List Ordered',
				'fas fa-th' => 'Grid',
				'fas fa-th-large' => 'Large Grid',
				'fas fa-th-list' => 'List Grid',
				'fas fa-bars' => 'Bars',
				'fas fa-ellipsis-h' => 'More Horizontal',
				'fas fa-ellipsis-v' => 'More Vertical',
				'fas fa-cog' => 'Settings',
				'fas fa-cogs' => 'Settings Multiple',
				'fas fa-sliders-h' => 'Sliders',
				'fas fa-palette' => 'Palette',
				'fas fa-adjust' => 'Adjust',
				'fas fa-toggle-on' => 'Toggle On',
				'fas fa-toggle-off' => 'Toggle Off',
				'fas fa-power-off' => 'Power Off',
				'fas fa-play' => 'Play',
				'fas fa-pause' => 'Pause',
				'fas fa-stop' => 'Stop',
				'fas fa-step-forward' => 'Step Forward',
				'fas fa-step-backward' => 'Step Backward',
				'fas fa-fast-forward' => 'Fast Forward',
				'fas fa-fast-backward' => 'Fast Backward',
			),
			'Communication & Social' => array(
				'fas fa-share' => 'Share',
				'fas fa-share-alt' => 'Share Alt',
				'fas fa-share-square' => 'Share Square',
				'far fa-share-square' => 'Share Square Outline',
				'fas fa-external-link-alt' => 'External Link',
				'fas fa-external-link-square-alt' => 'External Link Square',
				'fas fa-link' => 'Link',
				'fas fa-unlink' => 'Unlink',
				'fas fa-envelope' => 'Envelope',
				'far fa-envelope' => 'Envelope Outline',
				'fas fa-envelope-open' => 'Envelope Open',
				'far fa-envelope-open' => 'Envelope Open Outline',
				'fas fa-envelope-square' => 'Envelope Square',
				'fas fa-phone' => 'Phone',
				'fas fa-phone-alt' => 'Phone Alt',
				'fas fa-phone-square' => 'Phone Square',
				'fas fa-phone-square-alt' => 'Phone Square Alt',
				'fas fa-mobile-alt' => 'Mobile',
				'fas fa-comment' => 'Comment',
				'far fa-comment' => 'Comment Outline',
				'fas fa-comment-alt' => 'Comment Alt',
				'far fa-comment-alt' => 'Comment Alt Outline',
				'fas fa-comments' => 'Comments',
				'far fa-comments' => 'Comments Outline',
				'fas fa-comment-dots' => 'Comment Dots',
				'far fa-comment-dots' => 'Comment Dots Outline',
				'fas fa-bell' => 'Bell',
				'far fa-bell' => 'Bell Outline',
				'fas fa-bell-slash' => 'Bell Slash',
				'far fa-bell-slash' => 'Bell Slash Outline',
				'fas fa-rss' => 'RSS',
				'fas fa-rss-square' => 'RSS Square',
			),
			'Media & Files' => array(
				'fas fa-image' => 'Image',
				'far fa-image' => 'Image Outline',
				'fas fa-images' => 'Images',
				'far fa-images' => 'Images Outline',
				'fas fa-photo-video' => 'Photo Video',
				'fas fa-camera' => 'Camera',
				'fas fa-camera-retro' => 'Camera Retro',
				'fas fa-video' => 'Video',
				'fas fa-video-slash' => 'Video Slash',
				'fas fa-film' => 'Film',
				'fas fa-music' => 'Music',
				'fas fa-volume-up' => 'Volume Up',
				'fas fa-volume-down' => 'Volume Down',
				'fas fa-volume-mute' => 'Volume Mute',
				'fas fa-volume-off' => 'Volume Off',
				'fas fa-file' => 'File',
				'far fa-file' => 'File Outline',
				'fas fa-file-alt' => 'File Alt',
				'far fa-file-alt' => 'File Alt Outline',
				'fas fa-file-image' => 'File Image',
				'far fa-file-image' => 'File Image Outline',
				'fas fa-file-video' => 'File Video',
				'far fa-file-video' => 'File Video Outline',
				'fas fa-file-audio' => 'File Audio',
				'far fa-file-audio' => 'File Audio Outline',
				'fas fa-file-pdf' => 'File PDF',
				'far fa-file-pdf' => 'File PDF Outline',
				'fas fa-file-word' => 'File Word',
				'far fa-file-word' => 'File Word Outline',
				'fas fa-file-excel' => 'File Excel',
				'far fa-file-excel' => 'File Excel Outline',
				'fas fa-file-powerpoint' => 'File PowerPoint',
				'far fa-file-powerpoint' => 'File PowerPoint Outline',
				'fas fa-file-archive' => 'File Archive',
				'far fa-file-archive' => 'File Archive Outline',
				'fas fa-download' => 'Download',
				'fas fa-upload' => 'Upload',
				'fas fa-cloud-download-alt' => 'Cloud Download',
				'fas fa-cloud-upload-alt' => 'Cloud Upload',
				'fas fa-folder' => 'Folder',
				'far fa-folder' => 'Folder Outline',
				'fas fa-folder-open' => 'Folder Open',
				'far fa-folder-open' => 'Folder Open Outline',
			),
			'User & People' => array(
				'fas fa-user' => 'User',
				'far fa-user' => 'User Outline',
				'fas fa-user-circle' => 'User Circle',
				'far fa-user-circle' => 'User Circle Outline',
				'fas fa-user-plus' => 'User Plus',
				'fas fa-user-minus' => 'User Minus',
				'fas fa-user-times' => 'User Times',
				'fas fa-user-check' => 'User Check',
				'fas fa-users' => 'Users',
				'fas fa-user-friends' => 'User Friends',
				'fas fa-user-tie' => 'User Tie',
				'fas fa-user-tag' => 'User Tag',
				'fas fa-user-edit' => 'User Edit',
				'fas fa-user-cog' => 'User Settings',
				'fas fa-user-shield' => 'User Shield',
				'fas fa-user-lock' => 'User Lock',
				'fas fa-address-book' => 'Address Book',
				'far fa-address-book' => 'Address Book Outline',
				'fas fa-address-card' => 'Address Card',
				'far fa-address-card' => 'Address Card Outline',
				'fas fa-id-card' => 'ID Card',
				'far fa-id-card' => 'ID Card Outline',
				'fas fa-id-badge' => 'ID Badge',
				'far fa-id-badge' => 'ID Badge Outline',
			),
			'Business & Office' => array(
				'fas fa-briefcase' => 'Briefcase',
				'fas fa-building' => 'Building',
				'far fa-building' => 'Building Outline',
				'fas fa-chart-bar' => 'Chart Bar',
				'far fa-chart-bar' => 'Chart Bar Outline',
				'fas fa-chart-line' => 'Chart Line',
				'fas fa-chart-pie' => 'Chart Pie',
				'fas fa-chart-area' => 'Chart Area',
				'fas fa-clipboard' => 'Clipboard',
				'far fa-clipboard' => 'Clipboard Outline',
				'fas fa-clipboard-list' => 'Clipboard List',
				'fas fa-clipboard-check' => 'Clipboard Check',
				'fas fa-tasks' => 'Tasks',
				'fas fa-project-diagram' => 'Project Diagram',
				'fas fa-sitemap' => 'Sitemap',
				'fas fa-calendar' => 'Calendar',
				'far fa-calendar' => 'Calendar Outline',
				'fas fa-calendar-alt' => 'Calendar Alt',
				'far fa-calendar-alt' => 'Calendar Alt Outline',
				'fas fa-calendar-check' => 'Calendar Check',
				'far fa-calendar-check' => 'Calendar Check Outline',
				'fas fa-calendar-plus' => 'Calendar Plus',
				'far fa-calendar-plus' => 'Calendar Plus Outline',
				'fas fa-calendar-minus' => 'Calendar Minus',
				'far fa-calendar-minus' => 'Calendar Minus Outline',
				'fas fa-clock' => 'Clock',
				'far fa-clock' => 'Clock Outline',
				'fas fa-stopwatch' => 'Stopwatch',
				'fas fa-hourglass' => 'Hourglass',
				'far fa-hourglass' => 'Hourglass Outline',
				'fas fa-hourglass-start' => 'Hourglass Start',
				'fas fa-hourglass-half' => 'Hourglass Half',
				'fas fa-hourglass-end' => 'Hourglass End',
			),
			'Technology & Devices' => array(
				'fas fa-laptop' => 'Laptop',
				'fas fa-desktop' => 'Desktop',
				'fas fa-tablet-alt' => 'Tablet',
				'fas fa-mobile-alt' => 'Mobile',
				'fas fa-tv' => 'TV',
				'fas fa-keyboard' => 'Keyboard',
				'far fa-keyboard' => 'Keyboard Outline',
				'fas fa-mouse' => 'Mouse',
				'fas fa-headphones' => 'Headphones',
				'fas fa-headset' => 'Headset',
				'fas fa-microphone' => 'Microphone',
				'fas fa-microphone-slash' => 'Microphone Slash',
				'fas fa-wifi' => 'WiFi',
				'fas fa-bluetooth' => 'Bluetooth',
				'fab fa-bluetooth-b' => 'Bluetooth B',
				'fas fa-usb' => 'USB',
				'fas fa-plug' => 'Plug',
				'fas fa-battery-full' => 'Battery Full',
				'fas fa-battery-three-quarters' => 'Battery 3/4',
				'fas fa-battery-half' => 'Battery Half',
				'fas fa-battery-quarter' => 'Battery Quarter',
				'fas fa-battery-empty' => 'Battery Empty',
				'fas fa-print' => 'Print',
				'fas fa-fax' => 'Fax',
				'fas fa-scanner' => 'Scanner',
			),
			'Transportation' => array(
				'fas fa-car' => 'Car',
				'fas fa-car-alt' => 'Car Alt',
				'fas fa-taxi' => 'Taxi',
				'fas fa-bus' => 'Bus',
				'fas fa-truck' => 'Truck',
				'fas fa-shipping-fast' => 'Shipping Fast',
				'fas fa-motorcycle' => 'Motorcycle',
				'fas fa-bicycle' => 'Bicycle',
				'fas fa-plane' => 'Plane',
				'fas fa-helicopter' => 'Helicopter',
				'fas fa-rocket' => 'Rocket',
				'fas fa-ship' => 'Ship',
				'fas fa-anchor' => 'Anchor',
				'fas fa-train' => 'Train',
				'fas fa-subway' => 'Subway',
				'fas fa-gas-pump' => 'Gas Pump',
				'fas fa-parking' => 'Parking',
				'fas fa-road' => 'Road',
				'fas fa-route' => 'Route',
				'fas fa-map' => 'Map',
				'far fa-map' => 'Map Outline',
				'fas fa-map-marker-alt' => 'Map Marker',
				'fas fa-map-pin' => 'Map Pin',
				'fas fa-compass' => 'Compass',
				'far fa-compass' => 'Compass Outline',
			),
			'Weather & Nature' => array(
				'fas fa-sun' => 'Sun',
				'far fa-sun' => 'Sun Outline',
				'fas fa-moon' => 'Moon',
				'far fa-moon' => 'Moon Outline',
				'fas fa-cloud' => 'Cloud',
				'fas fa-cloud-rain' => 'Cloud Rain',
				'fas fa-cloud-sun' => 'Cloud Sun',
				'fas fa-cloud-moon' => 'Cloud Moon',
				'fas fa-snowflake' => 'Snowflake',
				'far fa-snowflake' => 'Snowflake Outline',
				'fas fa-bolt' => 'Bolt',
				'fas fa-rainbow' => 'Rainbow',
				'fas fa-umbrella' => 'Umbrella',
				'fas fa-tree' => 'Tree',
				'fas fa-leaf' => 'Leaf',
				'fas fa-seedling' => 'Seedling',
				'fas fa-mountain' => 'Mountain',
				'fas fa-water' => 'Water',
				'fas fa-fire' => 'Fire',
				'fas fa-fire-alt' => 'Fire Alt',
			),
			'Food & Drink' => array(
				'fas fa-utensils' => 'Utensils',
				'fas fa-utensil-spoon' => 'Spoon',
				'fas fa-coffee' => 'Coffee',
				'fas fa-wine-glass' => 'Wine Glass',
				'fas fa-wine-glass-alt' => 'Wine Glass Alt',
				'fas fa-cocktail' => 'Cocktail',
				'fas fa-beer' => 'Beer',
				'fas fa-glass-cheers' => 'Glass Cheers',
				'fas fa-pizza-slice' => 'Pizza Slice',
				'fas fa-hamburger' => 'Hamburger',
				'fas fa-hotdog' => 'Hotdog',
				'fas fa-ice-cream' => 'Ice Cream',
				'fas fa-cookie' => 'Cookie',
				'fas fa-cookie-bite' => 'Cookie Bite',
				'fas fa-birthday-cake' => 'Birthday Cake',
				'fas fa-candy-cane' => 'Candy Cane',
				'fas fa-apple-alt' => 'Apple',
				'fas fa-carrot' => 'Carrot',
				'fas fa-pepper-hot' => 'Pepper Hot',
				'fas fa-fish' => 'Fish',
				'fas fa-egg' => 'Egg',
				'fas fa-cheese' => 'Cheese',
			),
			'Sports & Recreation' => array(
				'fas fa-football-ball' => 'Football',
				'fas fa-basketball-ball' => 'Basketball',
				'fas fa-baseball-ball' => 'Baseball',
				'fas fa-tennis-ball' => 'Tennis Ball',
				'fas fa-volleyball-ball' => 'Volleyball',
				'fas fa-golf-ball' => 'Golf Ball',
				'fas fa-bowling-ball' => 'Bowling Ball',
				'fas fa-table-tennis' => 'Table Tennis',
				'fas fa-hockey-puck' => 'Hockey Puck',
				'fas fa-dumbbell' => 'Dumbbell',
				'fas fa-running' => 'Running',
				'fas fa-walking' => 'Walking',
				'fas fa-biking' => 'Biking',
				'fas fa-swimming-pool' => 'Swimming Pool',
				'fas fa-skiing' => 'Skiing',
				'fas fa-snowboarding' => 'Snowboarding',
				'fas fa-gamepad' => 'Gamepad',
				'fas fa-dice' => 'Dice',
				'fas fa-chess' => 'Chess',
				'fas fa-puzzle-piece' => 'Puzzle Piece',
			),
			'Health & Medical' => array(
				'fas fa-heart' => 'Heart',
				'fas fa-heartbeat' => 'Heartbeat',
				'fas fa-plus-square' => 'Medical Plus',
				'fas fa-user-md' => 'Doctor',
				'fas fa-stethoscope' => 'Stethoscope',
				'fas fa-syringe' => 'Syringe',
				'fas fa-pills' => 'Pills',
				'fas fa-capsules' => 'Capsules',
				'fas fa-prescription-bottle' => 'Prescription Bottle',
				'fas fa-prescription-bottle-alt' => 'Prescription Bottle Alt',
				'fas fa-thermometer' => 'Thermometer',
				'fas fa-band-aid' => 'Band Aid',
				'fas fa-ambulance' => 'Ambulance',
				'fas fa-hospital' => 'Hospital',
				'far fa-hospital' => 'Hospital Outline',
				'fas fa-hospital-alt' => 'Hospital Alt',
				'fas fa-wheelchair' => 'Wheelchair',
				'fas fa-crutch' => 'Crutch',
				'fas fa-tooth' => 'Tooth',
				'fas fa-eye-dropper' => 'Eye Dropper',
			),
			'Security & Safety' => array(
				'fas fa-lock' => 'Lock',
				'fas fa-unlock' => 'Unlock',
				'fas fa-unlock-alt' => 'Unlock Alt',
				'fas fa-key' => 'Key',
				'fas fa-shield-alt' => 'Shield',
				'fas fa-user-shield' => 'User Shield',
				'fas fa-fingerprint' => 'Fingerprint',
				'fas fa-user-secret' => 'User Secret',
				'fas fa-mask' => 'Mask',
				'fas fa-hard-hat' => 'Hard Hat',
				'fas fa-fire-extinguisher' => 'Fire Extinguisher',
				'fas fa-exclamation-triangle' => 'Warning',
				'fas fa-exclamation-circle' => 'Exclamation Circle',
				'fas fa-exclamation' => 'Exclamation',
				'fas fa-question-circle' => 'Question Circle',
				'far fa-question-circle' => 'Question Circle Outline',
				'fas fa-question' => 'Question',
				'fas fa-info-circle' => 'Info Circle',
				'fas fa-info' => 'Info',
			),
		);
	}

	/**
	 * Public method to get FontAwesome icons for external use (like Elementor)
	 */
	public function get_fontawesome_icons_public() {
		return $this->get_fontawesome_icons();
	}

	/**
	 * Add admin menu styles.
	 */
	public function add_admin_menu_styles() {
		?>
		<style>
		#adminmenu .toplevel_page_product-display .wp-menu-image img {
			width: 35px;
			padding: 6px;
			opacity: 0.6;
			/* filter: brightness(0) invert(1); */
			transition: all 0.3s ease;
		}
		
		#adminmenu .toplevel_page_product-display .wp-menu-image {
			display: flex;
			align-items: center;
			justify-content: center;
		}

		#adminmenu .toplevel_page_product-display:hover .wp-menu-image img,
		#adminmenu .toplevel_page_product-display.current .wp-menu-image img {
			opacity: 1;
		}
		</style>
		<?php
	}
}

// Initialize assets class
PRODDISP_Assets::get_instance();

