/*
    Table Styles
    ----------------------------------------------
    Most table styles are located in the Bootstrap
    Theme. Styles in here are for specific additions
    to tables that bootstrap does not do on its own
*/

// table-custom class allows us to make a table from divs so we can use
// forms inside a table
.table-custom {
  display: table !important;
  border-collapse: separate;
  border-spacing: 2px;
  width: 100%;
  padding: 10px;
  .thead {
    display: table-header-group;
    color: white;
    color: $g17-whisper !important;
    border-width: 1px;
  }
  .th {
    display: table-cell;
    font-weight: 700;
    color: $g14-chromium !important;
    border: 0 !important;
    padding: 6px 8px !important;
  }
  .tbody {
    display: table-row-group;
  }
  .tr {
    display: table-row;
  }
  .td {
    display: table-cell;
    font-weight: 500;
    color: $g14-chromium !important;
    border: 0 !important;
    padding: 6px 8px !important;
  }
  .tr .td .input {
    background-color: $g5-pepper;
    color: $g19-ghost !important;
  }
}

/*
    Sortable Tables
    ----------------------------------------------
*/
.sortable-header {
  transition: color 0.25s ease, background-color 0.25s ease;
  position: relative;

  > .icon {
    display: block;
    position: absolute;
    top: 50%;
    right: 8px;
    color: $g20-white;
    opacity: 0;
    transform: translateY(-50%);
    transition: opacity 0.25s ease, color 0.25s ease, transform 0.35s ease;
  }

  &:hover {
    cursor: pointer;
    color: $g19-ghost;
    background-color: $g5-pepper;
  }
  &.sorting-ascending,
  &.sorting-descending {
    background-color: $g5-pepper;
    color: $g19-ghost;

    > .icon {
      opacity: 1;
    }
  }
  &.sorting-ascending > .icon {
    transform: translateY(-50%) rotate(180deg);
  }
  &.sorting-descending > .icon {
    transform: translateY(-50%) rotate(0deg);
  }
}

/*
    Empty State for Tables
    ----------------------------------------------
*/
tr.table-empty-state,
.table.table-highlight > tbody > tr.table-empty-state:hover {
  background-color: transparent;

  > th {
    text-align: center;
    @include no-user-select();

    > p {
      font-weight: 400;
      font-size: 18px;
      color: $g9-mountain;
      margin-bottom: 16px;
    }
    > *:first-child {
      margin-top: 75px;
    }
    > *:last-child {
      margin-bottom: 75px;
    }
  }
}

/*
    Table Tabs
    ----------------------------------------------
*/
$table-tab-height: 30px;
$table-tab-scrollbar-height: 6px;

.table--tabs {
  display: flex;
  height: $table-tab-height;
  align-items: center;
}
.table--tab {
  font-size: 12px;
  font-weight: 600;
  @include no-user-select();
  height: $table-tab-height;
  border-radius: $radius-small $radius-small 0 0;
  line-height: $table-tab-height;
  padding: 0 6px;
  background-color: $g4-onyx;
  color: $g11-sidewalk;
  margin-right: 2px;
  transition: color 0.25s ease, background-color 0.25s ease;

  &:hover {
    background-color: $g5-pepper;
    color: $g15-platinum;
    cursor: pointer;
  }
  &.active {
    background-color: $g6-smoke;
    color: $g18-cloud;
  }
}
.table--tabs-dropdown {
  display: inline-block;
}
.table--tabs-content {
  width: 100%;
  height: calc(100% - #{$table-tab-height});
  position: absolute;
  top: $table-tab-height;
}

.table--tabs + .table--tabs-content > .generic-empty-state {
  background-color: $g6-smoke !important;
  border-radius: 0 $radius-small $radius-small $radius-small;
}

.table > tbody > tr.highlight,
.table.table-highlight > tbody > tr.highlight {
  background-color: $g4-onyx;
}

/*
    Alert History "Page"
    ----------------------------------------------
*/
.alert-history-page,
.empty-tasks-page,
.hosts-list-page {
  .container-fluid,
  .row,
  .col-md-12,
  .panel,
  .panel-body > .generic-empty-state {
    height: 100%;
  }

  .panel-body {
    height: calc(100% - 90px);
  }
}

/*
    Misc
    ----------------------------------------------
*/
.table .empty-string {
  font-weight: 500;
  color: $g8-storm;
  font-style: italic;
}
.table .table--temp-var {
  color: $c-comet;
  font-weight: 600;
}

/*
    Alert History "Table"
    ----------------------------------------------
*/

.alert-history-table {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.alert-history-table--thead {
  display: flex;
  width: 100%;
  border-bottom: 2px solid $g5-pepper;
}
.alert-history-table--th {
  @include no-user-select();
  padding: 8px;
  font-size: 13px;
  font-weight: 500;
  color: $g17-whisper;
}
.alert-history-table--tbody {
  flex: 1 0 0;
  width: 100%;
}
.alert-history-table--tr {
  display: flex;
  width: 100%;
  &:hover {
    background-color: $g4-onyx;
  }
}
.alert-history-table--td {
  font-size: 12px;
  font-family: $code-font;
  font-weight: 500;
  padding: 4px 8px;
  line-height: 1.42857143em;
  color: $g13-mist;
  white-space: pre-wrap;
  word-break: break-all;

  &.alert-history-table--host {
    white-space: nowrap;
    word-break: normal;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/*
    No Wrap Cells
    ----------------------------------------------
*/

table .table-cell-nowrap {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/*
    Hosts "Table"
    ----------------------------------------------
*/

.hosts-table {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.hosts-table--thead {
  display: flex;
  width: 100%;
  border-bottom: 2px solid $g5-pepper;
}
.hosts-table--th {
  @include no-user-select();
  padding: 8px;
  font-size: 13px;
  font-weight: 500;
  color: $g17-whisper;
}
.hosts-table--tbody {
  flex: 1 0 0;
  width: 100%;
}
.hosts-table--tr {
  display: flex;
  width: 100%;
  &:hover {
    background-color: $g4-onyx;
  }
}
.hosts-table--td {
  font-size: 12px;
  font-family: $code-font;
  font-weight: 500;
  padding: 4px 8px;
  line-height: 1.42857143em;
  color: $g13-mist;
  white-space: pre-wrap;
  word-break: break-all;
}
