/* 在线客服挂件 —— 类名统一加 cs-chat- 前缀，避免与 style.css 冲突 */
.cs-chat-bubble {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-accent, #4CAF50);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    z-index: 99998;
    transition: transform .2s ease;
    font-family: var(--font-family, -apple-system, BlinkMacSystemFont, 'PingFang SC', sans-serif);
}
.cs-chat-bubble:hover { transform: scale(1.06); }
.cs-chat-bubble svg { width: 28px; height: 28px; fill: #fff; }
.cs-chat-bubble .cs-chat-badge {
    position: absolute;
    top: -2px; right: -2px;
    min-width: 18px; height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #f5222d;
    color: #fff;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
}

.cs-chat-panel {
    position: fixed;
    right: 20px;
    bottom: 88px;
    width: 360px;
    height: 540px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 99999;
    font-family: var(--font-family, -apple-system, BlinkMacSystemFont, 'PingFang SC', sans-serif);
}
.cs-chat-panel.cs-chat-open { display: flex; }

.cs-chat-header {
    background: var(--color-accent, #4CAF50);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.cs-chat-header .cs-chat-title { font-size: 15px; font-weight: 600; }
.cs-chat-header .cs-chat-status { font-size: 12px; opacity: .85; margin-left: 8px; font-weight: 400; }
.cs-chat-header .cs-chat-close { cursor: pointer; font-size: 20px; line-height: 1; opacity: .9; }
.cs-chat-header .cs-chat-close:hover { opacity: 1; }

.cs-chat-cancelbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 14px;
    background: #fff7e6;
    border-bottom: 1px solid #ffe7ba;
    font-size: 12px;
    color: #ad6800;
}
.cs-chat-cancel-btn {
    flex-shrink: 0;
    border: 1px solid var(--color-accent, #4CAF50);
    color: var(--color-accent, #4CAF50);
    background: #fff;
    border-radius: 14px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
}
.cs-chat-cancel-btn:hover { background: var(--color-accent-light, rgba(76,175,80,.1)); }

.cs-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #f6f7f9;
}

.cs-chat-msg { margin: 8px 0; display: flex; flex-direction: column; }
.cs-chat-msg.cs-right { align-items: flex-end; }
.cs-chat-msg.cs-left { align-items: flex-start; }
.cs-chat-bubble-text {
    max-width: 78%;
    width: fit-content;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}
.cs-left .cs-chat-bubble-text { background: #fff; color: #1a1a1a; border: 1px solid #eee; }
.cs-right .cs-chat-bubble-text { background: var(--color-accent, #4CAF50); color: #fff; }
.cs-chat-bubble-text img { max-width: 200px; max-height: 200px; border-radius: 6px; display: block; }

/* 图片全屏预览 */
.cs-chat-imgviewer {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100000;
}
.cs-chat-imgviewer img { max-width: 92vw; max-height: 92vh; object-fit: contain; }
.cs-chat-imgviewer-close {
    position: absolute;
    top: 16px;
    right: 20px;
    width: 40px;
    height: 40px;
    line-height: 38px;
    text-align: center;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    border-radius: 50%;
    background: rgba(0, 0, 0, .35);
    user-select: none;
}
.cs-chat-imgviewer-close:hover { background: rgba(0, 0, 0, .6); }

.cs-chat-system {
    text-align: center;
    color: #999;
    font-size: 12px;
    margin: 10px 0;
}

.cs-chat-menu { margin: 8px 0 8px 0; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.cs-chat-menu-btn {
    background: #fff;
    border: 1px solid var(--color-accent, #4CAF50);
    color: var(--color-accent, #4CAF50);
    border-radius: 16px;
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: background .15s ease;
}
.cs-chat-menu-btn:hover { background: var(--color-accent-light, rgba(76,175,80,.1)); }

.cs-chat-msg-time { font-size: 11px; color: #aaa; margin-bottom: 2px; }

.cs-chat-typing { color: #999; font-size: 12px; padding: 0 14px 6px; }

/* 全屏模式（customer.html）：铺满视口，无圆角，隐藏关闭按钮，适配安全区 */
.cs-chat-panel.cs-chat-fullscreen {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    box-shadow: none;
    display: flex;
}
.cs-chat-panel.cs-chat-fullscreen .cs-chat-close { display: none; }
.cs-chat-panel.cs-chat-fullscreen .cs-chat-header { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
.cs-chat-panel.cs-chat-fullscreen .cs-chat-footer { padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }

.cs-chat-footer {
    border-top: 1px solid #eee;
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: #fff;
}
.cs-chat-footer .cs-chat-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 18px;
    padding: 8px 14px;
    font-size: 14px;
    outline: none;
    resize: none;
    max-height: 80px;
    font-family: inherit;
}
.cs-chat-footer .cs-chat-input:focus { border-color: var(--color-accent, #4CAF50); }
.cs-chat-icon-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: #888;
    flex-shrink: 0;
}
.cs-chat-icon-btn:hover { background: #f0f0f0; color: var(--color-accent, #4CAF50); }
.cs-chat-icon-btn svg { width: 22px; height: 22px; fill: currentColor; }
.cs-chat-send {
    background: var(--color-accent, #4CAF50);
    color: #fff;
}
.cs-chat-send:hover { background: var(--color-accent-hover, #43A047); color: #fff; }

@media (max-width: 480px) {
    .cs-chat-panel {
        right: 0; bottom: 0;
        width: 100%; height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    .cs-chat-bubble { right: 16px; bottom: 16px; }
}
