/* 用户管理页面样式 - 基于 UIPro Figma 设计 */
@use '@/styles/variables' as *;
@use '@/styles/mixins' as *;

.users {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 24px;
  text-align: left;
  font-family: 'Noto Sans SC', $font-family-base;
}

/* 页面标题区域 */
.users__header {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
}

.users__title {
  margin: 0;
  position: relative;
  font-size: 30px;
  line-height: 36px;
  font-weight: 700;
  color: #000;
}

/* 操作按钮组 */
.users__actions {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.users__actionBtn {
  cursor: pointer;
  border: 1px solid #e5e7eb;
  padding: 8px 16px;
  background-color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  @include transition-fast;

  &:hover {
    background-color: #f9fafb;
    border-color: #d1d5db;
  }

  svg {
    width: 16px;
    height: 16px;
    color: #333;
  }
}

.users__actionText {
  position: relative;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  font-family: 'Noto Sans SC', $font-family-base;
  color: #333;
  text-align: left;
}

/* 主内容卡片区域 */
.users__card {
  align-self: stretch;
  box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.05);
  border-radius: 12px;
  background-color: #fff;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
  gap: 16px;
}

/* 搜索和筛选区域 */
.users__filters {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
}

.users__searchBar {
  align-self: stretch;
  border-radius: 8px;
  background-color: #f3f4f6;
  display: flex;
  align-items: center;
}

.users__searchIcon {
  height: 48px;
  width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;

  svg {
    width: 20px;
    height: 20px;
    color: #6b7280;
  }
}

.users__searchInput {
  width: calc(100% - 40px);
  border: none;
  outline: none;
  background-color: transparent;
  flex: 1;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  padding: 14px 8px 15px;
  box-sizing: border-box;
  font-family: 'Noto Sans SC', $font-family-base;
  font-size: 16px;
  color: #333;

  &::placeholder {
    color: #6b7280;
  }
}

/* 高级筛选折叠面板 */
.users__filterPanel {
  align-self: stretch;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  overflow: hidden;
}

.users__filterHeader {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  cursor: pointer;
  @include transition-fast;

  &:hover {
    background-color: #f9fafb;
  }
}

.users__filterTitle {
  position: relative;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: #333;
}

.users__filterArrow {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  @include transition-fast;

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

  svg {
    width: 16px;
    height: 16px;
    color: #6b7280;
  }
}

.users__filterContent {
  align-self: stretch;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border-top: 1px solid #e5e7eb;
  background-color: #fafafa;
}

/* 表格区域 */
.users__table {
  align-self: stretch;
  overflow-x: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* 表格头部 */
.users__tableHeader {
  align-self: stretch;
  min-width: 900px;
  background-color: #f3f4f6;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
}

.users__tableHeaderCell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 16px 8px;
  font-size: 12px;
  line-height: 16px;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;

  &--checkbox {
    width: 48px;
    flex-shrink: 0;
  }

  &--id {
    width: 70px;
    flex-shrink: 0;
  }

  &--avatar {
    width: 50px;
    flex-shrink: 0;
  }

  &--nickname {
    width: 60px;
    flex-shrink: 0;
  }

  &--phone {
    width: 100px;
    flex-shrink: 0;
  }

  &--adoptions {
    width: 70px;
    flex-shrink: 0;
  }

  &--teamAddress {
    width: 90px;
    flex-shrink: 0;
  }

  &--teamTotal {
    width: 80px;
    flex-shrink: 0;
  }

  &--prePlanting {
    width: 80px;
    flex-shrink: 0;
  }

  &--province {
    width: 100px;
    flex-shrink: 0;
  }

  &--city {
    width: 100px;
    flex-shrink: 0;
  }

  &--referrer {
    width: 80px;
    flex-shrink: 0;
  }

  &--ranking {
    width: 50px;
    flex-shrink: 0;
    text-align: center;
  }

  &--actions {
    width: 80px;
    flex-shrink: 0;
  }
}

/* 表格行 */
.users__tableBody {
  align-self: stretch;
  min-width: 900px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.users__tableRow {
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border-bottom: 1px solid #e5e7eb;
  @include transition-fast;

  &:hover {
    background-color: #f9fafb;
  }

  &--selected {
    background-color: #eff6ff;

    &:hover {
      background-color: #dbeafe;
    }
  }
}

.users__tableCell {
  display: flex;
  align-items: center;
  padding: 16px 8px;
  font-size: 14px;
  line-height: 20px;
  color: #333;

  &--checkbox {
    width: 48px;
    flex-shrink: 0;
    justify-content: center;
  }

  &--id {
    width: 70px;
    flex-shrink: 0;
    font-family: 'Consolas', monospace;
  }

  &--avatar {
    width: 50px;
    flex-shrink: 0;
    justify-content: center;
  }

  &--nickname {
    width: 60px;
    flex-shrink: 0;
    font-weight: 500;
  }

  &--phone {
    width: 100px;
    flex-shrink: 0;
    font-family: 'Consolas', monospace;
    color: #6b7280;
  }

  &--adoptions {
    width: 70px;
    flex-shrink: 0;
  }

  &--teamAddress {
    width: 90px;
    flex-shrink: 0;
  }

  &--teamTotal {
    width: 80px;
    flex-shrink: 0;
  }

  &--prePlanting {
    width: 80px;
    flex-shrink: 0;
  }

  &--province {
    width: 100px;
    flex-shrink: 0;
    flex-direction: column;
    align-items: flex-start;
  }

  &--city {
    width: 100px;
    flex-shrink: 0;
    flex-direction: column;
    align-items: flex-start;
  }

  &--referrer {
    width: 80px;
    flex-shrink: 0;
    font-family: 'Consolas', monospace;
  }

  &--ranking {
    width: 50px;
    flex-shrink: 0;
    justify-content: center;
    font-weight: 500;

    &.users__tableCell--gold {
      color: #333;
    }

    &.users__tableCell--normal {
      color: #6b7280;
    }
  }

  &--actions {
    width: 80px;
    flex-shrink: 0;
    justify-content: center;
    gap: 8px;
  }
}

.users__percentage {
  font-size: 14px;
  line-height: 20px;
  color: #6b7280;
}

/* 用户头像 */
.users__avatar {
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  position: relative;
  flex-shrink: 0;
}

.users__avatarStatus {
  width: 12px;
  height: 12px;
  position: absolute;
  right: 0;
  bottom: 0;
  box-shadow: 0px 0px 0px 2px #fff;
  border-radius: 9999px;

  &--online {
    background-color: #22c55e;
  }

  &--offline {
    background-color: #94a3b8;
  }

  &--busy {
    background-color: #ef4444;
  }
}

/* 操作按钮 */
.users__rowAction {
  cursor: pointer;
  border: none;
  padding: 0;
  background-color: transparent;
  font-size: 12px;
  line-height: 16px;
  font-family: 'Noto Sans SC', $font-family-base;
  color: #005a9c;
  text-align: center;
  @include transition-fast;

  &:hover {
    text-decoration: underline;
  }
}

/* 复选框 */
.users__checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #005a9c;
}

/* 分页区域 */
.users__pagination {
  align-self: stretch;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 16px 0 0;
  gap: 16px;
}

.users__paginationInfo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  line-height: 20px;
  color: #333;
}

.users__paginationLabel {
  color: #6b7280;
}

.users__paginationSelect {
  border-radius: 8px;
  background-color: #f3f4f6;
  border: 1px solid #cbd5e1;
  padding: 7px 30px 7px 12px;
  font-size: 14px;
  line-height: 20px;
  color: #333;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 8px center;
  background-repeat: no-repeat;
  background-size: 16px;
}

.users__paginationTotal {
  color: #6b7280;

  span {
    font-weight: 600;
    color: #333;
  }
}

/* 分页按钮列表 */
.users__paginationList {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
}

.users__pageBtn {
  cursor: pointer;
  border: 1px solid #cbd5e1;
  padding: 6px 12px;
  background-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 20px;
  font-family: 'Noto Sans SC', $font-family-base;
  color: #333;
  margin-left: -1px;
  @include transition-fast;

  &:first-child {
    border-radius: 8px 0 0 8px;
    margin-left: 0;
  }

  &:last-child {
    border-radius: 0 8px 8px 0;
  }

  &:hover:not(&--active):not(&--disabled) {
    background-color: #f3f4f6;
  }

  &--active {
    background-color: #005a9c;
    border-color: #005a9c;
    color: #fff;
    z-index: 1;
  }

  &--disabled {
    color: #9ca3af;
    cursor: not-allowed;
  }

  &--ellipsis {
    cursor: default;
  }
}

/* 用户详情弹窗 */
.userDetail {
  &__header {
    @include flex-start;
    gap: $spacing-lg;
    margin-bottom: $spacing-xl;
    padding-bottom: $spacing-lg;
    border-bottom: 1px solid $border-color;

    h3 {
      font-size: $font-size-lg;
      font-weight: $font-weight-semibold;
      margin: 0 0 $spacing-xs;
    }

    p {
      font-size: $font-size-sm;
      color: $text-secondary;
      margin: 0;
    }
  }

  &__stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: $spacing-lg;
  }

  &__statItem {
    @include flex-column;
    align-items: center;
    padding: $spacing-base;
    background-color: $background-color;
    border-radius: $border-radius-base;
  }

  &__statLabel {
    font-size: $font-size-xs;
    color: $text-secondary;
    margin-bottom: $spacing-xs;
  }

  &__statValue {
    font-family: $font-family-number;
    font-size: $font-size-xl;
    font-weight: $font-weight-semibold;
    color: $text-primary;
  }
}
