/* 在线聊天系统样式 */

/* 1. 聊天按钮 - 右下角浮动 */
.chat-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    transition: all 0.3s ease;
    border: none;
    outline: none;
}

.chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.chat-button i {
    color: white;
    font-size: 28px;
}

/* 未读消息徽章 */
.chat-button .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid white;
}

/* 2. 聊天窗口容器 */
.chat-window {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 400px;
    height: 600px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3);
    display: none;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    animation: slideUp 0.3s ease;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

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

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

/* 3. 聊天窗口头部 */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-header-title i {
    font-size: 24px;
}

.chat-header-info h4 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

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

.chat-status {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #2ecc71;
    border-radius: 50%;
    margin-right: 5px;
    animation: pulse 2s infinite;
}

.chat-status.offline {
    background: #95a5a6;
    animation: none;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s;
}

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

/* 4. 聊天消息区域 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 5. 消息气泡 */
.message {
    display: flex;
    margin-bottom: 10px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    justify-content: flex-end;
}

.message.admin,
.message.system {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 18px;
    word-wrap: break-word;
    position: relative;
}

/* 发送者名称 */
.message-sender {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 4px;
    opacity: 0.8;
}

.message.user .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.admin .message-bubble {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.message.system .message-bubble {
    background: #e3f2fd;
    color: #1976d2;
    font-size: 13px;
    text-align: center;
    max-width: 80%;
    margin: 0 auto;
}

.message-sender {
    font-size: 11px;
    margin-bottom: 4px;
    opacity: 0.7;
}

.message-text {
    font-size: 14px;
    line-height: 1.4;
}

.message-time {
    font-size: 12px;
    margin-top: 6px;
    opacity: 0.85;
    font-weight: 500;
    display: block;
}

/* 用户消息的时间（白色文字） */
.message.user .message-time {
    color: rgba(255, 255, 255, 0.95);
    text-align: right;
}

/* 客服消息的时间（深色文字） */
.message.admin .message-time {
    color: rgba(0, 0, 0, 0.6);
    text-align: left;
}

/* 6. 输入区域 */
.chat-input-area {
    padding: 15px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.chat-input-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 25px;
    padding: 12px 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}

.chat-input:focus {
    border-color: #667eea;
}

.chat-send-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.chat-send-btn:hover {
    transform: scale(1.1);
}

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

.chat-send-btn i {
    font-size: 18px;
}

/* 7. 欢迎界面 */
.chat-welcome {
    padding: 30px 20px;
    text-align: center;
}

.chat-welcome i {
    font-size: 60px;
    color: #667eea;
    margin-bottom: 20px;
}

.chat-welcome h3 {
    color: #333;
    margin-bottom: 10px;
}

.chat-welcome p {
    color: #666;
    margin-bottom: 25px;
}

.chat-welcome-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chat-welcome-form input {
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

.chat-welcome-form button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.2s;
}

.chat-welcome-form button:hover {
    transform: translateY(-2px);
}

/* 8. 加载动画 */
.chat-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.chat-loading-dots {
    display: flex;
    gap: 5px;
}

.chat-loading-dots span {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.chat-loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.chat-loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* 9. 响应式设计 */
@media (max-width: 768px) {
    .chat-window {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }

    .chat-button {
        bottom: 20px;
        right: 20px;
        width: 55px;
        height: 55px;
    }

    .chat-button i {
        font-size: 24px;
    }

    /* 移动端消息气泡优化 */
    .message-bubble {
        max-width: 85%;
        padding: 12px 16px;
    }

    /* 移动端时间显示优化 - 更大更清晰 */
    .message-time {
        font-size: 11px;
        margin-top: 8px;
        opacity: 1;
        font-weight: 600;
        letter-spacing: 0.3px;
    }

    /* 移动端用户消息时间 - 白色加阴影 */
    .message.user .message-time {
        color: rgba(255, 255, 255, 1);
        text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    }

    /* 移动端客服消息时间 - 深色 */
    .message.admin .message-time {
        color: rgba(0, 0, 0, 0.75);
    }

    /* 移动端消息文字 */
    .message-text {
        font-size: 15px;
        line-height: 1.5;
    }

    /* 移动端发送者名称 */
    .message-sender {
        font-size: 12px;
        margin-bottom: 6px;
        font-weight: 700;
    }
}

/* 10. 打字指示器 */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 15px;
    background: white;
    border-radius: 18px;
    width: fit-content;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* 11. 离线提示 */
.chat-offline-notice {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
    color: #2d3436;
    font-size: 13px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    animation: slideDown 0.3s ease;
}

.chat-offline-notice i {
    font-size: 16px;
    color: #fdcb6e;
}

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

/* 12. 文件上传工具栏 */
.chat-input-toolbar {
    display: flex;
    gap: 5px;
    padding: 8px 15px;
    border-bottom: 1px solid #e0e0e0;
    background: #fafafa;
}

.chat-tool-btn {
    background: none;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    color: #667eea;
    font-size: 16px;
}

.chat-tool-btn:hover {
    background: #f0f0f0;
    transform: scale(1.1);
}

.chat-tool-btn:active {
    transform: scale(0.95);
}

/* 移动端工具按钮文字标签（图标库未加载时也可见） */
.chat-tool-btn .label {
    display: none;
    margin-left: 6px;
    font-size: 14px;
    vertical-align: middle;
    color: #4a5568;
}

@media (max-width: 768px) {
    .chat-tool-btn .label { display: inline; }
    .chat-tool-btn i { margin-right: 6px; }
}


/* 13. 消息中的图片 */
.message-image {
    margin: 5px 0;
}

.message-image img {
    display: block;
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}

.message-image img:hover {
    transform: scale(1.05);
}

/* 13.5 消息中的视频 */
.message-video {
    margin: 5px 0;
}

.message-video video {
    display: block;
    max-width: 300px;
    max-height: 300px;
    border-radius: 8px;
    background: #000;
}

/* 14. 消息中的文件 */
.message-file {
    margin: 5px 0;
}

.file-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    text-decoration: none;
    color: #2d3436;
    transition: all 0.2s;
    max-width: 250px;
}

.file-link:hover {
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.file-link > i:first-child {
    font-size: 24px;
    color: #667eea;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #2d3436;
}

.file-size {
    font-size: 11px;
    color: #636e72;
    margin-top: 2px;
}

.file-link > i:last-child {
    font-size: 16px;
    color: #b2bec3;
}

/* 15. 输入框样式更新 */
.chat-input {
    resize: none;
    overflow-y: auto;
    min-height: 40px;
    max-height: 100px;
    line-height: 1.5;
    padding: 10px 15px;
}

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

.chat-input::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 2px;
}

/* 16. 用户消息中的文件样式 */
.message.user .file-link {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.message.user .file-link:hover {
    background: rgba(255, 255, 255, 0.3);
}

.message.user .file-name,
.message.user .file-size {
    color: white;
}

.message.user .file-link > i {
    color: white;
}



/* 17. 提示词（客户侧）- 气泡样式（默认） */
.chat-hint {
    position: fixed;
    right: 30px;
    bottom: 98px; /* 显示在按钮上方，避免贴近底边 */
    background: rgba(255, 255, 255, 0.85);
    -webkit-backdrop-filter: saturate(180%) blur(6px);
    backdrop-filter: saturate(180%) blur(6px);
    color: #2d3436;
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.2;
    border: 1px solid rgba(0,0,0,0.08);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 9997; /* 低于聊天窗口(9999)和按钮(9998) */
    pointer-events: none; /* 不阻挡点击按钮 */
    white-space: nowrap;
    animation: hint-fade-in .25s ease-out;
}
.chat-hint::after { /* 小三角，指向按钮 */
    content: "";
    position: absolute;
    right: 36px; /* 与按钮中心大致对齐 */
    top: 100%;
    width: 0; height: 0;
    border: 6px solid transparent;
    border-top-color: rgba(255, 255, 255, 0.85);
    filter: drop-shadow(0 -1px 0 rgba(0,0,0,0.04));
}
@keyframes hint-fade-in { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: translateY(0);} }

/* 备选样式：胶囊标签（将 chat-hint 改为 chat-hint pill 即可） */
.chat-hint.pill { border-radius: 999px; padding: 8px 14px; }

@media (max-width: 768px) {
    .chat-hint { right: 20px; bottom: 88px; font-size: 12px; }
    .chat-hint::after { right: 30px; }
}


/* 18. 环形提示（客户侧）- 方案A */
.chat-hint-ring { position: fixed; right: 5px; bottom: 5px; width: 110px; height: 110px; pointer-events: none; z-index: 9997; }
.chat-hint-ring svg { position: absolute; inset: 0; filter: drop-shadow(0 2px 8px rgba(0,0,0,.35)); }
.chat-hint-ring .ring-text { font-size: 11px; fill: #fff; paint-order: stroke; stroke: rgba(0,0,0,.45); stroke-width: .8; letter-spacing: .2px; }
.chat-hint-ring::before { content: none; }
@media (max-width: 768px) { .chat-hint-ring { right: 5px; bottom: 5px; width: 100px; height: 100px; } .chat-hint-ring .ring-text { font-size: 10px; } }
