<?php
/**
 * Template View: Button Group
 *
 * Multiple buttons in a group.
 *
 * @package    BoostBot
 * @subpackage Templates/Views
 * @since      1.6.0
 *
 * @var array  $buttons   Array of button objects with text, url, style, icon.
 * @var string $layout    Layout: 'horizontal', 'vertical', 'stacked'.
 */

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

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

// Validate required data
if ( empty( $buttons ) || ! is_array( $buttons ) ) {
    return;
}

$layout = $layout ?? 'horizontal';
$layout_class = 'bb-btn-group-' . sanitize_html_class( $layout );
?>

<div class="bb-button-group <?php echo esc_attr( $layout_class ); ?>">
    <?php foreach ( $buttons as $button ) : 
        if ( empty( $button['text'] ) || empty( $button['url'] ) ) {
            continue;
        }
        $style = $button['style'] ?? 'primary';
        $btn_class = 'bb-grp-btn-' . sanitize_html_class( $style );
    ?>
        <a href="<?php echo esc_url( $button['url'] ); ?>" class="bb-group-btn <?php echo esc_attr( $btn_class ); ?>">
            <?php if ( ! empty( $button['icon'] ) ) : ?>
                <span class="bb-grp-icon"><?php echo esc_html( $button['icon'] ); ?></span>
            <?php endif; ?>
            <span class="bb-grp-text"><?php echo esc_html( $button['text'] ); ?></span>
        </a>
    <?php endforeach; ?>
</div>
