@import '../common.less';

/* 内容卡片基础样式 */
.content-card {
  background-color: #ffffff;
  border-radius: 0;
  margin: 0 0 1px;
  overflow: hidden;
  border-bottom: 1px solid @border-color;
  width: 100%;
  box-shadow: none;
}

/* 选中知识指示器 */
.selected-knowledge-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background-color: @selected-bg;
  border-radius: @border-radius-base;
  color: @primary-color;
  font-size: 13px;
  margin-bottom: 6px;
}

.knowledge-icon {
  font-size: 16px;
}

/* 空状态样式 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: auto;
  padding: 10px 0;
  text-align: center;
  width: 100%;
  max-width: 340px;
  margin: 0 auto;
  overflow: hidden;
  margin-top: auto;
  margin-bottom: auto;
}

.empty-icon {
  font-size: 24px;
  color: #ccc;
  margin: 10px 0;
}

.empty-text {
  color: #888;
  font-size: 14px;
  margin: 0 0 10px;
}

/* 知识库卡片区域 - 浏览器插件风格 */
.knowledge-carousel {
  margin: 5px auto 10px;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  padding: 10px;
  border: 1px solid @border-color;
  transition: @transition-fast;
  width: 340px; /* 精确匹配输入框宽度 */
  box-sizing: border-box;
  position: relative;
  overflow: visible;
  z-index: 1;
  left: 0;
  right: 0;
  margin-left: auto;
  margin-right: auto;
}

.knowledge-carousel:hover {
  box-shadow: @box-shadow-hover;
}

.knowledge-carousel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  width: 100%;
}

.knowledge-carousel-title {
  font-size: 14px;
  font-weight: 600;
  color: @text-primary;
  margin-right: 8px;
  position: relative;
}

.knowledge-carousel-title::after {
  content: "";
  position: absolute;
  bottom: -3px;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: @primary-color;
}

.selected-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: @border-radius-pill;
  background-color: @selected-bg;
  color: @primary-color;
  font-size: 12px;
  font-weight: 500;
}

/* 知识库胶囊容器 */
.knowledge-carousel-container {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: @border-radius-base;
  padding: 5px 0;
  overflow: visible;
  margin: 0 auto;
  box-sizing: border-box;
}

/* 切换栏样式 */
.knowledge-tabs {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  border-bottom: 1px solid @border-color;
  padding-bottom: 6px;
  justify-content: space-around;
  width: 100%;
}

.knowledge-tab {
  padding: 4px 10px;
  font-size: 12px;
  color: @text-secondary;
  cursor: pointer;
  border-radius: @border-radius-base;
  transition: @transition-fast;
  margin-right: 0;
  flex: 1;
  text-align: center;
}

.knowledge-tab.active {
  background-color: @primary-color;
  color: #fff;
  font-weight: 500;
}

.knowledge-tab:hover:not(.active) {
  background-color: @hover-bg;
  color: @text-primary;
}

/* 推荐工具卡片风格 */
.knowledge-cards {
  display: flex;
  width: 100%;
  padding: 2px 0;
  box-sizing: border-box;
  justify-content: center;
}

.knowledge-cards::-webkit-scrollbar {
  display: none;
}

/* 推荐工具卡片样式 */
.knowledge-card {
  height: 68px;
  border-radius: 6px;
  border: 1px solid @border-color;
  transition: all 0.25s ease;
  padding: 10px 2px 16px;
  cursor: pointer;
  background-color: #fff;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
  overflow: visible;
}

.knowledge-card:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  border-color: @primary-color;
  transform: translateY(-2px);
}

.knowledge-card.selected {
  background-color: @selected-bg;
  border-color: @primary-color;
  box-shadow: 0 2px 6px rgba(6, 177, 171, 0.2);
}

/* 知识卡片图标 - 右上角显示 */
.knowledge-card-icon {
  display: block;
  position: absolute;
  top: 3px;
  right: 3px;
  font-size: 9px;
  opacity: 0.6;
  z-index: 1;
}

.knowledge-card-title {
  font-weight: 600;
  font-size: 12px;
  color: @text-primary;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
  max-width: 100%;
  padding: 0 8px;
  box-sizing: border-box;
  margin: 5px 0 7px;
  line-height: 1.2;
  height: 29px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 知识库类型标识 */
.custom-knowledge .knowledge-card-icon {
  color: @primary-color;
}

.system-knowledge .knowledge-card-icon {
  color: @info-color;
}

.knowledge-card:hover .knowledge-card-icon {
  opacity: 1;
}

/* 知识库指示器 */
.knowledge-indicator {
  font-size: 10px;
  color: @text-secondary;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  bottom: 6px;
  width: 100%;
  cursor: pointer;
  z-index: 5;
  padding: 2px 0;
  transition: all 0.2s ease;
}

.knowledge-indicator:hover {
  color: @primary-color;
  background-color: rgba(240, 240, 240, 0.5);
}

.knowledge-card:hover .knowledge-indicator {
  color: @primary-color;
}

.knowledge-status-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background-color: @primary-color;
  display: inline-block;
  margin-right: 3px;
  opacity: 0.7;
}

.knowledge-card.selected .knowledge-status-dot {
  background-color: @primary-color;
  animation: pulseDot 1.5s infinite ease-in-out;
  opacity: 1;
}

@keyframes pulseDot {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.7; }
  100% { transform: scale(1); opacity: 1; }
}

/* 添加知识按钮 */
.add-knowledge-btn {
  background-color: @primary-color;
  border-color: @primary-color;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: @border-radius-circle;
  padding: 0;
  font-size: 14px;
  margin-left: 6px;
  transition: all 0.2s ease;
}

.add-knowledge-btn:hover {
  background-color: darken(@primary-color, 10%);
  transform: scale(1.05);
}

/* 自定义工具提示，确保内容正确显示 */
.ant-tooltip {
  max-width: 300px;
  z-index: 1500;
  margin-right: 20px !important; /* 防止工具提示超出右边界 */
  /* 修改工具提示位置为页面中心 */
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
}

.ant-tooltip-arrow {
  display: none !important; /* 隐藏箭头 */
}

.ant-tooltip-content {
  text-align: left;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15));
}

/* 确保提示内容可以很高但不会影响页面布局 */
.ant-tooltip-inner {
  padding: 14px 16px !important;
  font-size: 13px !important;
  line-height: 1.6 !important;
  color: rgba(0, 0, 0, 0.85) !important;
  text-align: left !important;
  background-color: #fff !important;
  border-radius: 10px !important; /* 确保所有边都是圆角 */
  box-shadow: 0 3px 16px rgba(0, 0, 0, 0.12) !important;
  white-space: pre-wrap !important;
  word-break: break-word !important;
  max-width: 320px !important;
  width: auto !important;
  max-height: 540px !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  border: 1px solid rgba(0, 0, 0, 0.06) !important;
}

/* 添加工具提示滚动条样式 */
.ant-tooltip-inner::-webkit-scrollbar {
  width: 4px;
}

.ant-tooltip-inner::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 2px;
}

.ant-tooltip-inner::-webkit-scrollbar-thumb {
  background: #C0C0C0;
  border-radius: 2px;
}

.ant-tooltip-inner::-webkit-scrollbar-thumb:hover {
  background: #A0A0A0;
}

/* 防止页面水平滚动 */
body, html {
  overflow-x: hidden !important;
}

/* 标题工具提示特殊样式 */
.knowledge-card-title + .ant-tooltip .ant-tooltip-inner {
  font-weight: 500;
  padding: 4px 8px;
}

/* 空知识状态 */
.empty-knowledge {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  color: @text-light;
  width: 100%;
  height: 70px;
  font-size: 12px;
  box-sizing: border-box;
}

/* 空知识提示 - 调整为长方形并水平居中 */
.empty-knowledge-prompt {
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
  border-radius: 6px;
  border: 1px dashed #d9d9d9;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}

/* 添加正方形容器用于容纳加号图标 */
.empty-knowledge-box {
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px dashed @primary-color;
  margin: 0;
}

.empty-knowledge-prompt:hover {
  color: @primary-color;
  border-color: @primary-color;
  background-color: rgba(6, 177, 171, 0.03);
}

.empty-knowledge-icon {
  font-size: 24px;
  color: @primary-color;
  margin: 0;
}

/* 轮播导航按钮样式 - 更小更精致 */
.carousel-nav-button {
  position: absolute;
  width: 12px !important;
  height: 12px !important;
  min-width: 12px !important;
  min-height: 12px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: white;
  border-radius: 50%;
  border: 1px solid #e0e0e0;
  z-index: 20;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  opacity: 0.75;
  top: 50%;
  transform: translateY(-50%);
  font-size: 6px;
  color: #999;
  padding: 0 !important;
  margin: 0;
  line-height: 1;
}

.carousel-nav-button.prev-button {
  left: -6px;
}

.carousel-nav-button.next-button {
  right: -6px;
}

.carousel-nav-button.ant-btn {
  padding: 0 !important;
}

.carousel-nav-button .anticon {
  font-size: 6px;
  line-height: 1;
}

.carousel-nav-button:hover {
  background-color: #fff;
  color: @primary-color;
  border-color: @primary-color;
  opacity: 1;
  box-shadow: 0 1px 2px rgba(6, 177, 171, 0.2);
}

/* 防止工具提示闪烁 */
.ant-tooltip-hidden {
  display: none;
}

/* 知识内容弹框特殊样式 */
.knowledge-content-modal {
  .ant-modal-content {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    padding: 0;
  }

  .ant-modal-header {
    background-color: #fdfdfd;
    border-bottom: 1px solid #f0f0f0;
    margin: 0;
  }

  .ant-modal-body {
    padding: 10px 12px;
    max-height: 380px;
    overflow-y: auto;
    margin: 0;
  }
}

.content-modal-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 22px;
  
  span {
    font-size: 14px;
    font-weight: 600;
    color: @text-primary;
    flex: 1;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
  }
  
  .content-modal-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
  }
  
  .edit-knowledge-btn, .delete-knowledge-btn {
    height: 20px;
    width: 20px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    
    .anticon {
      font-size: 12px;
      color: @text-secondary;
    }
  }
  
  .edit-knowledge-btn:hover .anticon {
    color: @primary-color;
  }
  
  .delete-knowledge-btn:hover .anticon {
    color: @error-color;
  }
}

.knowledge-content {
  font-size: 13px;
  line-height: 1.5;
  color: @text-primary;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.edit-knowledge-form {
  .ant-form-item {
    margin-bottom: 12px;
  }
  
  .ant-form-item-label {
    padding-bottom: 2px;
    
    label {
      font-size: 13px;
      height: 20px;
    }
  }
  
  textarea.ant-input {
    padding: 6px 8px;
    font-size: 13px;
    resize: none;
  }
}

.edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
}

/* 为整个Modal添加更紧凑的样式 */
.ant-modal {
  padding-bottom: 0;
}

.ant-modal-wrap {
  padding: 0;
}

/* 修复知识库组件水平居中 */
.empty-knowledge-container {
  width: 100%;
  padding: 0;
  margin: 0 auto;
  max-width: 340px;
  align-self: center;
  box-sizing: border-box;
}

/* 确保header空间足够放置标题和关闭按钮 */
.ant-modal-title {
  line-height: 22px !important;
  display: flex !important;
  align-items: center !important;
  margin: 0 !important;
}

/* 重置并美化Modal关闭按钮样式 */
.ant-modal {
  .ant-modal-close {
    position: absolute !important;
    right: 14px !important;
    top: 12px !important;
    height: 24px !important;
    width: 24px !important;
    transform: none !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 50% !important;
    background-color: transparent !important;
    transition: all 0.2s ease-in-out !important;
    z-index: 10 !important;
    
    &:hover {
      background-color: rgba(0, 0, 0, 0.05) !important;
      transform: rotate(90deg) !important;
    }
  }

  .ant-modal-close-x {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 100% !important;
    width: 100% !important;
    line-height: 1 !important;
    font-size: 14px !important;
    color: rgba(0, 0, 0, 0.55) !important;
    
    .anticon {
      font-size: 14px !important;
      font-weight: normal !important;
    }
  }

  .ant-modal-header {
    position: relative !important;
    padding: 16px 16px !important;
    display: flex !important;
    align-items: center !important;
    min-height: 48px !important;
    height: auto !important;
    box-sizing: border-box !important;
  }

  .ant-modal-title {
    line-height: 22px !important;
    display: flex !important;
    align-items: center !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    color: rgba(0, 0, 0, 0.85) !important;
  }
}

/* 删除确认弹窗样式 */
.ant-modal {
  /* 通用Modal样式调整 */
  border-radius: 12px !important;
  overflow: hidden !important;
  
  .ant-modal-content {
    border-radius: 12px !important;
    overflow: hidden !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15) !important;
    padding: 0 !important;
  }
  
  .ant-modal-header {
    background-color: #fdfdfd !important;
    border-bottom: 1px solid #f0f0f0 !important;
    margin: 0 !important;
    height: 52px !important;
    padding: 14px 16px !important;
    align-items: center !important;
    display: flex !important;
  }
  
  .ant-modal-body {
    padding: 16px !important;
    font-size: 14px !important;
    color: @text-primary !important;
    line-height: 1.5 !important;
  }
  
  .ant-modal-footer {
    border-top: 1px solid #f0f0f0 !important;
    padding: 12px 16px !important;
    margin-top: 0 !important;
    display: flex !important;
    justify-content: flex-end !important;
    gap: 8px !important;
  }
  
  /* 按钮样式 */
  .ant-btn-primary.ant-btn-dangerous {
    background-color: @error-color !important;
    border-color: @error-color !important;
    
    &:hover {
      background-color: darken(@error-color, 10%) !important;
      border-color: darken(@error-color, 10%) !important;
    }
  }
  
  /* 对齐标题和关闭按钮 */
  .ant-modal-close {
    top: 14px !important;
  }
  
  /* 适配确认提示文本样式 */
  p {
    margin: 0 !important;
    padding: 0 !important;
    color: @text-primary !important;
    font-size: 14px !important;
    line-height: 1.6 !important;
    word-wrap: break-word !important;  /* 确保文本能够换行 */
    white-space: normal !important;    /* 防止文本在一行内显示 */
    overflow-wrap: break-word !important;
  }
}

/* 确保模态框遮罩层在知识库卡片上层 */
.ant-modal-mask {
  z-index: 1040 !important;
}

/* 提高所有模态框的z-index */
.ant-modal-wrap {
  z-index: 1050 !important;
}

/* 删除确认弹窗专用包装器 */
.knowledge-delete-modal-wrap {
  z-index: 9999 !important; /* 使用极高的z-index */
  
  .ant-modal-mask {
    z-index: 9990 !important;
  }
  
  .ant-modal {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important;
    z-index: 9999 !important;
  }
  
  .ant-modal-content {
    border-radius: 12px !important;
    overflow: hidden !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15) !important;
    padding: 0 !important;
  }
  
  .ant-modal-header {
    background-color: #fdfdfd !important;
    border-bottom: 1px solid #f0f0f0 !important;
    margin: 0 !important;
    height: 52px !important;
    padding: 14px 16px !important;
    align-items: center !important;
    display: flex !important;
  }
  
  .ant-modal-body {
    padding: 16px !important;
    font-size: 14px !important;
    color: @text-primary !important;
    line-height: 1.5 !important;
    max-height: 200px;
    overflow-y: auto;
  }
  
  .ant-modal-footer {
    border-top: 1px solid #f0f0f0 !important;
    padding: 12px 16px !important;
    margin-top: 0 !important;
    display: flex !important;
    justify-content: flex-end !important;
    gap: 8px !important;
  }
  
  /* 按钮样式 */
  .ant-btn-primary.ant-btn-dangerous {
    background-color: @error-color !important;
    border-color: @error-color !important;
    
    &:hover {
      background-color: darken(@error-color, 10%) !important;
      border-color: darken(@error-color, 10%) !important;
    }
  }
  
  /* 对齐标题和关闭按钮 */
  .ant-modal-close {
    top: 14px !important;
  }
  
  /* 适配确认提示文本样式 */
  p {
    margin: 0 !important;
    padding: 0 !important;
    color: @text-primary !important;
    font-size: 14px !important;
    line-height: 1.6 !important;
    word-wrap: break-word !important;
    white-space: normal !important;
    overflow-wrap: break-word !important;
  }
}