/* ===== 浮动按钮 ===== */
#chatFloatingBtn {
    position: fixed; bottom: 30px; right: 24px; z-index: 9998;
    width: 56px; height: 56px; border-radius: 50%;
    background: #e5e7eb;   /* 默认灰色；仅 .chat-btn-active 时显示蓝紫渐变（按原频率闪烁） */
    color: #374151; border: none; cursor: pointer;
    box-shadow: 0 4px 20px rgba(55,65,81,0.4);
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), box-shadow 0.25s;
    -webkit-tap-highlight-color: transparent;
}
#chatFloatingBtn:hover { transform: scale(1.12); box-shadow: 0 6px 28px rgba(55,65,81,0.45); }
#chatFloatingBtn:active { transform: scale(0.95); }
#chatFloatingBtn svg { width: 26px; height: 26px; }
/* 脉冲动画 */
#chatFloatingBtn::after {
    content: ''; position: absolute; inset: -4px; border-radius: 50%;
    border: 2px solid rgba(37,99,235,0.35);
    animation: chatPulse 2s ease-in-out infinite;
}
@keyframes chatPulse {
    0%, 100% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(1.18); opacity: 0; }
}
/* 未读红点 */
#chatFloatingBtn .chat-badge {
    position: absolute; top: 1px; right: 1px;
    width: 18px; height: 18px; border-radius: 50%;
    background: #ef4444; color: #fff; font-size: 10px; font-weight: 700;
    display: none; align-items: center; justify-content: center;
    line-height: 1; border: 2px solid #fff;
}

/* ===== 面板容器 ===== */
#chatPanel {
    position: fixed; bottom: 96px; right: 24px; z-index: 9999;
    width: 380px; max-width: calc(100vw - 32px); height: min(600px, calc(100vh - 120px));
    background: #fff; border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2), 0 0 0 1px rgba(0,0,0,0.05);
    display: none; flex-direction: column; overflow: hidden;
    transition: opacity 0.3s, transform 0.3s;
    opacity: 0; transform: translateY(16px) scale(0.96);
}
#chatPanel.open { opacity: 1; transform: translateY(0) scale(1); }
@media (max-width: 480px) {
    #chatPanel {
        bottom: 0; right: 0; width: 100%; max-width: 100%;
        border-radius: 20px 20px 0 0; height: 85vh; max-height: 85vh;
    }
    #chatFloatingBtn {
        width: 40px; height: 40px;
        bottom: 76px; right: 16px;
        background: #e5e7eb;   /* 移动端同样默认灰色 */
        color: #374151;
        box-shadow: 0 2px 12px rgba(0,0,0,0.12);
    }
    #chatFloatingBtn:hover { background: #f3f4f6; box-shadow: 0 4px 16px rgba(0,0,0,0.15); }
    #chatFloatingBtn::after {
        border-color: rgba(37,99,235,0.3);
    }
    #chatFloatingBtn svg { width: 20px; height: 20px; }
    #chatFloatingBtn .chat-badge {
        width: 16px; height: 16px; font-size: 9px;
        top: 0; right: 0;
    }
    #chatPanel.open + #chatFloatingBtn { display: none; }
    #chatAutoPrompt { display: none !important; }
}

/* ===== 面板头部 ===== */
.chat-panel-header {
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #fff; padding: 16px 18px;
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
}
.chat-panel-header .title { font-size: 15px; font-weight: 700; }
.chat-panel-header .subtitle { font-size: 11px; opacity: 0.8; margin-top: 2px; }
.chat-panel-header .close-btn {
    width: 32px; height: 32px; border-radius: 50%; border: none;
    background: rgba(255,255,255,0.18); color: #fff;
    font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background 0.2s;
}
.chat-panel-header .close-btn:hover { background: rgba(255,255,255,0.3); }

/* ===== 表单区 ===== */
.chat-form-body {
    padding: 24px 20px; flex: 1; overflow-y: auto;
}
.chat-form-body .form-intro {
    font-size: 13px; color: #6b7280; margin-bottom: 20px; line-height: 1.7;
}
.chat-form-body .form-intro strong { color: #1f2937; }
.chat-form-body .form-group { margin-bottom: 16px; }
.chat-form-body .form-group label {
    display: block; font-size: 12px; font-weight: 600;
    color: #374151; margin-bottom: 6px;
}
.chat-form-body .form-group input {
    width: 100%; padding: 10px 14px; border: 1.5px solid #e5e7eb;
    border-radius: 10px; font-size: 14px; color: #1f2937;
    outline: none; transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}
.chat-form-body .form-group input:focus {
    border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.chat-form-body .form-group input.error { border-color: #ef4444; }
.chat-form-body .form-group .error-msg {
    font-size: 11px; color: #ef4444; margin-top: 4px; display: none;
}
.chat-form-body .submit-btn {
    width: 100%; padding: 12px; border: none; border-radius: 12px;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #fff; font-size: 15px; font-weight: 700; cursor: pointer;
    transition: opacity 0.2s, transform 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.chat-form-body .submit-btn:hover { opacity: 0.92; }
.chat-form-body .submit-btn:active { transform: scale(0.97); }
.chat-form-body .submit-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ===== 聊天消息区 ===== */
.chat-messages-area {
    flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px;
    background: #f8fafc; min-height: 200px;
    display: none; flex-direction: column; gap: 10px;
}
.chat-messages-area.active { display: flex; }
.chat-message {
    max-width: 82%; padding: 10px 14px; border-radius: 14px;
    font-size: 13.5px; line-height: 1.65; word-break: break-word;
    animation: chatMsgIn 0.3s ease;
}
@keyframes chatMsgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.chat-message.user {
    align-self: flex-end; background: linear-gradient(135deg, #2563eb, #6366f1);
    color: #fff; border-bottom-right-radius: 4px;
}
.chat-message.ai, .chat-message.admin {
    align-self: flex-start; background: #fff; color: #1f2937;
    border-bottom-left-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.chat-message .msg-meta {
    font-size: 10px; margin-top: 6px; opacity: 0.65;
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.chat-message .msg-meta a {
    color: #6366f1; text-decoration: none; font-weight: 600;
    display: inline-flex; align-items: center; gap: 3px;
}
.chat-message .msg-meta a:hover { text-decoration: underline; }
.chat-message .typing-dots {
    display: flex; gap: 4px; padding: 8px 0;
}
.chat-message .typing-dots span {
    width: 7px; height: 7px; border-radius: 50%; background: #94a3b8;
    animation: typingBounce 1.4s infinite ease-in-out;
}
.chat-message .typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-message .typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }

/* ===== 输入区域 ===== */
.chat-input-area {
    padding: 10px 14px; border-top: 1px solid #e5e7eb; background: #fff;
    display: none; align-items: center; gap: 8px; flex-shrink: 0;
}
.chat-input-area.active { display: flex; }
.chat-input-area input {
    flex: 1; border: 1.5px solid #e5e7eb; border-radius: 20px;
    padding: 9px 16px; font-size: 13.5px; outline: none;
    transition: border-color 0.2s;
}
.chat-input-area input:focus { border-color: #6366f1; }
.chat-input-area .send-btn {
    width: 38px; height: 38px; border-radius: 50%; border: none;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: opacity 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.chat-input-area .send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.chat-input-area .send-btn svg { width: 16px; height: 16px; }

/* ===== 内联联系方式（输入框下方小字段） ===== */
.chat-contact-inline {
    padding: 6px 14px 10px; background: #fff; flex-shrink: 0;
}
.chat-contact-row {
    display: flex; gap: 8px; align-items: flex-start;
}
.chat-contact-row .contact-field {
    flex: 1; min-width: 0;
    border: 1.5px solid #e5e7eb; border-radius: 8px;
    padding: 7px 10px; font-size: 12px; color: #374151; outline: none;
    transition: border-color 0.2s; box-sizing: border-box;
}
.chat-contact-row .contact-field::placeholder { color: #9ca3af; }
.chat-contact-row .contact-field:focus { border-color: #6366f1; }
.chat-contact-row .contact-field.error { border-color: #ef4444; }
.contact-error {
    font-size: 11px; color: #ef4444; margin-top: 4px; padding: 0 2px;
}

/* ===== 关闭通知横条 ===== */
.chat-closed-bar {
    display: none; padding: 14px 18px; background: #fef3c7; color: #92400e;
    font-size: 13px; text-align: center; border-top: 1px solid #fbbf24;
}
.chat-closed-bar.active { display: block; }

/* ===== 遮罩层（移动端） ===== */
#chatOverlay {
    position: fixed; inset: 0; z-index: 9997; background: rgba(0,0,0,0.35);
    display: none;
}
@media (max-width: 480px) { #chatOverlay.open { display: block; } }

/* 状态提示 */
.chat-status-tip {
    text-align: center; padding: 8px; font-size: 11px; color: #94a3b8;
}

/* ===== 底部按钮变色过渡 ===== */
.chat-footer-btn {
    transition: background 0.6s ease, box-shadow 0.6s ease, transform 0.25s !important;
}
.chat-footer-btn.chat-btn-active {
    background: linear-gradient(135deg, #2563eb, #7c3aed) !important;
    box-shadow: 0 4px 20px rgba(37,99,235,0.45) !important;
    color: #fff !important;
}
.chat-footer-btn.chat-btn-active:hover {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6) !important;
    box-shadow: 0 6px 28px rgba(37,99,235,0.6) !important;
}

/* ===== 在线咨询按钮：默认灰色 =====
   默认灰底由 footer.php 的 Tailwind 灰类（bg-gray-100 / bg-gray-300）呈现；
   仅当 JS 加 .chat-btn-active 时显示蓝→紫渐变（见上方规则）。
   2026-09-10 曾用 ID 规则强制常亮渐变，现需求改为「默认灰 + 按原频率闪烁」，
   故移除常亮规则，闪烁节奏由 chat-widget.js 的 startFooterBtnFlash() 控制
   （5s 后变彩色 → 彩色 30s → 灰 30s → 循环）。 */
#footerChatBtnPc, #footerChatBtnMobile {
    background: #d1d5db;   /* 灰底兜底（bg-gray-300 同色） */
    color: #fff;
}
#footerChatBtnMobile {
    background: #f3f4f6;   /* 移动端浅灰兜底（bg-gray-100 同色） */
    color: #374151;
}
#footerChatBtnPc:hover, #footerChatBtnMobile:hover {
    background: #9ca3af;
}

/* ===== 5秒/30秒循环引导提示气泡 — 玻璃拟态半透明 ===== */
#chatAutoPrompt {
    position: fixed; bottom: 170px; right: 68px; z-index: 9999;
    opacity: 0; transform: translateX(40px);
    transition: opacity 0.5s ease, transform 0.5s cubic-bezier(.34,1.56,.64,1);
    pointer-events: none;
}
#chatAutoPrompt.show {
    opacity: 1; transform: translateX(0);
    pointer-events: auto;
    animation: promptFloat 4s ease-in-out infinite;
}
@keyframes promptFloat {
    0%, 100% { transform: translateX(0) translateY(0); }
    50% { transform: translateX(0) translateY(-8px); }
}
#chatAutoPrompt .prompt-bubble {
    position: relative;
    border-radius: 16px;
    padding: 14px 18px;
    max-width: 210px;
    cursor: pointer;
    /* 玻璃拟态 — 高透明 */
    background: rgba(255,255,255,0.28);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.25);
    box-shadow: 0 1px 2px rgba(0,0,0,0.03), 0 4px 12px rgba(0,0,0,0.05);
    animation: bubbleBounce 3s ease-in-out infinite;
}
@keyframes bubbleBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}
#chatAutoPrompt .prompt-bubble::after {
    content: ''; position: absolute; bottom: 18px; right: -8px;
    width: 0; height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 10px solid rgba(255,255,255,0.28);
}
#chatAutoPrompt .prompt-bubble .bubble-title {
    font-size: 13px; font-weight: 600; color: rgba(55,65,81,0.75);
    margin-bottom: 4px; letter-spacing: 0.01em;
}
#chatAutoPrompt .prompt-bubble .bubble-sub {
    font-size: 11px; color: rgba(107,114,128,0.65); line-height: 1.5;
    opacity: 0.85;
}
#chatAutoPrompt .prompt-close {
    position: absolute; top: 8px; right: 8px;
    width: 20px; height: 20px; border-radius: 50%;
    background: rgba(255,255,255,0.35);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid rgba(0,0,0,0.04); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; color: #9ca3af; line-height: 1;
    transition: background 0.2s, color 0.2s; z-index: 2;
}
#chatAutoPrompt .prompt-close:hover { background: rgba(255,255,255,0.9); color: #374151; }

/* ===== 面板内表单并排布局 ===== */
.chat-form-inline {
    display: flex; gap: 10px; padding: 0;
}
.chat-form-inline .form-group {
    flex: 1; min-width: 0; margin-bottom: 0;
    text-align: center;
}
.chat-form-inline .form-group label {
    display: block; text-align: center;
}
.chat-form-inline .form-group input {
    width: 100%; padding: 9px 12px; font-size: 13px;
    text-align: center;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px; outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.chat-form-inline .form-group input:focus {
    border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.chat-form-inline .form-group input::placeholder {
    text-align: center;
}

/* 表单底部容器 */
.chat-form-footer {
    flex-shrink: 0;
    padding: 0 16px 16px;
}
.chat-form-footer .submit-btn {
    width: 100%; padding: 11px; border: none; border-radius: 10px;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #fff; font-size: 14px; font-weight: 700; cursor: pointer;
    transition: opacity 0.2s, transform 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.chat-form-footer .submit-btn:hover { opacity: 0.92; }
.chat-form-footer .submit-btn:active { transform: scale(0.97); }
.chat-form-footer .submit-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* 面板内错误提示 */
.chat-form-inline .error-msg {
    font-size: 10px; color: #ef4444; margin-top: 3px; display: none;
    text-align: center;
}
.chat-form-inline input.error { border-color: #ef4444; }

/* ===== 智能推荐卡片 ===== */
.chat-recommendations {
    align-self: flex-start; max-width: 88%;
    margin: 4px 0; animation: chatMsgIn 0.3s ease;
}
.chat-recommendations .rec-header {
    font-size: 11px; color: #6366f1; font-weight: 600;
    margin-bottom: 6px; padding: 0 2px;
}
.chat-recommendations .rec-card {
    display: block; background: #fff; border: 1px solid #e5e7eb;
    border-radius: 10px; padding: 10px 12px; margin-bottom: 6px;
    text-decoration: none; color: #1f2937;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.chat-recommendations .rec-card:last-child { margin-bottom: 0; }
.chat-recommendations .rec-card:hover {
    border-color: #6366f1; box-shadow: 0 2px 8px rgba(99,102,241,0.1);
}
.chat-recommendations .rec-card .rec-type {
    font-size: 10px; color: #6366f1; font-weight: 600;
    background: #eef2ff; padding: 2px 8px; border-radius: 10px;
    display: inline-block; margin-bottom: 4px;
}
.chat-recommendations .rec-card .rec-title {
    font-size: 13px; font-weight: 600; color: #111827;
    line-height: 1.4;
}
.chat-recommendations .rec-card .rec-desc {
    font-size: 11px; color: #6b7280; margin-top: 3px; line-height: 1.4;
}

/* ===== 库存查询快捷链接卡片（2026-11-06） ===== */
.chat-stock-card {
    align-self: flex-start; width: 100%;
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px; margin: 2px 0 6px;
    border-radius: 14px; text-decoration: none;
    background: linear-gradient(135deg, #0f2d5c 0%, #1e4b8f 55%, #2563eb 100%);
    border: 1px solid rgba(255,255,255,0.14);
    box-shadow: 0 6px 18px rgba(15,45,92,0.22);
    color: #fff; animation: chatMsgIn 0.3s ease;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.chat-stock-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(15,45,92,0.30);
}
.chat-stock-card .stock-card-icon {
    flex: 0 0 34px; width: 34px; height: 34px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; background: rgba(255,255,255,0.14);
}
.chat-stock-card .stock-card-body {
    flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px;
}
.chat-stock-card .stock-card-title {
    font-size: 13.5px; font-weight: 700; line-height: 1.35; color: #fff;
}
.chat-stock-card .stock-card-sub {
    font-size: 11px; color: rgba(255,255,255,0.78); line-height: 1.35;
}
.chat-stock-card .stock-card-go {
    flex: 0 0 auto; font-size: 11.5px; font-weight: 700; white-space: nowrap;
    padding: 5px 10px; border-radius: 999px; background: rgba(255,255,255,0.18);
    color: #fff;
}
@media (max-width: 400px) {
    .chat-stock-card { padding: 10px; gap: 8px; }
    .chat-stock-card .stock-card-go { display: none; }
}