/* Typesense 搜索功能样式 */

/* 搜索触发按钮 - 旧样式（保留兼容） */
.ddkk-search-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-right: 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #666;
}

.ddkk-search-trigger:hover {
  background-color: rgba(0, 0, 0, 0.04);
  color: #1677ff;
}

/* 导航栏搜索框 - 新样式 */
.ddkk-nav-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 240px;
  height: 36px;
  padding: 0 12px;
  margin-right: 12px;
  background-color: rgba(0, 0, 0, 0.04);
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  white-space: nowrap;
}

.ddkk-nav-search-box:hover {
  background-color: #fff;
  border-color: #1677ff;
  border-width: 2px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.ddkk-nav-search-box:active {
  border-color: #1677ff;
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.1);
}

.ddkk-nav-search-icon {
  flex-shrink: 0;
  color: #999;
  transition: color 0.2s ease;
}

.ddkk-nav-search-box:hover .ddkk-nav-search-icon {
  color: #1677ff;
}

.ddkk-nav-search-text {
  flex: 1;
  font-size: 14px;
  color: #999;
  user-select: none;
}

.ddkk-nav-search-shortcut {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 18px;
  padding: 0 5px;
  font-size: 12px;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "SF Mono", monospace;
  color: #9333ea; /* 紫色字体 */
  background: transparent; /* 透明背景 */
  border: 1px solid #c084fc; /* 紫色细边框 */
  border-radius: 3px;
  line-height: 1;
  letter-spacing: 1px;
  transition: all 0.2s ease;
}

.ddkk-nav-search-shortcut:hover {
  border-color: #9333ea; /* hover时边框加深 */
  color: #7e22ce;
  box-shadow: 0 0 0 1px rgba(147, 51, 234, 0.1);
}

/* 移动端搜索按钮 */
.ddkk-mobile-search-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  margin-right: 8px;
  border: none;
  background-color: transparent;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ddkk-mobile-search-btn:hover {
  color: #1677ff;
  background-color: rgba(22, 119, 255, 0.08);
  border-radius: 8px;
}

.ddkk-mobile-search-btn:active {
  color: #1677ff;
  background-color: rgba(22, 119, 255, 0.15);
}

/* 移动端适配 */
@media (max-width: 991px) {
  .ddkk-nav-search-box {
    display: none !important; /* 移动端隐藏桌面端搜索框 */
  }
  
  .ddkk-mobile-search-btn {
    display: flex; /* 移动端显示搜索按钮 */
  }
}

/* 搜索弹窗 */
.ddkk-search-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.ddkk-search-modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
}

.ddkk-search-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.ddkk-search-container {
  position: relative;
  width: 90%;
  max-width: 1200px;
  height: 80vh;
  max-height: 800px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: searchModalSlideIn 0.3s ease;
}

@keyframes searchModalSlideIn {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* 搜索头部 */
.ddkk-search-header {
  padding: 24px 32px 16px;
  border-bottom: 1px solid #f0f0f0;
}

.ddkk-search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #f5f5f5;
  border-radius: 12px;
  transition: all 0.2s ease;
}

.ddkk-search-input-wrapper:focus-within {
  background: #fff;
  box-shadow: 0 0 0 2px #1677ff;
}

.ddkk-search-icon {
  flex-shrink: 0;
  color: #999;
}

.ddkk-search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 16px;
  color: #333;
  padding: 0;
  min-height: 24px;
  line-height: 24px;
  white-space: pre-wrap;
  word-break: break-word;
  -webkit-user-select: text;
  user-select: text;
}

/* contenteditable placeholder */
.ddkk-search-input:empty:before {
  content: attr(data-placeholder);
  color: #bbb;
  pointer-events: none;
}

.ddkk-search-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  transition: all 0.2s ease;
}

.ddkk-search-close:hover {
  background: #f0f0f0;
  color: #333;
}

.ddkk-search-stats {
  margin-top: 12px;
  font-size: 14px;
  color: #999;
}

/* 搜索主体 */
.ddkk-search-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* 左侧分类筛选 */
.ddkk-search-sidebar {
  width: 280px;
  border-right: 1px solid #f0f0f0;
  padding: 20px 16px;
  overflow-y: auto;
}

.ddkk-search-sidebar-title {
  font-size: 13px;
  font-weight: 600;
  color: #333;
  margin-bottom: 12px;
  padding: 0 8px;
}

.ddkk-search-categories {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ddkk-search-category {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0; /* 不被压缩 */
  display: inline-block;
}

.ddkk-search-category:hover {
  background: #f5f5f5;
  color: #333;
}

.ddkk-search-category.active {
  background: #e6f4ff;
  color: #1677ff;
  font-weight: 500;
}

/* 右侧搜索结果 */
.ddkk-search-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ddkk-search-results {
  flex: 1;
  padding: 24px 32px;
  overflow-y: auto;
}

.ddkk-search-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #bbb;
}

.ddkk-search-empty svg {
  margin-bottom: 16px;
  opacity: 0.3;
}

.ddkk-search-empty p {
  font-size: 16px;
  margin: 0;
}

/* 搜索提示信息 */
.ddkk-search-tip {
  padding: 32px 16px;
  text-align: center;
  color: #666;
  font-size: 14px;
  background: #f9f9f9;
  border-radius: 8px;
  margin: 16px;
}

/* 搜索结果项 */
.ddkk-search-result-item {
  padding: 12px 16px;
  border-radius: 4px;
  margin-bottom: 8px;
  border: 1px solid #f0f0f0;
  cursor: pointer;
  transition: all 0.15s ease;
  background: #fff;
}

.ddkk-search-result-item:hover {
  border-color: #d9d9d9;
  background: #fafafa;
}

.ddkk-search-result-item.selected {
  border-color: #1677ff;
  background: #e6f4ff;
  box-shadow: 0 2px 8px rgba(22, 119, 255, 0.15);
}

.ddkk-search-result-title {
  font-size: 15px;
  font-weight: 600;
  color: #333;
  margin-bottom: 6px;
  line-height: 1.4;
}

.ddkk-search-result-title mark {
  background: #ffeb3b;
  color: #000;
  font-weight: 600;
  padding: 2px 4px;
  border-radius: 3px;
}

.ddkk-search-result-content {
  font-size: 13px;
  color: #666;
  line-height: 1.6;
  margin: 0;
}

.ddkk-search-result-content mark {
  background: #ffeb3b;
  color: #000;
  font-weight: 500;
  padding: 2px 4px;
  border-radius: 2px;
  border-radius: 4px;
  font-weight: 500;
}

/* 加载中状态 */
.ddkk-search-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #999;
}

.ddkk-search-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #f0f0f0;
  border-top-color: #1677ff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* 加载更多提示 */
.ddkk-search-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: #999;
  font-size: 13px;
  border-top: 1px solid #f5f5f5;
  margin-top: 16px;
}

.ddkk-search-loading span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ddkk-search-loading span::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #e0e0e0;
  border-top-color: #1677ff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 底部工具栏 */
.ddkk-search-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-top: 1px solid #f0f0f0;
  background-color: #fafafa;
  font-size: 12px;
}

.ddkk-search-shortcuts {
  display: flex;
  align-items: center;
  gap: 16px;
}

.ddkk-search-shortcut-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #666;
}

.ddkk-search-shortcut-item svg {
  flex-shrink: 0;
  padding: 3px;
  color: #666;
  background: #fff;
  border: 1px solid #d9d9d9;
  border-radius: 3px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.ddkk-search-shortcut-item kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 20px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
  color: #666;
  background: #fff;
  border: 1px solid #d9d9d9;
  border-radius: 3px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* 组合快捷键样式：让两个 kbd 和中间的 + 看起来像一个组合 */
.ddkk-search-shortcut-item kbd:first-of-type {
  border-radius: 3px 0 0 3px;
  margin-right: 0;
}

.ddkk-shortcut-plus {
  display: inline-flex;
  align-items: center;
  padding: 0 4px;
  font-size: 12px;
  color: #666;
  font-weight: 500;
}

.ddkk-search-shortcut-item kbd:first-of-type + .ddkk-shortcut-plus + kbd {
  border-left: none;
  border-radius: 0 3px 3px 0;
  margin-left: 0;
}

.ddkk-search-shortcut-item span {
  font-size: 12px;
  color: #999;
}

.ddkk-search-provider {
  color: #9333ea; /* 紫色 */
  font-size: 14px;
}

.ddkk-search-provider span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  /* 移动端弹窗避开导航栏 */
  .ddkk-search-modal.active {
    align-items: flex-start;
    padding-top: 64px; /* 导航栏高度 */
  }
  
  .ddkk-search-container {
    width: 96%;
    height: calc(100vh - 70px); /* 减去导航栏高度和间距 */
    max-height: none;
    border-radius: 12px; /* 更小的圆角 */
  }
  
  /* 移动端分类改为横向滚动 */
  .ddkk-search-sidebar {
    position: relative; /* 为伪元素定位 */
    display: block;
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    border-right: none;
    border-bottom: 1px solid #f0f0f0;
    padding: 8px 12px;
    padding-right: 8px; /* 右侧减少padding，为滚动留出空间 */
    max-height: none;
    overflow: hidden; /* 防止内容溢出屏幕 */
    box-sizing: border-box; /* 确保padding包含在宽度内 */
  }
  
  .ddkk-search-sidebar-title {
    font-size: 11px;
    margin-bottom: 8px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: #666;
  }
  
  .ddkk-search-sidebar-title::after {
    content: '← 滑动查看 →';
    font-size: 13px;
    color: #9333ea; /* 紫色 */
    font-weight: 600;
    flex-shrink: 0;
  }
  
  /* 分类容器包装 */
  .ddkk-search-categories-wrapper {
    position: relative;
  }
  
  .ddkk-search-categories {
    position: relative;
    display: flex;
    flex-direction: column; /* 垂直方向排列 */
    flex-wrap: wrap; /* 允许换列 */
    align-content: flex-start;
    gap: 6px;
    height: 64px; /* 固定高度，能放2行 */
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 0;
    padding-right: 50px; /* 右侧留出空间，防止被遮罩挡住 */
    padding-bottom: 2px;
    box-sizing: border-box; /* 确保padding包含在宽度内 */
  }
  
  .ddkk-search-categories::-webkit-scrollbar {
    display: none;
  }
  
  /* 右侧渐变遮罩提示（暗示有更多内容） */
  .ddkk-search-categories::after {
    content: '';
    position: absolute;
    right: 50px; /* 与padding-right对齐，在可见区域右边缘 */
    top: 0;
    bottom: 0;
    width: 40px;
    background: linear-gradient(to left, rgba(255,255,255,0.95), transparent);
    pointer-events: none;
    z-index: 1;
  }
  
  .ddkk-search-category {
    flex-shrink: 0;
    padding: 4px 10px;
    font-size: 11px;
    white-space: nowrap;
    position: relative;
    z-index: 2; /* 在渐变遮罩之上 */
  }
  
  .ddkk-search-body {
    flex-direction: column;
  }
  
  .ddkk-search-content {
    flex: 1;
    min-height: 0;
  }
  
  /* 搜索头部更紧凑 */
  .ddkk-search-header {
    padding: 8px 12px; /* 更紧凑 */
  }
  
  .ddkk-search-input-wrapper {
    padding: 8px 12px; /* 更小 */
    gap: 8px;
    border-radius: 8px; /* 更小圆角 */
  }
  
  .ddkk-search-icon {
    width: 16px;
    height: 16px;
  }
  
  /* 移动端也隐藏搜索框自带的清除按钮 */
  .ddkk-search-input::-webkit-search-cancel-button {
    display: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
  }
  
  .ddkk-search-input::-moz-search-clear-button {
    display: none !important;
  }
  
  .ddkk-search-input {
    font-size: 13px; /* 更小 */
  }
  
  .ddkk-search-close {
    width: 28px; /* 更小 */
    height: 28px;
  }
  
  .ddkk-search-close svg {
    width: 16px;
    height: 16px;
  }
  
  .ddkk-search-stats {
    font-size: 11px; /* 更小 */
    margin-top: 6px;
  }
  
  /* 搜索结果更紧凑 */
  .ddkk-search-results {
    padding: 8px 12px; /* 更紧凑 */
  }
  
  .ddkk-search-result-item {
    padding: 10px; /* 更小 */
    margin-bottom: 6px; /* 更小间距 */
  }
  
  .ddkk-search-result-title {
    font-size: 13px; /* 更小 */
    margin-bottom: 4px;
    line-height: 1.4;
  }
  
  .ddkk-search-result-content {
    font-size: 11px; /* 更小 */
    line-height: 1.4;
  }
  
  /* 高亮样式也更小 */
  .ddkk-search-result-title mark {
    padding: 1px 3px; /* 更小 */
    font-size: 13px;
  }
  
  .ddkk-search-result-content mark {
    padding: 1px 2px; /* 更小 */
    font-size: 11px;
  }
  
  /* 空状态更紧凑 */
  .ddkk-search-empty {
    padding: 24px 12px; /* 更紧凑 */
  }
  
  .ddkk-search-empty svg {
    width: 40px; /* 更小 */
    height: 40px;
  }
  
  .ddkk-search-empty p {
    font-size: 12px; /* 更小 */
    margin-top: 8px;
  }
  
  /* 加载更多提示（移动端） */
  .ddkk-search-loading {
    padding: 16px;
    font-size: 12px;
  }
  
  /* 底部工具栏（移动端） */
  .ddkk-search-footer {
    justify-content: center;
    padding: 10px 12px;
  }
  
  /* 手机上隐藏快捷键提示 */
  .ddkk-search-shortcuts {
    display: none;
  }
  
  .ddkk-search-provider {
    font-size: 10px;
    text-align: center;
  }
}

