// 全局变量定义
$primary-color: #165DFF;
$secondary-color: #6B7280;
$success-color: #00B42A;
$warning-color: #FFAA00;
$error-color: #F53F3F;
$text-primary: #333333;
$text-secondary: #666666;
$text-tertiary: #999999;
$border-color: #E5E7EB;
$bg-light: #F9FAFB;
$bg-white: #FFFFFF;
$shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
$shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
$shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

// 对话框容器
.setting-dialog {
  min-width: 600px;
  max-width: 800px;
  border-radius: 12px;
  overflow: hidden;
  background-color: $bg-white;
}

// 对话框头部
.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid $border-color;
  background-color: $bg-light;

  .dialog-title {
    font-size: 18px;
    font-weight: 600;
    color: $text-primary;
    margin: 0;
  }

  .close-btn {
    color: $text-tertiary;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.2s ease;

    &:hover {
      background-color: #E5E7EB;
      color: $text-secondary;
    }
  }
}

// 对话框内容
.dialog-content {
  padding: 24px;
  max-height: 60vh;
  overflow-y: auto;
}

// 表单区域
.form-section {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid $border-color;

  &:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
  }

  .section-title {
    font-size: 16px;
    font-weight: 600;
    color: $text-primary;
    margin-bottom: 16px;
  }
}

// 表单组
.form-group {
  margin-bottom: 16px;

  .form-field {
    width: 100%;
    .mat-form-field-wrapper {
      .mat-form-field-flex {
        border-radius: 8px;
      }

      .mat-form-field-outline {
        border-radius: 8px;
      }

      .mat-form-field-infix {
        padding: 10px 0;

        input,
        textarea {
          font-size: 14px;
          color: $text-primary;
        }

        .mat-input-element {
          &::placeholder {
            color: $text-tertiary;
          }
        }

        textarea {
          resize: vertical;
          min-height: 80px;
        }
      }

      .mat-form-field-label {
        font-size: 14px;
        color: $text-secondary;
      }

      .mat-form-field-suffix {
        .mat-icon,
        span {
          color: $text-tertiary;
        }
      }

      .mat-form-field-hint {
        font-size: 12px;
        color: $text-tertiary;
        margin-top: 4px;
      }
    }
  }

  // 激活状态切换
  .toggle-wrapper {
    .active-toggle {
      display: flex;
      justify-content: flex-start;
      .mat-slide-toggle-content {
        font-size: 14px;
        color: $text-secondary;
      }
    }
  }
}

// 步骤容器
.steps-container {
  .steps-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;

    .steps-label {
      font-size: 14px;
      font-weight: 500;
      color: $text-primary;
    }

    .step-input-wrapper {
      display: flex;
      gap: 8px;
      align-items: flex-end;

      .step-input {
        width: 200px;
        .mat-form-field-wrapper {
          .mat-form-field-flex {
            border-radius: 6px;
          }
          .mat-form-field-outline {
            border-radius: 6px;
          }
        }
      }

      .add-step-btn {
        height: 40px;
        border-radius: 6px;
        min-width: auto;
        width: 40px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
      }
    }
  }

  // 步骤列表
  .steps-list {
    background-color: $bg-light;
    border-radius: 8px;
    padding: 16px;
    max-height: 300px;
    overflow-y: auto;

    .step-item {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 12px;
      background-color: $bg-white;
      border-radius: 6px;
      border: 1px solid $border-color;
      margin-bottom: 8px;
      transition: all 0.2s ease;

      &:hover {
        border-color: $primary-color;
        box-shadow: 0 2px 4px rgba(22, 93, 255, 0.1);
      }

      &:last-child {
        margin-bottom: 0;
      }

      .step-number {
        flex-shrink: 0;
        width: 24px;
        height: 24px;
        border-radius: 50%;
        background-color: $primary-color;
        color: $bg-white;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 12px;
        font-weight: 600;
      }

      .step-name {
        flex: 1;
        font-size: 14px;
        color: $text-primary;
      }

      .step-actions {
        display: flex;
        gap: 4px;

        .action-btn {
          width: 28px;
          height: 28px;
          padding: 0;
          min-width: auto;

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

    // 空步骤提示
    .empty-steps {
      text-align: center;
      padding: 40px 20px;
      color: $text-tertiary;
      font-size: 14px;
      border: 2px dashed $border-color;
      border-radius: 6px;
    }
  }
}

// 对话框底部
.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 20px 24px;
  border-top: 1px solid $border-color;
  background-color: $bg-light;

  .cancel-btn {
    padding: 8px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: $text-secondary;
    background-color: $bg-white;
    border: 1px solid $border-color;
    transition: all 0.2s ease;

    &:hover {
      background-color: #F3F4F6;
      border-color: $text-tertiary;
    }
  }

  .save-btn {
    padding: 8px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    background-color: $primary-color;
    color: $bg-white;
    transition: all 0.2s ease;
    box-shadow: $shadow-sm;

    &:hover {
      background-color: #0E4BD8;
      box-shadow: $shadow-md;
      transform: translateY(-1px);
    }
  }
}

// 响应式设计
@media (max-width: 768px) {
  .setting-dialog {
    min-width: auto;
    width: 90vw;
    max-width: 600px;
  }

  .steps-header {
    flex-direction: column;
    align-items: stretch !important;
  }

  .step-input-wrapper {
    flex-direction: column;
    align-items: stretch !important;
  }

  .step-input {
    width: 100% !important;
  }

  .add-step-btn {
    width: 100% !important;
  }
}

@media (max-width: 480px) {
  .dialog-header,
  .dialog-content,
  .dialog-footer {
    padding: 16px;
  }

  .dialog-title {
    font-size: 16px !important;
  }

  .cancel-btn,
  .save-btn {
    padding: 6px 16px !important;
    font-size: 13px !important;
  }
}

// 滚动条样式
.dialog-content,
.steps-list {
  &::-webkit-scrollbar {
    width: 6px;
  }

  &::-webkit-scrollbar-track {
    background: $bg-light;
    border-radius: 3px;
  }

  &::-webkit-scrollbar-thumb {
    background: $border-color;
    border-radius: 3px;
  }

  &::-webkit-scrollbar-thumb:hover {
    background: $text-tertiary;
  }
}