// Tables
// --------------------------------------------------
@sort-icon-offset: 10px;
@sort-icon-width: 12px;
@sort-icon-height: 8px;

@sort-icon-position-none: 0;
@sort-icon-position-sortable: -1;
@sort-icon-position-sortable-asc: -2;
@sort-icon-position-sortable-asc-disabled: -3;
@sort-icon-position-sortable-asc-disabled-desc: -4;
@sort-icon-position-sortable-desc: -5;
@sort-icon-position-sortable-desc-disabled: -6;
@sort-icon-position-sortable-desc-disabled-asc: -7;

.table-wrapper {
  margin-bottom: 17px;
  &:last-child {
    margin-bottom: 0;
  }
  &.table-m {
    width: 50%;
  }
  &.table-sm {
    width: 30%;
  }
  .table-content {
    overflow: auto;
    //&.scroll-scrollx_visible {
    //  padding-bottom: 11px;
    //}
    //+ .scroll-element.scroll-scrollx_visible {
    //  bottom: 0px;
    //}
  }
  &.edge-2-edge {
    margin-left: -18px;
    margin-right: -18px;
    form > & {
      margin-left: -(@form-padding + 18);
      margin-right: -(@form-padding + 18);
    }
    .table-toolbar {
      margin-left: 18px;
      margin-right: 18px;
      form > & {
        margin-left: (@form-padding + 18);
        margin-right: (@form-padding + 18);
      }
      .toolbar-filter {
        margin-left: -18px;
        margin-right: -18px;
        form > & {
          margin-left: -(@form-padding + 18);
          margin-right: -(@form-padding + 18);
        }
      }
    }
  }
  //form > & {
  //  margin-left: -@form-padding;
  //  margin-right: -@form-padding;
  //}
}

table, .table {
  min-width: 100%;
  margin-bottom: 0;
  tr {
    td {
    }
  }
  td {
    word-wrap: break-word;
  }
  th {
    white-space: nowrap;
    .form-group {
      &.no-label {
        label {
          float: left;
        }
      }
    }
  }
  tbody {
    .form-inline {
      .form-group {
        width: 100%;
      }
    }
    form {
      padding: 0;
      margin: 0;
    }
    .form-group {
      &:only-child {
        margin: 0;
      }
      &.no-label {
        .form-control {
          width: 100%;
        }
      }
      &.formatted-telephone {
        label {
          width: 20%;
        }
        .formatted-telephone-country {
          width: 53px;
        }
        .formatted-telephone-area {
          width: 63px;
        }
        .formatted-telephone-number {
          width: 140px;
        }
      }
      &.left-aligned, &.checkbox, &.radio, &.tristate {
        label {
          width: auto;
        }
      }
      &.checkbox, &.radio, &.tristate {
        input[type='checkbox'],
        input[type='radio'] {
          width: 18px;
        }
      }
    }
  }
}

//----------------------------------------------------------



.table-handles {
  text-align: center;
  a {
    width: 10px;
    height: 10px;
    display: inline-block;
    .border-radius(100%);
    background-color: @black040;
    vertical-align: middle;
    &.table-notification {
      background-color: @enterprise-blue;
    }
    &.table-notification-alert {
      background-color: @red;
    }
  }

}

.table {
  border-collapse: collapse;
  border-spacing: 1px;

  .filter {
    .form-control {
      width: 100%;
      &.bootstrap-select {
        min-width: 100%;
      }
    }
    .checkbox, .radio {
      .form-control {
        width: auto;
      }
    }
    .form-group {
      margin: 0;
      width: 100%;
    }

    .form-inline {
      padding: 2px 0 2px 10px;
      .form-group {
        width: auto;
        vertical-align: middle;
      }
      &.form-row {
        .btn {
          margin-bottom: 0;
        }
      }
    }
  }

  > thead,
  > tbody,
  > tfoot {
    > tr {
      > th,
      > td {
        border: 0 solid @white;
        border-top: 1px solid @enterprise-blue020;
        border-right: 1px solid @enterprise-blue020;
        padding: 0 8px;
        vertical-align: middle;
        &:first-child {
          border-left: 1px solid @enterprise-blue020;
        }
        &.handle {
          padding: 0;
          width: @single-pane-offset + @single-pane-item-offset;
        }
      }
      > th {
        border-right: 1px solid @enterprise-blue020;
        &:first-child {
          border-left: 1px solid @enterprise-blue020;
        }
        &.handle {
          background-color: @enterprise-blue020;
        }
      }
    }
  }

  &.remove-vertical-line {
    > thead,
    > tbody,
    > tfoot {
      > tr {
        > th,
        > td {
          border-right: none;
        }
      }
    }
  }

  > thead > tr {
    > td,
    > th {
      background-color: @enterprise-blue020;
      color: @black080;
    }
    > th {
      vertical-align: middle;
      > span {
        display: inline-block;
        max-width: 100%;
        vertical-align: middle;
        margin-right: -50px;
        padding-right: 50px;
        &:last-child {
          margin-right: 0;
          padding-right: 0;
        }
      }
    }

    &.filter {
      > th,
      > td {
        padding: 2px;
        vertical-align: middle;
        &.handle {
          border-right: 1px solid @enterprise-blue020;
        }
      }
    }
  }

  thead, tbody {
    td, th {
      height: 26px;
    }
  }
  tfoot td {
    border-spacing: 0;
    background-color: @enterprise-blue020;
    color: @black080;
    .font-size(11);
    height: 31px;
  }

  > tbody {
    > tr {
      > th,
      > td {
        &.handle {
          border-right: 1px solid @enterprise-blue020;

        }
      }
    }
  }

  .sorting {
    background-image: url('../images/icons/table-sort.png');
    background-size: 30px auto;
    background-repeat: no-repeat;
    background-position: @sort-icon-offset 0;
    content: "";
    width: @sort-icon-offset + @sort-icon-width;
    height: 14px;
    .inline;
    vertical-align: middle;
  }

  .sorting-desc, .tablesorter-headerDesc .sorting {
    background-position: 10px (@sort-icon-position-sortable-desc * @sort-icon-height);
  }

  .sorting-desc-disabled {
    background-position: 10px (@sort-icon-position-sortable-desc-disabled * @sort-icon-height);
    cursor: not-allowed;
  }

  .sorting-desc-disabled-asc {
    background-position: 10px (@sort-icon-position-sortable-desc-disabled-asc * @sort-icon-height);
  }

  .sorting-asc, .tablesorter-headerAsc .sorting {
    background-position: 10px (@sort-icon-position-sortable-asc * @sort-icon-height);
  }

  .sorting-asc-disabled {
    background-position: 10px (@sort-icon-position-sortable-asc-disabled * @sort-icon-height);
    cursor: not-allowed;
  }

  .sorting-asc-disabled-desc {
    background-position: 10px (@sort-icon-position-sortable-asc-disabled-desc * @sort-icon-height);
  }

  .sorting-disabled {
    background-image: none;
  }
  .tablesorter-headerUnSorted .sorting {
    background-position: 10px 0;
  }
}

// Table Footer
.table-footer {
  background-color: @enterprise-blue020;
  color: @black080;
  .font-size(11);
  min-height: 30px;
  padding: 4px 8px;
  border-right: 1px solid @enterprise-blue020;
  border-left: 1px solid @enterprise-blue020;
  &:after {
    content: '';
    height: 0;
    display: block;
    clear: both;
  }
  .pagination {
    padding-left: 4px;
    padding-right: 4px;
    margin-top: -4px;
    margin-bottom: -4px;
  }
  .pagination-page-view {
    padding-left: 4px;
    padding-right: 4px;
    height: 22px;
    .control-label {
      line-height: 22px;
      width: auto;
      padding-top: 0;
      margin-bottom: 0;
    }
    .form-group {
      width: auto;
      display: inline-block;
      margin-right: 0;
      margin-bottom: 0;
      .control-label {
        text-align: left;
        padding: 0;
      }
      .control-input {
        width: auto;
      }
      .form-control {
        height: 22px;
      }
    }
  }
}

//filter
.table-toolbar {
  margin-bottom: 1px;

  .btn-text{
    height: 24px;
    margin-bottom: 5px;
    padding: 6px 30px;
    line-height: 1;
  }

  .toolbar-filter {
    display: none;
    padding: 10px;
    background-color: @enterprise-blue010;
    border: 1px solid @black010;
    > form {
      margin: 0;
      padding: 0;
    }
    .form-row {
      &:after {
        content: '';
        display: block;
        height: 0;
        clear: both;
      }
    }
    .form-group {
      margin-bottom: 0;
      vertical-align: middle;
      + .form-group {
        margin-bottom: 0;
      }
      &.pull-right {
        &:last-child {
          margin-right: 8px;
        }
        .btn {
          &:last-child {
            margin-right: 0;
          }
        }
      }
      .control-input{
        @media @desktop {
          margin-bottom: 10px;          
        }
      }
    }
  }
  > .form-group, >.btn {
    margin-bottom: 5px;
  }
  &:after {
    content: '';
    display: block;
    height: 0;
    clear: both;
  }
}

.btn-filter {
  &:extend(.btn-text);
  padding: 6px 30px 7px 30px;
  line-height: 1;
  margin-bottom: 5px;
  &.selected {
    &:extend(.btn-default);
    padding: 6px 30px 7px 30px;
    font-weight: bold;
    text-decoration: none;
    @media @desktop {
      color: @black080;      
    }
  }
}

tr.filter {
  display: none;
}

.table-striped {
  >tbody {
    >tr {
      &:nth-of-type(odd) {
        background-color: @enterprise-blue010;
      }
    }
  }
}

//table head grouping
.has-table-group {
  tr:first-child {
    th {
      border-right: 1px solid @white;
      background-color: @causeway-blue-50;
      text-align: center;
      &:last-child {
        border-right: 1px solid @causeway-blue-50;
      }
    }
  }
}

@media @desktop {
  .table-toolbar {
    text-align: right;
    .btn-filter {
      font-family: FontAwesome;
      margin-right: 20px;
      text-indent: -99999px;
      position: relative;
      padding: 0;
      &:before {
        content: "\f0b0";
        position: absolute;
        left: 0;
        text-indent: 0;
        font-size: 20px;
      }
      &:hover, &:active {
        color: @enterprise-blue;
      }
      .selected {
        color: @black080 !important;
      }
    }
  }
  .table-content {
    overflow-x: auto;
  }
  .table-wrapper{
    margin-right: -20px;
    margin-left: -20px;
    &.edge-2-edge {
      margin-right: -20px;
      margin-left: -20px;
    }
  }
  form {
    .table-wrapper {
      margin-right: 0;
      margin-left: 0;
    }
  }

  //styling
  .table, table {
    > thead {
      > tr {
        > th {
          height: @primary-tap-height;
          background-color: @enterprise-blue020;
          &:first-child, &.handle + td {
            border-right-width:2px;
            //margin-right: -2px;
          }
        }
      }
    }
    tr:last-child {
      td {
        border-bottom: none;
      }
    }

    thead, tbody {
      td, th {
        height: @secondary-tap-height;
      }
    }

    tbody {
      .form-group {
        &.formatted-telephone {
          label {
            width: 100%;
          }
        } 
      }
      td {
        &.fTHLC-left-col {
          display: flex;
          align-items: center;
          //margin-right: -1px;
        }
      }
    }
    thead {
      .fTHLC-head-row {
        display: flex;
        align-items: center;
        padding-left: 9px;
      }
    }
  }

//  Filters
  .table-filter-list {
    padding: 0;
    margin: 0;
    list-style: none;
    display: none;
    li {
      border-bottom: 1px solid @causeway-blue-50;
      &.applied {
        border-bottom-color: @enterprise-blue;
        background-color: #eef4fd;
      }
    }
    button {
      margin: 0;
      width: 50%;
      height: 44px;
      &.btn-default {
        background-color: @causeway-blue-50;
      }
    }
    p {
      padding: 10px 10px 0 10px;
      font-weight: bold;
      margin: 0;
    }
    .form-group {
      margin-bottom: 0;
      input {
        border-bottom: 0 none;
        background-color: transparent;
      }
    }
  }


//  Scrollbars
  .fTHLC-outer-wrapper {
    //background-color: @causeway-blue-30;
    .box-sizing(content-box);
    width:auto !important;
    border: 1px solid @black010;
  }
  .fTHLC-inner-wrapper {
    direction: rtl;
    border-left: 1px solid @black010;
    table,.table {
      direction: ltr;
    }
  }
  .MobScroll::-webkit-scrollbar {
    width: 4px;
    height: 4px;
  }

  /* Track */
  .MobScroll::-webkit-scrollbar-track {
    background-color: transparent;
  }

  .MobScroll::-webkit-scrollbar-track-piece {
    background-color: transparent;
  }

  .MobScroll::-webkit-scrollbar-corner {
    background-color: transparent;
  }

  /* Handle */
  .MobScroll::-webkit-scrollbar-thumb {
    background-color: @enterprise-blue;
  }
  .table-footer {
    .pagination {
      margin-top: 30px;
      margin-bottom: 0px;
    }
  }
}