<?php
/**
 * SalonPro X - Button Component
 * Usage: <?php component('button', ['text' => 'Save', 'type' => 'primary', 'icon' => 'fa-save']); ?>
 * @var string $text Button text
 * @var string $type primary, secondary, success, danger, warning, info, ghost, gold (default: primary)
 * @var string $icon Font Awesome icon class
 * @var string $size sm, lg (optional)
 * @var string $href If set, renders as anchor tag
 * @var string $class Additional classes
 * @var bool $outline Use outline variant
 * @var bool $block Full width button
 * @var string $extra Extra attributes
 */
$text = $text ?? 'Button';
$type = $type ?? 'primary';
$icon = $icon ?? '';
$size = $size ?? '';
$href = $href ?? '';
$class = $class ?? '';
$outline = $outline ?? false;
$block = $block ?? false;
$extra = $extra ?? '';
$id = $id ?? '';

$btnClass = $type === 'gold' ? 'btn-gold' : ($outline ? "btn-outline-{$type}" : "btn-{$type}");
$sizeClass = $size ? "btn-{$size}" : '';
$blockClass = $block ? 'w-100' : '';
$fullClass = trim("btn {$btnClass} {$sizeClass} {$blockClass} {$class}");

$html = '';
if ($href) {
    $html .= '<a href="' . e($href) . '" class="' . $fullClass . '" id="' . e($id) . '" ' . $extra . '>';
} else {
    $html .= '<button type="button" class="' . $fullClass . '" id="' . e($id) . '" ' . $extra . '>';
}
if ($icon) {
    $html .= '<i class="fas ' . e($icon) . ' me-2"></i>';
}
$html .= e($text);
$html .= $href ? '</a>' : '</button>';
echo $html;
?>
