<?php

/**
 * Levels & Badges Settings Tab
 */
if ( !defined( 'ABSPATH' ) ) {
    exit;
}
function spar_settings_tab_levels() {
    $defaults = spar_settings_default();
    $options = get_option( 'spar_options', $defaults );
    $options = array_merge( $defaults, $options );
    $levels = ( isset( $options['levels'] ) ? $options['levels'] : [] );
    $levels = ( is_array( $levels ) ? $levels : [] );
    // Always show at least one empty level row if none exist in options
    if ( empty( $levels ) ) {
        $levels = [[
            'name'              => esc_html__( 'Bronze Member', 'simple-points-and-rewards' ),
            'badge_icon'        => '🥉',
            'badge_type'        => 'preset',
            'required_points'   => 2500,
            'points_multiplier' => 1.1,
        ]];
        // Rendering placeholder
    }
    $badge_icons = spar_get_badge_icons();
    $starter_badge = spar_normalize_badge_fields(
        $options['levels_starter_badge_icon'] ?? '⭐',
        $options['levels_starter_badge_url'] ?? '',
        $options['levels_starter_badge_type'] ?? '',
        $options['levels_starter_badge_text'] ?? ''
    );
    $starter_badge_type = $starter_badge['badge_type'];
    $starter_selected_icon = ( 'preset' === $starter_badge_type ? $starter_badge['badge_icon'] ?? '' : '' );
    $starter_badge_preview = spar_get_level_badge_markup( array(
        'badge_type' => $starter_badge['badge_type'],
        'badge_icon' => $starter_badge['badge_icon'],
        'badge_url'  => $starter_badge['badge_url'],
        'badge_text' => $starter_badge['badge_text'],
        'name'       => $options['levels_starter_name'] ?? esc_html__( 'Starter', 'simple-points-and-rewards' ),
    ), array(
        'icon_class'  => 'spar-level-badge-icon',
        'image_class' => 'spar-level-badge-img',
    ) );
    if ( !empty( $levels ) ) {
        foreach ( $levels as $level_index => $level_data ) {
            $badge_data = spar_normalize_badge_fields(
                $level_data['badge_icon'] ?? '',
                $level_data['badge_url'] ?? '',
                $level_data['badge_type'] ?? '',
                $level_data['badge_text'] ?? ''
            );
            $levels[$level_index] = array_merge( $level_data, $badge_data );
        }
    }
    $earn_options = $options['earn'] ?? [];
    $order_options = $earn_options['order'] ?? [];
    ?>
    <div class="spar-levels-settings">
        <h3><?php 
    esc_html_e( 'Levels & Badges System', 'simple-points-and-rewards' );
    ?></h3>

        <p style="margin-top: 20px;">
            <label>
                <div class="spar-toggle-switch">
                    <input type="checkbox" name="levels_enabled" data-canonical-toggle="true" <?php 
    checked( !empty( $options['levels_enabled'] ) );
    ?> />
                    <span class="spar-toggle-slider"></span>
                </div>
                <?php 
    esc_html_e( 'Enable Levels & Badges System', 'simple-points-and-rewards' );
    ?>
            </label>
        </p>

        <p><?php 
    esc_html_e( 'Create a tiered loyalty system where customers unlock benefits and exclusive access as they earn more points.', 'simple-points-and-rewards' );
    ?></p>

        <div id="spar-levels-body" class="<?php 
    echo esc_attr( ( !empty( $options['levels_enabled'] ) ? '' : 'spar-hidden' ) );
    ?>">
            <div id="spar-levels-configuration">
            
            <div class="spar-level-zero-option">
                <div class="spar-level-item spar-level-starter" data-index="starter">
                    <div class="spar-level-header">
                        <span class="spar-level-badge">
                            <?php 
    echo ( $starter_badge_preview ? wp_kses_post( $starter_badge_preview ) : esc_html( $starter_badge['badge_icon'] ?? '⭐' ) );
    ?>
                        </span>
                        <h4>
                            <?php 
    echo esc_html( $options['levels_starter_name'] ?? esc_html__( 'Starter', 'simple-points-and-rewards' ) );
    ?>
                            <span class="spar-small spar-text-muted spar-ml-8"><?php 
    esc_html_e( '(Level 0)', 'simple-points-and-rewards' );
    ?></span>
                        </h4>
                        <div class="spar-level-actions">
                            <button type="button" class="button spar-toggle-level-starter"><?php 
    esc_html_e( 'Edit', 'simple-points-and-rewards' );
    ?></button>
                        </div>
                    </div>
                    <div class="spar-level-content-starter spar-hidden">
                        <div class="spar-p-18">
                            <div class="spar-level-row">
                                <div class="spar-level-col">
                                    <label><?php 
    esc_html_e( 'Level Name:', 'simple-points-and-rewards' );
    ?></label>
                                    <input type="text" name="levels_starter_name" value="<?php 
    echo esc_attr( $options['levels_starter_name'] ?? esc_html__( 'Starter', 'simple-points-and-rewards' ) );
    ?>" placeholder="<?php 
    esc_attr_e( 'Starter', 'simple-points-and-rewards' );
    ?>" />
                                </div>
                            </div>
                            <div class="spar-level-row">
                                <div class="spar-level-col">
                                    <label><?php 
    esc_html_e( 'Badge Icon:', 'simple-points-and-rewards' );
    ?></label>
                                    <select name="levels_starter_badge_icon" class="spar-badge-select" data-badge-context="starter">
                                        <option value=""><?php 
    esc_html_e( 'Select an icon', 'simple-points-and-rewards' );
    ?></option>
                                        <?php 
    foreach ( $badge_icons as $icon => $label ) {
        ?>
                                            <option value="<?php 
        echo esc_attr( $icon );
        ?>" <?php 
        selected( $starter_selected_icon, $icon );
        ?>>
                                                <?php 
        echo esc_html( $icon . ' ' . $label );
        ?>
                                            </option>
                                        <?php 
    }
    ?>
                                        <option value="custom_url" <?php 
    selected( 'custom_url', $starter_badge_type );
    ?>><?php 
    esc_html_e( 'Custom (Image URL)', 'simple-points-and-rewards' );
    ?></option>
                                        <option value="custom_text" <?php 
    selected( 'custom_text', $starter_badge_type );
    ?>><?php 
    esc_html_e( 'Custom (Text/Emoji)', 'simple-points-and-rewards' );
    ?></option>
                                    </select>
                                    <input type="hidden" name="levels_starter_badge_type" class="spar-badge-type-field" value="<?php 
    echo esc_attr( $starter_badge_type );
    ?>" />
                                </div>
                            </div>
                            <div class="spar-level-row spar-badge-url-row <?php 
    echo ( 'custom_url' === $starter_badge_type ? '' : 'spar-hidden' );
    ?>" data-badge-field="url">
                                <div class="spar-level-col">
                                    <label><?php 
    esc_html_e( 'Custom Badge (Image URL):', 'simple-points-and-rewards' );
    ?></label>
                                    <input type="url" name="levels_starter_badge_url" class="spar-badge-url-input" value="<?php 
    echo esc_attr( $starter_badge['badge_url'] ?? '' );
    ?>" placeholder="https://example.com/badge.png" />
                                    <small><?php 
    esc_html_e( 'Provide an image URL that will be used when Custom (Image URL) is selected.', 'simple-points-and-rewards' );
    ?></small>
                                </div>
                            </div>
                            <div class="spar-level-row spar-badge-text-row <?php 
    echo ( 'custom_text' === $starter_badge_type ? '' : 'spar-hidden' );
    ?>" data-badge-field="text">
                                <div class="spar-level-col">
                                    <label><?php 
    esc_html_e( 'Custom Badge (Text/Emoji):', 'simple-points-and-rewards' );
    ?></label>
                                    <input type="text" name="levels_starter_badge_text" class="spar-badge-text-input" value="<?php 
    echo esc_attr( $starter_badge['badge_text'] ?? '' );
    ?>" placeholder="<?php 
    esc_attr_e( 'e.g. VIP or 😎', 'simple-points-and-rewards' );
    ?>" />
                                    <small><?php 
    esc_html_e( 'Shown instead of the preset icon when Custom (Text/Emoji) is selected.', 'simple-points-and-rewards' );
    ?></small>
                                </div>
                            </div>
                            <div class="spar-level-row">
                                <div class="spar-level-col">
                                    <label><?php 
    esc_html_e( 'Benefits:', 'simple-points-and-rewards' );
    ?></label>
                                    <ul class="spar-ul-indent">
                                        <?php 
    $pp_points = ( isset( $order_options['points_per_points'] ) ? (float) $order_options['points_per_points'] : (float) ($order_options['points_per'] ?? 5) );
    $pp_amount = ( isset( $order_options['points_per_amount'] ) && (float) $order_options['points_per_amount'] > 0 ? (float) $order_options['points_per_amount'] : 1.0 );
    $currency_code = ( function_exists( 'get_woocommerce_currency' ) ? get_woocommerce_currency() : (( defined( 'WC_VERSION' ) ? get_option( 'woocommerce_currency' ) : 'USD' )) );
    $symbol = ( function_exists( 'get_woocommerce_currency_symbol' ) ? get_woocommerce_currency_symbol( $currency_code ) : '$' );
    ?>
                                        <li><?php 
    esc_html_e( '1.0x points multiplier', 'simple-points-and-rewards' );
    ?></li>
                                        <li><?php 
    esc_html_e( 'No extra benefits', 'simple-points-and-rewards' );
    ?></li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <div id="spar-levels-list">
                <?php 
    if ( !empty( $levels ) ) {
        ?>
                    <?php 
        foreach ( $levels as $index => $level ) {
            ?>

                        <?php 
            ?>
                            <?php 
            if ( $index >= 1 ) {
                break;
            }
            ?>
                        <?php 
            ?>

                        <div class="spar-level-item" data-index="<?php 
            echo esc_attr( $index );
            ?>">
                            <div class="spar-level-header clickable-header">
                                <span class="spar-drag-handle dashicons dashicons-move" aria-label="<?php 
            echo esc_attr__( 'Drag to reorder', 'simple-points-and-rewards' );
            ?>" title="<?php 
            echo esc_attr__( 'Drag to reorder', 'simple-points-and-rewards' );
            ?>"></span>
                                <?php 
            $level_badge_type = $level['badge_type'] ?? 'preset';
            $level_selected_icon = ( 'preset' === $level_badge_type ? $level['badge_icon'] ?? '' : '' );
            $level_badge_preview = spar_get_level_badge_markup( array_merge( $level, array(
                'name' => $level['name'] ?? '',
            ) ), array(
                'icon_class'  => 'spar-level-badge-icon',
                'image_class' => 'spar-level-badge-img',
            ) );
            $level_email_enabled = !empty( $level['level_up_email_enabled'] );
            $level_email_subject = ( isset( $level['level_up_email_subject'] ) ? (string) $level['level_up_email_subject'] : '' );
            $level_email_body = ( isset( $level['level_up_email_body'] ) ? (string) $level['level_up_email_body'] : '' );
            // Keep the customise email section closed by default.
            // Users can open it via the "Customise Email" button when needed.
            $level_email_open = false;
            $email_button_label = esc_html__( 'Customise Email', 'simple-points-and-rewards' );
            $level_email_subject_value = ( '' !== trim( $level_email_subject ) ? $level_email_subject : spar_get_default_level_email_subject() );
            ?>
                                <span class="spar-level-badge">
                                    <?php 
            echo ( $level_badge_preview ? wp_kses_post( $level_badge_preview ) : esc_html( $level_selected_icon ) );
            ?>
                                </span>
                                <h4>
                                    <?php 
            echo esc_html( $level['name'] ?? esc_html__( 'Untitled Level', 'simple-points-and-rewards' ) );
            ?>
                                </h4>
                                <div class="spar-level-actions">
                                    <button type="button" class="button spar-toggle-level"><?php 
            esc_html_e( 'Edit', 'simple-points-and-rewards' );
            ?></button>
                                    <button type="button" class="button spar-delete-level"><?php 
            esc_html_e( 'Delete', 'simple-points-and-rewards' );
            ?></button>
                                </div>
                            </div>
                            
                            <div class="spar-level-content spar-hidden">
                                <input type="hidden" name="levels[<?php 
            echo esc_attr( $index );
            ?>][id]" value="<?php 
            echo esc_attr( $level['id'] ?? spar_generate_level_id() );
            ?>" />

                                <fieldset>
                                
                                <div class="spar-level-row">
                                    <div class="spar-level-col">
                                        <label><?php 
            esc_html_e( 'Level Name:', 'simple-points-and-rewards' );
            ?></label>
                                        <input type="text" name="levels[<?php 
            echo esc_attr( $index );
            ?>][name]" value="<?php 
            echo esc_attr( $level['name'] ?? '' );
            ?>" placeholder="<?php 
            esc_attr_e( 'Bronze Member', 'simple-points-and-rewards' );
            ?>" />
                                    </div>
                                    
                                    <div class="spar-level-col">
                                        <label><?php 
            esc_html_e( 'Required Points:', 'simple-points-and-rewards' );
            ?></label>
                                        <input type="number" name="levels[<?php 
            echo esc_attr( $index );
            ?>][required_points]" value="<?php 
            echo esc_attr( $level['required_points'] ?? '' );
            ?>" min="0" placeholder="100" />
                                    </div>
                                </div>
                                
                                <div class="spar-level-row">
                                    <div class="spar-level-col">
                                        <label><?php 
            esc_html_e( 'Badge Icon:', 'simple-points-and-rewards' );
            ?></label>
                                        <select name="levels[<?php 
            echo esc_attr( $index );
            ?>][badge_icon]" class="spar-badge-select" data-badge-context="level">
                                            <option value=""><?php 
            esc_html_e( 'Select an icon', 'simple-points-and-rewards' );
            ?></option>
                                            <?php 
            foreach ( $badge_icons as $icon => $label ) {
                ?>
                                                <option value="<?php 
                echo esc_attr( $icon );
                ?>" <?php 
                selected( $level_selected_icon, $icon );
                ?>>
                                                    <?php 
                echo esc_html( $icon . ' ' . $label );
                ?>
                                                </option>
                                            <?php 
            }
            ?>
                                            <option value="custom_url" <?php 
            selected( 'custom_url', $level_badge_type );
            ?>><?php 
            esc_html_e( 'Custom (Image URL)', 'simple-points-and-rewards' );
            ?></option>
                                            <option value="custom_text" <?php 
            selected( 'custom_text', $level_badge_type );
            ?>><?php 
            esc_html_e( 'Custom (Text/Emoji)', 'simple-points-and-rewards' );
            ?></option>
                                        </select>
                                        <input type="hidden" name="levels[<?php 
            echo esc_attr( $index );
            ?>][badge_type]" class="spar-badge-type-field" value="<?php 
            echo esc_attr( $level_badge_type );
            ?>" />
                                    </div>
                                </div>
                                <div class="spar-level-row spar-badge-url-row <?php 
            echo ( 'custom_url' === $level_badge_type ? '' : 'spar-hidden' );
            ?>" data-badge-field="url">
                                    <div class="spar-level-col">
                                        <label><?php 
            esc_html_e( 'Custom Badge (Image URL):', 'simple-points-and-rewards' );
            ?></label>
                                        <input type="url" name="levels[<?php 
            echo esc_attr( $index );
            ?>][badge_url]" class="spar-badge-url-input" value="<?php 
            echo esc_attr( $level['badge_url'] ?? '' );
            ?>" placeholder="https://example.com/badge.png" />
                                        <small><?php 
            esc_html_e( 'Provide an image URL that will be used when Custom (Image URL) is selected.', 'simple-points-and-rewards' );
            ?></small>
                                    </div>
                                </div>
                                <div class="spar-level-row spar-badge-text-row <?php 
            echo ( 'custom_text' === $level_badge_type ? '' : 'spar-hidden' );
            ?>" data-badge-field="text">
                                    <div class="spar-level-col">
                                        <label><?php 
            esc_html_e( 'Custom Badge (Text/Emoji):', 'simple-points-and-rewards' );
            ?></label>
                                        <input type="text" name="levels[<?php 
            echo esc_attr( $index );
            ?>][badge_text]" class="spar-badge-text-input" value="<?php 
            echo esc_attr( $level['badge_text'] ?? '' );
            ?>" placeholder="<?php 
            esc_attr_e( 'e.g. VIP or 😎', 'simple-points-and-rewards' );
            ?>" />
                                        <small><?php 
            esc_html_e( 'Shown instead of the preset icon when Custom (Text/Emoji) is selected.', 'simple-points-and-rewards' );
            ?></small>
                                    </div>
                                </div>
                                
                                <h5><?php 
            esc_html_e( 'Level Benefits', 'simple-points-and-rewards' );
            ?></h5>

                                <div class="spar-level-section-box">
                                    <div class="spar-level-section-box-title"><?php 
            esc_html_e( 'Points Multiplier', 'simple-points-and-rewards' );
            ?></div>
                                    <div class="spar-level-row">
                                        <div class="spar-level-col">
                                            <label><?php 
            esc_html_e( 'Points Multiplier:', 'simple-points-and-rewards' );
            ?></label>
                                            <input type="number" step="0.01" name="levels[<?php 
            echo esc_attr( $index );
            ?>][points_multiplier]" value="<?php 
            echo esc_attr( $level['points_multiplier'] ?? '1.0' );
            ?>" min="0" placeholder="1.0" class="spar-global-multiplier-input" />
                                            <small><?php 
            esc_html_e( 'Multiply all earned points by this amount (e.g., 1.5 = 50% bonus on all activities)', 'simple-points-and-rewards' );
            ?></small>
                                        </div>
                                    </div>

                                    <?php 
            ?>
                                    <div class="spar-level-row">
                                        <div class="spar-level-col">
                                            <label style="opacity: 0.6; cursor: default;">
                                                <input type="checkbox" disabled />
                                                <?php 
            esc_html_e( 'Use different multipliers per earn type', 'simple-points-and-rewards' );
            ?>
                                                <span class="spar-premium-settings-badge">(PRO)</span>
                                            </label>
                                            <small><?php 
            esc_html_e( 'Override the global multiplier above with a unique multiplier for each way to earn points.', 'simple-points-and-rewards' );
            ?></small>
                                        </div>
                                    </div>
                                    <?php 
            ?>
                                </div>

                                <div class="spar-level-section-box">
                                    <div class="spar-level-section-box-title"><?php 
            esc_html_e( 'Custom Benefits', 'simple-points-and-rewards' );
            ?></div>
                                    <div class="spar-level-row">
                                        <div class="spar-level-col">
                                            <label><?php 
            esc_html_e( 'Custom Benefits:', 'simple-points-and-rewards' );
            ?></label>
                                            <textarea name="levels[<?php 
            echo esc_attr( $index );
            ?>][custom_benefits]" placeholder="<?php 
            esc_attr_e( 'Enter one benefit per line...', 'simple-points-and-rewards' );
            ?>" rows="4" class="spar-full-width"><?php 
            echo esc_textarea( $level['custom_benefits'] ?? '' );
            ?></textarea>
                                            <small><?php 
            esc_html_e( 'Enter one benefit per line. These will be displayed to customers alongside the automatic benefits.', 'simple-points-and-rewards' );
            ?></small>
                                        </div>
                                    </div>
                                </div>

                                <div class="spar-level-section-box">
                                    <div class="spar-level-section-box-title"><?php 
            esc_html_e( 'Level Up Email', 'simple-points-and-rewards' );
            ?></div>
                                    <div class="spar-level-row spar-level-email-row">
                                        <div class="spar-level-col">
                                            <label>
                                                <input type="hidden" name="levels[<?php 
            echo esc_attr( $index );
            ?>][level_up_email_enabled]" value="0" />
                                                <input type="checkbox" name="levels[<?php 
            echo esc_attr( $index );
            ?>][level_up_email_enabled]" value="1" class="spar-level-email-toggle" <?php 
            checked( $level_email_enabled );
            ?> />
                                                <span><?php 
            esc_html_e( 'Send email to customer on level up', 'simple-points-and-rewards' );
            ?></span>
                                            </label>
                                            <small><?php 
            esc_html_e( 'Email is sent as soon as the customer reaches this level.', 'simple-points-and-rewards' );
            ?></small>
                                            <div class="spar-level-email-actions<?php 
            echo ( $level_email_enabled ? '' : ' spar-hidden' );
            ?>">
                                                <button type="button" class="button button-secondary spar-level-email-customize" data-open-text="<?php 
            esc_attr_e( 'Customise Email', 'simple-points-and-rewards' );
            ?>" data-close-text="<?php 
            esc_attr_e( 'Close', 'simple-points-and-rewards' );
            ?>">
                                                    <?php 
            echo esc_html( $email_button_label );
            ?>
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                                <?php 
            if ( !isset( $level_body_editor_index ) ) {
                $level_body_editor_index = 0;
            }
            $level_body_editor_index++;
            $editor_id = 'level_up_email_body_' . $level_body_editor_index;
            $editor_value = $level_email_body;
            $editor_value = ( '' === trim( wp_strip_all_tags( $editor_value ) ) ? spar_get_default_level_email_body() : $editor_value );
            ?>
                                    <div class="spar-level-row spar-level-email-fields <?php 
            echo ( $level_email_open ? '' : 'spar-hidden' );
            ?>" data-email-fields="1">
                                        <div class="spar-level-col">
                                            <label><?php 
            esc_html_e( 'Subject:', 'simple-points-and-rewards' );
            ?></label>
                                            <input type="text" name="levels[<?php 
            echo esc_attr( $index );
            ?>][level_up_email_subject]" value="<?php 
            echo esc_attr( $level_email_subject_value );
            ?>" placeholder="<?php 
            esc_attr_e( 'Congratulations! You reached {level_name}', 'simple-points-and-rewards' );
            ?>" class="spar-full-width" />
                                            <label><?php 
            esc_html_e( 'Email Body:', 'simple-points-and-rewards' );
            ?></label>
                                            <?php 
            wp_editor( $editor_value, $editor_id, array(
                'textarea_name' => 'levels[' . esc_attr( $index ) . '][level_up_email_body]',
                'textarea_rows' => 6,
                'media_buttons' => false,
                'teeny'         => true,
            ) );
            ?>
                                            <small>
                                                <?php 
            esc_html_e( 'Available placeholders: {user_name}, {user_email}, {level_name}, {previous_level_name}, {points_label}, {total_points}, {site_name}, {site_url}, {rewards_url}', 'simple-points-and-rewards' );
            ?>
                                            </small>
                                        </div>
                                    </div>
                                </div>
                                </fieldset>
                            </div>
                        </div>
                    <?php 
        }
        ?>
                <?php 
    }
    ?>
            </div>
            
        <?php 
    ?>
            <p>
                <!-- Disabled button for free version users -->
                <a type="button" class="button button-secondary spar-disabled-button" disabled>
                    <?php 
    esc_html_e( 'Add New Level', 'simple-points-and-rewards' );
    ?> (PRO)
                </a>
            </p>
            <small><?php 
    esc_html_e( 'Add unlimited levels with the PRO version.', 'simple-points-and-rewards' );
    ?></small>
        <?php 
    ?>
            
            <div class="spar-levels-info">
                <h4><?php 
    esc_html_e( 'How It Works', 'simple-points-and-rewards' );
    ?></h4>
                <ul>
                    <li><?php 
    esc_html_e( 'Customers automatically reach new levels when they accumulate enough points', 'simple-points-and-rewards' );
    ?></li>
                    <li><?php 
    esc_html_e( 'Higher levels can earn more points per order and referral bonuses', 'simple-points-and-rewards' );
    ?></li>
                    <li><?php 
    esc_html_e( 'You can restrict access to specific products and pages by level', 'simple-points-and-rewards' );
    ?></li>
                    <li><?php 
    esc_html_e( 'Levels are displayed on the customer\'s account page and rewards widget', 'simple-points-and-rewards' );
    ?></li>
                </ul>
            </div>

            <hr style="margin: 30px 0;" />

            <h4><?php 
    esc_html_e( 'Level Points Requirement', 'simple-points-and-rewards' );
    ?></h4>
            <p><?php 
    esc_html_e( 'Choose how the required points for levels are calculated.', 'simple-points-and-rewards' );
    ?></p>

            <select name="levels_points_type">
                <option value="total_earned" <?php 
    selected( $options['levels_points_type'] ?? 'total_earned', 'total_earned' );
    ?>>
                    <?php 
    esc_html_e( 'Total Points Earned (Lifetime)', 'simple-points-and-rewards' );
    ?>
                </option>
                <option value="available_balance" <?php 
    selected( $options['levels_points_type'] ?? 'total_earned', 'available_balance' );
    ?>>
                    <?php 
    esc_html_e( 'Available Points Balance', 'simple-points-and-rewards' );
    ?>
                </option>
            </select>
            <br/>
            <small class="spar-text-muted">
                <?php 
    esc_html_e( 'Total Points Earned: Levels are based on the total points a customer has earned over time. Points spent on rewards do not affect their level.', 'simple-points-and-rewards' );
    ?>
                <br/>
                <?php 
    esc_html_e( 'Available Points Balance: Levels are based on the customer\'s current available points balance. Spending points on rewards may lower their level.', 'simple-points-and-rewards' );
    ?>
            </small>
        
            </div><!-- /#spar-levels-configuration -->
        </div><!-- /#spar-levels-body -->
    </div>
    

    <?php 
}
