* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f9f0;  /* 浅绿色背景，西域风格 */
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-container {
    width: 1200px;
    max-width: 90vw;
    height: 85vh;
    background: white;
    border-radius: 24px;
    box-shadow: 0 20px 40px rgba(0,40,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

header {
    background: #1a7a2e;  /* 西域绿色主色调 */
    color: white;
    padding: 20px 24px;
    text-align: center;
    border-bottom: 3px solid #ffcd3c;  /* 西域常用黄色点缀 */
}
header h1 { font-size: 1.8rem; margin-bottom: 4px; letter-spacing: 1px; }
header p { opacity: 0.9; font-size: 0.9rem; }

.chat-panel {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fefef7;
    overflow: hidden;
}

.clear-icon-btn {
    position: absolute;
    top: 10px;
    right: 16px;
    z-index: 5;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid #dce8dc;
    background: rgba(255,255,255,0.85);
    color: #4a6741;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: background 0.2s, color 0.2s;
}
.clear-icon-btn:hover {
    background: #fff4e5;
    color: #a16207;
}

.clear-confirm-popover {
    position: absolute;
    top: 46px;
    right: 16px;
    z-index: 6;
    background: white;
    border: 1px solid #dce8dc;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    padding: 12px 14px;
    width: 200px;
}
.clear-confirm-popover p {
    font-size: 0.85rem;
    color: #333;
    margin-bottom: 10px;
}
.clear-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.clear-confirm-cancel, .clear-confirm-ok {
    border: none;
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 0.8rem;
    cursor: pointer;
}
.clear-confirm-cancel {
    background: #eef3ea;
    color: #4a6741;
}
.clear-confirm-cancel:hover {
    background: #e2e8dc;
}
.clear-confirm-ok {
    background: #ef4444;
    color: white;
}
.clear-confirm-ok:hover {
    background: #dc2626;
}

.toast {
    position: absolute;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30,30,30,0.88);
    color: white;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 0.85rem;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}
.toast.show {
    opacity: 1;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    gap: 12px;
    animation: fadeIn 0.3s ease;
}
.message.user { flex-direction: row-reverse; }
.message .avatar {
    width: 36px;
    height: 36px;
    background: #e2f0e2;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}
.message.user .avatar { background: #2d9c3e; color: white; }  /* 用户头像绿色 */
.message .content {
    max-width: 70%;
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    word-break: break-word;
}
.message.user .content { background: #2d9c3e; color: white; }  /* 用户气泡绿色 */

/* ---------- 商品列表区域（滚动条） ---------- */
.product-list {
    margin-top: 12px;
    border-top: 1px solid #dce8dc;
    padding-top: 12px;
    max-height: 400px;
    overflow-y: auto;
    scrollbar-width: thin;
}
.product-list::-webkit-scrollbar {
    width: 6px;
}
.product-list::-webkit-scrollbar-track {
    background: #e2f0e2;
    border-radius: 3px;
}
.product-list::-webkit-scrollbar-thumb {
    background: #2d9c3e;
    border-radius: 3px;
}
.product-list::-webkit-scrollbar-thumb:hover {
    background: #1f6e2c;
}

.product-card {
    background: #f8faf5;
    margin: 8px 0;
    padding: 12px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    border-left: 3px solid #2d9c3e;
}
.product-info h4 { margin-bottom: 4px; color: #1a5c2a; }
.product-spec { font-size: 0.8rem; color: #4a6741; }
.product-spec a {
    color: #2d9c3e;
    text-decoration: none;
    font-weight: 500;
}
.product-spec a:hover {
    text-decoration: underline;
}

/* ---------- 选购建议样式 ---------- */
.buying-advice {
    background: #e8f5e8;
    padding: 12px;
    border-radius: 12px;
    margin: 12px 0;
    border-left: 4px solid #2d9c3e;
    font-size: 0.9rem;
    color: #1e4620;
}
.buying-advice p {
    margin: 4px 0;
}
.buying-advice strong {
    color: #1a7a2e;
}

/* ---------- 更多商品列表（折叠） ---------- */
.more-products {
    margin-top: 12px;
    background: #f4f8f2;
    border-radius: 12px;
    padding: 8px;
}
.more-products summary {
    cursor: pointer;
    font-weight: bold;
    color: #2d9c3e;
    padding: 8px;
    user-select: none;
}
.more-products summary:hover {
    background: #e2f0e2;
    border-radius: 8px;
}
.compact-product-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 8px;
    scrollbar-width: thin;
}
.compact-product-list::-webkit-scrollbar {
    width: 6px;
}
.compact-product-list::-webkit-scrollbar-track {
    background: #e2f0e2;
    border-radius: 3px;
}
.compact-product-list::-webkit-scrollbar-thumb {
    background: #2d9c3e;
    border-radius: 3px;
}
.compact-product-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 8px 12px;
    border-radius: 8px;
    margin: 4px 0;
    gap: 8px;
    flex-wrap: wrap;
}
.compact-info {
    font-size: 0.85rem;
    flex: 1;
}
.compact-name {
    font-weight: 500;
    margin-right: 12px;
    color: #1a5c2a;
}
.compact-spec {
    color: #5a7a50;
    font-size: 0.75rem;
}
.compact-spec a {
    color: #2d9c3e;
    text-decoration: none;
}
.compact-spec a:hover {
    text-decoration: underline;
}

/* ---------- 缺失提示 ---------- */
.missing-hint {
    background: #fff4e5;
    border-left: 4px solid #f5a623;
    padding: 8px 12px;
    margin: 8px 0;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #a16207;
}

/* ---------- 输入区域 ---------- */
.input-area {
    background: white;
    border-top: 1px solid #dce8dc;
    padding: 16px;
}
.image-preview {
    position: relative;
    display: inline-block;
    margin-bottom: 8px;
}
.image-preview img { height: 80px; border-radius: 8px; }
.image-preview button {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    cursor: pointer;
}
textarea {
    width: 100%;
    border: 1px solid #cbd5c1;
    border-radius: 12px;
    padding: 10px;
    font-size: 1rem;
    resize: vertical;
    transition: border 0.2s;
}
textarea:focus {
    outline: none;
    border-color: #2d9c3e;
    box-shadow: 0 0 0 2px rgba(45,156,62,0.2);
}
.action-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
}
.upload-btn, .send-btn {
    padding: 8px 20px;
    border-radius: 24px;
    border: none;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
}
.upload-btn {
    background: #eef3ea;
    color: #2d6a2f;
    border: 1px solid #cde0cd;
}
.upload-btn:hover {
    background: #e2f0e2;
}
.send-btn {
    background: #2d9c3e;
    color: white;
}
.send-btn:hover {
    background: #248c34;
}
.image-understanding {
    background: #eef2ff;
    padding: 8px 12px;
    border-radius: 8px;
    margin: 8px 0;
    font-size: 0.85rem;
    color: #1e40af;
    border-left: 4px solid #3b82f6;
}
/* 用户消息中的图片样式 */
.user-image-container {
    margin-top: 8px;
}
.user-image {
    max-width: 200px;
    max-height: 200px;
    border-radius: 12px;
    border: 1px solid #dce8dc;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}