/* ================================================
 * CustomerService.css - 用户端客服聊天窗口样式
 * ================================================ */

/* 客服入口浮层 */
.customer-service-bar {
    position: fixed;
    right: 20px;
    bottom: 80px;
    z-index: 1000;
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 0;
    transform: translateX(60px);
    pointer-events: none;
}

.customer-service-bar.visible {
    opacity: 1;
    transform: translateX(0);
    pointer-events: all;
}

.customer-service-icon {
    position: relative;
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.5);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.customer-service-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(102, 126, 234, 0.7);
}

.customer-service-icon svg {
    width: 26px;
    height: 26px;
    color: #fff;
    fill: none;
    stroke: #fff;
    stroke-width: 2;
}

/* 未读红点 */
.cs-unread-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
    animation: cs-pulse 1.5s infinite;
}

.cs-unread-dot.active {
    display: block;
}

@keyframes cs-pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }
}

/* ================================================
 * 聊天弹窗
 * ================================================ */
.cs-chat-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    /* 背景虚化 */
    -webkit-backdrop-filter: blur(4px);
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.cs-chat-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.cs-chat-window {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 120px);
    overscroll-behavior: contain;
    background: #1a1a2e;
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.12));
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    z-index: 2001;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transform: translate(-50%, -100%) scale(0.9);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    pointer-events: none;
}

.cs-chat-window.active {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    pointer-events: all;
}

/* 聊天头部 */
.cs-chat-header {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--glass-border, rgba(255, 255, 255, 0.1));
    gap: 12px;
    flex-shrink: 0;
}

.cs-chat-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
}

.cs-chat-title {
    flex: 1;
    font-weight: 600;
    font-size: 1em;
    color: var(--text-primary, #fff);
}

.cs-chat-title small {
    display: block;
    font-size: 0.75em;
    font-weight: 400;
    color: var(--text-secondary, rgba(255, 255, 255, 0.55));
}

.cs-chat-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary, rgba(255, 255, 255, 0.6));
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 32px;
    text-align: center;
    transition: background 0.2s;
}

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

/* 消息列表区 */
.cs-msg-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}

.cs-msg-list::-webkit-scrollbar {
    width: 4px;
}

.cs-msg-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

/* 加载更多区 */
.cs-load-more-bar {
    text-align: center;
    flex-shrink: 0;
}

.cs-load-more-btn {
    background: none;
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.12));
    color: var(--text-secondary, rgba(255, 255, 255, 0.55));
    font-size: 0.8em;
    padding: 4px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.cs-load-more-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

/* 消息气泡 */
.cs-msg-item {
    display: flex;
    gap: 8px;
    max-width: 85%;
}

.cs-msg-item.user-msg {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.cs-msg-item.admin-msg {
    align-self: flex-start;
}

.cs-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.92em;
    line-height: 1.5;
    word-break: break-word;
}

.user-msg .cs-bubble {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.admin-msg .cs-bubble {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary, #fff);
    border-bottom-left-radius: 4px;
}

.cs-bubble img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    display: block;
    cursor: pointer;
}

.cs-time {
    font-size: 0.72em;
    color: var(--text-secondary, rgba(255, 255, 255, 0.4));
    align-self: flex-end;
    white-space: nowrap;
    padding-bottom: 2px;
}

/* 输入区 */
.cs-input-area {
    border-top: 1px solid var(--glass-border, rgba(255, 255, 255, 0.1));
    padding: 10px 12px;
    flex-shrink: 0;
}

.cs-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.cs-text-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 9px 14px;
    color: var(--text-primary, #fff);
    font-size: 0.92em;
    outline: none;
    resize: none;
    max-height: 100px;
    min-height: 38px;
    line-height: 1.5;
    transition: border-color 0.2s;
    font-family: inherit;
}

.cs-text-input:focus {
    border-color: rgba(102, 126, 234, 0.6);
}

.cs-text-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.cs-img-btn {
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary, rgba(255, 255, 255, 0.5));
    transition: all 0.2s;
    flex-shrink: 0;
}

.cs-img-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.cs-img-btn svg {
    width: 18px;
    height: 18px;
}

.cs-send-btn {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s, opacity 0.2s;
}

.cs-send-btn:hover {
    transform: scale(1.08);
}

.cs-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.cs-send-btn svg {
    width: 18px;
    height: 18px;
    stroke: #fff;
}

/* 加载状态 */
.cs-loading-bar {
    text-align: center;
    padding: 6px;
    color: var(--text-secondary, rgba(255, 255, 255, 0.4));
    font-size: 0.8em;
    display: none;
}

.cs-loading-bar.active {
    display: block;
}

/* 空状态 */
.cs-empty-tip {
    text-align: center;
    color: var(--text-secondary, rgba(255, 255, 255, 0.4));
    font-size: 0.85em;
    padding: 20px;
    display: none;
}

.cs-empty-tip.active {
    display: block;
}