<ng-container *transloco="let t; prefix: 'statsUser.readingSurvival'">
<div class="reading-survival-container">
  <div class="chart-header">
    <div class="chart-title">
      <h3>
        <i class="pi pi-chart-line reading-survival-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>
  </div>

  @if (totalStarted > 0) {
    <div class="stats-row">
      <div class="stat-card">
        <span class="stat-value">{{ totalStarted }}</span>
        <span class="stat-label">{{ t('started') }}</span>
      </div>
      <div class="stat-card">
        <span class="stat-value">{{ completionRate }}%</span>
        <span class="stat-label">{{ t('completionRate') }}</span>
      </div>
      <div class="stat-card">
        <span class="stat-value">{{ medianDropout }}</span>
        <span class="stat-label">{{ t('medianDropout') }}</span>
      </div>
      <div class="stat-card danger">
        <span class="stat-value">{{ dangerZoneRange }}</span>
        <span class="stat-subtitle">{{ dangerZoneDrop }}</span>
        <span class="stat-label">{{ t('dangerZone') }}</span>
      </div>
    </div>
  }

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

  @if (totalStarted === 0) {
    <div class="no-data-message">
      <i class="pi pi-info-circle"></i>
      <p>{{ t('noData') }}</p>
      <small>{{ t('noDataHint') }}</small>
    </div>
  }
</div>
</ng-container>
