$table-graph--font: 12px;
$table-graph--text-color: $g11-sidewalk;
$table-graph--text-highlight: $g20-white;
$table-graph--cell: $g0-obsidian;
$table-graph--cell-highlight: $g2-kevlar;
$table-graph--heading-text: $g14-chromium;
$table-graph--heading-text-corner: $g18-cloud;
$table-graph--heading-sort: $c-pool;
$table-graph--heading-bg: $g1-raven;
$table-graph--heading-bg--active: $g3-castle;
$table-graph--border: $g3-castle;

$table-light-graph--text-color: $g8-storm;
$table-light-graph--text-highlight: $g5-pepper;
$table-light-graph--cell: $g20-white;
$table-light-graph--cell-highlight: $g18-cloud;
$table-light-graph--heading-text: $g9-mountain;
$table-light-graph--heading-text-corner: $g6-smoke;
$table-light-graph--heading-sort: $c-pool;
$table-light-graph--heading-bg: $g17-whisper;
$table-light-graph--heading-bg--active: $g16-pearl;
$table-light-graph--border: $g16-pearl;

.time-machine-tables {
  display: flex;
  align-items: stretch;
  flex-wrap: nowrap;
  width: 100%;
  height: 100%;
}

.time-machine-sidebar {
  flex: 1 0 180px;
  background-color: $table-graph--cell;
  margin-right: $cf-marg-a;
  overflow: hidden;
  border-radius: $cf-radius;
  border: $cf-border solid $table-graph--border;
}

.time-machine-sidebar--heading {
  padding: 10px;
  background: $table-graph--heading-bg--active;
  height: 50px;
}

.time-machine-sidebar--scroll {
  height: calc(100% - 50px) !important;
}

.time-machines-sidebar--filter.form-control.cf-input-xs {
  font-size: 12px;
}

.time-machine-sidebar--items {
  width: 100%;
  display: inline-flex;
  flex-direction: column;
}

.time-machine-sidebar-item {
  @include no-user-select();
  color: $table-graph--text-color;
  font-size: $table-graph--font;
  font-weight: $cf-font-weight--regular;
  padding: $cf-marg-b $cf-marg-b;
  transition: color 0.25s ease, background-color 0.25s ease;
  white-space: nowrap;

  > span {
    padding-right: $cf-border;
  }

  > span.key,
  > span.equals {
    color: rgba($table-graph--text-color, 70%);
  }

  > span.value {
    font-weight: $cf-font-weight--medium;
    padding-right: $cf-marg-b;
    color: $table-graph--text-color;
  }

  &:hover {
    background-color: $table-graph--cell-highlight;
    color: $table-graph--text-color;
    cursor: pointer;

    > span.key,
    > span.equals {
      color: $table-graph--text-color;
    }

    > span.value {
      color: $table-graph--text-highlight;
    }
  }
  
  &.active {
    background-color: $table-graph--heading-bg--active;
    color: $table-graph--text-highlight;

    > span.key,
    > span.equals {
      color: $table-graph--text-highlight;
    }

    > span.value {
      color: $table-graph--heading-sort;
    }
  }
}

.time-machine-table {
  flex: 4 0 100px;
  border: $cf-border solid $table-graph--border;
  border-radius: $cf-radius-sm;
  overflow: hidden;

  &:only-child {
    border: 1;
  }
}

/*
    Table Type Graphs in Dashboards
    ----------------------------------------------------------------------------
*/

.table-graph-cell {
  user-select: text !important;
  -o-user-select: text !important;
  -moz-user-select: text !important;
  -webkit-user-select: text !important;
  line-height: 28px; // Cell height - 2x border width
  padding: 0 6px;
  font-size: $table-graph--font;
  background-color: $table-graph--cell;
  font-weight: 500;
  color: $table-graph--text-color;
  border: ($cf-border / 2) solid $table-graph--border;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;

  &__highlight-row {
    color: $table-graph--text-highlight;
    background-color: $table-graph--cell-highlight;
  }
  &__numerical {
    font-family: $cf-code-font;
    text-align: right;
  }
  &__fixed-row,
  &__fixed-column {
    font-weight: 700;
    color: $table-graph--heading-text;
    background-color: $table-graph--heading-bg;
  }
  &__fixed-row {
    border-top: 0;
  }
  &__fixed-column {
    border-left: 0;
  }
  &__fixed-corner {
    font-weight: 700;
    border-top: 0;
    border-left: 0;
    color: $table-graph--heading-text-corner;
    background-color: $table-graph--heading-bg--active;
  }
  &__field-name {
    padding-right: 17px;

    &:before {
      font-family: 'icomoon';
      content: '\e902';
      font-size: 17px;
      position: absolute;
      top: 50%;
      right: 6px;
      transform: translateY(-50%) rotate(180deg);
      font-size: 13px;
      opacity: 0;
      transition: opacity 0.25s ease, color 0.25s ease, transform 0.25s ease;
    }
    &:hover {
      cursor: pointer;
    }
    &:hover:before {
      opacity: 1;
    }
  }
  &__sort-asc,
  &__sort-desc {
    color: $table-graph--heading-sort;

    &:before {
      opacity: 1;
    }
  }
  &__sort-asc:before {
    transform: translateY(-50%) rotate(180deg);
  }
  &__sort-desc:before {
    transform: translateY(-50%) rotate(0deg);
  }
}

/*
    Light Mode
    ----------------------------------------------------------------------------
*/

.time-machine-table.time-machine-table__light-mode {
  border-color: $table-light-graph--border;

  .table-graph-cell {
    background-color: $table-light-graph--cell;
    color: $table-light-graph--text-color;
    border-color: $table-light-graph--border;

    &__highlight-row {
      color: $table-light-graph--text-highlight;
      background-color: $table-light-graph--cell-highlight;
    }
    &__fixed-row,
    &__fixed-column {
      color: $table-light-graph--heading-text;
      background-color: $table-light-graph--heading-bg;
    }
    &__fixed-corner {
      color: $table-light-graph--heading-text-corner;
      background-color: $table-light-graph--heading-bg--active;
    }
    &__sort-asc,
    &__sort-desc {
      color: $table-light-graph--heading-sort;
    }
  }
}

.time-machine-sidebar.time-machine-sidebar__light {
  background-color: $table-light-graph--cell;
  border-color: $table-light-graph--border;

  .time-machine-sidebar--heading {
    background: $table-light-graph--heading-bg--active;
  }

  .time-machine-sidebar-item {
    color: $table-light-graph--text-color;

    > span.key,
    > span.equals {
      color: rgba($table-light-graph--text-color, 70%);
    }

    > span.value {
      color: $table-light-graph--text-color;
    }

    &:hover {
      background-color: $table-light-graph--cell-highlight;
      color: $table-light-graph--text-color;

      > span.key,
      > span.equals {
        color: $table-light-graph--text-color;
      }

      > span.value {
        color: $table-light-graph--text-highlight;
      }
    }
    
    &.active {
      background-color: $table-light-graph--heading-bg--active;
      color: $table-light-graph--text-highlight;

      > span.key,
      > span.equals {
        color: $table-light-graph--text-highlight;
      }

      > span.value {
        color: $table-light-graph--heading-sort;
      }
    }
  }

  .cf-input.time-machine-sidebar--filter > input {
    background-color: $g18-cloud;
    color: $g7-graphite;
    border-color: $g15-platinum;

    &::-webkit-input-placeholder {
      color: $g15-platinum;
    }
    &::-moz-placeholder {
      color: $g15-platinum;
    }
    &:-ms-input-placeholder {
      color: $g15-platinum;
    }
    &:-moz-placeholder {
      color: $g15-platinum;
    }

    &:focus {
      border-color: $c-pool;
      background-color: $g20-white;
    }
  }
  .cf-input.time-machine-sidebar--filter:hover > input {
    background-color: $g20-white;
    border-color: mix($g15-platinum, $c-pool, 50%);
  }

  .cf-input.cf-input__focused.time-machine-sidebar--filter > .cf-input-icon {
    color: $c-pool;
  }

  .time-machine-sidebar--scroll .cf-dapper-scrollbars--track-y {
    background-color: $g15-platinum !important;
  }
}
