<?php
/**
 * Chat Settings
 *
 * CSF settings section for the chat feature.
 *
 * @package Forumax
 */

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

CSF::createSection(
	$prefix,
	array(
		'id'     => 'chat_opt',
		'title'  => __( 'Chat', 'forumax' ),
		'icon'   => 'dashicons dashicons-format-chat',
		'fields' => array(
			// Main Toggle.
			array(
				'type'    => 'subheading',
				'content' => __( 'Chat System', 'forumax' ),
			),

			array(
				'id'       => 'forumax_chat_enabled',
				'type'     => 'switcher',
				'title'    => __( 'Enable Chat', 'forumax' ),
				'subtitle' => __( 'Enable the private messaging chat system for forum users.', 'forumax' ),
				'default'  => false,
				'class'    => 'st-promax-notice',
			),

			// File Upload Settings.
			array(
				'type'       => 'subheading',
				'content'    => __( 'File Attachments', 'forumax' ),
				'dependency' => array( 'forumax_chat_enabled', '==', true ),
			),

			array(
				'id'         => 'forumax_chat_file_upload',
				'type'       => 'switcher',
				'title'      => __( 'Enable File Uploads', 'forumax' ),
				'subtitle'   => __( 'Allow users to send file attachments in chat.', 'forumax' ),
				'default'    => true,
				'dependency' => array( 'forumax_chat_enabled', '==', true ),
				'class'      => 'st-promax-notice',
			),

			array(
				'id'         => 'forumax_chat_max_file_size',
				'type'       => 'slider',
				'title'      => __( 'Max File Size', 'forumax' ),
				'subtitle'   => __( 'Define the maximum allowed file size (in Megabytes) for each individual uploaded chat attachment.', 'forumax' ),
				'unit'       => 'MB',
				'min'        => 1,
				'max'        => 20,
				'step'       => 1,
				'default'    => 5,
				'dependency' => array(
					array( 'forumax_chat_enabled', '==', true ),
					array( 'forumax_chat_file_upload', '==', true ),
				),
				'class'      => 'st-promax-notice',
			),

			array(
				'id'         => 'forumax_chat_allowed_file_types',
				'type'       => 'checkbox',
				'title'      => __( 'Allowed File Types', 'forumax' ),
				'subtitle'   => __( 'Specify which file formats users are permitted to upload and share within the chat interface.', 'forumax' ),
				'inline'     => true,
				'options'    => array(
					'jpg'  => __( 'JPG', 'forumax' ),
					'jpeg' => __( 'JPEG', 'forumax' ),
					'png'  => __( 'PNG', 'forumax' ),
					'gif'  => __( 'GIF', 'forumax' ),
					'webp' => __( 'WebP', 'forumax' ),
					'pdf'  => __( 'PDF', 'forumax' ),
					'doc'  => __( 'DOC', 'forumax' ),
					'docx' => __( 'DOCX', 'forumax' ),
					'zip'  => __( 'ZIP', 'forumax' ),
					'mp4'  => __( 'MP4', 'forumax' ),
					'webm' => __( 'WebM', 'forumax' ),
				),
				'default'    => array( 'jpg', 'jpeg', 'png', 'gif', 'webp', 'pdf', 'doc', 'docx', 'zip', 'mp4', 'webm' ),
				'dependency' => array(
					array( 'forumax_chat_enabled', '==', true ),
					array( 'forumax_chat_file_upload', '==', true ),
				),
				'class'      => 'st-promax-notice',
			),

			// Emoji Settings.
			array(
				'type'       => 'subheading',
				'content'    => __( 'Emoji', 'forumax' ),
				'dependency' => array( 'forumax_chat_enabled', '==', true ),
			),

			array(
				'id'         => 'forumax_chat_emoji',
				'type'       => 'switcher',
				'title'      => __( 'Enable Emoji Picker', 'forumax' ),
				'subtitle'   => __( 'Enable the emoji picker icon in the chat input area, allowing users to search and seamlessly insert emojis.', 'forumax' ),
				'default'    => true,
				'dependency' => array( 'forumax_chat_enabled', '==', true ),
				'class'      => 'st-promax-notice',
			),

			// Notification Settings.
			array(
				'type'       => 'subheading',
				'content'    => __( 'Notifications', 'forumax' ),
				'dependency' => array( 'forumax_chat_enabled', '==', true ),
			),

			array(
				'id'         => 'forumax_chat_sound_enabled',
				'type'       => 'switcher',
				'title'      => __( 'Enable Notification Sound', 'forumax' ),
				'subtitle'   => __( 'When enabled, plays a ring notification sound alert whenever a new real-time message is received in an active conversation.', 'forumax' ),
				'desc'       => __( 'When enabled, plays a ring notification sound alert whenever a new real-time message is received in an active conversation.', 'forumax' ),
				'default'    => true,
				'dependency' => array( 'forumax_chat_enabled', '==', true ),
				'class'      => 'st-promax-notice',
			),

			// UI Settings.
			array(
				'type'       => 'subheading',
				'content'    => __( 'Appearance', 'forumax' ),
				'dependency' => array( 'forumax_chat_enabled', '==', true ),
			),

			array(
				'id'               => 'forumax_chat_user_bubble_color',
				'type'             => 'color',
				'title'            => __( 'User Message Bubble Background', 'forumax' ),
				'subtitle'         => __( 'Choose the background color for messages sent by the currently logged-in user (these appear on the right side of the chat interface).', 'forumax' ),
				'default'          => '#4c4cf1',
				'output'           => ':root',
				'output_mode'      => '--forumax-chat-bubble-user',
				'output_important' => true,
				'dependency'       => array( 'forumax_chat_enabled', '==', true ),
				'class'            => 'st-promax-notice',
			),

			array(
				'id'               => 'forumax_chat_other_bubble_color',
				'type'             => 'color',
				'title'            => __( 'Other User Message Bubble Background', 'forumax' ),
				'subtitle'         => __( 'Choose the background color for incoming messages received from the person you are chatting with (these appear on the left side of the chat interface).', 'forumax' ),
				'default'          => '#eeeeee',
				'output'           => ':root',
				'output_mode'      => '--forumax-chat-bubble-other',
				'output_important' => true,
				'dependency'       => array( 'forumax_chat_enabled', '==', true ),
				'class'            => 'st-promax-notice',
			),

			// Chat Assistants Settings.
			array(
				'type'       => 'subheading',
				'content'    => __( 'Chat Assistants', 'forumax' ),
				'dependency' => array( 'forumax_chat_enabled', '==', true ),
			),

			array(
				'id'         => 'forumax_chat_assistants_enabled',
				'type'       => 'switcher',
				'title'      => __( 'Enable Chat Assistants', 'forumax' ),
				'subtitle'   => __( 'Allow designated moderators/keymasters to reply to any user in chat. These users will appear in the conversations list for everyone.', 'forumax' ),
				'default'    => false,
				'dependency' => array( 'forumax_chat_enabled', '==', true ),
				'class'      => 'st-promax-notice',
			),

			array(
				'id'          => 'forumax_chat_assistants',
				'type'        => 'select',
				'title'       => __( 'Select Assistants', 'forumax' ),
				'subtitle'    => __( 'Select users who can assist anyone in chat. Only moderators and keymasters are shown.', 'forumax' ),
				'placeholder' => __( 'Select assistants...', 'forumax' ),
				'options'     => 'frmx_get_moderator_users',
				'multiple'    => true,
				'chosen'      => true,
				'dependency'  => array(
					array( 'forumax_chat_enabled', '==', true ),
					array( 'forumax_chat_assistants_enabled', '==', true ),
				),
				'class'       => 'st-promax-notice',
			),

			array(
				'id'         => 'forumax_chat_assistants_label',
				'type'       => 'text',
				'title'      => __( 'Assistants Section Label', 'forumax' ),
				'subtitle'   => __( 'Customize the header text displayed above the dedicated list of active chat assistants (e.g., "Support Team").', 'forumax' ),
				'default'    => __( 'Support Team', 'forumax' ),
				'dependency' => array(
					array( 'forumax_chat_enabled', '==', true ),
					array( 'forumax_chat_assistants_enabled', '==', true ),
				),
				'class'      => 'st-promax-notice',
			),
		),
	)
);
