/* 共管钱包组件样式 */
@use '@/styles/variables' as *;
@use '@/styles/mixins' as *;

/* ============================================
   共管钱包管理区域
   ============================================ */
.coManagedWalletSection {
  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;
  padding: 24px;
  gap: 20px;

  &__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
  }

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

  &__desc {
    margin: 4px 0 0;
    font-size: 14px;
    line-height: 20px;
    color: #6b7280;
  }

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

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

  &__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
  }

  &__emptyIcon {
    font-size: 48px;
    margin-bottom: 16px;
  }

  &__emptyText {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 500;
    color: #1e293b;
  }

  &__emptyHint {
    margin: 0 0 20px;
    font-size: 14px;
    color: #6b7280;
    max-width: 300px;
  }

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

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

  &__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
  }

  &__help {
    font-size: 12px;
    line-height: 18px;
    color: #6b7280;
    margin: 0;
    padding-top: 8px;
  }
}

/* ============================================
   钱包卡片
   ============================================ */
.walletCard {
  background-color: #f9fafb;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  overflow: hidden;
  @include transition-fast;

  &:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  }

  &__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background-color: #fff;
    border-bottom: 1px solid #e5e7eb;
  }

  &__name {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
  }

  &__threshold {
    padding: 4px 10px;
    background-color: #005a9c;
    color: #fff;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
  }

  &__body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  &__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  &__label {
    font-size: 13px;
    color: #6b7280;
  }

  &__value {
    font-size: 13px;
    color: #1e293b;
    font-family: monospace;
  }

  &__footer {
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
  }

  &__actionBtn {
    cursor: pointer;
    background-color: transparent;
    color: #005a9c;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    @include transition-fast;

    &:hover {
      border-color: #005a9c;
      background-color: rgba(0, 90, 156, 0.05);
    }
  }
}

/* ============================================
   模态框
   ============================================ */
.modalOverlay {
  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;
  padding: 20px;
}

.createWalletModal {
  background-color: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;

  &__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
  }

  &__title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
  }

  &__closeBtn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    border: none;
    border-radius: 6px;
    font-size: 24px;
    color: #6b7280;
    cursor: pointer;
    @include transition-fast;

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

  &__steps {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 24px;
    gap: 8px;
    border-bottom: 1px solid #e5e7eb;
  }

  &__step {
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0.5;

    &--active {
      opacity: 1;
    }

    &--completed {
      opacity: 1;

      .createWalletModal__stepNumber {
        background-color: #22c55e;
        border-color: #22c55e;
        color: #fff;
      }
    }

    &::after {
      content: '';
      width: 40px;
      height: 2px;
      background-color: #e5e7eb;
    }

    &:last-child::after {
      display: none;
    }
  }

  &__stepNumber {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid #e5e7eb;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
  }

  &__step--active &__stepNumber {
    border-color: #005a9c;
    background-color: #005a9c;
    color: #fff;
  }

  &__stepLabel {
    font-size: 13px;
    color: #6b7280;
  }

  &__step--active &__stepLabel {
    color: #1e293b;
    font-weight: 500;
  }

  &__content {
    padding: 24px;
  }

  &__form {
    display: flex;
    flex-direction: column;
    gap: 20px;
  }

  &__field {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  &__label {
    font-size: 14px;
    font-weight: 500;
    color: #1e293b;
  }

  &__input {
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 14px;
    color: #1e293b;
    background-color: #f9fafb;
    outline: none;
    @include transition-fast;

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

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

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

  &__hint {
    margin: 0;
    font-size: 12px;
    color: #6b7280;
  }

  &__error {
    margin: 0;
    padding: 10px 14px;
    background-color: rgba(220, 53, 69, 0.1);
    color: #dc2626;
    border-radius: 6px;
    font-size: 13px;
  }

  &__actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 8px;
  }

  &__cancelBtn {
    padding: 10px 20px;
    background-color: transparent;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    @include transition-fast;

    &:hover:not(:disabled) {
      border-color: #005a9c;
      color: #005a9c;
    }

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

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

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

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

  &__invite,
  &__progress {
    display: flex;
    flex-direction: column;
    gap: 24px;
  }
}

/* ============================================
   阈值配置
   ============================================ */
.thresholdConfig {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px;
  background-color: #f9fafb;
  border-radius: 8px;

  &__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }

  &__label {
    font-size: 12px;
    color: #6b7280;
  }

  &__control {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  &__btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 18px;
    color: #1e293b;
    cursor: pointer;
    @include transition-fast;

    &:hover:not(:disabled) {
      border-color: #005a9c;
      color: #005a9c;
    }

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

  &__value {
    font-size: 20px;
    font-weight: 600;
    color: #005a9c;
    min-width: 32px;
    text-align: center;
  }

  &__divider {
    font-size: 16px;
    font-weight: 600;
    color: #6b7280;
  }
}

/* ============================================
   邀请二维码
   ============================================ */
.inviteQrCode {
  display: flex;
  gap: 24px;
  padding: 20px;
  background-color: #f9fafb;
  border-radius: 8px;

  @media (max-width: 540px) {
    flex-direction: column;
    align-items: center;
  }

  &__qrWrapper {
    flex-shrink: 0;
  }

  &__qr {
    width: 160px;
    height: 160px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
  }

  &__placeholder {
    width: 160px;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    color: #6b7280;
    font-size: 13px;
  }

  &__info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  &__field {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  &__label {
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
  }

  &__codeWrapper,
  &__urlWrapper {
    display: flex;
    gap: 8px;
  }

  &__code {
    flex: 1;
    padding: 8px 12px;
    background-color: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-family: monospace;
    font-size: 14px;
    color: #1e293b;
  }

  &__url {
    flex: 1;
    padding: 8px 12px;
    background-color: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 12px;
    color: #1e293b;
    outline: none;
  }

  &__copyBtn {
    padding: 8px 14px;
    background-color: #005a9c;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    @include transition-fast;

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

  &__hint {
    margin: 0;
    font-size: 12px;
    color: #6b7280;
  }
}

/* ============================================
   参与方列表
   ============================================ */
.participantList {
  display: flex;
  flex-direction: column;
  gap: 12px;

  &__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  &__title {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
  }

  &__items {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  &__item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background-color: #f9fafb;
    border-radius: 6px;

    &--empty {
      opacity: 0.5;
    }
  }

  &__info {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  &__index {
    font-size: 12px;
    color: #6b7280;
    font-family: monospace;
  }

  &__name {
    font-size: 14px;
    color: #1e293b;
  }

  &__status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 9999px;

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

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

    &--processing {
      background-color: #dbeafe;
      color: #1e40af;
    }

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

    &--failed {
      background-color: #fee2e2;
      color: #991b1b;
    }
  }

  &__statusIcon {
    font-size: 14px;
  }
}

/* ============================================
   会话进度
   ============================================ */
.sessionProgress {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  background-color: #f9fafb;
  border-radius: 8px;

  &__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  &__status {
    font-size: 14px;
    font-weight: 500;

    &--waiting {
      color: #854d0e;
    }

    &--ready {
      color: #1e40af;
    }

    &--processing {
      color: #005a9c;
    }

    &--completed {
      color: #166534;
    }

    &--failed {
      color: #991b1b;
    }
  }

  &__round {
    font-size: 13px;
    color: #6b7280;
  }

  &__bar {
    height: 8px;
    background-color: #e5e7eb;
    border-radius: 9999px;
    overflow: hidden;
  }

  &__fill {
    height: 100%;
    background-color: #005a9c;
    border-radius: 9999px;
    @include transition-fast;

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

    &--failed {
      background-color: #dc2626;
    }
  }

  &__hint {
    margin: 0;
    font-size: 12px;
    color: #6b7280;
  }

  &__error {
    margin: 0;
    padding: 10px 14px;
    background-color: rgba(220, 53, 69, 0.1);
    color: #dc2626;
    border-radius: 6px;
    font-size: 13px;
  }
}

/* ============================================
   钱包结果
   ============================================ */
.walletResult {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;

  &__successIcon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #22c55e;
    color: #fff;
    border-radius: 50%;
    font-size: 32px;
  }

  &__title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #1e293b;
  }

  &__info {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    background-color: #f9fafb;
    border-radius: 8px;
  }

  &__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  &__label {
    font-size: 13px;
    color: #6b7280;
  }

  &__value {
    font-size: 13px;
    color: #1e293b;
    font-weight: 500;
  }

  &__publicKey {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  &__keyWrapper {
    display: flex;
    gap: 8px;
  }

  &__key {
    flex: 1;
    padding: 10px 14px;
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-family: monospace;
    font-size: 12px;
    color: #1e293b;
    word-break: break-all;
  }

  &__copyBtn {
    padding: 10px 14px;
    background-color: #005a9c;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    @include transition-fast;

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

  &__notice {
    align-self: stretch;
    padding: 16px;
    background-color: #fef9c3;
    border-radius: 8px;
    font-size: 13px;
    color: #854d0e;

    strong {
      display: block;
      margin-bottom: 8px;
    }

    ul {
      margin: 0;
      padding-left: 20px;

      li {
        margin-bottom: 4px;
      }
    }
  }

  &__actions {
    align-self: stretch;
    display: flex;
    justify-content: center;
    padding-top: 8px;
  }

  &__closeBtn {
    padding: 12px 32px;
    background-color: #005a9c;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    @include transition-fast;

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

/* ============================================
   密码输入对话框
   ============================================ */
.passwordDialog {
  position: absolute;
  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: 10;
  padding: 20px;

  &__content {
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    padding: 24px;
    width: 100%;
    max-width: 400px;
  }

  &__title {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
  }

  &__description {
    margin: 0 0 20px;
    font-size: 13px;
    line-height: 1.5;
    color: #6b7280;
  }
}
