<ng-container *transloco="let t; prefix: 'statsUser.bookLength'">
<div class="book-length-container">
  <div class="chart-header">
    <div class="chart-title">
      <h3>
        <i class="pi pi-book book-length-icon"></i>
        {{ t('title') }}
        <i class="pi pi-question-circle chart-info-icon"
           [pTooltip]="t('tooltip')"
           tooltipPosition="bottom"
           tooltipStyleClass="chart-info-tooltip"
           [appendTo]="'body'"></i>
      </h3>
      <p class="chart-description">{{ t('description') }}</p>
    </div>
    @if (totalRatedBooks > 0) {
      <div class="stats-badge">
        <span class="badge-value">{{ totalRatedBooks }}</span>
        <span class="badge-label">{{ t('booksAnalyzed') }}</span>
      </div>
    }
  </div>

  @if (totalRatedBooks > 0) {
    <div class="stats-row">
      <div class="stat-card">
        <span class="stat-value-sm">{{ sweetSpot }}</span>
        <span class="stat-label">{{ t('sweetSpot') }}</span>
      </div>
      <div class="stat-card">
        <span class="stat-value-sm">{{ highestRatedLength }}</span>
        <span class="stat-label">{{ t('highestRated') }}</span>
      </div>
    </div>
  }

  <div class="chart-wrapper">
    <canvas baseChart
            [data]="(chartData$ | async) ?? {datasets: []}"
            [options]="chartOptions"
            [type]="chartType">
    </canvas>
  </div>
</div>
</ng-container>
