/* 全域設定，包含所有元素 */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* 基本樣式 */
body {
    font-family: Arial, sans-serif;
    background-color: #fff;
    margin: 0;
    padding: 0;
}

/* 確保圖片響應式 */
img {
    max-width: 100%;
    height: auto;
}

.container {
    width: 90%;
    max-width: 1000px;
    margin: 20px auto;
    background-color: #fff;
    padding: 20px;
}

h1,
h2,
h3,
h5 {
    margin: 0 0 10px 0;
}

a {
    text-decoration: none;
}

.logo {
    /* max-height: 100%; */
    height: 100px;
    margin-top: 50px;
}

.alert {
    color: #721c24;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    padding: 10px;
    margin-bottom: 20px;
    border-radius: 4px;
}

.chip {
    display: inline-block;
    padding: 0 10px;
    margin: 4px;
    height: 30px;
    font-size: 16px;
    line-height: 30px;
    border-radius: 25px;
    background-color: #0a4f49;
    color: #FFF;
}

.pop-hint {
    color: #5D5D5D;
}

.pop-chip {
    display: inline-block;
    padding: 0 10px;
    margin: 4px;
    height: 30px;
    font-size: 14px;
    line-height: 30px;
    border-radius: 25px;
    border: 1px solid #E5E5E5;
    background-color: #FFF;
    color: #5D5D5D;
}

/* 產品列表區塊 */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    padding: 10px;
}

/* 產品卡片樣式 */
.product-card {
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #fff;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
}

.product-card img {
    height: 200px;
    width: 100%;
    object-fit: contain;
    display: block;
}

.card-content {
    padding: 10px;
    flex-grow: 1;
}

.card-title {
    font-size: 1.1em;
    font-weight: bold;
    margin-bottom: 8px;
    color: #2F2F2F;
}

.price-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-price {
    font-size: large;
    font-weight: 700;
    margin-top: auto;
    color: #2F2F2F;
    /* 將價格推到容器底部 */
}

del.card-price {
    margin-left: 10px;
    font-size: small;
    color: #888;
    text-decoration: line-through;
}

.card-footer {
    padding: 10px;
    text-align: center;
    margin-top: auto;
}

.card-button {
    width: 100%;
    display: inline-block;
    background-color: #0a4f49;
    color: #fff;
    padding: 10px 15px;
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.card-button:hover {
    background-color: #0d6a62;
}

/* 分頁相關樣式 */
.pagination {
    list-style: none;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.pagination li {
    margin: 0 5px;
}

.pagination li a,
.pagination li span {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: none;
    cursor: pointer;
    font-size: 1em;
    color: #000;
    text-decoration: none;
    display: block;
}

.pagination li a:hover {
    color: #000;
    background-color: #e9ecef;
}

.pagination li.active a {
    background-color: #0a4f49;
    color: #fff;
    border-color: #0d6a62;
}

.pagination li.disabled span {
    color: #ccc;
    cursor: default;
}

/* 利用包覆容器達成漸層邊框效果 */
.chat-wrapper {
    /* width: 100%; */
    margin: 20px auto;
    padding: 1px;
    border-radius: 25px;
    background: linear-gradient(90deg, rgba(120, 201, 203, 0.8) 0%, rgba(100, 45, 173, 0.8) 100%);
    box-shadow: 0px 1px 10px 0px #D9D9D94D;
}

.chat-box {
    background-color: #fff;
    height: 116px;
    border-radius: 25px;
    position: relative;
    overflow: hidden;
    padding: 10px 0px;
}

/* 上方輸入區 */
.input-section {
    height: calc(100% - 60px);
    padding: 10px;
}
.input-section input {
    width: 100%;
    resize: none;
    padding: 8px;
    font-size: 14px;
    border: none;
}

.input-section input:focus {
    outline: none;
    border: none;
}

/* 下方按鈕區，左右分布 */
.button-section {
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.button-section button {
    width: 37px;
    height: 37px;
    border: none;
    border-radius: 50%;
    /* 圓型 */
    cursor: pointer;
    background: transparent;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    outline: none;
    padding: 0;
}


.chatbot-title {
    color: #545454;
    font-weight: 500;
    font-size: 24px;
    line-height: 35.52px;
    letter-spacing: 0%;
}

/* 搜尋相關樣式 */
.search-container {
    display: flex;
    justify-content: center;
    margin: 20px 0;
    width: 100%;
}

.search-form {
    display: flex;
    width: 100%;
    max-width: 600px;
    overflow: hidden;
}

.search-input {
    flex-grow: 1;
    padding: 10px 15px;
    border: none;
    outline: none;
    font-size: 16px;
    background-color: #e7e7e7;
}

.search-hint {
    flex: 1;
    margin: 0 10px;
    display: flex;
    align-items: center;
    overflow: hidden;
    white-space: normal;
    word-break: break-word;
    color: #808080;
    font-size:12px;
}

.search-button {
    background-color: #e7e7e7;
    color: white;
    border: none;
    padding: 10px 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* Image Upload Modal */
.image-upload-modal {
    display: none;
    /* Initially hidden */
    position: fixed;
    /* Stay in place */
    z-index: 1;
    /* Sit on top */
    left: 0;
    top: 0;
    width: 100%;
    /* Full width */
    height: 100%;
    /* Full height */
    overflow: auto;
    /* Enable scroll if needed */
    background-color: rgba(0, 0, 0, 0.4);
    /* Black w/ opacity */
}

.image-upload-modal-content {
    background-color: #fefefe;
    margin: 15% auto;
    /* 15% from the top and centered */
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    /* Could be more or less, depending on screen size */
    border-radius: 8px;
    position: relative;
    /* For close button positioning */
}

.image-upload-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
    margin-bottom: 15px;
}

.image-upload-modal-title {
    font-size: 1.2em;
    font-weight: bold;
    margin: 0;
}

.image-upload-modal-close-button {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    top: 10px;
    right: 15px;
    cursor: pointer;
}

.image-upload-modal-close-button:hover,
.image-upload-modal-close-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.image-upload-area {
    border: 2px dashed #bbb;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    margin-bottom: 15px;
    position: relative;
    overflow: hidden;
    height: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.image-upload-area.dragover {
    background-color: #eee;
    border-color: #888;
}

.image-upload-area p {
    margin: 10px 0;
    color: #777;
}

.image-preview {
    display: none;
    max-width: 100%;
    max-height: 200px;
    margin-top: 10px;
    object-fit: contain;
    /* 或使用 contain 看你希望圖片完整呈現還是覆蓋 */
    z-index: 1;
}
.image-upload-buttons {
    text-align: center;
}

.image-upload-buttons button {
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    background-color: #007bff;
    color: white;
    cursor: pointer;
    margin: 5px;
}

.image-upload-buttons button:hover {
    background-color: #0056b3;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

#back-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background-color: transparent;
    border: none;
    cursor: pointer;
    z-index: 100;
}

#back-to-top img {
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s;
}

#back-to-top:hover img {
    transform: scale(1.1);
}

/* 手機版調整 */
@media (max-width: 768px) {
    .container {
        width: 100%;
        padding: 15px;
        margin: 10px auto;
    }

    .search-form {
        max-width: 95%;
    }

    .search-hint {
        font-size: 11px;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(100%, 1fr));
    }

    /* 分頁容器增加換行，避免超出畫面 */
    .pagination {
        flex-wrap: wrap;
    }
}

/* 平板版調整 */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        width: 95%;
        padding: 20px;
        margin: 20px auto;
    }

    .search-form {
        max-width: 80%;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }

    .product-card {
        height: auto;
    }

    .card img {
        height: 180px;
    }
}

/* 大型桌面版調整 */
@media (min-width: 1025px) {
    /* 可依需求做進一步調整 */
}

/* Skeleton UI */
@keyframes skeleton-pulse {
    0% {
        background-color: #eee;
    }

    50% {
        background-color: #ddd;
    }

    100% {
        background-color: #eee;
    }
}

.skeleton-card {
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background-color: #f5f5f5;
    animation: skeleton-pulse 1.5s infinite ease-in-out;
}

.skeleton-img {
    width: 100%;
    height: 200px;
    background-color: #e0e0e0;
}

.skeleton-content {
    padding: 10px;
    flex-grow: 1;
}

.skeleton-line {
    height: 16px;
    background-color: #e0e0e0;
    margin-bottom: 8px;
    border-radius: 4px;
}

.skeleton-line.short {
    width: 50%;
}

.skeleton-button {
    margin: 10px;
    height: 36px;
    background-color: #e0e0e0;
    border-radius: 4px;
}

/* 搜尋結果區 */
#overview-text {
    margin-bottom: 20px;
    color: #2F2F2F;
    white-space: pre-wrap;
}

#products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    padding: 10px 0;
}

/* Skeleton for suggestion chips */
.skeleton-chip {
    display: inline-block;
    width: 80px;
    /* 可調整 */
    height: 30px;
    margin: 4px;
    border-radius: 15px;
    background-color: #e0e0e0;
    animation: skeleton-pulse 1.5s infinite ease-in-out;
}