/* 聊天组件样式 - 微信绿色风格 */
.chat-widget {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: none;
}

.chat-widget.show {
    display: block;
}

/* 折叠状态的预览条 */
.chat-preview {
    background: #07c160;
    padding: 12px 20px;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: none; /* 默认隐藏 */
}

.chat-preview.show {
    display: flex;
}

.chat-preview:hover {
    background: #06ad56;
}

.chat-preview-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.chat-preview-left span:first-child {
    font-size: 16px;
}

.preview-content {
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.unread-badge {
    background: #ff4444;
    color: white;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 12px;
    min-width: 18px;
    text-align: center;
    display: none;
    font-weight: bold;
}

.connection-status {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.connection-status.connected {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.connection-status.connecting {
    background: rgba(255, 193, 7, 0.8);
    color: white;
}

.connection-status.disconnected {
    background: rgba(220, 53, 69, 0.8);
    color: white;
}

/* 展开状态的聊天界面 */
.chat-expanded {
    display: none;
    background: #f7f7f7;
    height: 400px;
    border-top: 1px solid #e0e0e0;
    box-shadow: 0 -2px 20px rgba(0,0,0,0.1);
    flex-direction: column;
}

.chat-expanded.show {
    display: flex;
}

.chat-header {
    padding: 15px 20px;
    background: #07c160;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.minimize-btn {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.minimize-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* 消息区域 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f7f7f7;
}

.message {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    animation: fadeInUp 0.3s ease;
}

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

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    margin: 3px 0;
    word-wrap: break-word;
    line-height: 1.4;
    position: relative;
}

.message-time {
    font-size: 11px;
    color: #999;
    margin: 2px 8px;
    text-align: center;
}

/* 自己发送的消息 - 右对齐，绿色气泡 */
.own-message {
    align-items: flex-end;
}

.own-message .message-content {
    background: #07c160;
    color: white;
    border-bottom-right-radius: 6px;
}

.own-message .message-content::after {
    content: '';
    position: absolute;
    right: -6px;
    bottom: 6px;
    width: 0;
    height: 0;
    border-left: 6px solid #07c160;
    border-bottom: 6px solid transparent;
}

.own-message .message-time {
    text-align: right;
}

/* 他人发送的消息 - 左对齐，白色气泡 */
.other-message {
    align-items: flex-start;
}

.other-message .message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.other-message .message-content::after {
    content: '';
    position: absolute;
    left: -6px;
    bottom: 6px;
    width: 0;
    height: 0;
    border-right: 6px solid white;
    border-bottom: 6px solid transparent;
}

.other-message .message-time {
    text-align: left;
}

/* 系统消息 */
.message.system {
    align-items: center;
}

.message.system .message-content {
    background: rgba(0, 0, 0, 0.05);
    color: #666;
    text-align: center;
    border-radius: 12px;
    font-size: 12px;
    padding: 8px 12px;
    max-width: 80%;
}

.message.system .message-content::after {
    display: none;
}

/* 输入区域 */
.chat-input {
    padding: 15px 10px;
    border-top: 1px solid #e0e0e0;
    background: white;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.input-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
}

.message-input {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
    resize: none;
    min-height: 40px;
    max-height: 100px;
    line-height: 1.4;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.message-input:focus {
    border-color: #07c160;
}

.input-tools {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 4px 0;
}

.tool-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.tool-btn:hover {
    background: #f0f0f0;
}

.send-button {
    background: #07c160;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.2s;
    min-width: 60px;
    height: 40px;
    align-self: flex-end;
}

.send-button:hover {
    background: #06ad56;
}

.send-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* 表情选择器 */
.emoji-picker {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    display: none;
    z-index: 1001;
    margin-bottom: 8px;
}

.emoji-picker.show {
    display: block;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.emoji-item {
    font-size: 24px;
    cursor: pointer;
    text-align: center;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.emoji-item:hover {
    background: #f0f0f0;
}

/* 文件上传 */
.file-input {
    display: none;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .chat-expanded {
        height: 350px;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .emoji-picker {
        width: 250px;
    }
    
    .emoji-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* 测试账号占位区域样式 */
.chat-widget.test-placeholder {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: block;
}

.test-placeholder-content {
    background: #e0e0e0;
    padding: 15px 20px;
    border-top: 1px solid #ccc;
    text-align: center;
    color: #666;
}

.placeholder-text {
    font-size: 14px;
    font-weight: 500;
    color: #888;
} 