@import '../../styles/foundation/colors.scss';

$table-vertical-spacing: spacing(base);
$table-horizontal-spacing: spacing(tightest);
$table-vertical-head-spacing: spacing(tighter);

$color-grey-dark: color(ink, base);
$color-grey-base: color(sky, base);

$border-color: color(sky, base);

.table {
  border: none;
  border-collapse: collapse;
  border-spacing: 0;
  display: table;
  width: 100%;
  
  .table {
    width: calc(100% - 29px);
  }
  thead tr th {
    color: #757575;
    font-weight: 600;
    text-transform: uppercase;

    &:nth-child(1) {
      padding-left: 1.6rem;
    }
  }

  tbody tr td:nth-child(1) {
    padding-left: 1.6rem;
  }

  th, td {
    border: none;
    border-radius: 2px;
    display: table-cell;
    padding: $table-vertical-head-spacing $table-horizontal-spacing;
    vertical-align: middle;
    white-space: nowrap; 
    text-overflow: ellipsis;
    text-align: left;

    .subText {
      margin-top: 0.2rem !important;
      margin-bottom: 0px !important;
      overflow-wrap: anywhere;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
    }
    
    .tableDataWrap {
      display: inline-block;
      width: -webkit-fill-available;
      white-space: break-spaces;
      text-overflow: ellipsis;
      overflow: hidden;
    }
    &[data-label='Name'] {
      .tableDataWrap {
        width: inherit;
      }
    }

    &.tableDataClick {
      cursor: pointer;
      span {
        display: inline-block;
      }
    }
  }

  th {
    background-color:transparent;
    color: $color-grey-dark;
    text-transform: uppercase;
    &:last-child{
      .iconPlusWrapper{
        right: 0px !important;
      }
    }
  }

  thead {
    border-bottom: 1px solid $border-color;
    color: $color-grey-base;
  }

  tr {
    display: table-row;
    vertical-align: inherit;
    border-color: inherit;
  }

  &.nestedTable {
    margin-left: 2.9rem;
    border-left: 3px solid $border-color;

    tr:last-child {
      border-bottom: none;
    }
  }

  .nestedCheckbox {
    padding-left: 1rem;
    padding-right: 1.6rem;
    width: 2rem;
  }
}

.parentChildTable {
  margin-left: 2.9rem;
  border-left: 3px solid $border-color;
}

.bordered {
  > thead > tr, > tbody > tr {
    border-bottom: 1px solid $border-color;
  }
}

.striped {
  > tbody {
    > tr {
      &:nth-child(odd) {
        background-color: #f2f2f2;
      }
      
      > td {
        border-radius: 0;
      }
    }
  }
}

.highlight {
  > tbody > tr {
    -webkit-transition: background-color .25s ease;
    transition: background-color .25s ease;

    &:hover {
      background-color: #f2f2f2;
    }
  }
}

.checkedRow{
  background: #E3F2FD;
  &:hover {
    background-color: #D1EAFF !important;
  }
}

.sortingHeader {
  display: flex;
  margin-left: 0px;
 
}

.sortIcon {
  display: flex;
  flex-direction: column;

  .iconStyle, .iconGroupStyle {
    width: 1.7rem;
    height: 1.7rem;
  }

  .iconStyle {
    position: relative;
    top: 3px;
  }

  .iconGroupStyle {
    width: 1.7rem;
    height: 1.7rem;

    &:last-child {
      margin-top: -1.2rem;
    }
  }
}
.iconPlusWrapper {
  position: absolute;
  width: 1.5rem;
  height: 100%;
  top: 0px;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 1;
  .iconPlusClick {
    top: -15px;
    position: absolute;
    cursor:pointer;
    border-radius: 50%;
    background: #757575;
    fill: white;
    height: 1.5rem;
    width: 1.5rem;
    padding: 3px;
  }
}

.resizeHandle{
  display: flex;
  width: 1px;
  height: 100%;
  z-index: 1;
  background: #757575;
  border-left: 1px solid #757575;
}

.searchField {
  input[type="text"] {
    position: relative;
    display: block;
    width: 1%;
    padding: .375rem .75rem;
    font-size: 1rem;
    line-height: 1.5;
    color: $color-grey-dark;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #ced4da;
    transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
    -webkit-box-flex: 1;
    -ms-flex: 1 1 auto;
    flex: 1 1 auto;
    margin-bottom: 0;
    border-top-left-radius: 0.25rem;
    border-bottom-left-radius: 0.25rem;
  }
}

.fieldGroup {
  position: relative;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  -webkit-box-align: stretch;
  -ms-flex-align: stretch;
  align-items: stretch;
  width: 100%;
}

.fieldGroupAddon {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
}

.rowActionButton {
  background: transparent !important;
  border: none !important;
  min-height: auto;
  padding: 0;
  &:hover {
    fill: color(text, link);
    color: color(text, link);
  }
  &:focus {
    fill: color(text, link);
    color: color(text, link);
  }
}

.bannerRow {
  padding: 0px !important;
}

tbody > tr.tableRowNoData {
  &:hover {
    background-color: transparent;
  }
}

@media screen and (max-width: 40em) {

    .table {
        border: 0;
    }

    .table thead {
        display: none;
    }

    .table tr,
    .table td {
        display: block;
    }

    .table tr {
        margin-bottom: 0.5em;
        
      &:after {
        clear:both;
        content:'';
        display: block;
      }
    }

    .table td {
        border-bottom: none;
        text-align: left;
    }

    .table td:last-child {
        border-bottom: 0;
        text-align: left;
     
    }

    .table td:before {
        content: attr(data-label);
        float: left;
        font-weight: bold;
        width:92px;
    }
    .table td.lastData {
      text-align:center;
      float:none!important;
      display: flex;
      .PositionedOverlay {
        margin-left:0px!important
      }
    }
}


.ResponsiveTableWrap {
  // overflow:auto;
  &::-webkit-scrollbar-track
  {
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
    background-color: color(white, base);
    height:5px;
  }

  &::-webkit-scrollbar
  {
    width: 10px;
    background-color: color(white, base);
    height:5px
  }

  &::-webkit-scrollbar-thumb
  {
    background-color: color(text, text);
    border: 2px solid color(text, darker);
    height:5px
  }
}