/* 聊天弹窗样式 */
.chat-popup {
    position: fixed;
    bottom: 140px;
    right: 20px;
    width: 380px;
    max-height: 520px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 10000 !important;
}

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

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #00a850 0%, #008a40 100%);
    color: #fff;
}

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

.chat-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.9;
}

.chat-close:hover {
    opacity: 1;
}

.chat-messages {
    flex: 1;
    height: 320px;
    overflow-y: auto;
    padding: 12px 12px 80px 12px;
    background: #f8f9fa;
    box-sizing: border-box;
    margin-bottom: 0;
}

.system-message {
    text-align: center;
    color: #999;
    font-size: 12px;
    margin-bottom: 12px;
}

.message {
    margin-bottom: 10px;
    max-width: 78%;
}

.message.visitor {
    margin-left: auto;
}

.message.admin {
    margin-right: auto;
}

.message-content {
    padding: 8px 12px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.visitor .message-content {
    background: linear-gradient(135deg, #00a850 0%, #008a40 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.admin .message-content {
    background: #fff;
    border: 1px solid #e8e8e8;
    color: #333;
    border-bottom-left-radius: 4px;
}

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

.message-content img:hover {
    transform: scale(1.02);
}

.message-time {
    font-size: 10px;
    color: #bbb;
    margin-top: 4px;
    display: block;
}

.chat-input-area {
    padding: 12px;
    border-top: 1px solid #eee;
    background: #fff;
    position: relative;
    z-index: 1;
}

.chat-tools {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.tool-btn {
    width: 34px;
    height: 34px;
    border: none;
    background: #f0f0f0;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: all 0.2s;
}

.tool-btn:hover {
    background: #e0e0e0;
    color: #333;
}

.tool-btn svg {
    width: 16px;
    height: 16px;
}

.input-row {
    display: flex;
    gap: 8px;
}

.input-row input {
    flex: 1;
    padding: 8px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.input-row input:focus {
    border-color: #00a850;
}

.send-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, #00a850 0%, #008a40 100%);
    color: #fff;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 168, 80, 0.3);
}

.emoji-panel {
    display: none;
    padding: 12px;
    border-top: 1px solid #eee;
    background: #fff;
}

.emoji-panel.active {
    display: block;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
}

.emoji {
    font-size: 22px;
    cursor: pointer;
    padding: 4px;
    text-align: center;
    border-radius: 6px;
    transition: background 0.15s;
}

.emoji:hover {
    background: #f0f0f0;
}

.voice-recording {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #fff8e1;
    border-radius: 20px;
    margin: 8px 0;
}

.voice-wave {
    display: flex;
    align-items: center;
    gap: 2px;
}

.voice-bar {
    width: 3px;
    height: 14px;
    background: #ffa726;
    border-radius: 2px;
    animation: wave 0.5s ease-in-out infinite;
}

.voice-bar:nth-child(2) { animation-delay: 0.1s; }
.voice-bar:nth-child(3) { animation-delay: 0.2s; }
.voice-bar:nth-child(4) { animation-delay: 0.3s; }

@keyframes wave {
    0%, 100% { height: 6px; }
    50% { height: 20px; }
}

.voice-duration {
    font-size: 12px;
    color: #666;
}

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

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

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

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

/* 图片预览弹窗 */
.image-preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    cursor: pointer;
}

.image-preview-overlay.active {
    display: flex;
}

.image-preview-content {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    cursor: default;
}

.image-preview-content img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
}

.image-preview-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.image-preview-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

@media (max-width: 768px) {
    .chat-popup {
        width: calc(100% - 32px);
        right: 16px;
        left: 16px;
        bottom: 100px;
        max-height: calc(100vh - 200px);
    }
    
    .chat-messages {
        height: 280px;
        padding: 12px 12px 60px 12px;
    }
    
    .message-content img {
        max-width: 150px;
        max-height: 150px;
    }
}
