<?php
/**
 * Template View: Pricing Card
 *
 * Displays a single pricing package with features and CTA.
 *
 * @package    BoostBot
 * @subpackage Templates/Views
 * @since      1.6.0
 *
 * @var string $name         Package name.
 * @var float  $price        Package price.
 * @var string $price_suffix Optional price suffix (e.g., "/לחודש").
 * @var array  $features     List of features.
 * @var bool   $featured     Whether this is the featured/recommended package.
 * @var string $cta_text     CTA button text.
 * @var string $cta_url      CTA button URL.
 * @var string $description  Optional description.
 */

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

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

$is_featured = ! empty( $featured );
$card_class  = 'bb-single-pricing-card' . ( $is_featured ? ' bb-single-pricing-featured' : '' );
?>

<div class="<?php echo esc_attr( $card_class ); ?>">
    <?php if ( $is_featured ) : ?>
        <div class="bb-single-pricing-badge"><?php esc_html_e( 'מומלץ', 'boostbot' ); ?></div>
    <?php endif; ?>

    <div class="bb-single-pricing-header">
        <h4 class="bb-single-pricing-name"><?php echo esc_html( $name ); ?></h4>
        
        <?php if ( $price > 0 ) : ?>
            <div class="bb-single-pricing-price">
                <span class="bb-single-price-amount">₪<?php echo esc_html( number_format( $price, 0 ) ); ?></span>
                <?php if ( ! empty( $price_suffix ) ) : ?>
                    <span class="bb-single-price-suffix"><?php echo esc_html( $price_suffix ); ?></span>
                <?php endif; ?>
            </div>
        <?php endif; ?>
    </div>

    <?php if ( ! empty( $description ) ) : ?>
        <p class="bb-single-pricing-description"><?php echo esc_html( $description ); ?></p>
    <?php endif; ?>

    <?php if ( ! empty( $features ) && is_array( $features ) ) : ?>
        <ul class="bb-single-pricing-features">
            <?php foreach ( $features as $feature ) : 
                $feature_text    = is_array( $feature ) ? ( $feature['text'] ?? '' ) : $feature;
                $feature_included = is_array( $feature ) ? ( $feature['included'] ?? true ) : true;
            ?>
                <li class="<?php echo $feature_included ? 'bb-single-feature-included' : 'bb-single-feature-excluded'; ?>">
                    <span class="bb-single-feature-icon"><?php echo $feature_included ? '✓' : '✗'; ?></span>
                    <span class="bb-single-feature-text"><?php echo esc_html( $feature_text ); ?></span>
                </li>
            <?php endforeach; ?>
        </ul>
    <?php endif; ?>

    <?php if ( ! empty( $cta_text ) ) : ?>
        <div class="bb-single-pricing-cta">
            <a href="<?php echo esc_url( $cta_url ?? '#' ); ?>" 
               class="bb-single-pricing-button<?php echo $is_featured ? ' bb-single-pricing-button-primary' : ''; ?>">
                <?php echo esc_html( $cta_text ); ?>
            </a>
        </div>
    <?php endif; ?>
</div>

