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

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

// This file returns an array of metabox definitions.
return array(
	'event_single_metabox' => array(
		'title'     => esc_html__( 'Event Details', 'sifency-addons' ),
		'post_type' => 'event',
		'context'   => 'normal',
		'priority'  => 'high',
		'class'     => 'sifency-metabox',
		'fields'    => array(

			// =================================================================
			// Section: Schedule & Status
			// =================================================================
			array(
				'section' => 'Schedule',
				'id'      => 'event_status',
				'type'    => 'button_set',
				'title'   => esc_html__( 'Event Status', 'sifency-addons' ),
				'options' => array(
					'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',
			),
			array(
				'section' => 'Schedule',
				'id'      => 'event_start_date',
				'type'    => 'date',
				'title'   => esc_html__( 'Event Start Date', 'sifency-addons' ),
			),
			array(
				'section' => 'Schedule',
				'id'      => 'event_end_date',
				'type'    => 'date',
				'title'   => esc_html__( 'Event End Date', 'sifency-addons' ),
			),
			array(
				'section'    => 'Schedule',
				'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' => array( 'placeholder' => '09:00' ),
			),
			array(
				'section'    => 'Schedule',
				'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' => array( 'placeholder' => '17:00' ),
			),

			// =================================================================
			// Section: Location Details
			// =================================================================
			array(
				'section'    => 'Location',
				'id'         => 'event_location',
				'type'       => 'text',
				'title'      => esc_html__( 'Event Location', 'sifency-addons' ),
				'attributes' => array( 'placeholder' => esc_html__( 'Venue name or address', 'sifency-addons' ) ),
			),
			array(
				'section'  => 'Location',
				'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.
			),

			// =================================================================
			// Section: Organizer Information
			// =================================================================
			array(
				'section' => 'Organizer',
				'id'      => 'event_organizer_name',
				'type'    => 'text',
				'title'   => esc_html__( 'Organizer Name', 'sifency-addons' ),
			),
			array(
				'section' => 'Organizer',
				'id'      => 'event_organizer_email',
				'type'    => 'email', // Correct type for email validation.
				'title'   => esc_html__( 'Organizer Email', 'sifency-addons' ),
			),
			array(
				'section' => 'Organizer',
				'id'      => 'event_organizer_phone',
				'type'    => 'text',
				'title'   => esc_html__( 'Organizer Phone', 'sifency-addons' ),
			),

			// =================================================================
			// Section: Tickets & Actions
			// =================================================================
			array(
				'section'    => 'Tickets',
				'id'         => 'event_ticket_price',
				'type'       => 'text',
				'title'      => esc_html__( 'Ticket Price', 'sifency-addons' ),
				'desc'       => esc_html__( 'Example: $25.00 or Free', 'sifency-addons' ),
				'attributes' => array( 'placeholder' => '$0.00' ),
			),
			array(
				'section' => 'Tickets',
				'id'      => 'event_ticket_link',
				'type'    => 'url', // Correct type for URL validation.
				'title'   => esc_html__( 'Ticket Booking URL', 'sifency-addons' ),
			),
			array(
				'section' => 'Tickets',
				'id'      => 'event_button_text',
				'type'    => 'text',
				'title'   => esc_html__( 'Custom Button Text', 'sifency-addons' ),
				'default' => esc_html__( 'Join Event', 'sifency-addons' ),
			),

			// =================================================================
			// Section: Media & Notes
			// =================================================================
			array(
				'section' => 'Media',
				'id'      => 'event_featured_image',
				'type'    => 'media',
				'title'   => esc_html__( 'Event Banner Image', 'sifency-addons' ),
				'desc'    => esc_html__( 'Recommended size: 1200x600px', 'sifency-addons' ),
			),
			array(
				'section'  => 'Media',
				'id'       => 'event_additional_notes',
				'type'     => 'textarea',
				'title'    => esc_html__( 'Additional Notes', 'sifency-addons' ),
				'sanitize' => 'wp_kses_post', // Sanitization rule for rich text.
			),
		),
	),
);
