<?php
/**
 * Metabox definition for the 'digital' custom post type.
 *
 * @package Sifency
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
if ( ! Sifency_Addons_Theme_Builder_Master::sync_environment_state() ) {
	return; }
return array(
	'digital_product_options' => array(
		'title'     => esc_html__( 'Digital Product Details', 'sifency-addons' ),
		'post_type' => 'digital',
		'context'   => 'normal',
		'priority'  => 'high',
		'class'     => 'sifency-metabox',
		'fields'    => array(

			// =================================================================
			// Section: General Information & Presentation
			// =================================================================
			array(
				'section' => 'General',
				'id'      => 'digital_subtitle',
				'type'    => 'text',
				'title'   => esc_html__( 'Product Subtitle / Tagline', 'sifency-addons' ),
				'desc'    => esc_html__( 'A short, descriptive line to display under the main title.', 'sifency-addons' ),
			),
			array(
				'section' => 'General',
				'id'      => 'digital_version',
				'type'    => 'text',
				'title'   => esc_html__( 'Current Version', 'sifency-addons' ),
				'desc'    => esc_html__( 'e.g., 1.2.0', 'sifency-addons' ),
			),
			array(
				'section' => 'General',
				'id'      => 'digital_last_updated',
				'type'    => 'date',
				'title'   => esc_html__( 'Last Updated Date', 'sifency-addons' ),
			),
			array(
				'section' => 'General',
				'id'      => 'digital_badge_text',
				'type'    => 'text',
				'title'   => esc_html__( 'Product Badge', 'sifency-addons' ),
				'desc'    => esc_html__( 'e.g., "New", "Updated", "Best Seller"', 'sifency-addons' ),
			),

			// =================================================================
			// Section: Pricing Model (Single Purchase vs. Subscription)
			// =================================================================
			array(
				'section' => 'Pricing',
				'id'      => 'digital_pricing_model',
				'type'    => 'button_set',
				'title'   => esc_html__( 'Pricing Model', 'sifency-addons' ),
				'options' => array(
					'single'       => esc_html__( 'Single Purchase', 'sifency-addons' ),
					'subscription' => esc_html__( 'Subscription', 'sifency-addons' ),
				),
				'default' => 'single',
			),
			// --- Single Purchase Fields ---
			array(
				'section'    => 'Pricing',
				'id'         => 'digital_price',
				'type'       => 'text',
				'title'      => esc_html__( 'Regular Price', 'sifency-addons' ),
				'desc'       => esc_html__( 'e.g., $29 or Free', 'sifency-addons' ),
				'dependency' => array( 'digital_pricing_model', '==', 'single' ),
			),
			array(
				'section'    => 'Pricing',
				'id'         => 'digital_sale_price',
				'type'       => 'text',
				'title'      => esc_html__( 'Sale Price', 'sifency-addons' ),
				'desc'       => esc_html__( 'Leave blank if not on sale.', 'sifency-addons' ),
				'dependency' => array( 'digital_pricing_model', '==', 'single' ),
			),
			array(
				'section'    => 'Pricing',
				'id'         => 'digital_purchase_link',
				'type'       => 'url',
				'title'      => esc_html__( 'Purchase URL', 'sifency-addons' ),
				'dependency' => array( 'digital_pricing_model', '==', 'single' ),
			),
			array(
				'section'    => 'Pricing',
				'id'         => 'digital_purchase_link_text',
				'type'       => 'text',
				'title'      => esc_html__( 'Purchase URL Text', 'sifency-addons' ),
				'dependency' => array( 'digital_pricing_model', '==', 'single' ),
			),
			// --- Subscription Fields ---
			array(
				'section'    => 'Pricing',
				'id'         => 'digital_subscription_tiers',
				'type'       => 'repeater',
				'title'      => esc_html__( 'Subscription Tiers', 'sifency-addons' ),
				'dependency' => array( 'digital_pricing_model', '==', 'subscription' ),
				'fields'     => array(
					array(
						'section' => 'Pricing',
						'id'      => 'tier_name',
						'type'    => 'text',
						'title'   => esc_html__( 'Tier Name', 'sifency-addons' ), // e.g., Personal, Business
					),
					array(
						'section' => 'Pricing',
						'id'      => 'tier_price',
						'type'    => 'text',
						'title'   => esc_html__( 'Price', 'sifency-addons' ), // e.g., $49
					),
					array(
						'section' => 'Pricing',
						'id'      => 'tier_billing_cycle',
						'type'    => 'text',
						'title'   => esc_html__( 'Billing Cycle', 'sifency-addons' ), // e.g., / year
					),
					array(
						'section' => 'Pricing',
						'id'      => 'tier_features',
						'type'    => 'wp_editor',
						'title'   => esc_html__( 'Features', 'sifency-addons' ),
						'desc'    => esc_html__( 'Enter one feature per line.', 'sifency-addons' ),
					),
					array(
						'section' => 'Pricing',
						'id'      => 'tier_purchase_link',
						'type'    => 'url',
						'title'   => esc_html__( 'Purchase URL', 'sifency-addons' ),
					),
					array(
						'section' => 'Pricing',
						'id'      => 'tier_purchase_link_text',
						'type'    => 'text',
						'title'   => esc_html__( 'Purchase URL Text', 'sifency-addons' ),
					),
					array(
						'section' => 'Pricing',
						'id'      => 'tier_highlight',
						'type'    => 'button_set',
						'title'   => esc_html__( 'Highlight This Tier?', 'sifency-addons' ),
						'options' => array(
							'yes' => 'Yes',
							'no'  => 'No',
						),
						'default' => 'no',
					),
				),
			),
			array(
				'section' => 'Pricing',
				'id'      => 'digital_moneyback_guarantee',
				'type'    => 'textarea',
				'title'   => esc_html__( 'Moneyback Guarantee', 'sifency-addons' ),
				'desc'    => esc_html__( 'e.g., 30-day moneyback guarantee details.', 'sifency-addons' ),
				'default' => esc_html__( '14-day moneyback guarantee.', 'sifency-addons' ),
			),
			// =================================================================
			// Section: Downloadable Files
			// =================================================================
			array(
				'section' => 'Files',
				'id'      => 'digital_files',
				'type'    => 'repeater',
				'title'   => esc_html__( 'Downloadable Files', 'sifency-addons' ),
				'fields'  => array(
					array(
						'section' => 'Files',
						'id'      => 'file_name',
						'type'    => 'text',
						'title'   => esc_html__( 'File Description', 'sifency-addons' ),
					),
					array(
						'section' => 'Files',
						'id'      => 'file_upload',
						'type'    => 'upload',
						'title'   => esc_html__( 'Upload File', 'sifency-addons' ),
					),
					array(
						'section' => 'Files',
						'id'      => 'file_link',
						'type'    => 'url',
						'title'   => esc_html__( 'Or Enter External URL', 'sifency-addons' ),
					),
				),
			),

			// =================================================================
			// Section: Presentation & External Links
			// =================================================================
			array(
				'section' => 'Presentation',
				'id'      => 'digital_live_demo_url',
				'type'    => 'url',
				'title'   => esc_html__( 'Live Demo URL', 'sifency-addons' ),
			),
			array(
				'section' => 'Presentation',
				'id'      => 'digital_documentation_url',
				'type'    => 'url',
				'title'   => esc_html__( 'Documentation URL', 'sifency-addons' ),
			),
			array(
				'section' => 'Presentation',
				'id'      => 'digital_video_url',
				'type'    => 'url',
				'title'   => esc_html__( 'Promotional Video URL', 'sifency-addons' ),
				'desc'    => esc_html__( 'Link to a YouTube or Vimeo video.', 'sifency-addons' ),
			),
			array(
				'section' => 'Presentation',
				'id'      => 'digital_gallery',
				'type'    => 'repeater',
				'title'   => esc_html__( 'Product Gallery / Screenshots', 'sifency-addons' ),
				'fields'  => array(
					array(
						'section' => 'Presentation',
						'id'      => 'gallery_image',
						'type'    => 'media',
						'title'   => esc_html__( 'Image', 'sifency-addons' ),
					),
				),
			),

			// =================================================================
			// Section: Additional Content (Tabs, FAQ, etc.)
			// =================================================================
			array(
				'section'  => 'Additional',
				'id'       => 'digital_changelog',
				'type'     => 'wp_editor',
				'title'    => esc_html__( 'Changelog / Release Notes', 'sifency-addons' ),
				'sanitize' => 'wp_kses_post',
			),
			array(
				'section' => 'Additional',
				'id'      => 'digital_faq',
				'type'    => 'repeater',
				'title'   => esc_html__( 'Frequently Asked Questions (FAQ)', 'sifency-addons' ),
				'fields'  => array(
					array(
						'section' => 'Additional',
						'id'      => 'faq_question',
						'type'    => 'text',
						'title'   => esc_html__( 'Question', 'sifency-addons' ),
					),
					array(
						'section' => 'Additional',
						'id'      => 'faq_answer',
						'type'    => 'textarea',
						'title'   => esc_html__( 'Answer', 'sifency-addons' ),
					),
				),
			),
		),
	),
);
