@use "@tencentcloud/uikit-base-component-react/dist/styles/theme/util" as *;
@use "../../../../styles/mixins/scrollbar" as scrollbar;
@use "../../../../styles/mixins/text" as text;

.group-members {
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
  background-color: transparent;

  &__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px 0;
  }

  &__title {
    font-size: 14px;
    display: flex;
    align-items: baseline;

    @include theme() {
      color: get(text-color-primary);
    }
  }

  &__count {
    font-size: 14px;
    margin-left: 4px;

    @include theme() {
      color: get(text-color-secondary);
    }
  }

  &__expand-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;

    @include theme() {
      color: get(text-color-secondary);

      &:hover {
        background-color: get(button-color-secondary-hover);
      }

      &:active {
        background-color: get(button-color-secondary-active);
      }
    }

    &--expanded {
      transform: rotate(90deg);
    }
  }

  &__grid {
    display: grid;
    width: 100%;
    min-width: 0;
    padding: 14px 20px;
    box-sizing: border-box;
    justify-items: center;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 6px;

    &--expanded {
      max-height: 400px;

      @include scrollbar.scrollbar-thin;
    }
  }

  &__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    transition: all 0.2s ease;
    width: 100%;
    max-width: 60px;

    &--skeleton {
      cursor: default;
      pointer-events: none;
    }
  }

  &__name {
    font-size: 12px;
    text-align: center;
    max-width: 100%;

    @include text.text-ellipsis;

    @include theme() {
      color: get(text-color-primary);
    }
  }

  &__skeleton-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;

    @include light() {
      background-color: rgba(0, 0, 0, 8%);
    }

    @include dark() {
      background-color: rgba(255, 255, 255, 15%);
    }
  }

  &__skeleton-name {
    width: 40px;
    height: 12px;
    border-radius: 6px;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    animation-delay: 0.2s;

    @include light() {
      background-color: rgba(0, 0, 0, 8%);
    }

    @include dark() {
      background-color: rgba(255, 255, 255, 15%);
    }
  }

  &__action-btn {
    &__icon {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 40px;
      height: 40px;
      border-radius: 50%;
      transition: all 0.2s ease;

      @include theme() {
        color: get(text-color-secondary);
        background-color: get(bg-color-input);
      }
    }
  }

  &__loading,
  &__no-more {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
  }

  &__loading-text {
    font-size: 14px;
    color: rgba(0, 0, 0, 50%);
  }

  &__no-more-text {
    font-size: 12px;

    @include theme() {
      color: get(text-color-secondary);
    }
  }

  &__collapse {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    padding: 16px 20px;
  }

  &__collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 24px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;

    @include theme() {
      color: get(text-color-secondary);
      background-color: get(button-color-secondary-default);

      &:hover {
        background-color: get(button-color-secondary-hover);
        color: get(text-color-primary);
      }

      &:active {
        background-color: get(button-color-secondary-active);
      }
    }
  }
}

@keyframes skeleton-pulse {
  0% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }

  100% {
    opacity: 1;
  }
}
