/* ai-chat.css —— 悬浮气泡 + 聊天窗（不依赖任何框架，前缀 aichat- 避免污染站点样式） */

.aichat-root {
    position: fixed;
    right: 20px;
    bottom: 20px;
    /* 抬到几乎最高，避免被浮动导航栏（常见 z-index: 999999）压住 */
    z-index: 2147483000;
    isolation: isolate;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

/* ---------- 气泡按钮 ---------- */
.aichat-bubble {
    position: relative;
    z-index: 2147483002;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, #2f7cf6, #1b5fd0);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(31, 106, 240, .38);
    transition: transform .18s ease, box-shadow .18s ease;
    padding: 0;
    line-height: 0;
}
.aichat-bubble:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(31, 106, 240, .45); }
.aichat-bubble:active { transform: scale(.96); }

/* 有未读提示时的小红点（预留） */
.aichat-root.has-news .aichat-bubble::after {
    content: '';
    position: absolute;
    right: 2px;
    top: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ff4d4f;
    border: 2px solid #fff;
}

/* ---------- 面板 ---------- */
.aichat-panel {
    position: absolute;
    right: 0;
    bottom: 72px;
    z-index: 2147483001;
    width: 372px;
    height: 540px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 18px 60px rgba(16, 36, 76, .22);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e8edf5;
}
.aichat-root.is-open .aichat-panel { display: flex; }

/* 头部 */
.aichat-head {
    height: 50px;
    flex: 0 0 50px;
    background: linear-gradient(135deg, #2f7cf6, #1b5fd0);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px 0 16px;
}
.aichat-title { font-size: 15px; font-weight: 600; letter-spacing: .3px; }
.aichat-close {
    width: 34px;
    height: 34px;
    border: none;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    border-radius: 8px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}
.aichat-close:hover { background: rgba(255, 255, 255, .26); }

/* 消息区 */
.aichat-list {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 14px 12px 6px;
    background: #f6f8fc;
    -webkit-overflow-scrolling: touch;
}
.aichat-row { display: flex; margin-bottom: 10px; }
.aichat-row.is-user { justify-content: flex-end; }
.aichat-bubble-msg {
    max-width: 82%;
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.55;
    color: #22303f;
    background: #fff;
    border: 1px solid #e6ebf3;
    word-break: break-word;
    white-space: pre-wrap;
}
.aichat-row.is-user .aichat-bubble-msg {
    background: #2f7cf6;
    border-color: #2f7cf6;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.aichat-row.is-bot .aichat-bubble-msg { border-bottom-left-radius: 4px; }

/* 加载点 */
.aichat-loading { display: flex; gap: 4px; align-items: center; }
.aichat-loading i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9fb4d4;
    display: block;
    animation: aichat-blink 1.2s infinite ease-in-out;
}
.aichat-loading i:nth-child(2) { animation-delay: .15s; }
.aichat-loading i:nth-child(3) { animation-delay: .3s; }
@keyframes aichat-blink {
    0%, 80%, 100% { opacity: .25; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-2px); }
}

/* 产品卡片 */
.aichat-cards { padding: 0 0 8px 2px; }
.aichat-card {
    display: block;
    background: #fff;
    border: 1px solid #e6ebf3;
    border-radius: 10px;
    padding: 10px 12px;
    margin: 0 0 8px;
    text-decoration: none;
    color: inherit;
    transition: border-color .15s, box-shadow .15s, transform .15s;
}
.aichat-card:hover {
    border-color: #b9d0f7;
    box-shadow: 0 4px 14px rgba(47, 124, 246, .12);
    transform: translateY(-1px);
}
.aichat-card-name {
    font-size: 13px;
    line-height: 1.45;
    color: #1b2a3a;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.aichat-card-meta { margin-top: 6px; font-size: 12px; color: #7b8aa0; }
.aichat-code {
    background: #eef4ff;
    color: #2f7cf6;
    border-radius: 4px;
    padding: 1px 6px;
    margin-right: 8px;
    font-family: Consolas, Menlo, monospace;
}
.aichat-price { color: #e4572e; font-weight: 600; }

/* 查看更多 */
.aichat-more {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 2px 0 10px 2px;
}
.aichat-more-btn {
    border: 1px solid #b9d0f7;
    background: #eef4ff;
    color: #2f7cf6;
    border-radius: 16px;
    padding: 6px 14px;
    font-size: 12.5px;
    cursor: pointer;
}
.aichat-more-btn:hover { background: #e2edff; }
.aichat-more-btn:disabled { opacity: .6; cursor: default; }
.aichat-more-link {
    font-size: 12.5px;
    color: #7b8aa0;
    text-decoration: underline;
}
.aichat-more-link:hover { color: #2f7cf6; }

/* 快捷问题 */
.aichat-chips {
    flex: 0 0 auto;
    padding: 6px 12px 0;
    background: #fff;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.aichat-chip {
    border: 1px solid #dbe6f7;
    background: #f7faff;
    color: #2f7cf6;
    border-radius: 14px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    line-height: 1.4;
}
.aichat-chip:hover { background: #eaf2ff; border-color: #b9d0f7; }

/* 输入区 */
.aichat-inputbar {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px 12px;
    background: #fff;
    border-top: 1px solid #eef1f7;
}
.aichat-input {
    flex: 1 1 auto;
    resize: none;
    border: 1px solid #dbe3ef;
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 13.5px;
    line-height: 1.45;
    max-height: 96px;
    outline: none;
    font-family: inherit;
    color: #22303f;
}
.aichat-input:focus { border-color: #9dc0f8; box-shadow: 0 0 0 3px rgba(47, 124, 246, .12); }
.aichat-send {
    flex: 0 0 auto;
    border: none;
    background: #2f7cf6;
    color: #fff;
    border-radius: 10px;
    padding: 9px 16px;
    font-size: 13.5px;
    cursor: pointer;
}
.aichat-send:hover { background: #1b5fd0; }
.aichat-send:disabled { background: #a9c4ee; cursor: default; }

/* ---------- 手机适配 ---------- */
@media (max-width: 640px) {
    .aichat-root { right: 12px; bottom: 12px; }
    .aichat-bubble { width: 50px; height: 50px; }
    .aichat-panel {
        position: fixed;
        right: 0;
        left: 0;
        bottom: 0;
        width: auto;
        height: 78vh;
        max-height: 78vh;
        border-radius: 14px 14px 0 0;
        border-left: none;
        border-right: none;
    }
}
