// ---------------------------------------------------------------------------
// Came from: where visitors were right before a 404 URL.
// PHP: views/components/objects/came-from.php (404 card on Page Insights > Overview, 404 Pages tab).
// ---------------------------------------------------------------------------

.wps-came-from {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 100%;
  min-width: 0;

  &__main {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
  }

  // The title shrinks and cuts its text only when it is long; the full title is in its tooltip.
  &__label {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  // "inside link" / "campaign" is short: never cut it.
  .wps-pill {
    flex: none;

    .wps-pill__text {
      overflow: visible;
    }
  }

  &__share {
    color: $wps-text-muted;
    font-size: 12px;
    line-height: 16px;
    white-space: nowrap;
  }
}

// Column share. The URL cell is a title cell (see _title-cell.scss), which takes
// `width: 100%` and would squeeze this column down to "P…". With a "Came from" column next
// to it, the URL gets 55% and "Came from" 45%, never under 180px.
#wpbody table.wps-new-table {
  > thead > tr > th.wps-col-came-from,
  > tbody > tr > td.wps-col-came-from {
    width: 45%;
    min-width: 180px;
    max-width: 0; // lets the label cut its text instead of widening the table
  }

  > tbody > tr > td:has(~ td.wps-col-came-from):first-child {
    width: 55%;
  }

  // 404 Pages tab (fixed layout, widths come from the header row): URL takes the rest,
  // Views stays narrow, "Came from" gets its share.
  &.wps-new-table--404 {
    > thead > tr > th.wps-col-came-from,
    > tbody > tr > td.wps-col-came-from {
      width: 40%;
      max-width: none;
    }
  }
}
