/**
* c-table
*/
@import url('../../styles/variables.css');

.c-table__sm {
  & table th,
  & table td {
    font-size: 12px;
  }
}

.c-table__md {
  & table th,
  & table td {
    font-size: 14px;
  }
}

.c-table__lg {
  & table th,
  & table td {
    font-size: 16px;
  }
}

.c-fixtable__left,
.c-fixtable__right {
  position: absolute;
  top: 0;
  z-index: 1;
  box-shadow: none;
  transition: box-shadow 0.3s ease;
}

.c-fixtable__left {
  left: 0;
}

.c-fixtable__right {
  right: 0;
  background: rgb(246, 250, 253);
}

.c-fixed__leftscroll {
  box-shadow: 6px 0 6px -4px rgba(0, 0, 0, 0.2);
}

.c-fixed__rightscroll {
  box-shadow: -6px 0 6px -4px rgba(0, 0, 0, 0.2);
}

.c-scroll__thead {
  overflow-x: hidden;
  overflow-y: scroll;

  & table {
    table-layout: fixed;
  }
}

.c-fixtable__left .c-scroll__thead {
  overflow-y: hidden;
}

.c-table__body table {
  width: 100%;
  margin: 0;
  table-layout: fixed;
}

.c-scroll__table,
.c-scroll__tbody,
.c-scrolltable {
  overflow-x: auto;
  position: relative;

  & table {
    table-layout: fixed;
  }
}

.c-table {
  position: relative;

  & table {
    width: 100%;
    overflow: auto;
    border-spacing: 0;
    border-collapse: collapse;
    margin: 0;

    & th,
    & td {
      text-align: left;
      padding: 0.7em 1em;
      border: 0;
    }

    & thead {
      & tr {
        background: color(var(--blue) l(98%));

        & th {
          color: color(var(--text-color) l(35%));
          font-weight: normal;
          padding-top: 0;
          padding-bottom: 0;
          vertical-align: middle;

          &[colspan]:not([colspan="1"]) {
            text-align: center !important;
          }
        }
      }
    }

    & tbody {
      & tr {
        background-color: #fff;

        &.row-hover {
          background: color(var(--primary-color) l(95%));
        }

        & td {
          color: color(var(--text-color));
        }

        & .c-table__noresult {
          text-align: center;
        }
      }
    }

    & .c-checkbox {
      line-height: inherit;
    }
  }

  &.c-table__horizon {
    border-bottom: 1px solid color(var(--gray) l(85%));

    & table {
      & th,
      & td {
        border-top: 1px solid color(var(--gray) l(85%));
      }
    }
  }

  &.c-table__vertical {
    border-top: 1px solid color(var(--gray) l(85%));
    border-bottom: 1px solid color(var(--gray) l(85%));
  }

  &.c-table__group {
    border-color: color(var(--gray) l(85%));
    border-bottom: 1px solid color(var(--gray) l(85%));

    & table th,
    & table td {
      &.c-table__bl {
        border-left: 1px solid color(var(--gray) l(85%));
      }

      &.c-table__br {
        border-right: 1px solid color(var(--gray) l(85%));
      }
    }

    & table th {
      border-top: 1px solid color(var(--gray) l(85%));
      border-bottom: 1px solid color(var(--gray) l(85%));

      &[colspan]:not([colspan="1"]) {
        border-left: 1px solid color(var(--gray) l(85%));
        border-right: 1px solid color(var(--gray) l(85%));
      }
    }
  }
}

.c-table__body {
  overflow-y: auto;
  position: relative;
  -ms-scroll-chaining: none;
  overscroll-behavior: none;
}

.c-table__all.c-table {
  & table {
    & th,
    & td {
      border: 1px solid color(var(--gray) l(85%));
    }
  }
}

.c-table__vertical.c-table {
  & table th,
  & table td {
    border-left: 1px solid color(var(--gray) l(85%));

    &:first-child {
      border-left: 0;
    }
  }
}

.c-table__group.c-table {
  & table th:first-child {
    border-left: 1px solid color(var(--gray) l(85%));
  }

  & table th:last-child {
    border-right: 1px solid color(var(--gray) l(85%));
  }
}

.c-table__wrapper .c-fixtable__left table,
.c-table__wrapper .c-fixtable__right table {
  width: auto;
  table-layout: fixed;
}

.c-table__vertical {
  &.c-table__horizon.c-table {
    border-top: 0;
  }

  &.c-table .c-fixtable__right {
    & table {
      & th,
      & td {
        border-left: 1px solid color(var(--gray) l(85%));
      }
    }
  }
}

.c-table__sort {
  margin-left: 8px;
  display: inline-block;
  vertical-align: middle;

  & .c-sort-asc,
  & .c-sort-desc {
    line-height: 6px;
    display: block;
    width: 1em;
    height: 6px;
    cursor: pointer;
    text-align: center;
    position: relative;

    & i.sort-asc {
      top: -8px;
    }

    & i.sort-desc {
      top: 18px;
    }

    & i.sort-asc::before,
    & i.sort-desc::before {
      content: '';
      width: 0;
      height: 0;
      border-bottom: 5px dashed;
      border-right: 4px solid transparent;
      border-left: 4px solid transparent;
      display: block;
    }

    & i.sort-desc::before {
      border-top: 5px dashed;
      border-bottom: 0;
    }

    &.sorted,
    &:hover {
      color: color(var(--primary-color));
    }

    &::after {
      position: absolute;
      content: '';
      height: 20px;
      width: 14px;
      left: 0;
      top: 3px;
    }
  }

  & .c-sort-asc::after {
    top: -23px;
  }
}

/* border */
.c-table__box {
  &.c-table {
    border: 1px solid color(var(--gray) l(85%));
  }
}

.c-table__wrapper {
  & .c-fixtable__left {
    & .c-table__body {
      border-bottom: 0;
      -ms-overflow-style: none;
      overflow: hidden;
    }
  }

  & .c-table__headwrapper + .c-table__bodywrapper {
    & table {
      border-top: 0;
    }
  }
}

.c-table__all.c-table .c-table__wrapper {
  & table tbody tr:first-child td {
    border-top: 0;
  }
}
