<?php
/**
 * Pro Features Visibility
 *
 * @package DokanKits\Features\Product
 */

namespace DokanKits\Features\Product;

/**
 * Pro Features Visibility
 *
 * Controls the visibility of Dokan Pro features in the product edit form.
 * This feature allows site administrators to hide specific Pro features
 * from vendors to simplify the product editing experience.
 *
 * @since   3.0.0
 * @package DokanKits\Features\Product
 */
class ProductProFields extends ProductFields {

	/**
	 * Feature settings section within the group
	 *
	 * @since 3.0.0
	 * @var string
	 */
	protected string $settings_section = 'pro_features';

	/**
	 * Pro fields configuration with option keys and selectors
	 *
	 * @since 3.0.0
	 * @var array
	 */
	protected array $fields = array(
		'bulk_discount'         => array(
			'option'   => 'remove_bulk_discount_checkbox',
			'selector' => '.dokan-discount-options',
		),
		'rma'                   => array(
			'option'   => 'remove_rma_checkbox',
			'selector' => '.dokan-rma-options',
		),
		'wholesale'             => array(
			'option'   => 'remove_wholesale_checkbox',
			'selector' => '.dokan-wholesale-options',
		),
		'min_max_product'       => array(
			'option'   => 'remove_min_max_product_checkbox',
			'selector' => '.dokan-order-min-max-product-metabox-wrapper',
		),
		'product_advertisement' => array(
			'option'   => 'remove_product_advertisement_checkbox',
			'selector' => '.dokan-product-advertisement',
		),
		'seo'                   => array(
			'option'   => 'remove_seo_checkbox',
			'selector' => '.dokan-seo-options',
		),
		'product_addon'         => array(
			'option'   => 'remove_product_addon_checkbox',
			'selector' => '.dokan-product-addon',
		),
	);

	/**
	 * Generate CSS to hide selected pro features
	 *
	 * Creates CSS rules to hide the pro features that have been selected for removal
	 * in the settings.
	 *
	 * @since 3.0.0
	 * @return string CSS rules.
	 */
	protected function get_field_css(): string {
		$css = '';

		foreach ( $this->fields as $field ) {
			if ( $this->is_field_hidden( $field['option'] ) ) {
				$css .= '.dokan-product-edit-form ' . esc_attr( $field['selector'] ) . " { display: none !important; }\n";
			}
		}

		return $css;
	}
}
