.prompt-editor {
  display: flex;
  flex-direction: column;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
  transition: border-color 0.2s;

  &:focus-within {
    border-color: #1890ff;
  }

  &.has-error {
    border-color: #f5222d;
  }

  &.disabled {
    background: #f5f5f5;
    cursor: not-allowed;

    .prompt-editor-content {
      cursor: not-allowed;
      color: #999;
    }
  }

  // 编辑区域容器
  .prompt-editor-content-wrapper {
    padding: 12px;
    overflow-y: auto;
    font-size: 13px;
    color: #333;
    width: 100%;
    line-height: 1.8;
  }

  // 编辑区域
  .prompt-editor-content {
    outline: none;
    white-space: pre-wrap;
    word-wrap: break-word;

    &:empty::before {
      content: attr(data-placeholder);
      color: #999;
      pointer-events: none;
    }
  }

  // 内联字段选择触发器容器
  .prompt-editor-inline-trigger-wrapper {
    display: inline-block;
    vertical-align: middle;
    margin-top: 4px;
  }

  // 内联字段选择触发器
  .prompt-editor-inline-field-trigger {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: #fff;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 12px;
    color: #1890ff;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    white-space: nowrap;

    &:hover {
      background: #e6f7ff;
      border-color: #91d5ff;
    }
  }

  // 变量标签样式
  .prompt-editor-variable {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 6px 2px 8px;
    margin: 0 2px;
    background: linear-gradient(135deg, #e6f7ff 0%, #f0f5ff 100%);
    border: 1px solid #91d5ff;
    border-radius: 4px;
    font-size: 12px;
    color: #1890ff;
    font-weight: 500;
    cursor: default;
    user-select: none;
    vertical-align: middle;
    line-height: 1.4;
    transition: all 0.2s;

    &:hover {
      background: linear-gradient(135deg, #bae7ff 0%, #d6e4ff 100%);
      border-color: #69c0ff;
    }

    // 可编辑的变量标签
    &--editable {
      cursor: pointer;
      padding-right: 4px;

      &:hover {
        background: linear-gradient(135deg, #bae7ff 0%, #d6e4ff 100%);
        border-color: #40a9ff;

        .prompt-editor-variable-dropdown {
          opacity: 1;
        }
      }
    }

    // 下拉图标
    .prompt-editor-variable-dropdown {
      display: inline-block;
      width: 0;
      height: 0;
      margin-left: 2px;
      border-left: 4px solid transparent;
      border-right: 4px solid transparent;
      border-top: 4px solid #1890ff;
      opacity: 0.6;
      transition: opacity 0.2s;
    }

    // 图标样式
    .prompt-editor-variable-icon {
      margin-left: 2px;
      opacity: 0.6;
    }
  }

  // 底部工具栏
  .prompt-editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #fafafa;
    border-top: 1px solid #f0f0f0;
  }

  // 插入字段按钮
  .prompt-editor-insert-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: #fff;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;

    &:hover {
      border-color: #1890ff;
      color: #1890ff;
    }
  }
}

// 字段选择器弹出层
.prompt-editor-field-selector {
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  min-width: 260px;
  max-width: 320px;
  max-height: 360px;
  overflow: hidden;
  display: flex;
  flex-direction: column;

  .prompt-editor-field-selector-search {
    padding: 10px;
    border-bottom: 1px solid #f0f0f0;
  }

  .prompt-editor-field-selector-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
  }

  .prompt-editor-field-group {
    margin-bottom: 8px;

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

  .prompt-editor-field-group-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    font-size: 13px;
    color: #666;
    cursor: pointer;
    border-radius: 4px;

    &:hover {
      background: #f5f5f5;
    }
  }

  .prompt-editor-field-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s;

    &:hover {
      background: #f5f5f5;
    }

    &.selected {
      background: #e6f7ff;
      color: #1890ff;
    }
  }

  .prompt-editor-field-empty {
    padding: 24px;
    text-align: center;
    color: #999;
    font-size: 13px;
  }
}

// 模型选择栏
.ai-field-config-model-bar {
  display: flex;
  align-items: center;
  gap: 8px;

  .ai-field-config-model-selector {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: 1px solid #e8e8e8;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: 12px;
    color: #333;
    user-select: none;
    transition: all 0.2s;

    &:hover {
      border-color: #91d5ff;
      background: #e6f7ff;
    }
  }
}

// 模型选择器弹出层样式
.ai-field-config-model-selector-menu {
  background: #fff !important;
  border: 1px solid #e8e8e8 !important;
  border-radius: 6px !important;
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.12),
    0 2px 4px rgba(0, 0, 0, 0.08) !important;
  min-width: 320px !important;
  max-width: 400px !important;
  padding: 8px !important;
  overflow: hidden !important;
  box-sizing: border-box !important;

  .ai-field-config-model-option {
    padding: 8px !important;
    cursor: pointer;
    user-select: none;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 4px;
    box-sizing: border-box;

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

    &:hover {
      background: #f5f5f5;
    }

    &.active {
      background: #e6f7ff;

      .ai-field-config-model-option-icon {
        background: #e6f7ff;
      }

      .ai-field-config-model-option-title {
        color: #1890ff;
      }
    }

    .ai-field-config-model-option-icon {
      flex-shrink: 0;
      width: 36px;
      height: 36px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 8px;
      background: #f0f0f0;
      box-sizing: border-box;

      .ai-field-config-model-option-q-icon {
        font-size: 20px;
        font-weight: 700;
        line-height: 1;
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
      }
    }

    .ai-field-config-model-option-content {
      flex: 1;
      min-width: 0;
      box-sizing: border-box;
    }

    .ai-field-config-model-option-title {
      font-size: 14px;
      font-weight: 500;
      color: #333;
      line-height: 20px;
      margin-bottom: 4px;
      display: flex;
      align-items: center;
      box-sizing: border-box;
    }

    .ai-field-config-model-option-description {
      font-size: 12px;
      color: #666;
      line-height: 18px;
      margin-bottom: 2px;
      box-sizing: border-box;
    }

    .ai-field-config-model-option-capability {
      font-size: 12px;
      color: #999;
      line-height: 18px;
      box-sizing: border-box;
    }
  }
}
