/* 搜索按鈕樣式 */
#nav-custom-search-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer;
  width: 24px;
  height: 24px;
}

#nav-custom-search-btn::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  background-color: currentColor;
  -webkit-mask: url('/images/Search_Icon.svg') no-repeat center / contain;
  mask: url('/images/Search_Icon.svg') no-repeat center / contain;
}

/* 搜索覆蓋層 */
.custom-search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 9999;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 100px;
  animation: fadeIn 0.3s ease;
}

.custom-search-overlay.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 搜索容器 */
.custom-search-container {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 700px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: slideDown 0.3s ease;
}

[data-theme="dark"] .custom-search-container {
  background: #1f2937;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

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

/* 搜索頭部 */
.custom-search-header {
  display: flex;
  align-items: center;
  padding: 20px;
  border-bottom: 2px solid #e5e7eb;
  gap: 12px;
}

[data-theme="dark"] .custom-search-header {
  border-bottom-color: #374151;
}

.custom-search-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.custom-search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 18px;
  color: #1f2937;
  background: transparent;
}

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

[data-theme="dark"] .custom-search-input {
  color: #f3f4f6;
}

[data-theme="dark"] .custom-search-input::placeholder {
  color: #6b7280;
}

.custom-search-close {
  width: 32px;
  height: 32px;
  border: none;
  background: #f3f4f6;
  border-radius: 6px;
  font-size: 24px;
  line-height: 1;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.custom-search-close:hover {
  background: #e5e7eb;
  color: #1f2937;
}

[data-theme="dark"] .custom-search-close {
  background: #374151;
  color: #9ca3af;
}

[data-theme="dark"] .custom-search-close:hover {
  background: #4b5563;
  color: #f3f4f6;
}

/* 搜索結果區域 */
.custom-search-results {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  min-height: 200px;
}

.search-result-count {
  color: #6b7280;
  font-size: 14px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e5e7eb;
}

[data-theme="dark"] .search-result-count {
  color: #9ca3af;
  border-bottom-color: #374151;
}

.search-result-item {
  padding: 16px;
  margin-bottom: 12px;
  border-radius: 8px;
  background: #f9fafb;
  transition: all 0.2s;
}

.search-result-item:hover {
  background: #f3f4f6;
  transform: translateX(4px);
}

[data-theme="dark"] .search-result-item {
  background: #111827;
}

[data-theme="dark"] .search-result-item:hover {
  background: #1f2937;
}

.search-result-title {
  display: block;
  font-size: 18px;
  font-weight: 600;
  color: #2563eb;
  text-decoration: none;
  margin-bottom: 8px;
  transition: color 0.2s;
}

.search-result-title:hover {
  color: #1d4ed8;
}

[data-theme="dark"] .search-result-title {
  color: #60a5fa;
}

[data-theme="dark"] .search-result-title:hover {
  color: #3b82f6;
}

.search-result-content {
  color: #4b5563;
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

[data-theme="dark"] .search-result-content {
  color: #9ca3af;
}

.search-result-meta {
  color: #9ca3af;
  font-size: 12px;
}

[data-theme="dark"] .search-result-meta {
  color: #6b7280;
}

.search-no-result {
  text-align: center;
  color: #9ca3af;
  padding: 60px 20px;
  font-size: 16px;
}

[data-theme="dark"] .search-no-result {
  color: #6b7280;
}

/* 高亮樣式 */
.custom-search-results mark {
  background: #dbeafe;
  color: #1d4ed8;
  padding: 2px 4px;
  border-radius: 3px;
  font-weight: 600;
}

[data-theme="dark"] .custom-search-results mark {
  background: #1e3a8a;
  color: #93c5fd;
}

/* 響應式設計 */
@media (max-width: 768px) {
  .custom-search-overlay {
    padding-top: 50px;
  }

  .custom-search-container {
    width: 95%;
    max-height: 85vh;
  }

  .custom-search-input {
    font-size: 16px;
  }

  .search-result-title {
    font-size: 16px;
  }
}
