<?php
/**
 * Template View: Bundle Savings Badge
 *
 * Inline badge showing savings.
 * Requires Pro + Bundles license.
 *
 * @package    BoostBot
 * @subpackage Templates/Views
 * @since      1.6.0
 *
 * @var int   $percent    Savings percentage (0-100).
 * @var float $amount     Savings amount in currency.
 * @var string $style     Badge style: 'default', 'minimal', 'prominent'.
 */

// phpcs:ignoreFile WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-scope variables set by the includer, not true globals.

// Prevent direct access
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

// Validate - need at least one value
if ( empty( $percent ) && empty( $amount ) ) {
    return;
}

$style = $style ?? 'default';
$badge_class = 'bb-savings-badge-' . sanitize_html_class( $style );
?>

<span class="bb-bundle-savings-badge <?php echo esc_attr( $badge_class ); ?>">
    <span class="bb-savings-icon">🏷️</span>
    <?php if ( ! empty( $percent ) ) : ?>
        <span class="bb-savings-percent"><?php /* translators: %d: savings percentage */
        echo esc_html( sprintf( __( 'חסוך %d%%', 'boostbot' ), $percent ) ); ?></span>
    <?php endif; ?>
    <?php if ( ! empty( $amount ) ) : ?>
        <span class="bb-savings-amount">(₪<?php echo esc_html( number_format( $amount, 0 ) ); ?>)</span>
    <?php endif; ?>
</span>

