@use "../abstracts/variables" as *;
@use "../abstracts/mixins" as *;

.no-kpi-card {
  @include card;

  &__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 1rem;
  }

  &__title-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
  }

  &__title {
    margin: 0;
    color: $color-text-soft;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
  }

  &__description {
    color: $color-text-muted;
    font-size: $font-size-sm;
    line-height: 1.45;
  }

  &__icon {
    display: inline-flex;
    flex: 0 0 2.5rem;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    text-transform: uppercase;
    color: $color-blue;
    border-radius: 999px;
    background: $color-blue-fill;
    font-size: 0.75rem;
    font-weight: 700;

    svg {
      width: 20px;
      height: 20px;
      stroke: currentColor;
      fill: none;
    }

    &--blue {
      color: $color-blue;
      background: $color-blue-fill;
    }

    &--orange {
      color: $color-orange;
      background: $color-orange-tint-12;
    }

    &--green {
      color: $color-green;
      background: $color-green-tint-12;
    }

    &--red {
      color: $color-red;
      background: $color-red-tint-12;
    }
  }

  &__body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    margin-bottom: 12px;
    gap: 0.875rem;
  }

  &__metric {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
  }

  &__value-wrap {
    display: flex;
    align-items: baseline;
    gap: 6px;
  }

  &__value {
    color: $color-text;
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;

    &--secondary {
      color: $color-text-soft;
      font-size: 1.5rem;
      font-weight: 700;
    }
  }

  &__unit {
    color: $color-text;
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
  }

  &__label {
    color: $color-text-muted;
    font-size: 0.95rem;
    font-weight: 600;
  }

  &__meta {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.25rem;
  }

  &__meta-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.9rem;
  }

  &__meta-label {
    color: $color-text-muted;
  }

  &__meta-value {
    color: $color-text;
    font-weight: 700;
  }

  &__chart {
    position: relative;
    height: 52px;
    margin-top: auto;
  }

  &__sparkline {
    display: block;
    width: 100%;
    height: 34px;
  }

  &__chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    color: $color-text-muted;
    font-size: $font-size-xs;
  }

  &__sample {
    margin-top: 8px;
    color: $color-text-muted;
    font-size: 12px;
    line-height: 1.3;
  }

  // ---------------------------------------------------------------------------
  // 2-column layout when breakdown donut is present.
  // Only active on the Response Time card via .no-kpi-card--has-breakdown.
  // ---------------------------------------------------------------------------

  &__content {
    display: flex;
    flex: 1 1 auto;
    flex-direction: row;
    gap: 0;

    .no-kpi-card__body {
      flex: 1 1 auto;
      margin-bottom: 0;
    }
  }

  &__breakdown {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-left: 12px;
    padding-left: 12px;
    border-left: 1px solid $color-border;
    gap: 8px;
  }

  &__breakdown-chart {
    flex: 0 0 72px;
    width: 72px;
    height: 72px;
  }

  &__breakdown-legend {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
    gap: 0.3rem;
  }

  &__breakdown-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: $font-size-xs;
  }

  &__breakdown-legend-dot {
    flex: 0 0 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
  }

  &__breakdown-legend-label {
    overflow: hidden;
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: $color-text-muted;
  }

  &__breakdown-legend-value {
    flex: 0 0 auto;
    color: $color-text;
    font-weight: 700;
  }

  &__breakdown-context {
    margin: 4px 0 0;
    color: $color-text-muted;
    font-size: $font-size-xs;
    font-style: italic;
  }

  &--blue &__icon {
    color: $color-blue;
    background: $color-blue-fill;
  }

  &--orange &__icon {
    color: $color-orange;
    background: $color-orange-tint-12;
  }

  &--red &__icon {
    color: $color-red;
    background: $color-red-tint-12;
  }

  &--green &__icon {
    color: $color-green;
    background: $color-green-tint-12;
  }
}

@media (max-width: 767px) {
  .no-kpi-card {
    min-height: auto;
  }
}
