/* ===== 悬浮客服聊天组件 ===== */
:root {
    --chat-deep: #0a1e4a;
    --chat-blue: #1e3a8a;
    --chat-bright: #2563eb;
    --chat-orange: #ff6b1a;
    --chat-white: #ffffff;
    --chat-gray: #f1f5f9;
    --chat-text: #1e293b;
    --chat-text-light: #64748b;
    --chat-radius: 16px;
}

/* 悬浮按钮 */
.chat-fab {
    position: fixed;
    right: 28px;
    bottom: 28px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff6b1a 0%, #ff8c42 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(255, 107, 26, 0.45), 0 2px 8px rgba(10, 30, 74, 0.2);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: chatFabPulse 2.5s ease-in-out infinite;
}
.chat-fab:hover {
    transform: scale(1.12);
    box-shadow: 0 12px 32px rgba(255, 107, 26, 0.6);
}
.chat-fab svg {
    width: 28px;
    height: 28px;
    color: #fff;
}
.chat-fab.hidden {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}
@keyframes chatFabPulse {
    0%, 100% { box-shadow: 0 8px 24px rgba(255, 107, 26, 0.45), 0 0 0 0 rgba(255, 107, 26, 0.4); }
    50% { box-shadow: 0 8px 24px rgba(255, 107, 26, 0.45), 0 0 0 16px rgba(255, 107, 26, 0); }
}

/* 未读消息红点 */
.chat-fab-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    line-height: 1;
}
.chat-fab-badge.show { display: flex; }

/* 聊天面板 */
.chat-panel {
    position: fixed;
    right: 28px;
    bottom: 100px;
    width: 380px;
    height: 560px;
    background: #fff;
    border-radius: var(--chat-radius);
    box-shadow: 0 20px 60px rgba(10, 30, 74, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.chat-panel.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* 面板头部 */
.chat-header {
    background: linear-gradient(135deg, #0a1e4a 0%, #1e3a8a 100%);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff6b1a, #ff8c42);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.chat-header-avatar svg { width: 22px; height: 22px; color: #fff; }
.chat-header-info { flex: 1; }
.chat-header-info h4 { font-size: 15px; font-weight: 600; margin: 0; }
.chat-header-info span { font-size: 12px; color: rgba(255,255,255,0.7); display: flex; align-items: center; gap: 4px; }
.chat-header-info .online-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: #4ade80; display: inline-block;
    animation: dotBlink 1.5s ease-in-out infinite;
}
@keyframes dotBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.chat-header-close {
    background: none; border: none; cursor: pointer;
    color: rgba(255,255,255,0.6); padding: 4px; border-radius: 8px;
    transition: all 0.2s;
}
.chat-header-close:hover { color: #fff; background: rgba(255,255,255,0.15); }
.chat-header-close svg { width: 20px; height: 20px; }

/* 消息区域 */
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.chat-body::-webkit-scrollbar { width: 5px; }
.chat-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

/* 消息气泡 */
.chat-msg {
    max-width: 78%;
    display: flex;
    flex-direction: column;
    gap: 2px;
    animation: msgSlideIn 0.3s ease-out;
}
@keyframes msgSlideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.chat-msg.user { align-self: flex-end; align-items: flex-end; }
.chat-msg.admin { align-self: flex-start; align-items: flex-start; }

.chat-msg-bubble {
    padding: 10px 16px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}
.chat-msg.user .chat-msg-bubble {
    background: linear-gradient(135deg, #2563eb, #1e3a8a);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg.admin .chat-msg-bubble {
    background: #fff;
    color: var(--chat-text);
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}
.chat-msg-time {
    font-size: 11px;
    color: var(--chat-text-light);
    margin: 0 4px;
}

/* 系统消息 */
.chat-system {
    text-align: center;
    font-size: 12px;
    color: var(--chat-text-light);
    padding: 8px;
    background: #f1f5f9;
    border-radius: 8px;
    margin: 4px 0;
}

/* 未登录提示 */
.chat-not-logged {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    text-align: center;
}
.chat-not-logged svg { width: 48px; height: 48px; color: var(--chat-bright); margin-bottom: 16px; }
.chat-not-logged h5 { font-size: 16px; font-weight: 600; color: var(--chat-text); margin: 0 0 8px; }
.chat-not-logged p { font-size: 13px; color: var(--chat-text-light); margin: 0 0 20px; line-height: 1.5; }
.chat-not-logged a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 28px;
    background: linear-gradient(135deg, #ff6b1a, #ff8c42);
    color: #fff !important;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.25s;
}
.chat-not-logged a:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(255,107,26,0.4); }

/* 企业微信咨询按钮 */
.chat-not-logged .chat-wecom-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    padding: 10px 28px;
    background: linear-gradient(135deg, #07c160, #06ad56);
    color: #fff;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.25s;
}
.chat-not-logged .chat-wecom-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(7,193,96,0.45);
}

/* 企业微信弹层 */
.chat-wecom-mask {
    position: fixed;
    inset: 0;
    background: rgba(10, 30, 74, 0.55);
    backdrop-filter: blur(6px);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.chat-wecom-mask.show {
    opacity: 1;
    pointer-events: auto;
}
.chat-wecom-pop {
    position: relative;
    width: 300px;
    background: #fff;
    border-radius: 20px;
    padding: 36px 28px 28px;
    text-align: center;
    box-shadow: 0 24px 80px rgba(10, 30, 74, 0.4);
    transform: translateY(16px) scale(0.95);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.chat-wecom-mask.show .chat-wecom-pop {
    transform: translateY(0) scale(1);
}
.chat-wecom-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: #f1f5f9;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    transition: all 0.2s;
}
.chat-wecom-close:hover { background: #e2e8f0; color: #0f172a; }
.chat-wecom-close svg { width: 16px; height: 16px; }
.chat-wecom-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    border-radius: 18px;
    background: linear-gradient(135deg, #07c160, #06ad56);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 8px 24px rgba(7, 193, 96, 0.35);
}
.chat-wecom-icon svg { width: 32px; height: 32px; }
.chat-wecom-pop h4 {
    font-size: 17px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 18px;
}
.chat-wecom-qr {
    width: 180px;
    height: 180px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    margin: 0 auto 14px;
    display: block;
}
.chat-wecom-desc {
    font-size: 13px;
    color: #64748b;
    line-height: 1.6;
    margin: 0;
}
.chat-wecom-missing {
    font-size: 13px;
    color: #ef4444;
    line-height: 1.6;
    padding: 32px 8px;
}
.chat-wecom-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 8px auto 14px;
    padding: 12px 26px;
    background: linear-gradient(135deg, #07c160, #06ad56);
    color: #fff !important;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.25s;
}
.chat-wecom-link:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(7,193,96,0.45); }

/* 打字指示器 */
.chat-typing { align-self: flex-start; }
.chat-typing-dots { display: flex; gap: 4px; padding: 12px 16px; background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; border-bottom-left-radius: 4px; }
.chat-typing-dots span {
    width: 7px; height: 7px; border-radius: 50%;
    background: #94a3b8;
    animation: typingBounce 1.2s ease-in-out infinite;
}
.chat-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* 输入区域 */
.chat-footer {
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.chat-input {
    flex: 1;
    border: 1.5px solid #e2e8f0;
    border-radius: 24px;
    padding: 10px 18px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}
.chat-input:focus { border-color: var(--chat-bright); }
.chat-send {
    width: 40px; height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, #2563eb, #1e3a8a);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.chat-send:hover { transform: scale(1.08); box-shadow: 0 4px 12px rgba(37,99,235,0.4); }
.chat-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.chat-send svg { width: 18px; height: 18px; }

/* 欢迎消息 */
.chat-welcome {
    text-align: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border-radius: 12px;
    font-size: 13px;
    color: var(--chat-blue);
    line-height: 1.5;
    margin-bottom: 8px;
}

/* 企业微信卡片（面板内） */
.chat-wecom-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border: 1px solid rgba(7, 193, 96, 0.2);
    border-radius: 14px;
    margin-bottom: 12px;
}
.chat-wecom-qr-sm {
    width: 72px;
    height: 72px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid #fff;
    box-shadow: 0 4px 12px rgba(7, 193, 96, 0.25);
}
.chat-wecom-card-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}
.chat-wecom-card-info strong { font-size: 14px; color: var(--chat-text); }
.chat-wecom-card-info span { font-size: 12px; color: var(--chat-text-light); }
.chat-wecom-card-info .chat-wecom-btn {
    margin-top: 6px;
    align-self: flex-start;
    padding: 6px 16px;
    background: linear-gradient(135deg, #07c160, #06ad56);
    color: #fff;
    border: none;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.25s;
}
.chat-wecom-card-info .chat-wecom-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(7, 193, 96, 0.4);
}

/* 联系方式列表 */
.chat-contact-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.chat-contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--chat-bg);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    text-decoration: none;
    color: var(--chat-text);
    transition: all 0.25s;
}
.chat-contact-item:hover {
    border-color: var(--chat-bright);
    background: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.1);
}
.chat-contact-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #eff6ff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.chat-contact-item strong { font-size: 14px; color: var(--chat-text); }
.chat-contact-item span { font-size: 12px; color: var(--chat-text-light); line-height: 1.5; }

/* 响应式 */
@media (max-width: 480px) {
    .chat-panel {
        width: calc(100vw - 16px);
        height: calc(100vh - 120px);
        right: 8px;
        bottom: 80px;
    }
    .chat-fab { right: 16px; bottom: 16px; width: 54px; height: 54px; }
}
