/* ================================================================
   グローバル検索機能のスタイル
   ================================================================ */

/* ナビゲーションバー内の検索ボタン（虫眼鏡アイコンのみ） */
.global-search-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: #f3f4f6;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.global-search-button svg {
  width: 20px;
  height: 20px;
  color: #6b7280;
  transition: color 0.3s ease;
}

.global-search-button:hover {
  background: #eef2ff;
  border-color: #818cf8;
  transform: translateY(-2px);
}

.global-search-button:hover svg {
  color: #6366f1;
}

.global-search-button:active {
  transform: translateY(0);
}

/* ヘッダー直下の検索ボタン（index.html, roadmap.html用） */
header > .global-search-button {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 50;
}

/* ヘッダーをrelativeに */
header:has(> .global-search-button) {
  position: relative;
}

/* サジェストリスト */
.global-search-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 2px solid #e5e7eb;
  border-top: none;
  border-radius: 0 0 12px 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 10;
  max-height: 300px;
  overflow-y: auto;
}

.suggestion-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background 0.2s ease;
  border-bottom: 1px solid #f3f4f6;
}

.suggestion-item:last-child {
  border-bottom: none;
  border-radius: 0 0 12px 12px;
}

.suggestion-item:hover {
  background: #f9fafb;
}

.suggestion-icon {
  width: 18px;
  height: 18px;
  color: #9ca3af;
  flex-shrink: 0;
}

.suggestion-item span:nth-child(2) {
  flex: 1;
  font-size: 0.9375rem;
  color: #374151;
}

.suggestion-category {
  font-size: 0.8125rem !important;
  color: #9ca3af !important;
  padding: 0.25rem 0.5rem;
  background: #f3f4f6;
  border-radius: 4px;
}

/* モバイル対応 */
@media (max-width: 768px) {
  .global-search-button {
    width: 32px;
    height: 32px;
  }

  .global-search-button svg {
    width: 18px;
    height: 18px;
  }

  header > .global-search-button {
    top: 1rem;
    right: 1rem;
  }

  .global-search-suggestions {
    max-height: 200px;
  }

  .suggestion-item {
    padding: 0.625rem 0.875rem;
  }

  .suggestion-item span:nth-child(2) {
    font-size: 0.875rem;
  }

  .suggestion-category {
    font-size: 0.75rem !important;
  }
}

/* 検索モーダル */
.global-search-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 5vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.global-search-modal.active {
  opacity: 1;
  pointer-events: all;
}

/* モーダルコンテンツ */
.global-search-modal-content {
  background: white;
  width: 90%;
  max-width: 800px;
  max-height: 85vh;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  transform: translateY(-20px);
  transition: transform 0.3s ease;
}

.global-search-modal.active .global-search-modal-content {
  transform: translateY(0);
}

/* ヘッダー */
.global-search-header {
  padding: 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.global-search-input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.global-search-icon {
  position: absolute;
  left: 1rem;
  width: 20px;
  height: 20px;
  color: #9ca3af;
  pointer-events: none;
}

.global-search-input {
  width: 100%;
  padding: 0.75rem 3rem 0.75rem 3rem;
  font-size: 1.125rem;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  outline: none;
  transition: all 0.2s ease;
}

.global-search-input:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.global-search-clear {
  position: absolute;
  right: 0.5rem;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.global-search-clear svg {
  width: 16px;
  height: 16px;
  color: #6b7280;
}

.global-search-clear:hover {
  background: #f3f4f6;
}

.global-search-close-button {
  width: 40px;
  height: 40px;
  border: none;
  background: #f3f4f6;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.global-search-close-button svg {
  width: 20px;
  height: 20px;
  color: #6b7280;
}

.global-search-close-button:hover {
  background: #e5e7eb;
}

/* 検索結果エリア */
.global-search-results {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

/* 空の状態 */
.global-search-empty,
.global-search-no-results,
.global-search-loading,
.global-search-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  color: #6b7280;
}

.global-search-empty svg,
.global-search-no-results svg,
.global-search-loading svg,
.global-search-error svg {
  width: 64px;
  height: 64px;
  margin-bottom: 1rem;
  color: #d1d5db;
}

.global-search-empty p,
.global-search-no-results p,
.global-search-error p {
  font-size: 1rem;
  text-align: center;
}

/* ローディングスピナー */
.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e5e7eb;
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

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

/* 検索結果ヘッダー */
.global-search-results-header {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid #e5e7eb;
}

.global-search-results-header p {
  font-size: 1rem;
  color: #374151;
}

/* 検索結果リスト */
.global-search-results-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* 検索結果カード */
.global-search-result-card {
  background: white;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 1.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.global-search-result-card:hover {
  border-color: #667eea;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
  transform: translateY(-2px);
}

/* カテゴリカラー */
.global-search-result-card.color-indigo:hover {
  border-color: #667eea;
}

.global-search-result-card.color-blue:hover {
  border-color: #3b82f6;
}

.global-search-result-card.color-purple:hover {
  border-color: #8b5cf6;
}

.global-search-result-card.color-yellow:hover {
  border-color: #f59e0b;
}

.global-search-result-card.color-green:hover {
  border-color: #10b981;
}

/* 結果カードヘッダー */
.result-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.result-category {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #6b7280;
}

.category-icon {
  font-size: 1.125rem;
}

.result-match-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: #667eea;
  background: #eef2ff;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
}

/* ページタイトル */
.result-page-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 0.5rem;
}

/* セクションタイトル */
.result-section-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 0.5rem;
}

/* スニペット */
.result-snippet {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: #4b5563;
}

.result-snippet mark.highlight {
  background: #fef3c7;
  color: #92400e;
  padding: 0.125rem 0.25rem;
  border-radius: 3px;
  font-weight: 600;
}

/* ハイライト（ページ内） */
mark.search-highlight {
  background: #fef3c7;
  color: #92400e;
  padding: 0.125rem 0.25rem;
  border-radius: 3px;
  font-weight: 600;
  transition: all 0.2s ease;
}

mark.search-highlight.active {
  background: #fbbf24;
  color: #78350f;
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.3);
}

/* ハイライトナビゲーションバー */
.highlight-nav-bar {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 100;
  padding: 0.75rem 1.5rem;
  animation: slideDown 0.3s ease;
}

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

.highlight-nav-content {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.highlight-nav-info {
  font-size: 0.9375rem;
  color: #374151;
}

.highlight-nav-count {
  font-size: 0.875rem;
  font-weight: 600;
  color: #667eea;
  background: #eef2ff;
  padding: 0.375rem 0.75rem;
  border-radius: 9999px;
}

.highlight-nav-buttons {
  display: flex;
  gap: 0.5rem;
}

.highlight-nav-button {
  width: 36px;
  height: 36px;
  border: 2px solid #e5e7eb;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.highlight-nav-button svg {
  width: 18px;
  height: 18px;
  color: #6b7280;
}

.highlight-nav-button:hover {
  border-color: #667eea;
  background: #eef2ff;
}

.highlight-nav-button:hover svg {
  color: #667eea;
}

.highlight-nav-close {
  width: 36px;
  height: 36px;
  border: none;
  background: #f3f4f6;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.highlight-nav-close svg {
  width: 18px;
  height: 18px;
  color: #6b7280;
}

.highlight-nav-close:hover {
  background: #e5e7eb;
}

/* モバイル対応 */
@media (max-width: 768px) {
  .global-search-modal-content {
    width: 95%;
    max-height: 90vh;
    border-radius: 12px;
  }

  .global-search-header {
    padding: 1rem;
    flex-wrap: wrap;
  }

  .global-search-input-wrapper {
    order: 1;
    width: 100%;
    margin-bottom: 0.5rem;
  }

  .global-search-close-button {
    order: 2;
  }

  .global-search-input {
    font-size: 1rem;
    padding: 0.625rem 2.5rem 0.625rem 2.5rem;
  }

  .global-search-results {
    padding: 1rem;
  }

  .result-page-title {
    font-size: 1rem;
  }

  .result-snippet {
    font-size: 0.875rem;
  }

  .highlight-nav-bar {
    top: auto;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    transform: none;
    padding: 0.625rem 1rem;
  }

  .highlight-nav-content {
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: space-between;
  }

  .highlight-nav-info {
    font-size: 0.875rem;
    flex: 1 1 100%;
  }
}

/* スクロールバーのスタイル */
.global-search-results::-webkit-scrollbar {
  width: 8px;
}

.global-search-results::-webkit-scrollbar-track {
  background: #f3f4f6;
  border-radius: 10px;
}

.global-search-results::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 10px;
}

.global-search-results::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}
