/* =============================================
   search.css — 搜索弹窗模块样式
   包含：遮罩层、搜索弹窗主体、Trending / Recent 两区块
   依赖：common.css（CSS 变量）
   ============================================= */

/* =============================================
   搜索页 — Header 搜索输入框点击样式覆盖
   （只读输入框，点击打开弹窗，显示指针光标）
   ============================================= */
.page-home .header-search-input[readonly] {
  cursor: pointer;
}

/* =============================================
   搜索页面 — 占位提示（无搜索结果时）
   ============================================= */
.search-page-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 120px 20px;
  color: var(--color-text-hint);
}

.search-page-hint svg,
.search-page-hint img {
  width: 56px;
  height: 56px;
  opacity: 0.3;
}

.search-page-hint p {
  font-size: 16px;
}

/* =============================================
   遮罩层
   ============================================= */
.search-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.50);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.search-overlay.active {
  display: block;
  opacity: 1;
}

/* =============================================
   弹窗容器（页面中央偏上）
   ============================================= */
.search-modal-wrap {
  position: fixed;
  inset: 0;
  z-index: 1001;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 100px;          /* 顶部距离，为 header 留出空间 */
  pointer-events: none;
}

.search-modal-wrap.active {
  display: flex;
}

/* =============================================
   弹窗卡片
   ============================================= */
.search-modal {
  width: 800px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 120px);
  overflow: hidden;
  background: var(--color-bg-white);
  border-radius: var(--radius-md);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  display: flex;
  flex-direction: column;
}

.search-modal-wrap.active .search-modal {
  opacity: 1;
  transform: translateY(0);
}

/* =============================================
   弹窗顶部搜索输入行
   ============================================= */
.search-modal__input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--color-border);
}

.search-modal__input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-modal__input-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--color-text-hint);
  pointer-events: none;
  flex-shrink: 0;
}

.search-modal__input {
  width: 100%;
  height: 48px;
  padding: 0 16px 0 44px;
  background: #f5f5f5;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--color-text-body);
  transition: border-color var(--transition-base), background var(--transition-base);
}

.search-modal__input:focus {
  background: var(--color-bg-white);
  border-color: var(--color-primary);
  outline: none;
}

.search-modal__input::placeholder {
  color: var(--color-text-placeholder);
}

/* 关闭按钮 */
.search-modal__close {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition-base), color var(--transition-base);
}

.search-modal__close:hover {
  background: #f5f5f5;
  color: var(--color-text-dark);
}

.search-modal__close svg,
.search-modal__close img {
  width: 20px;
  height: 20px;
}

.search-modal__close svg {
  stroke: currentColor;
}

.search-modal__close img {
  object-fit: contain;
  filter: brightness(0) saturate(100%) invert(42%) sepia(3%) saturate(0%) hue-rotate(152deg) brightness(95%) contrast(89%);
}

.search-modal__close:hover img {
  filter: brightness(0) saturate(100%) invert(8%) sepia(4%) saturate(0%) hue-rotate(172deg) brightness(95%) contrast(93%);
}

/* 内容可滚动区域 */
.search-modal__body {
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}

/* =============================================
   Section 通用
   ============================================= */
.search-section {
  padding: 24px 24px 0;
}

.search-section + .search-section {
  border-top: 1px solid var(--color-border);
  padding-top: 24px;
}

.search-section:last-child {
  padding-bottom: 24px;
}

/* Section 标题行 */
.search-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.search-section__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text-dark);
  line-height: 1.5;
}

.search-section__title img,
.search-section__title svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* "Clear All" 按钮 */
.search-clear-btn {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-primary);
  cursor: pointer;
  padding: 0;
  transition: opacity var(--transition-base);
  white-space: nowrap;
}

.search-clear-btn:hover {
  opacity: 0.75;
}

/* =============================================
   Trending Searches — 标签区域
   ============================================= */
.search-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 24px;
}

.search-tag {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  background: #f5f5f5;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-body);
  cursor: pointer;
  transition: background var(--transition-base), border-color var(--transition-base), color var(--transition-base);
  white-space: nowrap;
}

.search-tag:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-text-white);
}

/* =============================================
   Recent Searches — 历史列表
   ============================================= */
.search-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 12px;
  background: #f5f5f5;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-base);
}

.search-history-item:hover {
  background: #ebebeb;
}

.search-history-item__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-history-item__icon img,
.search-history-item__icon svg {
  width: 16px;
  height: 16px;
  display: block;
}

.search-history-item__text {
  font-size: 15px;
  font-weight: 400;
  color: var(--color-text-body);
  line-height: 1.467;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-history-item__remove {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-hint);
  opacity: 0;
  transition: opacity var(--transition-base), color var(--transition-base);
  cursor: pointer;
}

.search-history-item:hover .search-history-item__remove {
  opacity: 1;
}

.search-history-item__remove:hover {
  color: var(--color-primary);
}

.search-history-item__remove svg,
.search-history-item__remove img {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2;
}

/* =============================================
   无历史记录提示
   ============================================= */
.search-history-empty {
  padding: 20px 0;
  text-align: center;
  font-size: 14px;
  color: var(--color-text-muted);
}

/* =============================================
   搜索关键词高亮（输入时）
   ============================================= */
.search-highlight {
  color: var(--color-primary);
  font-weight: 600;
}

/* =============================================
   响应式 — 平板（≤ 1024px）
   ============================================= */
@media (max-width: 1024px) {
  .search-modal-wrap {
    padding-top: 80px;
  }

  .search-modal {
    width: calc(100vw - 40px);
  }
}

/* =============================================
   响应式 — 手机（≤ 640px）
   ============================================= */
@media (max-width: 640px) {
  .search-modal-wrap {
    padding-top: 0;
    align-items: flex-start;
  }

  .search-modal {
    width: 100vw;
    max-width: 100vw;
    max-height: 85vh;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
  }

  .search-section {
    padding: 18px 16px 0;
  }

  .search-section + .search-section {
    padding-top: 18px;
  }

  .search-section:last-child {
    padding-bottom: 18px;
  }

  .search-tags {
    gap: 8px;
    padding-bottom: 18px;
  }
}
