@use "sass:color";

/**
 * Tables
 */

$am-table-background: #fff !default;
$am-table-border-color: am-color(divider);

@mixin am-table {
  background: $am-table-background;
  width: 100%;
  word-break: break-word;
}

@mixin am-table-header {
  border-bottom: 1px solid $am-table-border-color;
  display: flex;
  padding: am-unit(2);
}

@mixin am-table-column-heading {
  @include am-color(secondary-text);
  @include am-font-size(13px);
  border-bottom: 1px solid $am-table-border-color;
  font-weight: $am-font-weight-semi-bold;
  height: am-unit(6);
  line-height: am-unit(2);
  padding: am-unit(1) am-unit(2);
  text-align: left;
  white-space: nowrap;
}

@mixin am-table-sort {
  position: relative;

  &:after {
    border: 5px solid transparent;
    margin-left: $am-unit-type;
    content: "";
    margin-top: -1.5px;
    position: absolute;
    top: 50%;
    right: -15px;
    width: 0;
    height: 0;
  }
}

@mixin am-table-sort-asc {
  &:after {
    border-bottom-color: am-color(primary);
    margin-top: -7.5px;
  }
}

@mixin am-table-sort-desc {
  &:after {
    border-top-color: am-color(primary);
  }
}

@mixin am-table-row {
  height: am-unit(6);
  transition: 0.12s background;
}

@mixin am-table-row-hover {
  background: #eee;

  td,
  th {
    box-shadow: 0 -1px 0 rgba(#000, 0.05);
    border-bottom: 1px solid color.adjust($am-table-border-color, $lightness: -5%, $space: hsl);
  }
}

@mixin am-table-row-selected {
  background: #e0e0e0;

  td,
  th {
    box-shadow: 0 -1px 0 rgba(#000, 0.15);
    border-bottom: 1px solid color.adjust($am-table-border-color, $lightness: -15%, $space: hsl);
  }
}

@mixin am-table-cell {
  @include am-color(text);
  @include am-font-size(13px);
  border-bottom: 1px solid $am-table-border-color;
  font-weight: $am-font-weight-regular;
  padding: am-unit(1) am-unit(2);

  img {
    display: block;
    height: auto;
    max-width: 320px;
    width: 100%;
  }
}

@mixin am-table-cell-selectable {
  padding: am-unit(2) am-unit(3) am-unit(2);
  width: 18px + am-unit(6);

  [type=checkbox] {
    display: inline-block;
    height: 18px;
    margin: 0;
    vertical-align: middle;
    width: 18px;
  }
}

@mixin am-table-cell-actions {
  background: url('data:image/svg+xml;utf8,<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve"> <path fill="none" d="M0,0h24v24H0V0z"/> <path opacity="0.875" d="M12,8c1.1,0,2-0.9,2-2s-0.9-2-2-2c-1.1,0-2,0.9-2,2S10.9,8,12,8z M12,10c-1.1,0-2,0.9-2,2c0,1.1,0.9,2,2,2 c1.1,0,2-0.9,2-2C14,10.9,13.1,10,12,10z M12,16c-1.1,0-2,0.9-2,2s0.9,2,2,2c1.1,0,2-0.9,2-2S13.1,16,12,16z"/> </svg>') 25% 50% no-repeat;
  position: relative;
  width: am-unit(6);
}
