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

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

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

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

/* 通用卡片样式 */
.authorization__card {
  align-self: stretch;
  box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  background-color: #fff;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
  gap: 15px;
}

.authorization__cardTitle {
  align-self: stretch;
  margin: 0;
  font-size: 18px;
  line-height: 28px;
  font-weight: 700;
  color: #1e293b;
}

/* 筛选区域 */
.authorization__filters {
  align-self: stretch;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.authorization__select {
  min-width: 160px;
  height: 38px;
  border-radius: 6px;
  background-color: #f3f4f6;
  border: 1px solid #e5e7eb;
  padding: 9px 13px;
  font-size: 14px;
  line-height: 20px;
  color: #1e293b;
  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;
}

.authorization__input {
  flex: 1;
  min-width: 120px;
  height: 36px;
  border-radius: 6px;
  background-color: #f3f4f6;
  border: 1px solid #e5e7eb;
  padding: 8px 12px;
  font-size: 14px;
  color: #1e293b;
  outline: none;
  font-family: inherit;

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

.authorization__searchBtn {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  background-color: #005a9c;
  padding: 8px 16px;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: #fff;
  font-family: inherit;
  @include transition-fast;

  &:hover {
    background-color: darken(#005a9c, 5%);
  }
}

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

.authorization__tableHeader {
  align-self: stretch;
  min-width: 800px;
  background-color: #f3f4f6;
  display: flex;
  align-items: center;
}

.authorization__tableRow {
  align-self: stretch;
  min-width: 800px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #e5e7eb;
  @include transition-fast;

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

.authorization__tableCell {
  display: flex;
  align-items: center;
  padding: 12px 24px;
  font-size: 14px;
  line-height: 20px;
  color: #1e293b;

  &--header {
    font-size: 12px;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
  }

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

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

  &--accountId {
    width: 120px;
    flex-shrink: 0;
  }

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

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

  &--teamAdoptions {
    width: 180px;
    flex-shrink: 0;
  }

  &--status {
    width: 120px;
    flex-shrink: 0;
  }

  &--actions {
    flex: 1;
    min-width: 200px;
    gap: 12px;
  }
}

/* 用户头像 */
.authorization__avatar {
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  background-size: cover;
  background-position: center;
  background-color: #e5e7eb;
}

/* 状态徽章 */
.authorization__badge {
  border-radius: 9999px;
  padding: 2.5px 10px;
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;

  &--authorized {
    background-color: #dcfce7;
    color: #166534;
  }

  &--pending {
    background-color: #fef9c3;
    color: #854d0e;
  }
}

/* 操作按钮 */
.authorization__actionBtn {
  cursor: pointer;
  border: none;
  padding: 0;
  background-color: transparent;
  font-size: 12px;
  line-height: 16px;
  font-family: inherit;
  @include transition-fast;

  &--authorize {
    color: #2563eb;

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

  &--revoke {
    color: #dc2626;

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

/* 帮助文本 */
.authorization__help {
  align-self: stretch;
  font-size: 12px;
  line-height: 16px;
  color: #6b7280;
  padding-top: 4px;
}

/* 表单区域 */
.authorization__form {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.authorization__formRow {
  align-self: stretch;
  display: flex;
  align-items: flex-start;
  gap: 24px;

  @media (max-width: 768px) {
    flex-direction: column;
  }
}

.authorization__formGroup {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 250px;
}

.authorization__formLabel {
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: #1e293b;
}

.authorization__formHint {
  font-size: 12px;
  line-height: 16px;
  color: #6b7280;
}

.authorization__formInput {
  align-self: stretch;
  border-radius: 6px;
  background-color: #f3f4f6;
  border: 1px solid #e5e7eb;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 20px;
  color: #1e293b;
  outline: none;
  font-family: inherit;
}

/* 开关切换行 */
.authorization__toggleRow {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 0;
}

.authorization__toggleLabel {
  flex: 1;
  font-size: 14px;
  line-height: 20px;
  color: #1e293b;
}

/* 开关样式 */
.authorization__toggle {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 9999px;
  cursor: pointer;
  @include transition-fast;

  &--on {
    background-color: #005a9c;
  }

  &--off {
    background-color: #e5e7eb;
  }
}

.authorization__toggleHandle {
  position: absolute;
  top: 2px;
  width: 20px;
  height: 20px;
  border-radius: 9999px;
  background-color: #fff;
  border: 1px solid #fff;
  @include transition-fast;

  &--on {
    left: 22px;
  }

  &--off {
    left: 2px;
  }
}

/* 保存按钮容器 */
.authorization__saveWrapper {
  align-self: stretch;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
}

.authorization__saveBtn {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  background-color: #005a9c;
  padding: 8px 24px;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: #fff;
  font-family: inherit;
  @include transition-fast;

  &:hover {
    background-color: darken(#005a9c, 5%);
  }
}

/* 正式公司授权管理区域 */
.authorization__officialSection {
  align-self: stretch;
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 24px;
}

.authorization__officialCard {
  flex: 1;
  min-width: 310px;
  box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  background-color: #fff;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 24px;
}

.authorization__officialTitle {
  margin: 0;
  font-size: 18px;
  line-height: 28px;
  font-weight: 700;
  color: #1e293b;
}

.authorization__officialDesc {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  color: #6b7280;
  padding-bottom: 16px;
}

.authorization__officialTable {
  align-self: stretch;
  background-color: #f3f4f6;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.authorization__officialRow {
  align-self: stretch;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.authorization__officialCell {
  flex: 1;
  min-width: 56px;
  padding: 8px 16px;
  font-size: 12px;
  line-height: 16px;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
}

/* 授权限制规则 */
.authorization__rules {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.authorization__ruleItem {
  align-self: stretch;
  border-radius: 6px;
  background-color: #f3f4f6;
  padding: 12px;
  font-size: 14px;
  line-height: 20px;
  color: #1e293b;
}

.authorization__ruleInline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.authorization__ruleNote {
  font-size: 12px;
  line-height: 16px;
  color: #6b7280;
}

.authorization__ruleInput {
  width: 80px;
  border-radius: 6px;
  background-color: #fff;
  border: 1px solid #e5e7eb;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 20px;
  color: #1e293b;
  text-align: center;
  outline: none;
  font-family: inherit;
}

/* 特殊城市规则 */
.authorization__specialRules {
  align-self: stretch;
  border-radius: 6px;
  background-color: #f3f4f6;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.authorization__specialTitle {
  font-size: 14px;
  line-height: 20px;
  color: #1e293b;
}

.authorization__specialTable {
  align-self: stretch;
  border-radius: 6px;
  background-color: #fff;
  overflow-x: auto;
  display: flex;
  flex-direction: column;
}

.authorization__specialRow {
  align-self: stretch;
  display: flex;
  align-items: center;
}

.authorization__specialCity {
  flex: 1;
  padding: 10px 16px;
  font-size: 14px;
  line-height: 20px;
  color: #1e293b;
}

.authorization__specialToggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  text-align: right;
}

.authorization__specialLabel {
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: #1e293b;
}

/* 阶梯性考核目标 */
.authorization__targetHeader {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.authorization__targetTitle {
  margin: 0;
  font-size: 18px;
  line-height: 28px;
  font-weight: 700;
  color: #1e293b;
}

.authorization__editBtn {
  cursor: pointer;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  background-color: transparent;
  padding: 8px 16px;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: #6b7280;
  font-family: inherit;
  @include transition-fast;

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

/* 目标表格 */
.authorization__targetTable {
  align-self: stretch;
  overflow-x: auto;
  display: flex;
  flex-direction: column;
}

.authorization__targetHeader2 {
  align-self: stretch;
  min-width: 660px;
  background-color: #f3f4f6;
  display: flex;
  align-items: center;
}

.authorization__targetBody {
  align-self: stretch;
  min-width: 660px;
  display: flex;
  flex-direction: column;
}

.authorization__targetRow {
  align-self: stretch;
  display: flex;
  align-items: center;

  &--bordered {
    border-bottom: 1px solid #e5e7eb;
  }
}

.authorization__targetCell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  font-size: 14px;
  line-height: 20px;
  color: #1e293b;
  text-align: center;

  &--header {
    font-size: 12px;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
  }

  &--month {
    flex: 0.6;
    min-width: 84px;
    max-width: 132px;
  }

  &--provinceMonthly,
  &--provinceTotal,
  &--cityTotal {
    flex: 0.75;
    min-width: 156px;
  }

  &--cityMonthly {
    flex: 1;
    min-width: 108px;
  }
}

/* 卡片头部 */
.authorization__cardHeader {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

/* 创建按钮 */
.authorization__createBtn {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  background-color: #005a9c;
  padding: 8px 16px;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: #fff;
  font-family: inherit;
  @include transition-fast;

  &:hover {
    background-color: darken(#005a9c, 5%);
  }
}

/* 类型徽章 */
.authorization__typeBadge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  background-color: #e0e7ff;
  color: #3730a3;
}

/* 类型和地区列 */
.authorization__tableCell--type {
  width: 100px;
  flex-shrink: 0;
}

.authorization__tableCell--region {
  width: 140px;
  flex-shrink: 0;
}

/* 空数据行 */
.authorization__emptyRow {
  align-self: stretch;
  padding: 40px 24px;
  text-align: center;
  color: #6b7280;
  font-size: 14px;
}

/* 已撤销状态 */
.authorization__badge--revoked {
  background-color: #fef2f2;
  color: #991b1b;
}

/* 模态框样式 */
.modal__overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal__content {
  background-color: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
}

.modal__title {
  margin: 0 0 20px 0;
  font-size: 18px;
  font-weight: 700;
  color: #1e293b;
}

.modal__form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal__formGroup {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal__label {
  font-size: 14px;
  font-weight: 500;
  color: #1e293b;
}

.modal__input {
  width: 100%;
  height: 40px;
  border-radius: 6px;
  background-color: #f3f4f6;
  border: 1px solid #e5e7eb;
  padding: 8px 12px;
  font-size: 14px;
  color: #1e293b;
  outline: none;
  font-family: inherit;
  box-sizing: border-box;

  &::placeholder {
    color: #9ca3af;
  }

  &:focus {
    border-color: #005a9c;
    background-color: #fff;
  }
}

.modal__select {
  width: 100%;
  height: 40px;
  border-radius: 6px;
  background-color: #f3f4f6;
  border: 1px solid #e5e7eb;
  padding: 8px 12px;
  font-size: 14px;
  color: #1e293b;
  cursor: pointer;
  font-family: inherit;
  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;
}

.modal__textarea {
  width: 100%;
  border-radius: 6px;
  background-color: #f3f4f6;
  border: 1px solid #e5e7eb;
  padding: 10px 12px;
  font-size: 14px;
  color: #1e293b;
  outline: none;
  font-family: inherit;
  resize: vertical;
  box-sizing: border-box;

  &::placeholder {
    color: #9ca3af;
  }

  &:focus {
    border-color: #005a9c;
    background-color: #fff;
  }
}

.modal__toggleRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}

.modal__toggleLabel {
  font-size: 14px;
  font-weight: 500;
  color: #1e293b;
}

.modal__hint {
  margin: 0;
  font-size: 12px;
  color: #6b7280;
}

.modal__warning {
  margin: 0;
  padding: 12px;
  background-color: #fef2f2;
  border-radius: 6px;
  font-size: 14px;
  color: #991b1b;
  line-height: 1.5;

  strong {
    font-weight: 600;
  }
}

.modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}

.modal__cancelBtn {
  cursor: pointer;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background-color: #fff;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  color: #6b7280;
  font-family: inherit;
  @include transition-fast;

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

.modal__confirmBtn {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  background-color: #005a9c;
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  font-family: inherit;
  @include transition-fast;

  &:hover:not(:disabled) {
    background-color: darken(#005a9c, 5%);
  }

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }

  &--danger {
    background-color: #dc2626;

    &:hover:not(:disabled) {
      background-color: darken(#dc2626, 5%);
    }
  }
}

/* 加载状态 */
.authorization__loading {
  align-self: stretch;
  padding: 40px 24px;
  text-align: center;
  color: #6b7280;
  font-size: 14px;
}

/* 错误状态 */
.authorization__error {
  align-self: stretch;
  padding: 24px;
  background-color: #fef2f2;
  border-radius: 6px;
  color: #991b1b;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.authorization__retryBtn {
  cursor: pointer;
  border: 1px solid #991b1b;
  border-radius: 4px;
  background-color: transparent;
  padding: 4px 12px;
  font-size: 12px;
  color: #991b1b;
  font-family: inherit;
  @include transition-fast;

  &:hover {
    background-color: #991b1b;
    color: #fff;
  }
}

/* 日期列 */
.authorization__tableCell--date {
  width: 100px;
  flex-shrink: 0;
  font-size: 12px;
  color: #6b7280;
}

/* 撤销原因显示 */
.authorization__revokeReason {
  font-size: 12px;
  color: #6b7280;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: help;
}

/* 分页 */
.authorization__pagination {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px 0;
  border-top: 1px solid #e5e7eb;
  margin-top: 8px;
}

.authorization__pageBtn {
  cursor: pointer;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background-color: #fff;
  padding: 6px 12px;
  font-size: 14px;
  color: #1e293b;
  font-family: inherit;
  @include transition-fast;

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

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
}

.authorization__pageInfo {
  font-size: 14px;
  color: #6b7280;
}
