/* ══════════════════════════════════════════
   検索バー
   ══════════════════════════════════════════ */

/* バーコードスキャンアイコン + 入力欄 + 検索ボタンの1行レイアウト */
.search-bar {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

/* バーコードスキャンボタン（左端のアイコンボタン） */
.scan-btn {
  flex-shrink: 0;
  width: 50px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}

.scan-btn:active,
.scan-btn.active {
  /* アクティブ時（スキャン中）はオレンジに変化して状態を視覚化 */
  background: var(--accent);
}

/* JAN コード入力欄 */
.search-bar input {
  flex: 1;
  padding: 13px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  outline: none;
  min-width: 0; /* flex内でテキストが溢れないよう */
  transition: border-color .15s;
}

.search-bar input:focus {
  border-color: var(--primary);
}

/* 検索実行ボタン（右端） */
.search-submit-btn {
  flex-shrink: 0;
  padding: 13px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}

.search-submit-btn:active {
  background: var(--primary-dark);
}


/* ══════════════════════════════════════════
   検索結果カード
   ══════════════════════════════════════════ */

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .1);
}

/* 商品名と星ボタンを横並びにするヘッダー行 */
.card-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 4px;
}

.product-name {
  flex: 1;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.5;
}

.jan-label {
  font-size: .8rem;
  color: var(--text-sub);
  margin-bottom: 14px;
}

/* 星ボタン（お気に入り追加・削除） */
.star-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: #bdbdbd;     /* 未登録: グレー */
  padding: 2px;
  line-height: 0;
  transition: color .15s, transform .1s;
}

.star-btn.active {
  color: var(--star-color); /* 登録済み: 金色 */
}

.star-btn:active {
  transform: scale(1.3);
}


/* ══════════════════════════════════════════
   価格テーブル
   ══════════════════════════════════════════ */

.price-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .95rem;
}

.price-table thead th {
  text-align: left;
  padding: 8px 10px;
  background: #f5f5f5;
  color: var(--text-sub);
  font-size: .8rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.price-table tbody tr {
  border-bottom: 1px solid var(--border);
}

.price-table tbody tr:last-child {
  border-bottom: none;
}

.price-table td {
  padding: 11px 10px;
  vertical-align: middle;
}

/* 最高値行のハイライト */
.best-row {
  background: var(--best-bg);
}

.best-row .price-cell {
  color: var(--best-color);
  font-weight: 700;
}

/* 「最高値」バッジ */
.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
  background: var(--accent);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  border-radius: 20px;
  vertical-align: middle;
}

.price-cell {
  font-size: 1.05rem;
  font-weight: 600;
  white-space: nowrap;
}

.price-table a {
  color: var(--primary);
  text-decoration: none;
  font-size: .85rem;
}

.price-table a:hover {
  text-decoration: underline;
}

/* 条件ラベル（シュリンク有など） */
.cond-label {
  display: block;
  font-size: .75rem;
  color: var(--text-sub);
  font-weight: 400;
  margin-top: 2px;
}


/* ══════════════════════════════════════════
   メッセージ
   ══════════════════════════════════════════ */

.msg {
  padding: 16px;
  text-align: center;
  color: var(--text-sub);
  font-size: .95rem;
}

.not-found {
  color: #c62828;
}


/* ══════════════════════════════════════════
   空状態メッセージ（お気に入りが0件のとき等）
   ══════════════════════════════════════════ */

.empty-state {
  padding: 16px;
  text-align: center;
  color: var(--text-sub);
  font-size: .88rem;
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  border: 1.5px dashed var(--border);
}


/* ══════════════════════════════════════════
   お気に入りリスト
   ══════════════════════════════════════════ */

.fav-item {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
  cursor: pointer;
  transition: opacity .15s;
  /* 各アイテムの間隔は favorites-list の gap で管理 */
}

.fav-item:active {
  opacity: .7;
}

#favorites-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fav-item-info {
  flex: 1;
  min-width: 0; /* テキスト省略に必要 */
}

.fav-item-name {
  font-size: .9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fav-item-price {
  font-size: .78rem;
  color: var(--text-sub);
  margin-top: 3px;
}

/* お気に入り削除ボタン（★を星アイコンで表示） */
.fav-remove-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--star-color);
  cursor: pointer;
  padding: 4px;
  line-height: 0;
  transition: transform .1s;
}

.fav-remove-btn:active {
  transform: scale(1.3);
}


/* ══════════════════════════════════════════
   よく検索されている商品リスト
   ══════════════════════════════════════════ */

#popular-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.popular-item {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
  cursor: pointer;
  transition: opacity .15s;
}

.popular-item:active {
  opacity: .7;
}

/* 順位バッジ（丸いサークル） */
.popular-rank {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-size: .75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 1〜3位はメダルカラー */
.popular-rank.rank-1 { background: #f9a825; } /* 金 */
.popular-rank.rank-2 { background: #9e9e9e; } /* 銀 */
.popular-rank.rank-3 { background: #795548; } /* 銅 */

.popular-info {
  flex: 1;
  min-width: 0;
}

.popular-name {
  font-size: .9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.popular-price {
  font-size: .78rem;
  color: var(--text-sub);
  margin-top: 3px;
}

/* 検索回数テキスト（右端） */
.popular-count {
  flex-shrink: 0;
  font-size: .75rem;
  color: var(--text-sub);
  white-space: nowrap;
}


/* ══════════════════════════════════════════
   認証モーダル
   ══════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-box {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px 20px 20px;
  width: 100%;
  max-width: 380px;
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.1rem;
  color: var(--text-sub);
  cursor: pointer;
  line-height: 1;
}

/* タブ */
.auth-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.auth-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 10px 0;
  font-size: .95rem;
  color: var(--text-sub);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-weight: 600;
  transition: color .15s, border-color .15s;
}

.auth-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* フォーム */
.auth-desc {
  font-size: .85rem;
  color: var(--text-sub);
  margin-bottom: 14px;
  line-height: 1.5;
}

.auth-input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
  margin-bottom: 12px;
  outline: none;
  transition: border-color .15s;
}

.auth-input:focus { border-color: var(--primary); }

.auth-submit-btn {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s;
}

.auth-submit-btn:disabled { opacity: .5; cursor: not-allowed; }
.auth-submit-btn:not(:disabled):hover { opacity: .88; }

/* メッセージ */
.auth-msg {
  margin-top: 12px;
  font-size: .85rem;
  text-align: center;
  min-height: 1.2em;
  line-height: 1.5;
}

.auth-msg.success { color: #2e7d32; }
.auth-msg.error   { color: #c62828; }

/* ログイン誘導ボタン */
.auth-prompt-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 5px 14px;
  font-size: .85rem;
  cursor: pointer;
  font-weight: 600;
}

/* ══════════════════════════════════════════
   トースト通知
   ══════════════════════════════════════════ */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #323232;
  color: #fff;
  padding: 12px 20px;
  border-radius: 24px;
  font-size: .9rem;
  z-index: 200;
  opacity: 0;
  transition: transform .3s, opacity .3s;
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.toast-error { background: #c62828; }
