/* Stat Card Component */

/* Display metrics with labels and optional trends */

@layer components {
  /* ============================================================================
   * STAT CARD BASE
   * ========================================================================= */

  .stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--space-6);
    background-color: var(--surface);
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-3);
    transition: all var(--transition-fast);
    min-height: 160px;
  }

  /* Main holds value + label, centered in the space above the footer.
     The footer reserves consistent vertical space across all cards so the
     value sits at the same position whether or not subtitle/trend exist. */
  .stat-card__main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
  }

  .stat-card__footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    min-height: 3.5rem;
  }

  /* Hover effect for linked stat cards */
  a.stat-card:hover {
    border-color: var(--brand);
    box-shadow: var(--shadow-2);
    transform: translateY(-2px);
  }

  /* ============================================================================
   * STAT CARD ICON
   * ========================================================================= */

  .stat-card__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    margin-bottom: var(--space-4);
    color: var(--brand);
  }

  .stat-card__icon svg {
    width: 100%;
    height: 100%;
  }

  /* ============================================================================
   * STAT CARD VALUE
   * ========================================================================= */

  .stat-card__value {
    font-size: 2.5rem;
    font-weight: var(--weight-bold);
    line-height: 1;
    margin-bottom: var(--space-3);
  }

  /* Value color variants */
  .stat-card__value--brand {
    color: var(--brand);
  }

  .stat-card__value--success {
    color: var(--brand);
  }

  .stat-card__value--error {
    color: var(--danger);
  }

  .stat-card__value--warning {
    color: var(--caution-strong);
  }

  .stat-card__value--neutral {
    color: var(--fg);
  }

  /* ============================================================================
   * STAT CARD LABEL
   * ========================================================================= */

  .stat-card__label {
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    color: var(--neutral-600);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  /* ============================================================================
   * STAT CARD SUBTITLE
   * ========================================================================= */

  .stat-card__subtitle {
    margin-top: var(--space-2);
    font-size: var(--text-xs);
    color: var(--neutral-400);
  }

  /* ============================================================================
   * STAT CARD TREND
   * ========================================================================= */

  .stat-card__trend {
    margin-top: var(--space-3);
    font-size: var(--text-2xs);
    font-weight: var(--weight-medium);
  }

  /* Trend with sentiment - determines if trend is good (gold) or bad (red) */
  .stat-card__trend--up--positive,
  .stat-card__trend--down--positive {
    color: var(--brand);
  }

  .stat-card__trend--up--negative,
  .stat-card__trend--down--negative {
    color: var(--danger);
  }

  /* Fallback: trend without sentiment (backward compatible) */
  .stat-card__trend--up {
    color: var(--brand);
  }

  .stat-card__trend--down {
    color: var(--danger);
  }

  .stat-card__trend--neutral {
    color: var(--neutral-400);
  }

  /* ============================================================================
   * RESPONSIVE ADJUSTMENTS
   * ========================================================================= */

  @media (width <= 768px) {
    .stat-card {
      padding: var(--space-5);
      min-height: 140px;
    }

    .stat-card__value {
      font-size: 2rem;
    }

    .stat-card__icon {
      width: 2.5rem;
      height: 2.5rem;
    }

    /* Mobile typically stacks cards in a single column, so cross-card value
       alignment isn't visible — drop the footer reservation to avoid growing
       every card by ~26px. */
    .stat-card__footer {
      min-height: 0;
    }
  }

  /* ============================================================================
   * DARK MODE ADJUSTMENTS
   * ========================================================================= */

  @media (prefers-color-scheme: dark) {
    .stat-card {
      background-color: var(--surface-sunken);
    }

    a.stat-card:hover {
      background-color: var(--neutral-100);
    }
  }
}
