@props([
    'variant' => 'primary',
    'size' => 'md',
    'href' => null,
    'type' => 'button',
    'icon' => null,
])

@php
    $base = 'inline-flex items-center justify-center gap-2 font-medium rounded-lg transition
             focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2
             disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap';

    $variants = [
        'primary'   => 'bg-brand-700 text-white hover:bg-brand-800 focus-visible:ring-brand-700 shadow-sm',
        'secondary' => 'bg-gold-300 text-brand-900 hover:bg-gold-400 focus-visible:ring-gold-500 shadow-sm',
        'outline'   => 'border border-slate-300 bg-white text-slate-700 hover:bg-slate-50 hover:border-slate-400 focus-visible:ring-brand-700',
        'ghost'     => 'text-slate-700 hover:bg-slate-100 focus-visible:ring-brand-700',
        'danger'    => 'bg-red-600 text-white hover:bg-red-700 focus-visible:ring-red-600 shadow-sm',
        'light'     => 'bg-white text-brand-800 hover:bg-brand-50 focus-visible:ring-white shadow-sm',
    ];

    $sizes = [
        'sm' => 'text-sm px-3 py-1.5',
        'md' => 'text-sm px-4 py-2.5',
        'lg' => 'text-base px-6 py-3',
    ];

    $classes = trim($base.' '.($variants[$variant] ?? $variants['primary']).' '.($sizes[$size] ?? $sizes['md']));
@endphp

@if ($href)
    <a href="{{ $href }}" {{ $attributes->class($classes) }}>{{ $slot }}</a>
@else
    <button type="{{ $type }}" {{ $attributes->class($classes) }}>{{ $slot }}</button>
@endif
