// ---------------------------------------------------------------------------
// Compare tables: "Channels compared" (Referrals > Overview) and the Marketing tables
// UTM Performance > Campaigns and Campaigns > Campaigns use the same row look.
// PHP: views/components/tables/channels-compared.php,
// Marketing views: pages/referrals/utm-performance.php, pages/referrals/campaigns.php.
// ---------------------------------------------------------------------------

$wps-compare-row-height: 40px;

.wps-channels-compared,
.wps-campaign-table {
  .wps-card-header__tools {
    display: flex;
    flex: none;
    align-items: center;
    gap: 8px;
    width: auto;
    max-width: 100%;
    height: auto;

    // Text and a switch here, not 24px icon buttons
    > .wps-channels-compared__versus,
    > .wps-campaign-table__count,
    > .wps-channel-switch {
      width: auto;
      height: auto;
      border-radius: 0;
    }

    > .wps-channel-switch {
      border-radius: 8px;
    }
  }

  .inside {
    margin: 0;
    padding: 0;
  }
}

.wps-channels-compared__versus,
.wps-campaign-table__count {
  color: $wps-text-subtle;
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
}

.wps-compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 18px;
  color: $wps-text;

  th,
  td {
    height: $wps-compare-row-height;
    padding: 0 12px;
    box-sizing: border-box;
    border-bottom: 1px solid $wps-card-rule;
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;

    &:first-child {
      padding-left: $wps-card-pad-x;
    }

    &:last-child {
      padding-right: $wps-card-pad-x;
    }

    .rtl & {
      text-align: right;
    }
  }

  th {
    height: 34px;
    color: $wps-text-subtle;
    font-size: 12px;
    font-weight: 500;
    border-bottom-color: $wps-card-border;
  }

  tbody:last-child tr:last-child td,
  tbody tr:last-child td {
    border-bottom: 0;
  }

  .wps-campaign-rows__group:not(:last-child) tr:last-child td {
    border-bottom: 1px solid $wps-card-rule;
  }

  &__num,
  th.wps-compare-table__num,
  td.wps-compare-table__num {
    text-align: right;
    font-variant-numeric: tabular-nums;

    .rtl & {
      text-align: left;
    }
  }

  &__name {
    color: $wps-text-strong;
    font-weight: 500;
  }

  &__dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 8px;
    border-radius: 50%;
    vertical-align: 0;

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

  &__source {
    max-width: 220px;
    color: $wps-text-muted;
  }

  &__ellipsis {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
  }

  &__none {
    color: $wps-text-subtle;
  }

  td.wps-compare-table__bad {
    color: $wps-bad;
    font-weight: 600;
  }
}

// "New": nothing to compare with last year
#wpbody .wps-change.wps-change--new {
  color: $wps-brand;
  background: $wps-brand-tint;

  &::before {
    content: none;
  }
}

// Card table rules elsewhere set their own th/td padding and alignment; keep the compare columns aligned.
#wpbody .wps-compare-table {
  th,
  td {
    padding: 0 12px;

    &:first-child {
      padding-left: $wps-card-pad-x;
    }

    &:last-child {
      padding-right: $wps-card-pad-x;
    }
  }

  th {
    text-align: left;
    vertical-align: middle;

    &.wps-compare-table__num {
      text-align: right;
    }
  }

  .wps-campaign-rows__sub td:first-child {
    padding-left: $wps-card-pad-x + 24px;
  }
}

.rtl #wpbody .wps-compare-table {
  th,
  td {
    &:first-child {
      padding-left: 12px;
      padding-right: $wps-card-pad-x;
    }

    &:last-child {
      padding-left: $wps-card-pad-x;
      padding-right: 12px;
    }
  }

  th {
    text-align: right;

    &.wps-compare-table__num {
      text-align: left;
    }
  }

  .wps-campaign-rows__sub td:first-child {
    padding-left: 12px;
    padding-right: $wps-card-pad-x + 24px;
  }
}

// Full-bleed tables: rows reach the card edges, text keeps the card padding
#wpbody .wps-channels-compared,
#wpbody .wps-campaign-table {
  .o-table-wrapper {
    margin-left: -$wps-card-pad-x;
    margin-right: -$wps-card-pad-x;
  }
}

@media (max-width: 480px) {
  #wpbody .wps-channels-compared,
  #wpbody .wps-campaign-table {
    .o-table-wrapper,
    .wps-campaign-table__note {
      margin-left: -16px;
      margin-right: -16px;
    }
  }
}
