@use "sass:map";
@use "@befe/brick-style/src/themes/base";
@use "@befe/brick-style/src/themes/table";

// sticky fixed columns
.brick-table {
  &-scroll-x-position-leave-left {
    .brick-cell-fixed-left-last {
      border-right-color: transparent;
    }
    .brick-cell-fixed-left-last::after {
      @include base.box-shadow-inset(left);
      & {
        bottom: -(base.$border-width-base);
      }
    }
  }
  &-scroll-x-position-leave-right {
    .brick-cell-fixed-right-first::after {
      @include base.box-shadow-inset(right);
      & {
        bottom: -(base.$border-width-base);
      }
    }
  }


}

// fixed-table
.brick-table {
  &-fixed-table {
    //width: auto;
    position: absolute;
    overflow: hidden;
    margin-top: -(base.$border-width-base);
    margin-bottom: -(base.$border-width-base);
    top: 0;

    &-left {
      left: 0;
    }

    &-right {
      right: 0;
    }

    table {
      width: auto;
    }
  }

  @each $fixed-type in ('left', 'right') {
    &-scroll-x-position-leave-#{$fixed-type} {
      .brick-table-fixed-table-#{$fixed-type} {
        box-shadow: map.get(table.$table-fixed-shadow, $fixed-type);
      }
    }
  }

  &-scroll-x-position-leave-neither {
    .brick-table-fixed-table {
      display: none;
    }
  }

  &-with-scroll-x {
    .brick-table-main-head-wrap,
    .brick-table-main-body-wrap {
      table {
        width: auto;
        min-width: 100%;
      }
    }
  }

  &-with-fixed-head {
    // 用于隐藏 scrollbar 取一个能容纳各浏览器滚动条的魔法值
    $generous-scrollbar-width: 20px;
    table th {
      //border-bottom: none;
    }

    .brick-table-head-wrap-outer {
      overflow: hidden;
    }

    .brick-table-head-wrap-inner {
      overflow: scroll;
      margin-bottom: -$generous-scrollbar-width;
      padding-bottom: $generous-scrollbar-width;
    }

    &.brick-table-with-scroll-x {
      .brick-table-main-body-wrap,
      .brick-table-fixed-body-wrap-inner {
        overflow: scroll;
      }
    }

    .brick-table-fixed-table-left {
      .brick-table-fixed-head-wrap-outer,
      .brick-table-fixed-body-wrap-outer {
        overflow: hidden;
      }

      .brick-table-fixed-head-wrap-inner,
      .brick-table-fixed-body-wrap-inner {
        margin-right: -$generous-scrollbar-width;
        padding-right: $generous-scrollbar-width;
      }
    }
  }
}

// 或许需要，备忘，后期清理
.brick-table-fixed-fallback {
  table {
    overflow: hidden;
    border-collapse: collapse;
  }
}
