<?php
/**
 * Mapping Shell - Reusable partial for all export types.
 * Includes left panel (file fields) and right panel (mapping) structure.
 *
 * @package PrimeLink
 */

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

/**
 * Variables expected:
 * - $export_id: Export ID
 * - $wc_fields: Array of WooCommerce fields (key => label)
 */
?>

<div class="mt_primelink-step mt_primelink-export-step-2" data-export-id="<?php echo esc_attr( $export_id ); ?>">
    <div class="mt_primelink-mapping-shell">
        <!-- Left panel: file fields -->
        <aside class="mt_primelink-fields-panel">
            <div class="mt_primelink-fields-header">
                <h3><?php esc_html_e( 'File Fields', 'primelink' ); ?></h3>
                <input type="search" id="mt_primelink-field-search" placeholder="<?php esc_attr_e( 'Search field...', 'primelink' ); ?>" />
            </div>
            <div class="mt_primelink-field-list" id="mt-primelink-export-fields">
                <?php if ( ! empty( $wc_fields ) && is_array( $wc_fields ) ) : ?>
                    <?php foreach ( $wc_fields as $key => $label ) : ?>
                        <div class="mt_primelink-file-field" data-field="<?php echo esc_attr( $key ); ?>" draggable="true">
                            <span class="mt_primelink-file-field__name"><?php echo esc_html( $label ); ?></span>
                        </div>
                    <?php endforeach; ?>
                <?php else : ?>
                    <div class="mt_primelink-empty"><?php esc_html_e( 'No fields available.', 'primelink' ); ?></div>
                <?php endif; ?>
            </div>
        </aside>

        <!-- Right panel: mapping -->
        <main class="mt_primelink-mapping-main">
            <div class="mt_primelink-template-row mt_primelink-template-row--actions">
                <input type="search" id="mt_primelink-target-search" placeholder="<?php esc_attr_e( 'Search target field...', 'primelink' ); ?>" aria-label="<?php esc_attr_e( 'Search target field', 'primelink' ); ?>">
                <select id="mt_primelink-load-template">
                    <option value=""><?php esc_html_e( 'Load existing template...', 'primelink' ); ?></option>
                </select>
                <button type="button" class="button" id="mt_primelink-load-template-btn"><?php esc_html_e( 'Load', 'primelink' ); ?></button>
                <button type="button" class="button mt_primelink-duplicate-btn" id="mt_primelink-duplicate-template"><?php esc_html_e( 'Duplicate', 'primelink' ); ?></button>
            </div>

            <?php
            // Include alias card (with customizable hint)
            $alias_hint = isset( $alias_hint ) ? $alias_hint : __( 'Add custom synonyms for export columns.', 'primelink' );
            include MT_PRIMELINK_PATH . 'templates/admin/exports/partials/alias-card.php';
            ?>

            <!-- Export Columns Mapping will be included here by each export type -->
