/* 系统设置页面样式 - 基于 UIPro Figma 设计 */
@use '@/styles/variables' as *;
@use '@/styles/mixins' as *;

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

/* 页面头部 */
.settings__header {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  max-width: 960px;
}

.settings__title {
  margin: 0;
  font-size: 30px;
  line-height: 36px;
  font-weight: 700;
  color: #0f172a;
}

.settings__desc {
  font-size: 16px;
  line-height: 24px;
  color: #6b7280;
  padding-bottom: 12px;
}

.settings__notice {
  align-self: stretch;
  border-radius: 8px;
  background-color: #f8f8f8;
  border: 1px solid #bfdbfe;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 12px;
  font-size: 14px;
  line-height: 20px;
  color: #1d4ed8;
}

/* 设置区块 */
.settings__section {
  width: 100%;
  box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  background-color: #fff;
  border: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
  gap: 16px;
  max-width: 960px;
}

.settings__sectionHeader {
  align-self: stretch;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.settings__sectionTitle {
  margin: 0;
  font-size: 18px;
  line-height: 28px;
  font-weight: 700;
  color: #0f172a;
}

.settings__resetBtn {
  cursor: pointer;
  background: none;
  border: none;
  font-size: 14px;
  line-height: 20px;
  color: #0061a8;
  padding: 0;

  &:hover {
    text-decoration: underline;
  }

  &:disabled {
    color: #94a3b8;
    cursor: not-allowed;
  }
}

.settings__sectionActions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings__error {
  align-self: stretch;
  padding: 12px;
  border-radius: 6px;
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  font-size: 14px;
  line-height: 20px;
}

/* 设置内容区域 */
.settings__content {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
}

/* 表单字段组 */
.settings__fieldGroup {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.settings__label {
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: #0f172a;
}

/* 复选框组 */
.settings__checkboxGroup {
  align-self: stretch;
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 24px;
  font-size: 16px;
}

.settings__checkboxItem {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.settings__checkbox {
  cursor: pointer;
  margin: 0;
  height: 16px;
  width: 16px;
  border-radius: 8px;
  background-color: #fff;
  border: 1px solid #6b7280;
  appearance: none;
  position: relative;

  &:checked {
    background-color: #0061a8;
    border-color: #0061a8;

    &::after {
      content: '';
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background-color: #fff;
    }
  }
}

.settings__checkboxLabel {
  font-size: 16px;
  line-height: 24px;
  color: #0f172a;
}

/* 下拉选择器 */
.settings__selectWrapper {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.settings__select {
  width: 100%;
  max-width: 320px;
  border-radius: 6px;
  background-color: #f3f4f6;
  border: 1px solid #e5e7eb;
  padding: 9px 12px;
  font-size: 16px;
  line-height: 24px;
  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 12px center;
  background-repeat: no-repeat;
  background-size: 16px;
  padding-right: 40px;

  &:focus {
    outline: none;
    border-color: #0061a8;
  }
}

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

/* 开关行 */
.settings__toggleRow {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.settings__toggleLabel {
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: #0f172a;
}

/* Toggle 开关 */
.settings__toggle {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 9999px;
  cursor: pointer;
  @include transition-fast;
  flex-shrink: 0;

  &--on {
    background-color: #0061a8;
  }

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

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

  &--on {
    left: 22px;
    border-color: #fff;
  }

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

/* 小型开关 */
.settings__toggleSmall {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 9999px;
  cursor: pointer;
  @include transition-fast;
  flex-shrink: 0;

  &--on {
    background-color: #0061a8;
  }

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

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

  &--on {
    left: 18px;
  }

  &--off {
    left: 2px;
    border-color: #cbd5e1;
  }
}

/* 输入框行 */
.settings__inputRow {
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings__input {
  flex: 1;
  border-radius: 6px;
  background-color: #f3f4f6;
  border: 1px solid #e5e7eb;
  padding: 8px 12px;
  font-size: 16px;
  line-height: 24px;
  color: #1e293b;
  font-family: 'Noto Sans SC', $font-family-base;

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

  &:focus {
    outline: none;
    border-color: #0061a8;
  }

  &--small {
    width: 80px;
    flex: none;
    text-align: right;
  }

  &--medium {
    max-width: 320px;
  }
}

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

/* 榜单开关组 */
.settings__switchGroup {
  align-self: stretch;
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 24px;
}

.settings__switchItem {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.settings__switchLabel {
  font-size: 14px;
  line-height: 20px;
  color: #0f172a;
}

/* 认种限额边框卡片 */
.settings__quotaCard {
  align-self: stretch;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
  gap: 8px;
}

.settings__quotaHeader {
  align-self: stretch;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.settings__quotaTitle {
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  color: #0f172a;
}

.settings__quotaInputRow {
  align-self: stretch;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  padding-top: 4px;
  gap: 8px;
  font-size: 14px;
  line-height: 20px;
  color: #0f172a;
}

.settings__quotaText {
  flex-shrink: 0;
}

/* 考核设置 */
.settings__assessmentRow {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.settings__assessmentLabel {
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: #0f172a;
}

.settings__assessmentInputRow {
  align-self: stretch;
  display: flex;
  align-items: center;
  padding-top: 4px;
  gap: 8px;
  font-size: 16px;
}

.settings__assessmentUnit {
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: #0f172a;
}

/* 豁免设置行 */
.settings__exemptionRow {
  align-self: stretch;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.settings__exemptionInfo {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 310px;
  max-width: 576px;
}

.settings__exemptionLabel {
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: #0f172a;
}

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

/* 考核目标表格区域 */
.settings__tableSection {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.settings__tableHeader {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.settings__tableTitle {
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  color: #0f172a;
  margin: 0;
}

.settings__tableBtns {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.settings__tableBtn {
  cursor: pointer;
  border-radius: 6px;
  background-color: #f3f4f6;
  border: 1px solid #e5e7eb;
  padding: 6px 12px;
  font-size: 14px;
  line-height: 20px;
  color: #0f172a;
  @include transition-fast;

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

/* 表格样式 */
.settings__table {
  align-self: stretch;
  overflow-x: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.settings__tableHead {
  align-self: stretch;
  background-color: #f8fafc;
  display: flex;
  align-items: flex-start;
  min-width: 490px;
}

.settings__tableHeadCell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 12px;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: #64748b;

  &--month {
    flex: 0.8;
    min-width: 82px;
  }

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

.settings__tableBody {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 490px;
}

.settings__tableRow {
  align-self: stretch;
  display: flex;
  align-items: flex-start;
  border-top: 1px solid #e5e7eb;

  &:first-child {
    border-top: none;
  }
}

.settings__tableCell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 12px;
  font-size: 14px;
  line-height: 20px;
  color: #0f172a;

  &--month {
    flex: 0.8;
    min-width: 82px;
  }

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

/* 前端展示设置 */
.settings__radioGroup {
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 16px;
}

.settings__radioItem {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.settings__radio {
  height: 16px;
  width: 16px;
  border-radius: 16px;
  background-color: #fff;
  border: 1px solid #6b7280;
  appearance: none;
  cursor: pointer;
  position: relative;

  &:checked {
    border-color: #0061a8;

    &::after {
      content: '';
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background-color: #0061a8;
    }
  }
}

.settings__radioLabel {
  font-size: 16px;
  line-height: 24px;
  color: #0f172a;
}

/* 后台账号与安全 */
.settings__securityContent {
  align-self: stretch;
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 32px;
}

.settings__securityLeft {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  min-width: 310px;
}

.settings__securityRight {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 24px;
  min-width: 310px;
}

/* 账号表格区域 */
.settings__accountHeader {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.settings__accountTitle {
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  color: #0f172a;
  margin: 0;
}

.settings__addBtn {
  cursor: pointer;
  border-radius: 6px;
  background-color: #0061a8;
  border: none;
  padding: 6px 12px;
  font-size: 14px;
  line-height: 20px;
  color: #fff;
  @include transition-fast;

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

/* 账号表格 */
.settings__accountTable {
  align-self: stretch;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  overflow: auto;
}

.settings__accountTableInner {
  min-width: 400px;
  display: flex;
  flex-direction: column;
}

.settings__accountHead {
  background-color: #f8fafc;
  display: flex;
  align-items: center;
}

.settings__accountHeadCell {
  padding: 12px;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: #64748b;

  &--name {
    flex: 1;
    min-width: 95px;
  }

  &--role {
    width: 80px;
  }

  &--status {
    width: 60px;
  }

  &--login {
    width: 90px;
  }

  &--actions {
    width: 86px;
    text-align: center;
  }
}

.settings__accountBody {
  display: flex;
  flex-direction: column;
}

.settings__accountRow {
  display: flex;
  align-items: center;
  border-top: 1px solid #e5e7eb;

  &:first-child {
    border-top: none;
  }
}

.settings__accountCell {
  padding: 12px;
  font-size: 14px;
  line-height: 20px;
  color: #0f172a;

  &--name {
    flex: 1;
    min-width: 95px;
  }

  &--role {
    width: 80px;
  }

  &--status {
    width: 60px;
  }

  &--login {
    width: 90px;
  }

  &--actions {
    width: 86px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
  }
}

.settings__statusBadge {
  display: inline-flex;
  border-radius: 9999px;
  background-color: #dcfce7;
  padding: 2px 8px;
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  color: #166534;

  &--disabled {
    background-color: #fee2e2;
    color: #dc2626;
  }
}

.settings__actionLink {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  line-height: 16px;
  color: #0061a8;

  &:hover {
    text-decoration: underline;
  }

  &--danger {
    color: #ef4444;
  }
}

/* 敏感操作区域 */
.settings__sensitiveCard {
  align-self: stretch;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
  gap: 16px;
}

.settings__sensitiveRow {
  align-self: stretch;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.settings__sensitiveLabel {
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: #0f172a;
}

.settings__sensitiveFieldGroup {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.settings__tagInput {
  align-self: stretch;
  border-radius: 6px;
  background-color: #f3f4f6;
  border: 1px solid #e5e7eb;
  padding: 8px 12px;
  font-size: 16px;
  line-height: 24px;
  color: #6b7280;

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

  &:focus {
    outline: none;
    border-color: #0061a8;
    color: #1e293b;
  }
}

.settings__tagList {
  align-self: stretch;
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
}

.settings__tag {
  border-radius: 9999px;
  background-color: #dcfce7;
  padding: 2px 10px;
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  color: #1e40af;
  display: flex;
  align-items: center;
  gap: 4px;
}

.settings__tagRemove {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-size: 14px;
  line-height: 1;
  color: #1e40af;

  &:hover {
    color: #1e3a8a;
  }
}

/* 操作日志区域 */
.settings__logSection {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
}

.settings__logTitle {
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  color: #0f172a;
  margin: 0;
}

.settings__logFilters {
  align-self: stretch;
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
}

.settings__dateInput {
  flex: 1;
  min-width: 136px;
  max-width: 160px;
  border-radius: 6px;
  background-color: #f3f4f6;
  border: 1px solid #e5e7eb;
  padding: 6px 12px;
  font-size: 14px;
  line-height: 20px;
  color: #0f172a;

  &:focus {
    outline: none;
    border-color: #0061a8;
  }
}

.settings__searchInput {
  flex: 1;
  min-width: 143px;
  border-radius: 6px;
  background-color: #f3f4f6;
  border: 1px solid #e5e7eb;
  padding: 6px 12px;
  font-size: 14px;
  line-height: 20px;
  color: #0f172a;

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

  &:focus {
    outline: none;
    border-color: #0061a8;
  }
}

.settings__exportBtn {
  cursor: pointer;
  border-radius: 6px;
  background-color: #f3f4f6;
  border: 1px solid #e5e7eb;
  padding: 6px 12px;
  font-size: 14px;
  line-height: 20px;
  color: #0f172a;
  @include transition-fast;

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

/* 日志表格 */
.settings__logTable {
  align-self: stretch;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  overflow: auto;
}

.settings__logTableInner {
  min-width: 300px;
  display: flex;
  flex-direction: column;
}

.settings__logHead {
  background-color: #f8fafc;
  display: flex;
  align-items: center;
}

.settings__logHeadCell {
  padding: 12px;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: #64748b;

  &--time {
    width: 70px;
  }

  &--account {
    width: 70px;
  }

  &--type {
    width: 60px;
  }

  &--desc {
    flex: 1;
    min-width: 80px;
  }

  &--result {
    width: 60px;
  }
}

.settings__logBody {
  display: flex;
  flex-direction: column;
}

.settings__logRow {
  display: flex;
  align-items: center;
  border-top: 1px solid #e5e7eb;

  &:first-child {
    border-top: none;
  }
}

.settings__logCell {
  padding: 12px;
  font-size: 14px;
  line-height: 20px;
  color: #0f172a;

  &--time {
    width: 70px;
  }

  &--account {
    width: 70px;
  }

  &--type {
    width: 60px;
  }

  &--desc {
    flex: 1;
    min-width: 80px;
  }

  &--result {
    width: 60px;
  }
}

.settings__logResult {
  &--pass {
    color: #16a34a;
  }

  &--reject {
    color: #ef4444;
  }

  &--pending {
    color: #f59e0b;
  }
}

/* 应用图片管理 */
.settings__imageGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  width: 100%;
}

.settings__imageSlot {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fafafa;
}

.settings__imageSlotLabel {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}

.settings__imagePreview {
  width: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 4px;
  overflow: hidden;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;

  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}

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

.settings__uploadLabel {
  cursor: pointer;
  font-size: 12px;
  line-height: 16px;
  color: #0061a8;
  font-weight: 500;

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

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

/* 客服联系方式管理 */
.settings__contactTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-bottom: 16px;

  th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
  }

  th {
    font-weight: 600;
    color: #374151;
    background: #f9fafb;
    font-size: 13px;
  }

  td {
    color: #4b5563;
  }
}

.settings__contactForm {
  margin-top: 16px;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fafafa;

  h3 {
    font-size: 15px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 12px;
  }
}

.settings__contactFormFields {
  display: grid;
  grid-template-columns: 120px 1fr 1fr 80px;
  gap: 12px;
  align-items: center;
}

/* 页面底部操作区 */
.settings__footer {
  width: 100%;
  border-top: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-top: 16px;
  gap: 16px;
  max-width: 960px;
}

.settings__cancelBtn {
  cursor: pointer;
  border-radius: 6px;
  background-color: #fff;
  border: 1px solid #e5e7eb;
  padding: 8px 24px;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: #0f172a;
  @include transition-fast;

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

.settings__saveBtn {
  cursor: pointer;
  border-radius: 6px;
  background-color: #0061a8;
  border: none;
  padding: 8px 24px;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: #fff;
  @include transition-fast;

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

  &:disabled {
    background-color: #94a3b8;
    cursor: not-allowed;
  }
}
