<bit-card class="tw-size-full tw-flex tw-flex-col">
  <!-- Title Section with Active Badge -->
  <div class="tw-flex tw-items-center tw-justify-between tw-mb-2">
    <ng-content select="[slot=title]"></ng-content>

    <!-- Active Badge (if provided) -->
    @if (activeBadge(); as activeBadgeValue) {
      <span bitBadge [variant]="activeBadgeValue.variant || 'primary'" class="tw-ml-3">
        {{ activeBadgeValue.text }}
      </span>
    }
  </div>

  <!-- Tagline with consistent height (exactly 2 lines) -->
  <div class="tw-mb-6 tw-h-6">
    <p bitTypography="helper" class="tw-text-muted tw-m-0 tw-leading-relaxed tw-line-clamp-2">
      {{ tagline() }}
    </p>
  </div>

  <!-- Price Section (if provided) -->
  @if (price(); as priceValue) {
    <div class="tw-mb-6">
      <div class="tw-flex tw-items-baseline tw-gap-1 tw-flex-wrap">
        <!-- Show no decimals for whole numbers (e.g. $5), but always show 2 decimals when present (e.g. $120.50) -->
        <span class="tw-text-3xl tw-font-medium tw-leading-none tw-m-0">{{
          priceValue.amount
            | currency: "$" : true : (priceValue.amount % 1 === 0 ? "1.0-0" : "1.2-2")
        }}</span>
        <span bitTypography="helper" class="tw-text-muted">
          / {{ priceValue.cadence | i18n }}
          @if (priceValue.showPerUser) {
            {{ "perUser" | i18n }}
          }
        </span>
      </div>
    </div>
  }

  <!-- Button -->
  @if (button(); as buttonConfig) {
    <div class="tw-mb-6 tw-h-12">
      <button
        bitButton
        [buttonType]="buttonConfig.type"
        [block]="true"
        [disabled]="buttonConfig.disabled"
        (click)="buttonClick.emit()"
        type="button"
      >
        @if (buttonConfig.icon && buttonConfig.icon.position === "before") {
          <bit-icon [name]="buttonConfig.icon.type" class="tw-me-2" aria-hidden="true"></bit-icon>
        }
        {{ buttonConfig.text }}
        @if (
          buttonConfig.icon &&
          (buttonConfig.icon.position === "after" || !buttonConfig.icon.position)
        ) {
          <bit-icon [name]="buttonConfig.icon.type" class="tw-ms-2" aria-hidden="true"></bit-icon>
        }
      </button>
    </div>
  }

  <!-- Features List -->
  <div class="tw-flex-grow">
    @if (features(); as featureList) {
      @if (featureList.length > 0) {
        <ul class="tw-list-none tw-p-0 tw-m-0">
          @for (feature of featureList; track feature) {
            <li class="tw-flex tw-items-start tw-gap-2 tw-mb-2 last:tw-mb-0">
              <bit-icon
                name="bwi-check"
                class="tw-text-primary-600 tw-mt-0.5 tw-flex-shrink-0"
                aria-hidden="true"
              >
              </bit-icon>
              <span bitTypography="helper" class="tw-text-muted tw-leading-relaxed">{{
                feature
              }}</span>
            </li>
          }
        </ul>
      }
    }
  </div>
</bit-card>
