{% set badge_attributes = badge_attributes ?: create_attribute() %}
{% set badge_html_tag = badge_html_tag ?? 'span' %}

{# --- Default Classes --- #}
{% set base_classes = "inline-flex items-center font-medium" %}
 
{# px-3 py-1 text-sm text-tertiary-base bg-rounded-2xl #}

{% set badge_color_class = color ? color : (variant ?  variant  : ' bg-body border-2 ') %}


{% if badge_color_class  == "bg-default"  %}
  {% set badge_color_class = " border border-body text-body" %}
  {% endif %}
{# --- Color (default if not provided) --- #}
{% set color_classes = badge_color_class ?? " border border-body text-body" %}

{# --- Size --- #}

{% set size_classes = {
  'xs': 'px-1 py-0.5 text-xs',
  'sm': 'px-2 py-1 text-sm',
  'default': 'px-3 py-1 text-sm',
  'lg': 'px-4 py-2 text-base',
  'xl': 'px-5 py-2 text-lg'
} %}
{% set size_class = size_classes[size|default('default')] %}

{% set style_classes = {
   'rounded': 'text-body-bg rounded-full bg-' ~ color_classes ,
   'square': 'text-body-bg rounded-sm bg-' ~ color_classes ,
   'soft': 'text-' ~ color_classes  ~ ' bg-' ~ color_classes ~'/25 ',
   'outline': 'text-' ~ color_classes  ~ ' !bg-none border-2 border-' ~ color_classes,
   'outline_dash': 'text-' ~ color_classes  ~ ' !bg-none border-2 border-dashed border-' ~ color_classes
} %}

{% set style_class = style_classes[badge_style|default('square')] %}
{# --- Merge all classes --- #}
{% set badge_classes = base_classes ~ " " ~ size_class ~ " " ~ style_class %}

{% if badgeUrl %}
  <a href="{{ badgeUrl }}" class="{{ badge_classes }} mr-1">
    <span class="mr-1">{{ content }}</span>
    {% if icon %}
      <span class="mr-1">{{ icon|raw }}</span>
    {% endif %}
  </a>
{% else %}
  <span class="{{ badge_classes }} mt-4 ">
    <span class="mr-1">{{ content }}</span>
    {% if icon %}
      <span class="mr-1">{{ icon|raw }}</span>
    {% endif %}
    
  </span>
{% endif %}


