<?php

/**
 * This template displaying addon items in shop/single product page.
 * This template can be overridden by copying it to yourtheme/eopfw-templates/epofw-addon-table-html.php
 * NOTE, on occasion Extra Product Options for WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @package Extra_Product_Options_For_WooCommerce/Templates
 * @version 4.4.0
 */
defined( 'ABSPATH' ) || exit;
// Get template arguments first.
$epofw_fields_data_arr = ( isset( $args['fields_data_arr'] ) ? $args['fields_data_arr'] : '' );
$epofw_action = ( isset( $args['epofw_action'] ) ? $args['epofw_action'] : '' );
$epofw_fields_general_data_arr = epofw_check_array_key_exists( 'general', $epofw_fields_data_arr );
$epofw_addon_id = ( isset( $epofw_fields_data_arr['epofw_addon_post_id'] ) ? $epofw_fields_data_arr['epofw_addon_post_id'] : '' );
global $product;
$epofw_product_id = $product->get_id();
$epofw_product_data = wc_get_product( $epofw_product_id );
if ( !empty( $epofw_product_data ) ) {
    if ( 'epofw_shop' === $epofw_action ) {
        $epofw_product_price = epofw_display_product_price( $epofw_product_data, 'shop' );
    } else {
        $epofw_product_price = epofw_display_product_price( $epofw_product_data, '' );
    }
}
$epofw_data_prd_attr = '';
if ( 'epofw_shop' === $epofw_action ) {
    $epofw_data_prd_attr = 'data-prd-attr=' . esc_attr( $epofw_product_id ) . '';
}
$epofw_data_unique_div_attr = 'data-uqd-attr=' . esc_attr( 'epofw_uqd_' . wp_rand() ) . '';
// Always use div structure - table structure has been removed.
$epofw_display_style = 'div';
/**
 * Start of table html.
 *
 * @since 2.5
 */
do_action( 'epofw_addon_table_html_start' );
/**
 * Filter addon wrapper CSS class.
 *
 * Allows modules to add custom CSS classes to the main addon wrapper div.
 *
 * @since 4.4.6
 *
 * @param string $wrapper_class   Default wrapper CSS classes.
 * @param array  $fields_data_arr Full addon data array.
 */
$epofw_wrapper_class = apply_filters( 'epofw_addon_wrapper_class', 'epofw_addon_html epofw_addon_str_' . $epofw_display_style . ' ' . $epofw_action, $epofw_fields_data_arr );
/**
 * Filter addon wrapper HTML attributes.
 *
 * Allows modules to add custom data-* attributes to the main addon wrapper div.
 *
 * @since 4.4.6
 *
 * @param array $wrapper_attrs   Array of attribute => value pairs.
 * @param array $fields_data_arr Full addon data array.
 */
$epofw_wrapper_attrs = apply_filters( 'epofw_addon_wrapper_attributes', array(), $epofw_fields_data_arr );
$epofw_wrapper_attrs_str = '';
if ( !empty( $epofw_wrapper_attrs ) && is_array( $epofw_wrapper_attrs ) ) {
    foreach ( $epofw_wrapper_attrs as $epofw_attr_key => $epofw_attr_value ) {
        $epofw_wrapper_attrs_str .= ' ' . esc_attr( $epofw_attr_key ) . '="' . esc_attr( $epofw_attr_value ) . '"';
    }
}
?>
	<div class="<?php 
echo esc_attr( $epofw_wrapper_class );
?>" <?php 
echo esc_attr( $epofw_data_prd_attr );
?> <?php 
echo esc_attr( $epofw_data_unique_div_attr );
echo $epofw_wrapper_attrs_str;
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
?>>
		<?php 
$epofw_additional_rule_datas = array();
$epofw_additional_data = epofw_data_attr_json( $epofw_additional_rule_datas );
// Preserve full addon data for hooks before reassigning.
$epofw_full_addon_data = $epofw_fields_data_arr;
$epofw_fields_data_arr = epofw_check_array_key_exists( 'general', $epofw_fields_data_arr );
$epofw_data_attr = ( isset( $epofw_additional_data['data_attr'] ) ? $epofw_additional_data['data_attr'] : array() );
$epofw_condition_type = ( isset( $epofw_additional_data['condition_type'] ) ? $epofw_additional_data['condition_type'] : '' );
$epofw_should_hide_initially = ( isset( $epofw_additional_data['should_hide_initially'] ) ? $epofw_additional_data['should_hide_initially'] : false );
// Default class for displaying fields.
$epofw_tbl_class = 'epofw_field_dl';
/**
 * Filter for main tag class.
 *
 * @since 1.0.0
 */
$epofw_main_tag_class = apply_filters( 'epofw_html_main_tag_class_display', 'epofw_fields_container epofw_fields_table ' . $epofw_tbl_class, $epofw_fields_data_arr );
// Always use div structure - create main container before sections.
?>
		<div class="<?php 
echo esc_attr( $epofw_main_tag_class );
?>"
		data-prd-type="<?php 
echo esc_attr( $epofw_condition_type );
?>"
		data-epofw_attr="<?php 
echo esc_attr( wc_esc_json( $epofw_data_attr ) );
?>">
			<div class="epofw_middle_tg">
				<?php 
/**
 * Action before sections loop - for tab navigation.
 *
 * Allows modules to render UI elements (like tab navigation) before the sections are rendered.
 *
 * @since 4.4.6
 *
 * @param array $epofw_fields_general_data_arr Sections data array.
 * @param array $epofw_full_addon_data         Full addon data array (includes layout settings).
 */
do_action( 'epofw_before_sections_loop', $epofw_fields_general_data_arr, $epofw_full_addon_data );
if ( !empty( $epofw_fields_general_data_arr ) ) {
    foreach ( $epofw_fields_general_data_arr as $epofw_section_id => $epofw_general_fields_arr ) {
        $epofw_section_title = epofw_check_array_key_exists( 'section_title', $epofw_general_fields_arr );
        $epofw_section_id = epofw_check_array_key_exists( 'section_id', $epofw_general_fields_arr );
        $epofw_section_status = epofw_check_array_key_exists( 'section_status', $epofw_general_fields_arr );
        $epofw_section_order = epofw_check_array_key_exists( 'section_order', $epofw_general_fields_arr );
        $epofw_section_settings = epofw_check_array_key_exists( 'section_settings', $epofw_general_fields_arr );
        // Extract fields from row_groups → columns_groups → rows → fields structure.
        $epofw_addon_fields_data = array();
        $epofw_row_groups_data = epofw_check_array_key_exists( 'row_groups', $epofw_general_fields_arr );
        if ( !empty( $epofw_row_groups_data ) && is_array( $epofw_row_groups_data ) ) {
            foreach ( $epofw_row_groups_data as $epofw_group_id => $epofw_group_data ) {
                if ( isset( $epofw_group_data['columns_groups'] ) && is_array( $epofw_group_data['columns_groups'] ) ) {
                    foreach ( $epofw_group_data['columns_groups'] as $epofw_columns_id => $epofw_columns_data ) {
                        if ( isset( $epofw_columns_data['rows'] ) && is_array( $epofw_columns_data['rows'] ) ) {
                            foreach ( $epofw_columns_data['rows'] as $epofw_row_id => $epofw_row_data ) {
                                if ( isset( $epofw_row_data['fields'] ) && is_array( $epofw_row_data['fields'] ) ) {
                                    // Filter out disabled fields.
                                    foreach ( $epofw_row_data['fields'] as $epofw_field_id => $epofw_field_data ) {
                                        // Check field_status at top level or nested in field array.
                                        $epofw_field_status = epofw_check_array_key_exists( 'field_status', $epofw_field_data );
                                        if ( empty( $epofw_field_status ) && isset( $epofw_field_data['field'] ) && is_array( $epofw_field_data['field'] ) ) {
                                            $epofw_field_status = epofw_check_array_key_exists( 'field_status', $epofw_field_data['field'] );
                                        }
                                        if ( 'on' === $epofw_field_status ) {
                                            $epofw_addon_fields_data[$epofw_field_id] = $epofw_field_data;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        // Check if this section has fields.
        if ( !empty( $epofw_addon_fields_data ) ) {
            // Render section wrapper if we have section styling and fields.
            // This opens <div class="epofw-section-wrapper"> and <div class="epofw-section-fields">.
            if ( !empty( $epofw_section_status ) ) {
                epofw_render_section_wrapper( $epofw_section_title, $epofw_section_settings, $epofw_section_id );
            }
            // Group fields by row associations for row-based rendering.
            $epofw_grouped_fields = epofw_group_fields_by_rows_admin( $epofw_addon_fields_data );
            // Prepare template arguments.
            $epofwtwp_args = array(
                'product_data'    => $epofw_product_data,
                'product_price'   => $epofw_product_price,
                'epofw_action'    => $epofw_action,
                'fields_data_arr' => $epofw_fields_general_data_arr,
            );
            if ( !empty( $epofw_grouped_fields['row_based'] ) ) {
                // Merge column_settings from database into grouped fields.
                if ( !empty( $epofw_row_groups_data ) && is_array( $epofw_row_groups_data ) ) {
                    foreach ( $epofw_row_groups_data as $epofw_group_id => $epofw_group_data ) {
                        if ( isset( $epofw_group_data['columns_groups'] ) && is_array( $epofw_group_data['columns_groups'] ) ) {
                            foreach ( $epofw_group_data['columns_groups'] as $epofw_columns_id => $epofw_columns_data ) {
                                if ( isset( $epofw_columns_data['rows'] ) && is_array( $epofw_columns_data['rows'] ) && isset( $epofw_grouped_fields['row_based'][$epofw_group_id]['columns_groups'][$epofw_columns_id] ) ) {
                                    foreach ( $epofw_columns_data['rows'] as $epofw_row_id => $epofw_row_data ) {
                                        if ( isset( $epofw_grouped_fields['row_based'][$epofw_group_id]['columns_groups'][$epofw_columns_id]['rows'][$epofw_row_id] ) ) {
                                            // Merge column_settings if exists.
                                            if ( isset( $epofw_row_data['column_settings'] ) ) {
                                                $epofw_grouped_fields['row_based'][$epofw_group_id]['columns_groups'][$epofw_columns_id]['rows'][$epofw_row_id]['column_settings'] = $epofw_row_data['column_settings'];
                                            }
                                            // Merge row_number if exists.
                                            if ( isset( $epofw_row_data['row_number'] ) ) {
                                                $epofw_grouped_fields['row_based'][$epofw_group_id]['columns_groups'][$epofw_columns_id]['rows'][$epofw_row_id]['row_number'] = $epofw_row_data['row_number'];
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                foreach ( $epofw_grouped_fields['row_based'] as $epofw_group_id => $epofw_group_data ) {
                    $epofw_layout_type = $epofw_group_data['layout_type'];
                    $epofw_rows_count = $epofw_group_data['rows_count'];
                    // Get row group settings for this specific group.
                    $epofw_row_group_settings = array();
                    if ( !empty( $epofw_row_groups_data ) && isset( $epofw_row_groups_data[$epofw_group_id] ) ) {
                        $epofw_row_group_settings = epofw_check_array_key_exists( 'row_group_settings', $epofw_row_groups_data[$epofw_group_id] );
                    }
                    // Always render row group containers (div structure).
                    // Determine CSS classes based on layout.
                    $epofw_group_classes = array('epofw-row-group');
                    if ( 'single' === $epofw_layout_type ) {
                        $epofw_group_classes[] = 'epofw-single-group';
                    } else {
                        $epofw_group_classes[] = 'epofw-multi-group';
                        // Add row count class for multi-row groups.
                        if ( !empty( $epofw_rows_count ) && is_numeric( $epofw_rows_count ) ) {
                            $epofw_group_classes[] = 'epofw-col-' . absint( $epofw_rows_count );
                        }
                    }
                    // Generate row group styles from settings.
                    $epofw_row_group_style_attr = epofw_generate_row_group_styles( $epofw_row_group_settings );
                    // Ensure it's a string (not an array) for wp_kses().
                    if ( !is_string( $epofw_row_group_style_attr ) ) {
                        $epofw_row_group_style_attr = '';
                    }
                    // Output custom CSS for row group if available.
                    $epofw_row_group_custom_css = ( !empty( $epofw_row_group_settings['custom_css'] ) ? $epofw_row_group_settings['custom_css'] : '' );
                    $epofw_row_group_selector = '.epofw-row-group[data-group-id="' . esc_attr( $epofw_group_id ) . '"]';
                    if ( !empty( $epofw_row_group_custom_css ) ) {
                        echo epofw_output_custom_css( $epofw_row_group_custom_css, $epofw_row_group_selector );
                        // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
                    }
                    // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $epofw_row_group_style_attr is sanitized.
                    echo '<div class="' . esc_attr( implode( ' ', $epofw_group_classes ) ) . '" data-group-id="' . esc_attr( $epofw_group_id ) . '"' . $epofw_row_group_style_attr . '>';
                    // Get columns_groups from the grouped data.
                    $epofw_columns_groups = array();
                    if ( !empty( $epofw_group_data['columns_groups'] ) && is_array( $epofw_group_data['columns_groups'] ) ) {
                        foreach ( $epofw_group_data['columns_groups'] as $epofw_columns_id => $epofw_cg_data ) {
                            $epofw_columns_groups[$epofw_columns_id] = array(
                                'columns_order' => ( isset( $epofw_cg_data['columns_order'] ) ? $epofw_cg_data['columns_order'] : 0 ),
                                'layout_type'   => ( isset( $epofw_cg_data['layout_type'] ) ? $epofw_cg_data['layout_type'] : 'single' ),
                                'columns_count' => ( isset( $epofw_cg_data['columns_count'] ) ? $epofw_cg_data['columns_count'] : 1 ),
                                'columns'       => ( isset( $epofw_cg_data['rows'] ) ? $epofw_cg_data['rows'] : array() ),
                            );
                        }
                    }
                    // Sort columns groups by order.
                    uasort( $epofw_columns_groups, function ( $epofw_a, $epofw_b ) {
                        return $epofw_a['columns_order'] - $epofw_b['columns_order'];
                    } );
                    // Helper function to render a single column.
                    $epofw_render_column = function (
                        $epofw_row_id,
                        $epofw_row_data,
                        $epofw_layout_type,
                        $epofwtwp_args
                    ) use($epofw_addon_fields_data, $epofw_addon_id) {
                        $epofw_fields = $epofw_row_data['fields'];
                        // Get column settings.
                        $epofw_column_settings = epofw_check_array_key_exists( 'column_settings', $epofw_row_data );
                        // Column classes.
                        $epofw_column_classes = array('epofw-column');
                        if ( 'single' === $epofw_layout_type ) {
                            $epofw_column_classes[] = 'epofw-single-column';
                        } else {
                            $epofw_column_classes[] = 'epofw-multi-column';
                        }
                        // Columns are layout-only, no styling.
                        echo '<div class="' . esc_attr( implode( ' ', $epofw_column_classes ) ) . '" data-row-id="' . esc_attr( $epofw_row_id ) . '">';
                        // Render fields within this column.
                        foreach ( $epofw_fields as $epofw_field_id => $epofw_field_data ) {
                            // Check field status - skip disabled fields.
                            // Check field_status at top level or nested in field array.
                            $epofw_field_status = epofw_check_array_key_exists( 'field_status', $epofw_field_data );
                            if ( empty( $epofw_field_status ) && isset( $epofw_field_data['field'] ) && is_array( $epofw_field_data['field'] ) ) {
                                $epofw_field_status = epofw_check_array_key_exists( 'field_status', $epofw_field_data['field'] );
                            }
                            if ( 'on' !== $epofw_field_status ) {
                                continue;
                            }
                            // Update the template arguments with current field data.
                            $epofw_current_args = $epofwtwp_args;
                            $epofw_current_args['fields_data'] = $epofw_field_data;
                            $epofw_current_args['fields_key'] = $epofw_field_id;
                            $epofw_current_args['addon_id'] = $epofw_addon_id;
                            // Add price data for label display.
                            $epofw_check_field_enable_price = epofw_check_enable_price_extra( $epofw_field_data );
                            $epofw_check_field_addon_price_type = epofw_get_addon_price_type( $epofw_field_data );
                            $epofw_check_field_addon_price = epofw_get_addon_price( $epofw_field_data );
                            if ( 'on' === $epofw_check_field_enable_price ) {
                                $epofw_current_args['opt_price'] = $epofw_check_field_addon_price;
                                $epofw_current_args['opt_price_type'] = $epofw_check_field_addon_price_type;
                            }
                            $epofw_check_field_title_position = epofw_get_field_label_title_position( $epofw_field_data );
                            $epofw_check_field_inp_type = epofw_get_field_type( $epofw_field_data );
                            // Get field container settings (with global defaults applied).
                            $epofw_field_container_settings = epofw_get_field_container_settings_with_global( $epofw_field_data );
                            // Generate field container style class from settings (returns class name).
                            $epofw_field_container_style_class = epofw_generate_field_container_styles( $epofw_field_container_settings );
                            /**
                             * Filter the field container CSS class.
                             *
                             * @since 1.0.0
                             *
                             * @param string $field_class  Default field CSS class.
                             * @param array  $current_args Current field arguments.
                             */
                            $epofw_field_class = apply_filters( 'epofw_html_field_class_display', 'epofw_field_container epofw_tr_se epofw_label_' . $epofw_check_field_title_position, $epofw_current_args );
                            if ( !empty( $epofw_field_container_style_class ) ) {
                                $epofw_field_class .= ' ' . esc_attr( $epofw_field_container_style_class );
                            }
                            // Add advanced title position class (placeholder, compact_above, auto, etc.).
                            if ( function_exists( 'epofw_is_advanced_title_position' ) && epofw_is_advanced_title_position( $epofw_check_field_title_position ) ) {
                                // For 'auto' mode, use smart detection based on field type.
                                if ( 'auto' === $epofw_check_field_title_position && function_exists( 'epofw_get_smart_label_class' ) ) {
                                    $epofw_title_position_class = epofw_get_smart_label_class( $epofw_check_field_inp_type );
                                } else {
                                    $epofw_title_position_class = epofw_get_title_position_class( $epofw_check_field_title_position );
                                }
                                if ( !empty( $epofw_title_position_class ) ) {
                                    $epofw_field_class .= ' ' . esc_attr( $epofw_title_position_class );
                                }
                            }
                            // Add field type class for specific styling (e.g., separator, repeater).
                            if ( 'separator' === $epofw_check_field_inp_type ) {
                                $epofw_field_class .= ' epofw_field_separator';
                            }
                            // Add stacked layout class for repeater fields (label above, content below).
                            if ( 'repeater' === $epofw_check_field_inp_type ) {
                                $epofw_field_class .= ' epofw-repeater-stacked';
                            }
                            // Output custom CSS for field container if available.
                            $epofw_field_container_custom_css = ( !empty( $epofw_field_container_settings['custom_css'] ) ? $epofw_field_container_settings['custom_css'] : '' );
                            if ( !empty( $epofw_field_container_custom_css ) ) {
                                $epofw_field_container_selector = '.epofw_field_container[id*="' . esc_attr( $epofw_field_id ) . '"]';
                                echo epofw_output_custom_css( $epofw_field_container_custom_css, $epofw_field_container_selector );
                                // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
                            }
                            // Conditional logic handling (Premium only).
                            $epofw_logical_conditional_style = '';
                            $epofw_logical_data_attr = '';
                            // Separator field - render simple structure without field_container.
                            if ( 'separator' === $epofw_check_field_inp_type ) {
                                // Get separator settings.
                                $epofw_separator_settings = epofw_check_array_key_exists( 'separator_settings', $epofw_field_data );
                                if ( empty( $epofw_separator_settings ) || !is_array( $epofw_separator_settings ) ) {
                                    $epofw_separator_settings = array();
                                }
                                $epofw_sep_color = ( !empty( $epofw_separator_settings['color'] ) ? $epofw_separator_settings['color'] : '#959595' );
                                $epofw_sep_style = ( !empty( $epofw_separator_settings['style'] ) ? $epofw_separator_settings['style'] : 'dashed' );
                                $epofw_sep_width = ( !empty( $epofw_separator_settings['width'] ) ? $epofw_separator_settings['width'] : '1' );
                                // Handle margin: check if it's a simple value or advanced array.
                                $epofw_sep_margin_settings = epofw_check_array_key_exists( 'margin', $epofw_separator_settings );
                                if ( is_array( $epofw_sep_margin_settings ) && !empty( $epofw_sep_margin_settings ) ) {
                                    // Advanced margin.
                                    $epofw_sep_margin_top = ( !empty( $epofw_sep_margin_settings['top'] ) ? $epofw_sep_margin_settings['top'] : '10' );
                                    $epofw_sep_margin_right = ( !empty( $epofw_sep_margin_settings['right'] ) ? $epofw_sep_margin_settings['right'] : '0' );
                                    $epofw_sep_margin_bottom = ( !empty( $epofw_sep_margin_settings['bottom'] ) ? $epofw_sep_margin_settings['bottom'] : '10' );
                                    $epofw_sep_margin_left = ( !empty( $epofw_sep_margin_settings['left'] ) ? $epofw_sep_margin_settings['left'] : '0' );
                                    $epofw_sep_margin_units = ( !empty( $epofw_sep_margin_settings['units'] ) ? $epofw_sep_margin_settings['units'] : 'px' );
                                } else {
                                    // Simple margin or empty, set defaults.
                                    $epofw_sep_margin_top = '10';
                                    $epofw_sep_margin_right = '0';
                                    $epofw_sep_margin_bottom = '10';
                                    $epofw_sep_margin_left = '0';
                                    $epofw_sep_margin_units = 'px';
                                }
                                $epofw_separator_style = sprintf(
                                    'border-top: %spx %s %s; margin: %s%s %s%s %s%s %s%s;',
                                    esc_attr( $epofw_sep_width ),
                                    esc_attr( $epofw_sep_style ),
                                    esc_attr( $epofw_sep_color ),
                                    esc_attr( $epofw_sep_margin_top ),
                                    esc_attr( $epofw_sep_margin_units ),
                                    esc_attr( $epofw_sep_margin_right ),
                                    esc_attr( $epofw_sep_margin_units ),
                                    esc_attr( $epofw_sep_margin_bottom ),
                                    esc_attr( $epofw_sep_margin_units ),
                                    esc_attr( $epofw_sep_margin_left ),
                                    esc_attr( $epofw_sep_margin_units )
                                );
                                ?>
												<div class="epofw-separator-wrapper" id="epofw_<?php 
                                echo esc_attr( $epofw_check_field_inp_type );
                                ?>_<?php 
                                echo esc_attr( $epofw_field_id );
                                ?>">
													<hr class="epofw-separator" style="<?php 
                                echo esc_attr( $epofw_separator_style );
                                ?>" />
												</div>
												<?php 
                                continue;
                            }
                            /**
                             * Filter the HTML tag used for field container.
                             *
                             * @since 1.0.0
                             *
                             * @param string $tag          Default HTML tag.
                             * @param array  $current_args Current field arguments.
                             */
                            $epofw_tag = apply_filters( 'epofw_html_start_field_tag_display', 'div', $epofw_current_args );
                            ?>
											<<?php 
                            echo esc_html( $epofw_tag );
                            ?> class="<?php 
                            echo esc_attr( $epofw_field_class );
                            ?>" id="epofw_<?php 
                            echo esc_attr( $epofw_check_field_inp_type );
                            ?>_<?php 
                            echo esc_attr( $epofw_field_id );
                            ?>"<?php 
                            echo $epofw_logical_data_attr;
                            // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
                            echo ( !empty( $epofw_logical_conditional_style ) ? ' style="' . esc_attr( $epofw_logical_conditional_style ) . '"' : '' );
                            ?>>
											<?php 
                            /**
                             * Fires before the field HTML is displayed.
                             *
                             * @since 1.0.0
                             *
                             * @param array $current_args Current field arguments.
                             */
                            do_action( 'epofw_before_html_field_display', $epofw_current_args );
                            // Label html.
                            wc_get_template(
                                'epofw-field-label-html.php',
                                array(
                                    'epofwtwp_args' => $epofw_current_args,
                                ),
                                epofw_get_template_path(),
                                epofw_get_default_path()
                            );
                            // Input html.
                            wc_get_template(
                                'epofw-field-input-html.php',
                                array(
                                    'epofwtwp_args' => $epofw_current_args,
                                ),
                                epofw_get_template_path(),
                                epofw_get_default_path()
                            );
                            /**
                             * Fires after the field HTML is displayed.
                             *
                             * @since 1.0.0
                             *
                             * @param array $current_args Current field arguments.
                             */
                            do_action( 'epofw_after_html_field_display', $epofw_current_args );
                            ?>
											</<?php 
                            echo esc_html( $epofw_tag );
                            ?>>
											<?php 
                        }
                        // Close column container.
                        echo '</div>';
                    };
                    // Render columns groups.
                    foreach ( $epofw_columns_groups as $epofw_columns_id => $epofw_columns_data ) {
                        $epofw_columns_count = ( isset( $epofw_columns_data['columns_count'] ) ? (int) $epofw_columns_data['columns_count'] : count( $epofw_columns_data['columns'] ) );
                        $epofw_columns_layout_type = ( isset( $epofw_columns_data['layout_type'] ) ? $epofw_columns_data['layout_type'] : 'single' );
                        // Determine column classes based on layout type.
                        $epofw_columns_classes = array('epofw-columns');
                        if ( 'single' === $epofw_columns_layout_type || 1 === (int) $epofw_columns_count ) {
                            $epofw_columns_classes[] = 'epofw-columns-single';
                        } else {
                            $epofw_columns_classes[] = 'epofw-columns-multi';
                            $epofw_columns_classes[] = 'epofw-col-' . $epofw_columns_count;
                            $epofw_columns_classes[] = 'epofw-layout-' . $epofw_columns_layout_type;
                        }
                        echo '<div class="' . esc_attr( implode( ' ', $epofw_columns_classes ) ) . '" data-columns-id="' . esc_attr( $epofw_columns_id ) . '" data-columns-count="' . esc_attr( $epofw_columns_count ) . '" data-layout-type="' . esc_attr( $epofw_columns_layout_type ) . '">';
                        foreach ( $epofw_columns_data['columns'] as $epofw_row_id => $epofw_row_data ) {
                            $epofw_column_layout_type = ( 'single' === $epofw_columns_layout_type || 1 === (int) $epofw_columns_count ? 'single' : 'multi' );
                            $epofw_render_column(
                                $epofw_row_id,
                                $epofw_row_data,
                                $epofw_column_layout_type,
                                $epofwtwp_args
                            );
                        }
                        echo '</div>';
                        // End columns container.
                    }
                    // Always close group container (div structure).
                    echo '</div>';
                    // End group container.
                }
            }
            // Close section wrapper if we have section styling and fields.
            // This closes </div> for epofw-section-fields and </div> for epofw-section-wrapper.
            if ( !empty( $epofw_section_status ) ) {
                epofw_close_section_wrapper( $epofw_section_id, $epofw_section_settings );
            }
        }
    }
}
// Close main container (always div structure).
?>
			</div> <!-- End epofw_middle_tg -->
		</div> <!-- End main container -->
	</div>
<?php 
/**
 * End of table.
 *
 * @since 2.5
 */
do_action( 'epofw_addon_table_html_end' );