.formula-field-config-panel {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e8e8e8;
  box-shadow: 0 4px 16px 0 rgba(13, 13, 13, 0.187);
  z-index: 1000;
  width: 380px;

  .formula-field-config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e8e8e8;

    .formula-field-config-header-left {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .formula-field-config-title {
      font-size: 16px;
      font-weight: 500;
      color: #333;
    }
  }

  .formula-field-config-content {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
  }

  .formula-field-config-section {
    margin-bottom: 16px;

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

  .formula-field-config-label {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 8px;
  }

  .formula-field-edit-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    color: #666;
    font-size: 14px;
    transition: all 0.2s;

    &:hover {
      background: #f5f7fa;
      border-color: #d9d9d9;
      color: #333;
    }
  }

  .formula-field-expression-preview {
    margin-top: 8px;
    padding: 8px 12px;
    background: #f0f5ff;
    border: 1px solid #d6e4ff;
    border-radius: 4px;
    font-size: 12px;
    color: #1677ff;
    font-family: Menlo, Monaco, 'Courier New', monospace;
    word-break: break-all;
  }

  .formula-field-config-validation-error {
    color: #f5222d;
    font-size: 12px;
    margin-top: 8px;
  }

  .formula-field-config-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-top: 1px solid #e8e8e8;

    .formula-field-config-footer-left {
      .formula-field-add-desc {
        font-size: 13px;
        color: #999;
        cursor: pointer;

        &:hover {
          color: #666;
        }
      }
    }
  }
}

/* 公式编辑器弹窗 */
.formula-editor-dialog {
  .cn-next-dialog-header {
    padding: 16px 24px;
    border-bottom: 1px solid #e8e8e8;
  }

  .cn-next-dialog-body {
    padding: 0 !important;
  }

  .formula-editor-dialog-title {
    display: flex;
    align-items: center;
    font-size: 16px;
    font-weight: 500;
  }
}

.formula-editor-dialog-content {
  display: flex;
  flex-direction: column;
  height: 560px;

  .formula-editor-dialog-editor-section {
    padding: 16px 24px;
    display: flex;
    flex-direction: column;
  }

  .formula-editor-dialog-editor-wrapper {
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.2s;
    position: relative;

    &:focus-within {
      border-color: #4161fd;
      box-shadow: 0 0 0 2px rgba(65, 97, 253, 0.08);
    }

    .formula-editor-container {
      border: none !important;
      border-radius: 0 !important;
      box-shadow: none !important;
    }

    .formula-editor-dialog-editor-footer {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      gap: 12px;
      padding: 8px 12px;
      border-top: 1px solid #f0f0f0;
      background: #fafafa;

      .formula-editor-preview-result {
        display: flex;
        align-items: center;
        gap: 6px;
        margin-right: auto;
        min-width: 0;
        overflow: hidden;

        .formula-editor-preview-label {
          flex-shrink: 0;
          font-size: 12px;
          color: #999;
        }

        .formula-editor-preview-tag {
          flex-shrink: 1;
          min-width: 0;
          padding: 1px 8px;
          background: #f0f0f0;
          border-radius: 4px;
          font-size: 12px;
          color: #595959;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          max-width: 160px;
        }

        .formula-editor-preview-separator {
          flex-shrink: 0;
          font-size: 12px;
          color: #999;
        }

        .formula-editor-preview-value {
          flex-shrink: 0;
          font-size: 13px;
          font-weight: 500;
          color: #333;
          font-family: Menlo, Monaco, 'Courier New', monospace;
        }
      }
    }
  }

  .formula-editor-dialog-bottom-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0 24px 16px;

    .formula-editor-dialog-bottom-panel-content {
      flex: 1;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      border: 1px solid #e8e8e8;
      border-radius: 8px;
    }

    .formula-editor-dialog-tabs {
      display: flex;
      align-items: center;
      gap: 0;
      border-bottom: 1px solid #e8e8e8;
      padding: 0 16px;

      .formula-editor-dialog-tab {
        display: flex;
        align-items: center;
        padding: 12px 16px;
        font-size: 14px;
        color: #999;
        cursor: pointer;
        border-bottom: 2px solid transparent;
        transition: all 0.2s;

        &:hover {
          color: #333;
        }

        &.active {
          color: #1677ff;
          border-bottom-color: #1677ff;
          font-weight: 500;
        }
      }
    }

    .formula-editor-dialog-panel-body {
      flex: 1;
      display: flex;
      overflow: hidden;
    }
  }
}

/* 左侧平铺列表 */
.formula-editor-dialog-fields {
  width: 240px;
  border-right: 1px solid #e8e8e8;
  display: flex;
  flex-direction: column;
  overflow: hidden;

  .formula-editor-dialog-fields-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px 8px;
  }

  .formula-editor-dialog-group-title {
    padding: 12px 12px 6px;
    font-size: 12px;
    color: #8c8c8c;
    font-weight: 500;
    line-height: 1;
    letter-spacing: 0.5px;

    &:not(:first-child) {
      margin-top: 4px;
      padding-top: 12px;
    }
  }

  .formula-editor-dialog-no-fields {
    padding: 16px;
    color: #999;
    font-size: 12px;
    text-align: center;
    display: block;
  }
}

.formula-editor-dialog-field-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;

  &:hover,
  &.active {
    background: #f0f5ff;
  }

  .formula-editor-dialog-field-icon {
    color: #999;
    flex-shrink: 0;
  }

  .formula-editor-dialog-fn-icon {
    flex-shrink: 0;
    width: 16px;
    font-size: 11px;
    font-weight: 600;
    font-style: italic;
    color: #8c8c8c;
    text-align: center;
  }

  .formula-editor-dialog-field-name {
    flex: 1;
    font-size: 13px;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .formula-editor-dialog-field-shortcut {
    flex-shrink: 0;
    padding: 1px 6px;
    background: #f0f0f0;
    border: 1px solid #d9d9d9;
    border-radius: 3px;
    font-size: 11px;
    color: #999;
  }
}

/* 右侧信息面板 */
.formula-editor-dialog-field-info {
  flex: 1;
  padding: 20px 24px;
  overflow-y: auto;

  .formula-editor-dialog-field-info-empty {
    color: #bfbfbf;
    font-size: 13px;
    text-align: center;
    padding-top: 48px;
  }

  .formula-editor-dialog-field-info-content {
    .formula-editor-dialog-field-info-header {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-bottom: 12px;

      .formula-editor-dialog-fn-icon-lg {
        font-size: 14px;
        font-weight: 600;
        font-style: italic;
        color: #1677ff;
      }

      .formula-editor-dialog-field-info-name {
        font-size: 15px;
        font-weight: 500;
        color: #333;
      }
    }

    .formula-editor-dialog-field-info-desc {
      font-size: 13px;
      color: #666;
      line-height: 1.6;
      margin-bottom: 16px;
    }

    .formula-editor-dialog-field-info-example-label {
      font-size: 12px;
      color: #999;
      margin-bottom: 8px;
    }

    .formula-editor-dialog-field-info-example {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 10px 16px;
      background: #f5f7fa;
      border: 1px solid #e8e8e8;
      border-radius: 6px;

      code {
        font-size: 13px;
        color: #333;
        font-family: Menlo, Monaco, 'Courier New', monospace;
      }

      .formula-editor-dialog-copy-btn {
        color: #999;
        cursor: pointer;

        &:hover {
          color: #1677ff;
        }
      }
    }
  }
}
