/* ========== 基礎 ========== */
body {
    font-family: "Noto Sans TC", sans-serif;
    background: #f9fcff;
    margin: 0;
    padding: 0;
    color: #222;
}

/* ========== Header ========== */
header {
    background-color: #1398b4;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 40px;
    color: white;
}
header .logo span { font-size: 28px; font-weight: bold; }
nav a {
    color: white;
    text-decoration: none;
    margin-left: 25px;
    font-size: 18px;
}
nav a:hover { text-decoration: underline; }

/* ========== Main Layout ========== */
.main-container {
    max-width: 1110px;
    margin: 40px auto;
    padding: 0 20px;
}
h1 {
    font-size: 28px;
    text-align: center;
    font-weight: 800;
    line-height: 1.5;
}
.subtitle {
    text-align: center;
    color: #666;
    margin-top: 8px;
}

/* ========== 輸入區 ========== */
.input-box {
    background: #fff;
    border-radius: 16px;
    padding: 5px;
    /* margin-top: 20px; */
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}
.input-field {
    display: flex;
    margin-top: 10px;
    border: 1px solid #d0d8e0;
    border-radius: 12px;
    overflow: hidden;
}
.input-field input {
    flex: 1;
    padding: 12px;
    border: none;
    outline: none;
}
.input-field button {
    background: #1398b4;
    color: white;
    border: none;
    padding: 0 22px;
    cursor: pointer;
}
.input-field button:hover { background:#0f7e96; }

/* ========== 標籤區 ========== */
.tags {
    margin-top: 25px;
    display: flex;
    justify-content: center;
    flex-wrap: nowrap;
    overflow: auto;
    gap: 12px;
}
.tag {
    background: #f3f4f6;
    border: 1px solid #ddd;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    white-space: nowrap;
}
.tag:hover {
    background: #eaf5ff;
    border-color: #1398b4;
}

/* ========== 商品區（通用） ========== */
.products-wrapper {
    position: relative;
    margin-top: 35px;
}
.products {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding: 10px 10px 20px;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
}
.products::-webkit-scrollbar { display:none; }

.product {
    flex: 0 0 250px;
    background: white;
    border-radius: 14px;
    padding: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    text-align: center;
}
.product img {
    width: 100%;
    border-radius: 10px;
}
.product h3 {
    font-size: 17px;
    margin: 10px 0 6px;
}
.product p { font-size: 14px; color:#666; }
.price {
    font-size: 20px;
    font-weight: bold;
    margin: 10px 0;
}

/* ========== 商品左右箭頭 ========== */
.arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
    color: #333;
}
.arrow.left { left: -22px; }
.arrow.right { right: -22px; }
.arrow:hover { background: #1398b4; color: #fff; }
.arrow.disabled { opacity: 0; pointer-events: none; }

/* ========== AI 推薦區（多組） ========== */
.recommend-group {
    padding: 15px 5px;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ========== Chat 訊息區 ========== */
.chat-history {
    margin-top: 30px;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 10px 5px;
}
.message {
    max-width: 75%;
    padding: 12px 18px;
    border-radius: 14px;
    line-height: 1.6;
    font-size: 16px;
    animation: fadeIn 0.25s ease-out;
    white-space: pre-wrap;
    word-break: break-word;
}
/* user 右側 */
.message.user {
    align-self: flex-end;
    background: #d7f5ff;
    color: #003d4d;
    border: 1px solid #b8eaff;
}
/* AI 左側 */
.message.ai {
    align-self: flex-start;
    background: #f5f5f5;
    border: 1px solid #e1e1e1;
    color: #333;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0);  }
}

/* ========== 商品置中（只有 1–2 個時） ========== */
.products.no-scroll {
    justify-content: center !important;
}

/* ========== 按鈕（查看更多） ========== */
.more {
    display: inline-block;
    background: #ffffff;
    color: #111;
    border: 1px solid #dcdcdc;
    padding: 8px 0;
    width: 100%;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease-in-out;
}
.more:hover {
    background: #f2f2f2;
    border-color: #bfbfbf;
}

/* ========== hidden 狀態（AI 商品淡出） ========== */
.hidden {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    height: auto;
    transition: opacity 0.25s ease;
}

/* ========== 聊天氣泡滑入動畫 ========== */

/* 使用者訊息：右側滑入 */
.message.user {
    animation: slideInRight 0.35s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(40px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* AI 訊息：左側滑入 */
.message.ai {
    animation: slideInLeft 0.35s ease-out;
}

@keyframes slideInLeft {
    from {
        transform: translateX(-40px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ========== 商品卡片淡入 + 輕微浮動 ========== */

.product {
    opacity: 0;
    animation: productFadeIn 0.5s ease-out forwards;
}

@keyframes productFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* 讓每張商品卡片有不同時間差（像 Google Material UI） */
.product:nth-child(1) { animation-delay: 0.05s; }
.product:nth-child(2) { animation-delay: 0.10s; }
.product:nth-child(3) { animation-delay: 0.15s; }
.product:nth-child(4) { animation-delay: 0.20s; }
.product:nth-child(5) { animation-delay: 0.25s; }

/* ==========================================================
   Loading (在聊天內)
========================================================== */
.loading-inline {
    display: flex;
    align-self: flex-start;
    align-items: center;
    gap: 8px;
    margin-left: 10px;
}

.loading-inline .dot {
    width: 10px;
    height: 10px;
    background: #1398b4;
    border-radius: 50%;
    animation: blink 1.4s infinite both;
}

.loading-inline .dot:nth-child(2) { animation-delay: -0.2s; }
.loading-inline .dot:nth-child(3) { animation-delay: -0.4s; }

@keyframes blink {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.6); }
    40% { opacity: 1; transform: scale(1); }
}

/* ================================
   改良版 LINE Loading：內距 = AI 氣泡
================================ */
.message.ai.typing {
    display: inline-flex;
    align-items: center;
    gap: 6px;

    /* 讓 loading 與 AI bubble 完全一致 */
    padding: 12px 18px;    /* ← 跟 .message.ai 完全相同 */
    background: #f5f5f5;
    border: 1px solid #e1e1e1;
    border-radius: 14px;

    width: fit-content;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #666;
    border-radius: 50%;
    opacity: 0.4;
    animation: typingBlink 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBlink {
    0% { opacity: 0.2; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-2px); }
    80% { opacity: 0.2; transform: translateY(0); }
    100% { opacity: 0.2; }
}

/* ========== RWD ========== */
@media (max-width: 768px) {
    .arrow { display: none !important; }
    .products { justify-content: flex-start !important; }
    .tags {
        justify-content: flex-start;
    }
}


/* ================================
   固定底部輸入區
================================ */
/* 外層（固定底部） */
.input-area {
    position: fixed;
    bottom: 20px;   
    
    left: 50%;
    transform: translateX(-50%);  

    width: 900px;   
    max-width: 90%; 

    background: #fff;
    padding: 12px;
    border-radius: 16px;

    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    z-index: 1000;
}

/* tags 在 input 上面 */
.input-area .tags {
    margin-bottom: 8px;
    justify-content: center;
}

.chat-history {
    padding-bottom: 180px;  /* ⭐ 關鍵 */
}

