// ---------------------------------------------------------------------------
// Marketing campaign tables: trend line, visitor bar, "Goals · rate", the rows that open to
// their landing pages, the "AI app links" row and the All / Paid / Email / Social switch.
// Marketing views: pages/referrals/utm-performance.php, pages/referrals/campaigns.php,
// components/objects/sparkline.php, components/tables/goals-rate-cell.php.
// ---------------------------------------------------------------------------

.wps-sparkline {
  display: block;
  overflow: visible;

  &__line {
    fill: none;
    stroke: $wps-brand;
    stroke-width: 1.6;
    stroke-linejoin: round;
    stroke-linecap: round;
  }

  &__area {
    fill: $wps-brand;
    opacity: .1;
  }

  &--empty {
    display: block;
    width: 70px;
    height: 20px;
  }
}

.wps-compare-table__trend {
  width: 70px;
}

.wps-compare-table__bar {
  display: inline-block;
  position: relative;
  width: 46px;
  height: 6px;
  margin-right: 8px;
  overflow: hidden;
  border-radius: 3px;
  background: $wps-track;
  vertical-align: middle;

  span {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    border-radius: 3px;
    background: $wps-brand;
  }

  .rtl & {
    margin-right: 0;
    margin-left: 8px;

    span {
      left: auto;
      right: 0;
    }
  }
}

.wps-goals-rate {
  &__count.is-zero,
  &__rate,
  &__none {
    color: $wps-text-subtle;
  }

  &__rate {
    font-size: 12px;
  }
}

// Campaigns: the switch sits in the card header
.wps-campaign-table__switch {
  padding: 2px;

  a.wps-channel-switch__item,
  .wps-channel-switch__item {
    padding: 3px 10px;
    font-size: 12px;
  }
}

.wps-campaign-rows__cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  vertical-align: middle;
}

.wps-campaign-rows {
  &__main {
    cursor: pointer;

    &:hover td {
      background: $wps-brand-tint;
    }
  }

  &__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 18px;
    height: 18px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: none;
    color: $wps-text-subtle;
    cursor: pointer;

    &:hover {
      color: $wps-text-strong;
    }

    &:focus {
      outline: none;
      box-shadow: none;
    }

    &:focus-visible {
      outline: 2px solid $wps-brand;
      outline-offset: 1px;
    }
  }

  // Right-pointing arrow; turns down when the row is open
  &__arrow {
    width: 0;
    height: 0;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-left: 5px solid currentColor;
    transition: transform .15s ease;

    .rtl & {
      border-left: 0;
      border-right: 5px solid currentColor;
    }
  }

  &__group.is-open {
    .wps-campaign-rows__main td {
      background: $wps-brand-tint;
    }

    .wps-campaign-rows__arrow {
      transform: rotate(90deg);
    }
  }

  &__sub td {
    height: 34px;
    color: $wps-text-muted;
    font-size: 12px;
    background: #FAFAFB;
  }

  &__sub td:first-child {
    padding-left: $wps-card-pad-x + 24px;

    .rtl & {
      padding-left: 12px;
      padding-right: $wps-card-pad-x + 24px;
    }
  }

  &__sub--head td {
    height: 30px;
    color: $wps-text-subtle;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .04em;
    text-transform: uppercase;
  }

  &__sub--more td {
    color: $wps-text-subtle;
  }

  &__page {
    max-width: 360px;

    a,
    span.wps-compare-table__ellipsis {
      max-width: calc(100% - 20px);
      color: $wps-text;
      text-decoration: none;
    }

    a:hover {
      color: $wps-brand;
    }
  }

  &__page-arrow {
    margin-right: 6px;
    color: $wps-text-subtle;

    .rtl & {
      margin-right: 0;
      margin-left: 6px;
    }
  }

  &__group--ai .wps-campaign-rows__main td,
  &__group--not_set .wps-campaign-rows__main td {
    background: #FAFAFB;
  }
}

// AI app links: same size as the campaign pill, dashed, no tag icon
.wps-ai-apps-label {
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  height: 18px;
  padding: 0 8px;
  border: 1px dashed #6B4FBB;
  border-radius: 9px;
  color: #6B4FBB;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: help;
}

.wps-campaign-table__note {
  margin: 0 (-$wps-card-pad-x);
  padding: 12px $wps-card-pad-x 0;
  border-top: 1px solid $wps-card-rule;
  color: $wps-text-subtle;
  font-size: 12px;
  line-height: 16px;
}
