@use "../../../assets/mixins.scss" as *;

.data-table {
  --cell-font-family: var(--font-family-base);
  --cell-font-weight: 500;
  --selected-bg: rgba(99, 224, 36, 0.12);

  width: 100%;
  max-height: 100%;
  flex-direction: column;
  border: 1px solid var(--bg-elevated-02);
  border-radius: 6px;
  position: relative;
  font-weight: 500;

  // outline: 1px solid yellow;

  &.monospace {
    --cell-font-family: var(--font-family-monospace);
    --cell-font-weight: 400;
  }

  .t-scroll {
    --handle-bg: #ccc;
    position: absolute;
    right: 0;
    bottom: 0;
    width: 0;
    z-index: 1;

    > div {
      position: absolute;
      top: 6px;
      bottom: 6px;
      width: 0px;
    }

    &__handle {
      position: absolute;
      width: 12px;
      background-color: var(--handle-bg);
      transform: translateX(-50%);
      cursor: pointer;
      &:before {
        background-color: var(--handle-bg);
        border-radius: 6px 6px 0 0;
        position: absolute;
        width: 100%;
        height: 6px;
        top: -6px;
        content: "";
      }
      &:after {
        background-color: var(--handle-bg);
        border-radius: 0 0 6px 6px;
        position: absolute;
        width: 100%;
        height: 6px;
        bottom: -6px;
        content: "";
      }
    }
  }

  .carets {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    pointer-events: none;
  }

  .column-caret {
    position: absolute;
    top: 0;
    height: 100%;
    pointer-events: none;
    &.selected {
      outline: 1px solid var(--border-color-focus);
      background: var(--selected-bg);
    }
    &.frozen {
      z-index: 1;
      box-shadow: 10px 0 5px -2px #888;
    }
  }

  .command-menu {
    display: inline-flex;
    height: 40px;
    align-items: center;
    flex-shrink: 0;
    gap: 12px;

    border-radius: 6px;
    background: #110529;
    color: #fff;
    padding: 0 12px;

    /* Shadow M */
    box-shadow:
      0px 4px 12px -2px rgba(15, 36, 77, 0.08),
      0px 6px 24px -2px rgba(15, 36, 77, 0.08);

    hr {
      width: 1px;
      height: 100%;
      margin: 12px 0;
      background-color: #9babcc;
      opacity: 0.24;
    }

    span.command {
      font-weight: 600;
      color: #fff;
      cursor: pointer;
    }

    &__container {
      position: absolute;
      top: -45px;
      left: 0;
      width: 100%;
      z-index: 1000;
      display: flex;
      gap: 12px;
    }
  }

  .table-head {
    position: relative;
    max-width: 100%;
    overflow: hidden;
    padding-bottom: 1px;
    background-color: var(--bg-elevated-02);
    border-bottom: 1px solid var(--txt-01);

    .tr-head {
      max-width: 100%;
      overflow: hidden;
      position: relative;
      display: flex;
      flex-direction: row;
      gap: 1px;
      min-height: 40px;
      background-color: transparent;
      overflow: hidden;
    }

    .th-cell {
      position: absolute;
      background-color: #f7f8fa;
      font-weight: 600;
      font-size: 14px;
      user-select: none;
      white-space: nowrap;
      padding: 8px 12px;
      overflow: hidden;
      display: flex;
      align-items: center;
      height: 100%;

      .integer {
        @include icon(url(./16_cell-type-num.svg), 16px);
        margin-right: 4px;
      }

      .float {
        @include icon(url(./16_cell-type-num.svg), 16px);
        margin-right: 4px;
      }

      .string {
        @include icon(url(./16_cell-type-txt.svg), 16px);
        margin-right: 4px;
      }

      .unknown {
        @include icon(url(./16_cell-type-txt.svg), 16px);
        margin-right: 4px;
        opacity: 0.5;
      }

      .sort {
        margin-left: auto;
        @include icon(url(./16_arrow-down.svg), 16px);
        opacity: 0.1;
        cursor: pointer;

        &:hover {
          opacity: 0.5;
        }

        &.DESC {
          display: block;
          opacity: 1;
        }

        &.ASC {
          display: block;
          transform: rotateZ(180deg);
          opacity: 1;
        }
      }
    }
  }

  .table-body {
    position: relative;
    max-height: 100%;
    max-width: 100%;
    overflow: hidden;
    background-color: var(--bg-elevated-02);

    .tr-body {
      position: absolute;
      left: 0;
      max-width: 100%;
      overflow: hidden;
      display: flex;
      flex-direction: row;
      gap: 1px;
      background-color: transparent;
      width: 100%;

      &.selected {
        background-color: #fff;
        outline: 1px solid var(--border-color-focus);
        .td-cell {
          &::after {
            position: absolute;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            content: "";
            background: var(--selected-bg);
            pointer-events: none;
          }
        }
      }
    }

    &__no-data {
      height: 212px;
      background-color: #f7f8fa;
      display: flex;
      align-items: center;
      justify-content: center;

      color: var(--txt-mask);
      font-size: 28px;
      font-style: normal;
      font-weight: 500;
      line-height: 32px;
      letter-spacing: -0.56px;

      > div {
        display: flex;
        flex-direction: column;
        gap: 4px;
        align-items: center;
      }
    }
  }

  .td-cell {
    position: absolute;
    background-color: #fff;
    overflow: hidden;
    display: flex;
    align-items: center;
    height: 100%;
    padding: 1px;

    &.justify-center {
      justify-content: center;
    }

    .control-cell {
      padding: 8px 12px;
    }

    .base-cell {
      font-family: var(--cell-font-family);
      font-weight: var(--cell-font-weight);
      padding: 8px 12px;
      width: 100%;
      height: 100%;
      display: flex;
      align-items: center;
      user-select: text;
      overflow: hidden;
      input {
        border: none;
        outline: none;
        font-size: inherit;
        font-family: inherit;
        font-weight: inherit;
        width: 100%;
        padding: 0;
      }
      &__edit {
        outline: 1px solid var(--border-color-focus);
      }
    }
  }
}
