/* ============================================
   Site Search Modal - Premium Design
   ============================================ */

:root {
  --search-width: 680px;
  --search-radius: 16px;
  --search-bg: rgba(255, 255, 255, 0.85);
  --search-backdrop: blur(20px) saturate(180%);
  --search-border: 1px solid rgba(255, 255, 255, 0.6);
  --search-shadow: 0 40px 100px -20px rgba(0, 0, 0, 0.3), 
                   0 20px 60px -30px rgba(0, 50, 100, 0.15);
  --item-hover-bg: rgba(235, 240, 250, 0.8);
  --primary-color: #0056b3;
  --accent-color: #00a8ff;
}

/* 遮罩层 */
.vs-search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.vs-search-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* 搜索主容器 - 居中悬浮面板 */
.vs-search-modal {
  position: fixed;
  top: 15%;
  left: 50%;
  width: var(--search-width);
  max-width: 90%;
  transform: translateX(-50%) scale(0.95);
  z-index: 10001;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.vs-search-modal.active {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) scale(1);
  top: 15%;
}

/* 搜索界面包裹层 */
.vs-search-wrapper {
  background: var(--search-bg);
  backdrop-filter: var(--search-backdrop);
  -webkit-backdrop-filter: var(--search-backdrop);
  border-radius: var(--search-radius);
  box-shadow: var(--search-shadow);
  border: var(--search-border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* 头部搜索区 */
.vs-search-header {
  position: relative;
  display: flex;
  align-items: center;
  padding: 24px 28px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.vs-search-icon {
  font-size: 24px;
  color: var(--primary-color);
  margin-right: 20px;
  opacity: 0.8;
}

.vs-search-input {
  flex: 1;
  font-size: 22px;
  font-weight: 500;
  color: #1e293b;
  border: none;
  background: transparent;
  outline: none;
  padding: 0;
  font-family: inherit;
  line-height: 1.2;
}

.vs-search-input::placeholder {
  color: #94a3b8;
  font-weight: 400;
}

/* 清除按钮 */
.vs-search-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e2e8f0;
  border: none;
  color: #64748b;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.2s ease;
  pointer-events: none;
}

.vs-search-clear.visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.vs-search-clear:hover {
  background: #cbd5e1;
  color: #334155;
}

/* 关闭按钮 - 移到右上角 */
.vs-search-close-btn {
  margin-left: 12px;
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.05);
  border: none;
  border-radius: 6px;
  font-size: 13px;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s;
  display: none; /* 桌面端一般按ESC或点遮罩，留给移动端显示 */
}

/* 内容区域 */
.vs-search-body {
  max-height: 500px;
  overflow-y: auto;
  scrollbar-width: thin;
  position: relative;
  min-height: 100px;
}

/* 结果列表 */
.vs-search-results {
  padding: 12px;
}

/* 分组标题 */
.vs-search-group-title {
  padding: 12px 16px 8px;
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* 结果项 */
.vs-search-result-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  padding: 16px;
  margin-bottom: 4px;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: all 0.15s ease;
  cursor: pointer;
  border: 1px solid transparent;
}

.vs-search-result-item.focused,
.vs-search-result-item:hover {
  background: var(--item-hover-bg);
  border-color: rgba(0, 86, 179, 0.1);
  transform: scale(1.01);
}

.vs-search-result-item.focused::before,
.vs-search-result-item:hover::before {
  content: '';
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 4px;
  background: var(--accent-color);
  border-radius: 0 4px 4px 0;
  box-shadow: 2px 0 10px rgba(0, 168, 255, 0.4);
}

.g-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(241, 245, 249, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 16px;
  color: #64748b;
  font-size: 18px;
  border: 1px solid rgba(0, 0, 0, 0.03);
}

.vs-search-result-item.focused .g-icon,
.vs-search-result-item:hover .g-icon {
  background: white;
  color: var(--primary-color);
  box-shadow: 0 4px 12px rgba(0, 30, 80, 0.08);
}

.g-content {
  flex: 1;
  min-width: 0; /* 允许文本截断 */
}

.g-title {
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 4px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.g-snippet {
  font-size: 13px;
  color: #64748b;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.g-snippet mark {
  background: transparent;
  color: var(--primary-color);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: rgba(0, 86, 179, 0.3);
  text-underline-offset: 2px;
  padding: 0;
}

.g-meta {
  display: flex;
  align-items: center;
  margin-top: 6px;
  font-size: 11px;
  color: #94a3b8;
  gap: 8px;
}

.g-tag {
  background: rgba(0, 0, 0, 0.04);
  padding: 2px 6px;
  border-radius: 4px;
}

/* 底部状态栏 */
.vs-search-footer {
  padding: 12px 20px;
  background: rgba(248, 250, 252, 0.8);
  border-top: 1px solid rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: #64748b;
}

.vs-shortcuts {
  display: flex;
  gap: 16px;
}

.vs-key-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

kbd {
  background: white;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 2px 6px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  box-shadow: 0 1px 1px rgba(0,0,0,0.05);
  min-width: 20px;
  text-align: center;
}

/* 空状态和加载状态 */
.vs-state-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: #64748b;
}

.vs-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.3;
  color: var(--primary-color);
}

.vs-state-title {
  font-size: 16px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 8px;
}

.vs-state-desc {
  font-size: 14px;
  max-width: 300px;
  line-height: 1.5;
}

/* 热门搜索标签 */
.vs-tags-cloud {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 24px;
}

.vs-tag-btn {
  background: white;
  border: 1px solid #e2e8f0;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s;
}

.vs-tag-btn:hover {
  border-color: var(--accent-color);
  color: var(--primary-color);
  background: #f0f9ff;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 168, 255, 0.15);
}

/* 加载动画 */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(0, 86, 179, 0.1);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* 滚动条美化 */
.vs-search-body::-webkit-scrollbar {
  width: 6px;
}
.vs-search-body::-webkit-scrollbar-track {
  background: transparent;
}
.vs-search-body::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
}
.vs-search-body::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.2);
}

/* 移动端适配 */
@media (max-width: 768px) {
  .vs-search-modal {
    top: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    transform: none;
    border-radius: 0;
  }
  
  .vs-search-modal.active {
    top: 0;
    transform: none;
  }
  
  .vs-search-wrapper {
    height: 100%;
    border-radius: 0;
    border: none;
  }
  
  .vs-search-header {
    padding: 16px 20px;
  }
  
  .vs-search-close-btn {
    display: block;
  }
  
  .vs-search-footer {
    display: none;
  }
}
