/* 共通の基本スタイル */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f7f6;
    color: #333;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ヘッダーのスタイル */
header {
    background-color: #fff;
    border-bottom: 1px solid #ddd;
    padding: 5px;
    text-align: center;
}
header h1, header p {
    margin: 0;
}
header h1 {
    color: #007bff;
}
header h1 a {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

/* 検索バーのスタイル */
.search-bar {
    padding: 20px;
    background-color: #e9ecef;
    display: flex;
    justify-content: center;
}
.search-container {
    position: relative;
    width: 80%;
    max-width: 500px;
    display: flex;
    border: 1px solid #ccc;
    border-radius: 5px;
    overflow: hidden;
}
.search-bar input {
    flex-grow: 1;
    padding: 10px 15px;
    border: none;
    outline: none;
}
.search-button {
    background-color: #007bff;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 18px;
    padding: 10px 15px;
    display: flex;
    align-items: center;
}
.search-button:hover {
    background-color: #0056b3;
}

/* ジャンルリンクのコンテナスタイル */
.genre-links-container {
    margin: 0; /* ← 上下左右のマージンをゼロに設定（ここが縦の余白の原因でした） */
    padding: 10px 0; /* 元に戻します */
    background-color: #fff;
    border: 1px solid #ddd;
    border-left: none;
    border-right: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); /* 元に戻します */
}
.genre-links {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px; /* ← 「|」の横幅（水平余白）を元に戻します */
}
.genre-links a {
    color: #007bff;
    text-decoration: none;
    font-weight: bold;
    font-size: 16px;
}
.genre-links .separator {
    color: #000;
}
/* フッターのスタイル */
footer {
    text-align: center;
    padding: 20px;
    border-top: 1px solid #ddd;
    background-color: #fff;
    margin-top: 10px;
}
.footer-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
}
.footer-links a {
    color: #007bff;
    text-decoration: none;
}

/* トップページ用のスタイル */
.content { padding: 0; }
.section-title { font-size: 24px; font-weight: bold; margin-bottom: 20px; text-align: center; }
.product-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: stretch;
    gap: 20px;
}
.product-card {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
    flex: 1 1 calc(33.333% - 20px);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    text-decoration: none;
    color: inherit;
}
.product-card:hover { transform: translateY(-5px); }
.product-card img {
    width: 100%;
    height: 180px;
    object-fit: contain;
    display: block;
}
.product-info {
    padding: 15px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 120px;
}
.product-name {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.product-price { color: #dc3545; font-size: 20px; font-weight: bold; margin-bottom: 5px; }
.product-status { font-size: 14px; color: #28a745; font-weight: bold; }
.product-card-buttons-full {
    display: flex;
    justify-content: center;
    width: 100%;
}

.product-card-buttons-full .btn {
    flex-grow: 1;
    font-size: 1.1em;
    padding: 12px 20px;
}
.ai-recommendation-section {
    background-color: #e9f0f1;
    padding: 30px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    margin: 10px 0;
    text-align: center;
}
.ai-section-title {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 20px;
    color: #007bff;
    display: inline-block;
    padding-bottom: 5px;
    border-bottom: 4px solid #007bff;
}

/* 個別ページ用のスタイル */
.item-detail {
    display: flex;
    gap: 40px;
    flex-wrap: wrap;
    margin-top: 40px;
}
.item-image {
    flex: 1;
    min-width: 300px;
    text-align: center;
}
.item-image img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.item-info {
    flex: 2;
}
.item-name {
    font-size: 28px;
    font-weight: bold;
    margin-bottom: 10px;
}
.item-category {
    font-size: 16px;
    color: #555;
    margin-bottom: 20px;
}
.price-section {
    background-color: #e9f0f1;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}
.current-price {
    font-size: 24px;
    color: #dc3545;
    font-weight: bold;
    margin: 0;
}
.current-price span {
    font-size: 32px;
}
.price-status {
    font-size: 18px;
    color: #007bff;
    font-weight: bold;
    margin-top: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.affiliate-links {
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}
.links-title {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 10px;
}
.shop-link {
    display: inline-block;
    padding: 12px 20px;
    margin-right: 10px;
    background-color: #007bff;
    color: #fff;
    text-decoration: none;
    border-radius: 5px;
    transition: background-color 0.3s;
}
.shop-link:hover {
    background-color: #0056b3;
}
.item-description {
    line-height: 1.6;
}

/* AI分析の枠のスタイル */
.ai-recommendation-section {
    padding: 20px;
    background-color: #f0f8ff;
    border-radius: 8px;
    text-align: center;
    margin-top: 20px;
}

/* 購入ボタンのスタイル */
.purchase-button {
    display: block;
    width: auto;
    max-width: 100%;
    text-align: center;
    padding: 15px 20px;
    margin-top: 15px;
    font-size: 1.2rem;
    font-weight: bold;
    color: #fff;
    background-color: #007bff;
    border-radius: 8px;
    text-decoration: none;
    transition: background-color 0.3s ease;
}

.purchase-button:hover {
    background-color: #0056b3;
}

/* 最安値ショップのボタンを整えるスタイル */
.affiliate-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

.affiliate-links .shop-link {
    flex-grow: 1;
    min-width: 120px;
    padding: 10px;
    text-align: center;
    font-weight: bold;
    color: #fff;
    background-color: #007bff;
    border-radius: 5px;
    text-decoration: none;
    transition: background-color 0.3s ease;
}

.affiliate-links .shop-link:hover {
    background-color: #0056b3;
}
.lowest-price-section {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
}

.lowest-price-label {
    font-weight: bold;
    white-space: nowrap;
}

.lowest-price-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .container {
        padding: 0 10px; /* ここを修正しました */
    }
    .ai-recommendation-section {
        padding: 20px 10px; /* ここも修正しました */
    }
    .product-card {
        flex: 1 1 calc(50% - 10px);
    }
    .product-grid {
        gap: 20px;
    }
    .product-name {
        font-size: 16px;
    }
    .product-price {
        font-size: 18px;
    }
    .product-status {
        font-size: 12px;
    }
    .item-detail {
        flex-direction: column;
        gap: 20px;
    }
    .item-image, .item-info {
        min-width: auto;
    }
    .lowest-price-section {
        flex-direction: column;
        align-items: flex-start;
    }
    .lowest-price-buttons {
        flex-direction: column;
        width: 100%;
    }
    .lowest-price-buttons .btn {
        width: 90%;
        margin: 0 auto;
        text-align: center;
        border-radius: 8px;
    }
    /* すべてのタグを見るボタンのスタイル */
    .tag-button-container {
        margin: 10px auto;
    }
}
/* トップページと個別ページ共通の「買い時」テキストのスタイル */
.product-card .price-status-title,
.product-detail .price-status-title {
    font-size: 14px;
    color: #28a745;
    font-weight: bold;
    text-align: center;
    margin-top: 5px;
    margin-bottom: 0;
}
.product-card .price-status-content,
.product-detail .price-status-content {
    font-size: 14px;
    color: #333;
    text-align: center;
    margin-top: 0;
    margin-bottom: 5px;
}
/* 個別ページの文字サイズを大きくするスタイル（優先度を上げるため、別途定義） */
.product-detail .price-status-title {
    font-size: 20px;
}
.product-detail .price-status-content {
    font-size: 20px;
}
/* 個別ページの商品タイトル */
.product-detail h1.item-name {
    font-size: 20px; /* ここでフォントサイズを調整してください */
    line-height: 1.4;
    font-weight: bold;
    margin-bottom: 10px;
}
/* ページネーションのスタイル */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin: 20px 0;
    gap: 4px;
    font-family: Arial, sans-serif;
}

/* 基本リンクデザイン */
.pagination a {
    display: block;
    padding: 8px 16px;
    margin: 0 2px;
    background-color: #f4f4f4;
    color: #333;
    text-decoration: none;
    border-radius: 4px;
    border: 1px solid #ddd;
    font-size: 14px;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

/* ホバー時 */
.pagination a:hover:not(.active) {
    background-color: #007bff;
    color: #fff;
    border-color: #007bff;
}

/* アクティブページ */
.pagination a.active {
    background-color: #007bff;
    color: #fff;
    border-color: #007bff;
}

/* 前へ・次へボタン */
.pagination a.prev,
.pagination a.next {
    font-weight: bold;
    color: #007bff;
    background-color: #f9f9f9;
}

.pagination a.prev:hover,
.pagination a.next:hover {
    background-color: #007bff;
    color: #fff;
}

/* ドット（省略記号） */
.pagination .dots {
    padding: 8px 10px;
    color: #777;
    font-size: 14px;
    border: none;
    background: transparent;
}
/* AI分析ブロック */
.ai-analysis-block {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    background-color: #f9f9f9;
}
.ai-analysis-block h2 {
    font-size: 1.2rem;
    color: #333;
    border-bottom: 2px solid #5a8;
    padding-bottom: 5px;
    margin-bottom: 15px;
}
.ai-analysis-block p {
    font-size: 1rem;
    color: #666;
    line-height: 1.6;
}
.ai-analysis {
  font-weight: bold;
  color: #dc3545; /* 赤色 */
  background-color: #f8f9fa; /* 薄いグレー */
  padding: 5px;
  border-radius: 5px;
  display: inline-block;
}
/* --- タグボタンのスタイル --- */
.product-tags {
    margin-top: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.product-tags .tag-button {
    display: inline-block;
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    background-color: #f0f0f0;
    font-size: 14px;
    color: #555;
    text-decoration: none;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}
.product-tags .tag-button:hover {
    background-color: #e0e0e0;
    border-color: #ccc;
    color: #333;
}
/* --- すべてのタグを見るボタンのスタイル --- */
.tag-button-container {
    text-align: center;
    margin: 10px auto;
    width: 90%;
    max-width: 1200px;
}
.all-tags-button {
    display: inline-block;
    padding: 10px 20px;
    background-color: #fff;
    color: #007bff;
    border: none;
    font-size: 16px;
    font-weight: bold;
    text-decoration: underline;
    border-radius: 5px;
    transition: background-color 0.3s, color 0.3s;
}
.all-tags-button:hover {
    background-color: #fff;
    color: #0056b3;
    text-decoration: none;
}
/* 画面幅が768px以下のデバイス（スマートフォンなど）に適用するスタイル */
@media (max-width: 768px) {
    .tag-button-container {
        margin: 10px auto;
    }
}
/* サブカテゴリーのタイトル */
.product-list-title {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 20px;
    text-align: center;
    margin-top: 30px;
}
/* AIコンシェルジュ用デザイン */
.ai-concierge-section {
    padding: 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    max-height: 800px;
}

.ai-section-title {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.8em;
    color: #333;
}

.chat-container {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    background-color: #fafafa;
}

.chat-messages {
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 14px;
    background-color: #fcfcfc;
}

/* 吹き出しの基本スタイル */
.chat-messages .message {
    padding: 10px 15px;
    border-radius: 18px;
    max-width: 80%;
    word-wrap: break-word;
    line-height: 1.6;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

/* ユーザーメッセージのスタイル */
.chat-messages .user-message {
    background-color: #007bff;
    color: white;
    align-self: flex-end;
}

/* AIメッセージのスタイル */
.chat-messages .ai-message {
    background-color: #e9ecef;
    color: #333;
    align-self: flex-start;
    position: relative;
    padding-top: 25px;
}

/* AIのラベル */
.ai-message::before {
    content: "ナビ";
    font-size: 10px;
    font-weight: bold;
    color: #666;
    position: absolute;
    top: 5px;
    left: 15px;
}

/* AIメッセージのローディングアニメーション */
.ai-message-loading {
    display: flex;
    align-items: center;
    padding: 10px 15px;
}

.ai-message-loading .dot {
    width: 8px;
    height: 8px;
    background-color: #999;
    border-radius: 50%;
    margin-right: 6px;
    animation: bounce 1.4s infinite ease-in-out both;
}

.ai-message-loading .dot:nth-child(1) { animation-delay: -0.32s; }
.ai-message-loading .dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

/* --- 新しい入力エリアのスタイル --- */
.chat-input-area {
    display: flex;
    flex-direction: column; /* 子要素を縦に並べる */
    padding: 10px;
    background-color: #f1f1f1;
    border-top: 1px solid #ddd;
    gap: 5px; /* 入力欄とカウンターの間の隙間 */
}

.input-container {
    display: flex;
    width: 100%;
}

#aiUserInput {
    flex-grow: 1;
    padding: 10px 15px; /* 適切なパディングに戻す */
    border: 1px solid #ccc;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
    resize: none;
}

#aiSendButton {
    padding: 10px 20px;
    margin-left: 10px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.3s;
    flex-shrink: 0;
}

#aiSendButton:hover {
    background-color: #0056b3;
}

.limit-and-counter {
    /* 他のプロパティはそのまま */
    display: flex;
    justify-content: flex-end;
    align-items: center; /* これを追加 */
    gap: 8px;
    font-size: 11px;
    color: #888;
    padding-right: 65px;
    white-space: nowrap;
}
/* 文字数が上限を超えた場合の入力欄のスタイル */
.ai-input-over-limit {
    background-color: #ffebeb; /* 薄い赤色の背景 */
    border-color: #ff0000; /* 赤色の枠線 */
}
