@charset "UTF-8";

/* =====================
*
検索コンテナ、検索モーダル
*
=====================*/

/* === 検索コンテナ === */
.search-container {
  text-align: left;
  position: absolute;
  top: 20px;
  left: 15px;
  right: auto;
  width: auto;
  /* 中身に合わせて縮む */
  display: inline-block;
  max-width: min(750px, calc(100vw - 15px - 60px));
  box-sizing: border-box;
  background: none;
  pointer-events: none;
}

.search-container .search-wrapper,
.search-container .search-wrapper * {
  pointer-events: auto;
}

.search-wrapper {
  width: 100%;
  max-width: 100%;
  background: var(--bg-glass);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border-radius: 28px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  padding: 12px;
  text-align: left;
  display: flex;
  flex-wrap: nowrap;
  flex-direction: row;
  gap: 16px;
  box-sizing: border-box;
  position: relative;
  overflow: visible;
  align-items: center;
}

.search-box-container {
  flex: 1;
  width: 100%;
  min-width: 280px;
  max-width: 480px;
}

.search-box {
  display: flex;
  position: relative;
  width: 100%;
  max-width: none;
  min-width: 280px;
  min-height: 34px;
  box-sizing: border-box;
  margin: 0;
  padding: 4px 6px 4px 10px;
  flex: 1 1 auto;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  background: var(--card-bg);
  border-radius: 18px;
}

.search-input {
  flex: 1 1 auto;
  min-width: 0;
  box-sizing: border-box;
  margin: 0;
  /* 右側のスペースはクリアボタン分を確保 */
  padding: 4px 34px 4px 0;
  border: none;
  background: none;
  outline: none;
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  /* Safari / iOS */
  -webkit-appearance: none;
  /* 古い Firefox（必要なら） */
  -moz-appearance: none;
  /* 標準プロパティ */
  appearance: none;
  color: var(--text-color);
}

.search-type-toggle {
  background: none;
  border: none;
  color: var(--primary-color);
  opacity: 1;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.search-type-toggle:hover {
  opacity: 0.8;
}

.menu-toggle,
.search-type-toggle {
  flex-shrink: 0;
  margin-left: 5px;
  /* 共通は0にして、個別で余白を作る */
  padding: 0;
  min-width: 24px;
  min-height: 24px;
}

/* 検索ボックス内のボタンアイコン */
.menu-toggle i,
.search-type-toggle i {
  width: 24px;
  height: 24px;
}

.menu-toggle i {
  color: var(--text-color);
  font-size: 16px;
}

.menu-toggle:hover {
  opacity: 1;
  color: var(--primary-color);
}

.back-btn {
  background: none;
  border: none;
  color: var(--text-color);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 4px;
  width: 24px;
  height: 24px;
}

.back-btn:hover {
  opacity: 0.7;
}

.back-btn i {
  width: 24px;
  height: 24px;
  background-size: contain;
  background-repeat: no-repeat;
  display: inline-block;
}

/* メニューボタン */
.menu-toggle {
  width: 30px;
  height: 30px;
  font-size: 14px;
  margin: 0 2px 0 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-color);
  opacity: 0.7;
  transition: opacity 0.3s ease, color 0.3s ease;
  position: relative;
}

/* === 検索モーダル === */
/* PCでは画面左に画面幅の1/4、最小320px、最大480px モバイルでは全画面（後に記述）*/
.search-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 25vw;
  min-width: 320px;
  max-width: 480px;
  height: 100%;
  background: var(--bg-color);
  opacity: 1;
  transition: opacity 0.3s ease;
}

.search-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.1);
}

.search-modal-content {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-color);
}

/* 検索ヘッダー */
.search-modal-header {
  display: flex;
  align-items: center;
  padding: 20px 16px;
  background: var(--bg-color);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
}

.search-back-btn {
  background: none;
  border: none;
  color: var(--text-color);
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  margin-right: 16px;
  border-radius: 50%;
  transition: background-color 0.3s ease;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-back-btn:hover {
  background: var(--hover-bg);
}

.search-modal-input {
  width: 100%;
  border: none;
  background: none;
  padding: 12px 40px 12px 0;
  font-size: 18px;
  outline: none;
  color: var(--text-color);
  font-family: inherit;
}

.search-modal-input::placeholder {
  color: var(--text-color);
  opacity: 0.6;
}

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

/* 検索フォーム内のクリアボタン */
.search-input-clear-btn,
.search-modal-input-clear-btn {
  position: absolute;
  right: 40px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.9);
  border: none;
  color: #666;
  font-size: 14px;
  cursor: pointer;
  padding: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  box-shadow: 0 1px 3px var(--shadow-color);
}
.search-input-clear-btn {
  /* ルート検索ボタンの分を確保 */
  right: 40px;
}

.search-modal-input-clear-btn {
  right: 8px;
}

.search-input-clear-btn:hover,
.search-modal-input-clear-btn:hover {
  background: rgba(255, 255, 255, 1);
  color: var(--text-color);
}

/* クリアボタンのアイコン */
.search-input-clear-btn i,
.search-modal-input-clear-btn i {
  width: 16px;
  height: 16px;
}

/* 検索履歴セクション */
.search-history-section {
  flex: 1;
  padding: 20px 16px;
  overflow-y: auto;
}

.search-history-section h3 {
  font-size: 16px;
  color: var(--text-color);
  margin: 0 0 16px 0;
  font-weight: 500;
}

.search-history-list {
  margin-bottom: 32px;
}

.search-history-item {
  display: flex;
  align-items: center;
  padding: 12px 0;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.3s ease;
}

.search-history-item:hover {
  background: var(--hover-bg);
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
}

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

.search-history-icon {
  width: 24px;
  height: 24px;
  margin-right: 16px;
  color: var(--text-color);
  opacity: 0.6;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 検索履歴アイコン */
.search-history-icon i {
  width: 16px;
  height: 16px;
}

.search-history-text {
  flex: 1;
  font-size: 16px;
  color: var(--text-color);
}

.search-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.clear-all-history-btn {
  background: none;
  border: none;
  color: var(--primary-color);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background-color 0.3s ease;
}

.clear-all-history-btn:hover {
  background: var(--hover-bg);
}

/* 個別削除ボタン */
.history-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  opacity: 0.6;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-left: 8px;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

/* 削除ボタンのアイコンサイズ */
.history-delete-btn i {
  width: 14px;
  height: 14px;
}

/* 検索戻るボタンのアイコン */
.search-back-btn i {
  width: 20px;
  height: 20px;
}

.search-input::placeholder {
  text-align: left;
  color: var(--text-color);
  opacity: 0.5;
}

/* 通知（検索結果0件メッセージ） */
.notification {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.95);
  color: #333;
  padding: 12px 20px;
  border-radius: 25px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 0, 0, 0.1);
  transition: all 0.3s;
  pointer-events: none;
}

/* 「この辺で検索」ボタンのスタイル */
.research-here-container {
  position: fixed;
  top: 150px;
  left: 50%;
  transform: translateX(-50%);
}

.search-here-btn {
  background: white;
  color: #007AFF;
  padding: 10px;
  border-radius: 25px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.search-here-icon,
.search-here-close-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  background-size: contain;
  background-repeat: no-repeat;
  display: inline-block;
  vertical-align: middle;
}


/* === サイズ別の指定 === */

/* 768px以下のモバイル、タブレット用 */
@media (max-width: 768px),
(hover: none) and (pointer: coarse) {

  .search-container {
    top: 10px;
    /* 伸びる原因を避ける */
    right: auto;
    left: 10px;
    width: auto;
    /* 右に60px残す */
    max-width: calc(100vw - 10px - 60px);
    box-sizing: border-box;
  }

  .search-wrapper {
    width: 100%;
    max-width: 400px;
    /* min-width: 300px; */
    /* 端末幅が小さい/横向きで膨らむ要因を減らす */
    min-width: 0;
    /* 左寄せにしたいので margin-left 0、右側も詰める */
    margin: 0;
    box-sizing: border-box;
    gap: 6px;
    /* PCでは横並び、モバイルタブレットでは縦積みにする */
    flex-direction: column;
    /* 内側余白も少し抑えめに */
    padding: 6px 10px;
  }

  .search-box-container {
    flex: none;
    width: 100%;
    max-width: 400px;
    min-width: 0;
  }

  .search-box {
    /* ラッパーの中で横幅を親に合わせる */
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 4px 4px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 32px;
    border-radius: 18px;
  }

  .search-input {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    padding: 6px 90px 6px 4px;
  }

  .menu-toggle,
  .search-type-toggle {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .menu-toggle i,
  .search-type-toggle i {
    font-size: 18px;
    width: 24px;
    height: 24px;
  }

  /* 検索フォーム内のクリアボタン */
  .search-input-clear-btn {
    width: 24px;
    height: 24px;
    padding: 4px;
  }

  .search-input-clear-btn i {
    width: 18px;
    height: 18px;
  }

  .search-modal {
    width: 100%;
    height: 100%;
    /* ベースの最小値を無効化 */
    min-width: 0;
    /* ベースの最大値を無効化 */
    max-width: none;
  }

  .search-modal-header {
    padding: 16px;
  }

  .search-modal-input {
    font-size: 14px;
    padding: 12px 44px 12px 0;
  }

  .search-back-btn i {
    width: 24px;
    height: 24px;
  }

  .search-history-section {
    padding: 16px;
  }
}

/* モバイル・タブレット横向き対応 */
/* 高さ500pxまでに対して、ボタン干渉を避けるため設定 */
@media (max-height: 500px) {

  /* 検索コンテナ */
  .search-container {
    /* FIXME: navi以下で同クラスへの設定があるので暫定important 後でマージ */
    right: 60px !important;
  }
}