/* =========================================================
   OSSAF - 搜索组件样式
   与站点主题风格保持一致（蓝色主调 #1565c0）
   ========================================================= */

.search-container {
  position: relative;
  width: 100%;
  max-width: 640px;
  margin: 0 auto 24px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  font-size: 16px;
  pointer-events: none;
  opacity: 0.6;
}

.search-input {
  width: 100%;
  padding: 12px 40px 12px 42px;
  font-size: 16px;
  border: 2px solid #e1e4e8;
  border-radius: 8px;
  background: #ffffff;
  color: #1f2933;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
  font-family: inherit;
}

.search-input::placeholder {
  color: #9ca3af;
}

.search-input:focus {
  outline: none;
  border-color: #1565c0;
  box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.12);
}

.search-clear {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: #9ca3af;
  cursor: pointer;
  display: none;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.search-clear:hover {
  color: #1f2933;
  background: #f1f3f5;
}

.search-clear:focus {
  outline: 2px solid #1565c0;
  outline-offset: 1px;
}

.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid #e1e4e8;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  max-height: 420px;
  overflow-y: auto;
  display: none;
  z-index: 1000;
}

.search-result-item {
  display: block;
  padding: 12px 16px;
  text-decoration: none;
  color: #1f2933;
  border-bottom: 1px solid #f0f2f5;
  transition: background-color 0.12s;
}

.search-result-item:hover,
.search-result-item:focus {
  background: #eef4fb;
  text-decoration: none;
}

.search-result-item:last-child {
  border-bottom: none;
}

.result-title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
  color: #0d47a1;
}

.result-alt {
  color: #2e7d32;
  font-weight: 500;
  font-size: 14px;
}

.result-summary {
  font-size: 13px;
  color: #4b5563;
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-bottom: 4px;
}

.result-score {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
}

/* 高亮匹配关键词 */
.search-highlight {
  background: #fef08a;
  color: #713f12;
  padding: 0 2px;
  border-radius: 3px;
  font-weight: 600;
}

.search-loading,
.search-empty,
.search-error {
  padding: 16px;
  text-align: center;
  color: #6b7280;
  font-size: 14px;
}

.search-error {
  color: #b91c1c;
}

/* 滚动条样式（Webkit）*/
.search-results::-webkit-scrollbar {
  width: 8px;
}
.search-results::-webkit-scrollbar-track {
  background: #f1f3f5;
  border-radius: 0 0 8px 8px;
}
.search-results::-webkit-scrollbar-thumb {
  background: #cdd3da;
  border-radius: 4px;
}
.search-results::-webkit-scrollbar-thumb:hover {
  background: #b0b8c2;
}

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  .search-container {
    max-width: 100%;
    margin-bottom: 18px;
  }

  .search-input {
    font-size: 16px; /* iOS 防止缩放 */
  }

  .search-results {
    max-height: 320px;
  }

  .result-title {
    font-size: 14px;
  }

  .result-summary {
    font-size: 12px;
  }
}

/* ---------- 深色模式（可选） ---------- */
@media (prefers-color-scheme: dark) {
  .search-input {
    background: #1a1f2e;
    border-color: #2d3548;
    color: #e5e7eb;
  }

  .search-input::placeholder {
    color: #6b7280;
  }

  .search-input:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.18);
  }

  .search-clear {
    color: #6b7280;
  }

  .search-clear:hover {
    color: #e5e7eb;
    background: #2d3548;
  }

  .search-results {
    background: #1a1f2e;
    border-color: #2d3548;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  }

  .search-result-item {
    color: #e5e7eb;
    border-color: #2d3548;
  }

  .search-result-item:hover,
  .search-result-item:focus {
    background: #2d3548;
  }

  .result-title {
    color: #93c5fd;
  }

  .result-summary {
    color: #9ca3af;
  }

  .search-highlight {
    background: #854d0e;
    color: #fef08a;
  }
}
