<?php
/**
 * Template View: Service Card
 *
 * Displays a service with description, features and price.
 *
 * @package    BoostBot
 * @subpackage Templates/Views
 * @since      1.6.0
 *
 * @var string $icon         Emoji or icon URL.
 * @var string $title        Service title.
 * @var string $description  Service description.
 * @var array  $features     List of features.
 * @var float  $price        Service price.
 * @var string $price_suffix Price suffix (e.g., "/לחודש").
 * @var array  $buttons      Action buttons.
 */

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

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

<div class="bb-service-card">
    <div class="bb-service-header">
        <?php if ( ! empty( $icon ) ) : ?>
            <span class="bb-service-icon"><?php echo esc_html( $icon ); ?></span>
        <?php endif; ?>
        <h4 class="bb-service-title"><?php echo esc_html( $title ); ?></h4>
    </div>

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

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

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

    <?php if ( ! empty( $buttons ) && is_array( $buttons ) ) : ?>
        <div class="bb-service-actions">
            <?php foreach ( $buttons as $index => $button ) : 
                $button_style = $index === 0 ? 'primary' : 'secondary';
            ?>
                <a href="<?php echo esc_url( $button['url'] ?? '#' ); ?>" 
                   class="bb-service-button bb-service-button-<?php echo esc_attr( $button_style ); ?>">
                    <?php echo esc_html( $button['text'] ?? '' ); ?>
                </a>
            <?php endforeach; ?>
        </div>
    <?php endif; ?>
</div>
