<?php
/**
 * Context menu settings tab template.
 *
 * @package KooKoa_Folders
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit; }
?>
	<!-- ============================================
		TAB 3: Context Menu
		============================================ -->
	<div class="kookoawpf-tab-panel" data-panel="context-menu" style="display:none;">

		<div class="kookoawpf-settings-section">
			<h2><?php esc_html_e( 'Context Menu', 'kookoa-folders' ); ?></h2>
			<p class="description" style="margin-bottom:20px;">
				<?php esc_html_e( 'Choose which actions appear in the right-click context menu on folders. Disabled actions will be hidden from the menu.', 'kookoa-folders' ); ?>
			</p>

			<div class="kookoawpf-ctx-toggles">
				<?php
				$kookoawpf_ctx_items = array(
					'subfolder'  => array(
						'label' => __( 'New Subfolder', 'kookoa-folders' ),
						'desc'  => __( 'Create a subfolder inside the selected folder.', 'kookoa-folders' ),
						'icon'  => 'plus-alt2',
						'force' => true,
					),
					'rename'     => array(
						'label'     => __( 'Rename', 'kookoa-folders' ),
						'desc'      => __( 'Rename the selected folder.', 'kookoa-folders' ),
						'icon'      => 'edit',
						'force'     => true,
						'sep_after' => true,
					),
					'color'      => array(
						'label' => __( 'Change Color', 'kookoa-folders' ),
						'desc'  => __( 'Change the folder icon color.', 'kookoa-folders' ),
						'icon'  => 'art',
					),
					'icon'       => array(
						'label'     => __( 'Change Icon', 'kookoa-folders' ),
						'desc'      => __( 'Set a custom emoji icon for the folder.', 'kookoa-folders' ),
						'icon'      => 'images-alt2',
						'sep_after' => true,
					),
					'duplicate'  => array(
						'label' => __( 'Duplicate', 'kookoa-folders' ),
						'desc'  => __( 'Create a copy of the folder and its subfolders.', 'kookoa-folders' ),
						'icon'  => 'admin-page',
					),
					'copy'       => array(
						'label'       => __( 'Copy', 'kookoa-folders' ),
						'desc'        => __( 'Copy the folder to clipboard for pasting elsewhere.', 'kookoa-folders' ),
						'icon'        => 'clipboard',
						'default_off' => true,
					),
					'cut'        => array(
						'label'       => __( 'Cut', 'kookoa-folders' ),
						'desc'        => __( 'Cut the folder to clipboard for moving elsewhere.', 'kookoa-folders' ),
						'icon'        => 'migrate',
						'default_off' => true,
					),
					'paste'      => array(
						'label'       => __( 'Paste', 'kookoa-folders' ),
						'desc'        => __( 'Paste the copied or cut folder into the selected folder.', 'kookoa-folders' ),
						'icon'        => 'download',
						'default_off' => true,
						'sep_after'   => true,
					),
					'move'       => array(
						'label'     => __( 'Move Folder', 'kookoa-folders' ),
						'desc'      => __( 'Reorder or move the folder to a different parent.', 'kookoa-folders' ),
						'icon'      => 'move',
						'sep_after' => true,
					),
					'pin'        => array(
						'label' => __( 'Pin / Unpin', 'kookoa-folders' ),
						'desc'  => __( 'Pin the folder to the top of its siblings.', 'kookoa-folders' ),
						'icon'  => 'star-empty',
						'note'  => __( 'Also hides Pin from the folder bulk toolbar.', 'kookoa-folders' ),
					),
					'lock'       => array(
						'label' => __( 'Lock / Unlock', 'kookoa-folders' ),
						'desc'  => __( 'Prevent the folder from being moved or deleted.', 'kookoa-folders' ),
						'icon'  => 'lock',
						'note'  => __( 'Also hides Lock from the folder bulk toolbar.', 'kookoa-folders' ),
					),
					'download'   => array(
						'label' => __( 'Download ZIP', 'kookoa-folders' ),
						'desc'  => __( 'Download all media files in the folder as a ZIP archive. Only available for Media folders.', 'kookoa-folders' ),
						'icon'  => 'download',
					),
					'edit-rules' => array(
						'label' => __( 'Edit Rules', 'kookoa-folders' ),
						'desc'  => __( 'Edit the filter rules of a Smart Folder.', 'kookoa-folders' ),
						'icon'  => 'admin-generic',
					),
					'delete'     => array(
						'label' => __( 'Delete', 'kookoa-folders' ),
						'desc'  => __( 'Delete the selected folder. Items inside are not deleted.', 'kookoa-folders' ),
						'icon'  => 'trash',
						'force' => true,
					),
				);

				/**
				 * Extension point: companion plugins can insert their own
				 * context-menu toggles (Download ZIP, Edit Rules, ...) into
				 * this list. Items are keyed by action slug.
				 */
				$kookoawpf_ctx_items = apply_filters( 'kookoawpf_ctx_items', $kookoawpf_ctx_items );

				foreach ( $kookoawpf_ctx_items as $kookoawpf_key => $kookoawpf_item ) :
					$kookoawpf_is_forced  = ! empty( $kookoawpf_item['force'] );
					$kookoawpf_is_enabled = $kookoawpf_is_forced || ! in_array( $kookoawpf_key, $kookoawpf_ctx_disabled, true );
					?>
					<div class="kookoawpf-ctx-toggle-row<?php echo esc_attr( $kookoawpf_is_forced ? ' kookoawpf-ctx-forced' : '' ); ?>">
						<div class="kookoawpf-ctx-toggle-info">
							<span class="dashicons dashicons-<?php echo esc_attr( $kookoawpf_item['icon'] ); ?> kookoawpf-ctx-toggle-icon"></span>
							<div>
								<span class="kookoawpf-ctx-toggle-label"><?php echo esc_html( $kookoawpf_item['label'] ); ?></span>
								<span class="kookoawpf-ctx-toggle-desc"><?php echo esc_html( $kookoawpf_item['desc'] ); ?></span>
								<?php if ( ! empty( $kookoawpf_item['note'] ) ) : ?>
									<span class="kookoawpf-ctx-toggle-note" style="color:#FF9500;display:block;margin-top:4px;font-size:12px;">
										<?php echo esc_html( $kookoawpf_item['note'] ); ?>
									</span>
								<?php endif; ?>
							</div>
						</div>
						<label class="kookoawpf-toggle-switch<?php echo esc_attr( $kookoawpf_is_forced ? ' kookoawpf-toggle-forced' : '' ); ?>">
							<input type="checkbox" name="kookoawpf_ctx[]" value="<?php echo esc_attr( $kookoawpf_key ); ?>"
								<?php checked( $kookoawpf_is_enabled ); ?>
								<?php disabled( $kookoawpf_is_forced ); ?>>
							<span class="kookoawpf-toggle-slider"></span>
						</label>
					</div>
					<?php if ( ! empty( $kookoawpf_item['sep_after'] ) ) : ?>
						<div class="kookoawpf-ctx-toggle-sep"></div>
					<?php endif; ?>
				<?php endforeach; ?>
			</div>
		</div>

		<p>
			<button type="button" id="kookoawpf-save-ctx-settings" class="button button-primary kookoawpf-btn-save">
				<?php esc_html_e( 'Save Settings', 'kookoa-folders' ); ?>
			</button>
		</p>

	</div>
