$prefix-column-width: rem(180px);
$suffix-column-width: rem(184px);
$breakpoint: 768px;

.Polaris-DataTable {
  position: relative;
  max-width: 100vw;
  overflow: hidden;
}

.Polaris-DataTable--hasFooter {
  .Polaris-DataTable__ScrollContainer {
    margin-bottom: rem(52px);
  }
}

.Polaris-DataTable__Navigation {
  display: none;
}

.Polaris-DataTable__Navigation--left,
.Polaris-DataTable__Navigation--right {
  position: absolute;
  top: 0;
  bottom: -1px;
  z-index: 2;
}

.Polaris-DataTable__Navigation--left {
  left: $prefix-column-width;
  .Polaris-DataTable__Navigation--button {
    box-shadow: inset 1px 0 rgba(color('ink'), 0.1);
    background: linear-gradient(
      to right,
      rgba(color('ink'), 0.15),
      rgba(color('ink'), 0.06),
      rgba(color('ink'), 0)
    );
  }
}

.Polaris-DataTable__Navigation--right {
  right: -1px;
  .Polaris-DataTable__Navigation--button {
    background: linear-gradient(
      to left,
      rgba(color('ink'), 0.15),
      rgba(color('ink'), 0.06),
      rgba(color('ink'), 0)
    );
  }
}

.Polaris-DataTable__Navigation--hasActionSuffix {
  right: calc(#{$suffix-column-width} - 1px);
}

.Polaris-DataTable__Navigation--button {
  display: flex;
  align-items: center;
  padding: spacing('loose');
  position: sticky;
  top: 0;
  bottom: 0;
  height: 100vh;
  max-height: 100%;
  z-index: 2;
  &:hover {
    cursor: pointer;
    @include state(press);
  }
}

.Polaris-DataTable__Navigation--chevron {
  width: rem(32px);
  height: rem(32px);
  filter: drop-shadow(0 1px rgba(color('black'), 0.5)) drop-shadow(0 0 4px rgba(color('black'), 0.25)) drop-shadow(0 0 16px black);
}

.Polaris-DataTable__Pip {
  height: rem(6px);
  width: rem(6px);
  background: color('ink', 'lightest');
  border-radius: border-radius();

  &:not(:last-of-type) {
    margin-right: spacing(extra-tight);
  }
}

.Polaris-DataTable__Pip--visible {
  background: color('ink');
}

.Polaris-DataTable__ScrollContainer {
  overflow-x: auto;
  // account for a mysterious gap in Safari when not collapsed
  margin-left: $prefix-column-width;
  -webkit-overflow-scrolling: touch;
}

.Polaris-DataTable__ScrollContainer--hasActionSuffix {
  margin-right: $suffix-column-width;
}

.Polaris-DataTable__Table {
  display: table;
  width: 100%;
  border-spacing: 0;

}

.Polaris-DataTable__TableHead,
.Polaris-DataTable__TableBody {
  display: table-header-group;
}

.Polaris-DataTable__TableRowWrapper {
  display: table-row-group;
}

.Polaris-DataTable__TableRow {
  display: table-row;
}

.Polaris-DataTable__TableRow--link {
  color: inherit;
  text-decoration: none;
  &:hover {
    .Polaris-DataTable__Cell--link {
      @include state(base);
    }
    .Polaris-DataTable__Cell--suffix:hover ~ .Polaris-DataTable__Cell--link {
      background: none;
    }
  }
  &:active {
    .Polaris-DataTable__Cell--link {
      @include state(hover);
    }
    .Polaris-DataTable__Cell--suffix:hover ~ .Polaris-DataTable__Cell--link {
      background: none;
    }
  }
}

.Polaris-DataTable__TableFoot {
  border-bottom: 0;
}

.Polaris-DataTable__Cell {
  display: table-cell;
  padding: spacing();
  border-top: border();
  white-space: nowrap;
  text-align: left;
  vertical-align: middle;
}

.Polaris-DataTable__Cell--link {
  color: inherit;
  text-decoration: none;
}

.Polaris-DataTable__Cell--numeric {
  text-align: right;
}

.Polaris-DataTable__Cell--prefix,
.Polaris-DataTable__Cell--suffix {
  display: flex;
  align-items: center;
  @include text-emphasis-normal;
  @include text-breakword;
  position: absolute;
  top: auto;
  white-space: unset;
  text-align: left;
  backface-visibility: hidden; // stops painting on scroll (due to positioning)
}

.Polaris-DataTable__Cell--prefix {
  left: 0;
  width: $prefix-column-width;
}

.Polaris-DataTable__Cell--suffix {
  right: 0;
  width: $suffix-column-width;
  border-left: border();
}

.Polaris-DataTable__Cell--truncated {
  white-space: nowrap;
  overflow-x: hidden;
  text-overflow: ellipsis;
}

.Polaris-DataTable__Cell--header {
  font-weight: 400;
  border-top: border();
}

.Polaris-DataTable__Icon {
  display: flex;
  align-self: flex-end;
  opacity: 0;
  transition: opacity duration() easing(), fill duration() easing();
}

.Polaris-DataTable__Heading {
  @include unstyled-button;
  color: inherit;
  position: relative;
  display: inline-flex;
  justify-content: flex-start;
  flex-direction: row-reverse;
  align-items: baseline;
  transition: color duration() easing();

  &:hover,
  &:focus {
    .Polaris-DataTable__Icon {
      opacity: 1;
    }
  }
}

.Polaris-DataTable__Heading--numeric {
  justify-content: flex-end;
}

.Polaris-DataTable__Cell--sorted {
  .Polaris-DataTable__Heading {
    @include text-emphasis-strong;
  }
  .Polaris-DataTable__Icon {
    opacity: 1;
  }
}

.Polaris-DataTable__Cell--total {
  @include text-emphasis-strong;
  background: color('sky', 'lighter');
  border-top: border();
}

.Polaris-DataTable__Cell--footer {
  @include text-emphasis-normal;
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  border-bottom: 0;
  background: color('sky', 'light');
  color: color('ink', 'lighter');
  white-space: unset;
  text-align: center;
  backface-visibility: hidden; // stop painting on scroll (due to positioning)
}

@media (min-width: 1100px) {
  .Polaris-DataTable--collapsed {
    position: relative;
    .Polaris-DataTable__Navigation {
      display: block;
    }
  }
}