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

if ( ! defined( 'ABSPATH' ) ) {
	die;
}

// This file returns an array of metabox definitions.
return [
	'event_single_metabox' => [
		'title'     => esc_html__( 'Event Details', 'sifency-addons' ),
		'post_type' => 'event',
		'context'   => 'normal',
		'priority'  => 'high',
		'class'     => 'sifency-metabox',
		'fields'    => [
			[
				'id'      => 'meta_event_single_type',
				'type'    => 'button_set',
				'title'   => esc_html__( 'Single Page Layout', 'sifency-addons' ),
				'desc'    => esc_html__( 'Choose between the default theme layout or a custom Elementor template.', 'sifency-addons' ),
				'options' => [
					'default' => esc_html__( 'Theme Default', 'sifency-addons' ),
					'custom'  => esc_html__( 'Custom Template', 'sifency-addons' ),
				],
				'default' => 'default',
			],
			[
				'id'         => 'meta_event_single_style',
				'type'       => 'select',
				'title'      => esc_html__( 'Select Custom Template', 'sifency-addons' ),
				'options'    => 'Sifency_Plugin_Helper::get_event_single_types',
				'dependency' => [ 'meta_event_single_type', '==', 'custom' ],
			],
			[
				'id'    => 'event_start_date',
				'type'  => 'date',
				'title' => esc_html__( 'Event Start Date', 'sifency-addons' ),
			],
			[
				'id'    => 'event_end_date',
				'type'  => 'date',
				'title' => esc_html__( 'Event End Date', 'sifency-addons' ),
			],
			[
				'id'         => 'event_start_time',
				'type'       => 'time', // Using the new HTML5 time type for a better UX.
				'title'      => esc_html__( 'Start Time', 'sifency-addons' ),
				'desc'       => esc_html__( 'e.g. 09:00 AM', 'sifency-addons' ),
				'attributes' => [ 'placeholder' => '09:00' ],
			],
			[
				'id'         => 'event_end_time',
				'type'       => 'time', // Using the new HTML5 time type.
				'title'      => esc_html__( 'End Time', 'sifency-addons' ),
				'desc'       => esc_html__( 'e.g. 05:00 PM', 'sifency-addons' ),
				'attributes' => [ 'placeholder' => '17:00' ],
			],
			[
				'id'         => 'event_location',
				'type'       => 'text',
				'title'      => esc_html__( 'Event Location', 'sifency-addons' ),
				'attributes' => [ 'placeholder' => esc_html__( 'Venue name or address', 'sifency-addons' ) ],
			],
			[
				'id'       => 'event_map_embed',
				'type'     => 'textarea',
				'title'    => esc_html__( 'Google Map Embed Code', 'sifency-addons' ),
				'desc'     => esc_html__( 'Paste iframe embed code from Google Maps.', 'sifency-addons' ),
				'sanitize' => 'allow_iframe', // Custom sanitization rule we will add to the framework.
			],
			[
				'id'    => 'event_organizer_name',
				'type'  => 'text',
				'title' => esc_html__( 'Organizer Name', 'sifency-addons' ),
			],
			[
				'id'    => 'event_organizer_email',
				'type'  => 'email', // Correct type for email validation.
				'title' => esc_html__( 'Organizer Email', 'sifency-addons' ),
			],
			[
				'id'    => 'event_organizer_phone',
				'type'  => 'text',
				'title' => esc_html__( 'Organizer Phone', 'sifency-addons' ),
			],
			[
				'id'         => 'event_ticket_price',
				'type'       => 'text',
				'title'      => esc_html__( 'Ticket Price', 'sifency-addons' ),
				'desc'       => esc_html__( 'Example: $25.00 or Free', 'sifency-addons' ),
				'attributes' => [ 'placeholder' => '$0.00' ],
			],
			[
				'id'    => 'event_ticket_link',
				'type'  => 'url', // Correct type for URL validation.
				'title' => esc_html__( 'Ticket Booking URL', 'sifency-addons' ),
			],
			[
				'id'      => 'event_status',
				'type'    => 'button_set',
				'title'   => esc_html__( 'Event Status', 'sifency-addons' ),
				'options' => [
					'upcoming' => esc_html__( 'Upcoming', 'sifency-addons' ),
					'ongoing'  => esc_html__( 'Ongoing', 'sifency-addons' ),
					'past'     => esc_html__( 'Past', 'sifency-addons' ),
					'canceled' => esc_html__( 'Canceled', 'sifency-addons' ),
				],
				'default' => 'upcoming',
			],
			[
				'id'      => 'event_button_text',
				'type'    => 'text',
				'title'   => esc_html__( 'Custom Button Text', 'sifency-addons' ),
				'default' => esc_html__( 'Join Event', 'sifency-addons' ),
			],
			[
				'id'    => 'event_featured_image',
				'type'  => 'media',
				'title' => esc_html__( 'Event Banner Image', 'sifency-addons' ),
				'desc'  => esc_html__( 'Recommended size: 1200x600px', 'sifency-addons' ),
			],
			[
				'id'       => 'event_additional_notes',
				'type'     => 'textarea',
				'title'    => esc_html__( 'Additional Notes', 'sifency-addons' ),
				'sanitize' => 'wp_kses_post', // Sanitization rule for rich text.
			],
		],
	],
];