/* ============================================================ */
/* 智能客服系统样式 - 带 .jz-chat- 前缀避免冲突 */
/* ============================================================ */

/* ----- 客服悬浮按钮 ----- */
.jz-chat-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0066cc, #00aaff);
    color: #fff;
    border: none;
    box-shadow: 0 4px 20px rgba(0, 102, 204, 0.4);
    cursor: pointer;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    transition: all 0.3s ease;
    animation: jz-chat-pulse 2s infinite;
}

.jz-chat-button:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 30px rgba(0, 102, 204, 0.5);
}

.jz-chat-button .jz-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ff4757;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

@keyframes jz-chat-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(0, 102, 204, 0.4); }
    50% { box-shadow: 0 4px 40px rgba(0, 102, 204, 0.6); }
}

/* ----- 客服窗口 ----- */
.jz-chat-window {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 380px;
    max-width: calc(100vw - 60px);
    max-height: 580px;
    height: 580px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    z-index: 9998;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    animation: jz-chat-slideUp 0.3s ease;
}

.jz-chat-window.active {
    display: flex;
}

@keyframes jz-chat-slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ----- 客服头部 ----- */
.jz-chat-header {
    background: linear-gradient(135deg, #0066cc, #00aaff);
    color: #fff;
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.jz-chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.jz-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.jz-chat-header-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.jz-chat-header-info p {
    margin: 0;
    font-size: 12px;
    opacity: 0.8;
}

.jz-chat-header-info p .jz-chat-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2ed573;
    margin-right: 6px;
    animation: jz-chat-blink 1.5s infinite;
}

@keyframes jz-chat-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.jz-chat-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
    opacity: 0.8;
}

.jz-chat-close:hover {
    background: rgba(255, 255, 255, 0.15);
    opacity: 1;
}

/* ----- 消息区域 ----- */
.jz-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    background: #f8f9fc;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.jz-chat-messages::-webkit-scrollbar {
    width: 4px;
}

.jz-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.jz-chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

/* 消息气泡 */
.jz-chat-msg {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.6;
    animation: jz-chat-msgIn 0.3s ease;
    word-wrap: break-word;
}

@keyframes jz-chat-msgIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.jz-chat-msg-bot {
    align-self: flex-start;
    background: #fff;
    color: #1a1a2e;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.jz-chat-msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #0066cc, #00aaff);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.jz-chat-msg-time {
    font-size: 10px;
    opacity: 0.5;
    margin-top: 4px;
    display: block;
}

.jz-chat-msg-user .jz-chat-msg-time {
    text-align: right;
}

/* 正在输入指示器 */
.jz-chat-typing {
    align-self: flex-start;
    background: #fff;
    padding: 12px 20px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    display: none;
}

.jz-chat-typing.active {
    display: block;
}

.jz-chat-typing-dots {
    display: flex;
    gap: 4px;
}

.jz-chat-typing-dots span {
    width: 8px;
    height: 8px;
    background: #d1d5db;
    border-radius: 50%;
    animation: jz-chat-dotBounce 1.4s infinite;
}

.jz-chat-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.jz-chat-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes jz-chat-dotBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* ----- 快捷回复按钮 ----- */
.jz-chat-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 20px;
    background: #fff;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.jz-chat-quick-btn {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #0066cc;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.jz-chat-quick-btn:hover {
    background: #0066cc;
    color: #fff;
    border-color: #0066cc;
}

/* ----- 输入区域 ----- */
.jz-chat-input-area {
    display: flex;
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #f0f0f0;
    gap: 10px;
    flex-shrink: 0;
    align-items: flex-end;
}

.jz-chat-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    padding: 10px 18px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    line-height: 1.5;
}

.jz-chat-input:focus {
    border-color: #0066cc;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.jz-chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0066cc, #00aaff);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.jz-chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(0, 102, 204, 0.3);
}

.jz-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ----- 消息中的链接样式 ----- */
.jz-chat-msg a {
    color: #0066cc;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

.jz-chat-msg a:hover {
    border-bottom-color: #0066cc;
}

.jz-chat-msg-user a {
    color: rgba(255, 255, 255, 0.9);
    border-bottom-color: rgba(255, 255, 255, 0.3);
}

.jz-chat-msg-user a:hover {
    border-bottom-color: #fff;
    color: #fff;
}

/* ===== 移动端适配 ===== */
@media (max-width: 576px) {
    .jz-chat-window {
        bottom: 80px;
        right: 10px;
        width: calc(100vw - 20px);
        height: calc(100vh - 160px);
        max-height: 600px;
        border-radius: 16px;
    }

    .jz-chat-button {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
        font-size: 24px;
    }

    .jz-chat-header {
        padding: 14px 18px;
    }

    .jz-chat-messages {
        padding: 12px 14px;
    }

    .jz-chat-input {
        font-size: 13px;
        padding: 8px 14px;
        min-height: 38px;
    }

    .jz-chat-send-btn {
        width: 38px;
        height: 38px;
        font-size: 15px;
    }
}

/* ===== 暗色模式兼容 ===== */
@media (prefers-color-scheme: dark) {
    .jz-chat-window {
        background: #1a1a2e;
    }
    .jz-chat-messages {
        background: #16213e;
    }
    .jz-chat-msg-bot {
        background: #2a2a4a;
        color: #e5e7eb;
    }
    .jz-chat-input {
        background: #2a2a4a;
        color: #e5e7eb;
        border-color: #3a3a5a;
    }
    .jz-chat-input:focus {
        border-color: #0066cc;
    }
    .jz-chat-quick-replies {
        background: #1a1a2e;
        border-top-color: #2a2a4a;
    }
    .jz-chat-input-area {
        background: #1a1a2e;
        border-top-color: #2a2a4a;
    }
    .jz-chat-quick-btn {
        background: #2a2a4a;
        color: #4bcffa;
        border-color: #3a3a5a;
    }
    .jz-chat-quick-btn:hover {
        background: #0066cc;
        color: #fff;
    }
    .jz-chat-typing {
        background: #2a2a4a;
    }
    .jz-chat-typing-dots span {
        background: #5a5a7a;
    }
}