/* 私聊客服 - 用户端样式 */

/* 悬浮球 */
.chat-float-btn {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #07C160 0%, #06AD56 100%);
    box-shadow: 0 4px 16px rgba(7, 193, 96, 0.4);
    cursor: pointer;
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    animation: chatFloatPulse 2s ease-in-out infinite;
}

.chat-float-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(7, 193, 96, 0.5);
}

.chat-float-btn:active {
    transform: scale(0.95);
}

.chat-float-btn svg {
    width: 28px;
    height: 28px;
    fill: white;
}

.chat-float-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: #ff4d4f;
    color: white;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    border: 2px solid white;
}

@keyframes chatFloatPulse {
    0%, 100% { box-shadow: 0 4px 16px rgba(7, 193, 96, 0.4); }
    50% { box-shadow: 0 4px 24px rgba(7, 193, 96, 0.6); }
}

/* 聊天窗口 */
.chat-window {
    position: fixed;
    bottom: 140px;
    right: 20px;
    width: 320px;
    height: 520px;
    background: #f5f5f5;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.chat-window.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* 聊天头部 */
.chat-header {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: white;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #07C160, #06AD56);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-avatar svg {
    width: 20px;
    height: 20px;
    fill: white;
}

.chat-header-info {
    flex: 1;
}

.chat-header-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 1px;
}

.chat-header-status {
    font-size: 11px;
    color: #07C160;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-header-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #07C160;
}

.chat-close-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background 0.2s;
}

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 消息区域 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

/* 消息气泡 */
.chat-msg {
    display: flex;
    gap: 6px;
    max-width: 82%;
    animation: chatMsgIn 0.2s ease;
}

@keyframes chatMsgIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-msg.staff {
    align-self: flex-start;
}

.chat-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: white;
}

.chat-msg.staff .chat-msg-avatar {
    background: linear-gradient(135deg, #07C160, #06AD56);
}

.chat-msg.user .chat-msg-avatar {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.chat-msg-bubble {
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.4;
    word-break: break-word;
}

.chat-msg.staff .chat-msg-bubble {
    background: white;
    color: #333;
    border-top-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.chat-msg.user .chat-msg-bubble {
    background: #07C160;
    color: white;
    border-top-right-radius: 4px;
}

.chat-msg-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

.chat-msg.user .chat-msg-time {
    text-align: right;
}

.chat-msg-read {
    font-size: 10px;
    color: #07C160;
    margin-left: 4px;
}

/* 输入区域 */
.chat-input-area {
    padding: 8px 10px;
    background: white;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}

.chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-input {
    flex: 1;
    height: 36px;
    min-height: 36px;
    max-height: 80px;
    margin: 0;
    padding: 0 12px;
    line-height: 36px;
    border: 1px solid #ddd;
    border-radius: 18px;
    font-size: 13px;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
    box-sizing: border-box;
}

.chat-input:focus {
    border-color: #07C160;
}

.chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #07C160, #06AD56);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    transform: scale(1.05);
}

.chat-send-btn:active {
    transform: scale(0.95);
}

.chat-send-btn svg {
    width: 16px;
    height: 16px;
    fill: white;
}

.chat-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* 底部声明 */
.chat-disclaimer {
    padding: 4px 10px;
    font-size: 9px;
    color: #999;
    text-align: center;
    background: white;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}

/* 新消息弹窗通知 */
.chat-notification {
    position: fixed;
    bottom: 140px;
    right: 20px;
    width: 320px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    z-index: 99997;
    opacity: 0;
    transform: translateX(100%);
    pointer-events: none;
    cursor: pointer;
    overflow: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.chat-notification.active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.chat-notification-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    color: white;
}

.chat-notification-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #07C160, #06AD56);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-notification-avatar svg {
    width: 18px;
    height: 18px;
    fill: white;
}

.chat-notification-title {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
}

.chat-notification-close {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-notification-body {
    padding: 12px 14px;
    font-size: 13px;
    color: #666;
    line-height: 1.4;
    max-height: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* 未登录提示 */
.chat-login-prompt {
    padding: 40px 20px;
    text-align: center;
    color: #666;
}

.chat-login-prompt p {
    margin-bottom: 16px;
    font-size: 14px;
}

.chat-login-btn {
    padding: 8px 24px;
    background: linear-gradient(135deg, #07C160, #06AD56);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
}

/* 响应式 */
@media (max-width: 480px) {
    .chat-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 160px);
        right: 16px;
        bottom: 110px;
    }

    .chat-float-btn {
        bottom: 70px;
        right: 16px;
        width: 48px;
        height: 48px;
    }

    .chat-notification {
        width: calc(100vw - 32px);
        right: 16px;
        bottom: 110px;
    }
}


/* P1：图片上传按钮 */
.chat-image-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

.chat-image-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.chat-image-btn svg {
    width: 22px;
    height: 22px;
    fill: #666;
}

/* P1：图片消息 */
.chat-msg-image {
    padding: 4px !important;
    background: transparent !important;
}

.chat-msg-image img {
    max-width: 180px;
    max-height: 240px;
    border-radius: 8px;
    display: block;
    cursor: pointer;
}

.chat-msg.user .chat-msg-image {
    background: transparent !important;
}
