/* ============================================
   Search Page - 搜索页面（1:1 对齐设计稿）
   UI：导航栏(返回+XenDrama) + 圆角搜索框 + 搜索历史标签 + 结果网格
   ============================================ */

#search-page {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #000000;
  z-index: var(--z-modal, 100);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease-out;
}

#search-page.visible {
  transform: translateX(0);
}

/* ================================
   导航栏（返回箭头 + XenDrama 标题）
   ================================ */
.search-nav {
  display: flex;
  align-items: center;
  height: 48px;
  padding: 0 14px;
  padding-top: calc(0px + env(safe-area-inset-top, 0px));
  background: #000000;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.search-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  border-radius: 50%;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.search-back-btn:active {
  background: rgba(255, 255, 255, 0.1);
}

.search-nav-title {
  flex: 1;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  color: #ffffff;
  margin: 0;
  letter-spacing: -0.2px;
}

.search-nav-spacer {
  width: 36px;
}

/* ================================
   搜索输入区域
   ================================ */
.search-input-wrap {
  padding: 12px 14px 8px;
  flex-shrink: 0;
}

.search-input-box {
  position: relative;
  width: 100%;
}

.search-input-field {
  width: 100%;
  height: 44px;
  padding: 0 16px 0 44px; /* 左侧留出图标空间 */
  background: #2c2c2e;
  border: none;
  border-radius: 22px;
  font-size: 16px;
  font-family: inherit;
  color: #ffffff;
  outline: none;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  transition: background 0.15s;
}

.search-input-field::placeholder {
  color: #8e8e93;
}

.search-input-field:focus {
  background: #38383a;
}

.search-input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.search-input-icon-img {
  width: 22px;
  height: 22px;
  display: block;
}

/* 清空按钮 */
.search-clear-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  display: none;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.search-clear-icon-img {
  width: 24px;
  height: 24px;
  display: block;
}

.search-clear-btn.visible {
  display: flex;
}

/* ================================
   搜索历史区域
   ================================ */
.search-history-section {
  padding: 4px 14px 0;
  flex-shrink: 0;
}

.search-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 0 2px;
}

.search-history-title {
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
  margin: 0;
}

.search-history-clear-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  border-radius: 8px;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.search-history-clear-btn:active {
  background: rgba(255, 255, 255, 0.08);
}

.search-clear-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

/* 历史标签容器 */
.search-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-bottom: 8px;
}

/* 单个历史标签（圆角胶囊） */
.search-tag-item {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 16px;
  background: #1c1c1e;
  border: none;
  border-radius: 17px;
  font-size: 14px;
  font-family: inherit;
  color: #ffffff;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.search-tag-item:active {
  background: #2c2c2e;
}

/* ================================
   搜索结果区域
   ================================ */
.search-results-section {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-top: 4px;
}

.search-results-header {
  padding: 8px 18px 12px;
  font-size: 15px;
  font-weight: 500;
  color: #8e8e93;
}

/* 结果 2 列网格 —— 与首页 Exclusive Dramas 一致 */
.search-results-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 0 16px 24px;
}

/* 搜索结果卡片 —— 复用首页 drama-card 样式 */
#search-page .drama-card {
  cursor: pointer;
  border-radius: 10px;
  overflow: hidden;
  transition: transform 0.15s ease;
  background: transparent;
  width: 100%;
}

#search-page .drama-card:active {
  transform: scale(0.97);
}

#search-page .drama-card .card-poster {
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  background: #1c1c1e;
  width: 100%;
  aspect-ratio: 3 / 4;
  height: auto;
}

#search-page .drama-card .card-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#search-page .drama-card .card-title {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  padding: 0 2px;
}

/* HOT/NEW 角标 —— 与首页一致 */
#search-page .card-badge.badge-img.hot {
  position: absolute;
  top: 0;
  right: 0;
  width: 45px;
  height: 17px;
  z-index: 2;
  object-fit: contain;
}

#search-page .card-badge.badge-img.new {
  position: absolute;
  top: 0;
  right: 0;
  width: 45px;
  height: 17px;
  z-index: 2;
  object-fit: contain;
}

/* 空状态 */
.search-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: #555;
}

.search-empty-state svg {
  margin-bottom: 12px;
  opacity: 0.5;
}

.search-empty-state p {
  font-size: 14px;
  color: #666;
}

/* ================================
   底部加载更多指示器
   ================================ */
.search-load-more {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 16px 0 28px;
}

.search-loading-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.30);
  animation: search-dot-pulse 1.2s infinite ease-in-out;
}

.search-loading-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.search-loading-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes search-dot-pulse {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.3;
  }
  40% {
    transform: scale(1);
    opacity: 0.8;
  }
}
