/* 全局样式 */ * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; display: flex; justify-content: center; align-items: center; padding: 20px; } /* 登录界面 */ .login-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.5); display: flex; justify-content: center; align-items: center; z-index: 1000; backdrop-filter: blur(5px); } .login-box { background: white; padding: 40px; border-radius: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); text-align: center; min-width: 350px; max-width: 90%; animation: fadeInUp 0.5s; } .login-box h2 { margin-bottom: 10px; color: #333; font-size: 24px; } .login-desc { color: #666; margin-bottom: 30px; font-size: 14px; } .login-box input { width: 100%; padding: 14px 16px; margin: 10px 0; border: 2px solid #e0e0e0; border-radius: 10px; font-size: 14px; transition: all 0.3s; outline: none; } .login-box input:focus { border-color: #667eea; box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1); } .login-box button { width: 100%; padding: 14px; margin-top: 20px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border: none; border-radius: 10px; cursor: pointer; font-size: 16px; font-weight: 600; transition: all 0.3s; } .login-box button:hover { transform: translateY(-2px); box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3); } .login-box button:active { transform: translateY(0); } /* 主容器 */ .container { width: 100%; max-width: 1400px; height: 85vh; min-height: 600px; background: white; border-radius: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); display: flex; overflow: hidden; animation: fadeIn 0.5s; } /* 侧边栏 */ .sidebar { width: 300px; background: #f8f9fa; border-right: 1px solid #e0e0e0; display: flex; flex-direction: column; } .sidebar-header { padding: 25px 20px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; } .sidebar-header h2 { font-size: 18px; margin-bottom: 12px; font-weight: 600; } .current-user { display: flex; align-items: center; font-size: 14px; opacity: 0.95; padding: 8px 12px; background: rgba(255, 255, 255, 0.2); border-radius: 8px; } .status-dot { width: 10px; height: 10px; background: #4caf50; border-radius: 50%; margin-right: 10px; animation: pulse 2s infinite; } /* 用户列表 */ .user-list { flex: 1; overflow-y: auto; padding: 15px; } .empty-users { text-align: center; color: #999; padding: 40px 20px; font-size: 14px; } .user-item { padding: 14px 16px; margin: 8px 0; background: white; border-radius: 12px; cursor: pointer; transition: all 0.3s; display: flex; align-items: center; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05); } .user-item:hover { background: #e3f2fd; transform: translateX(5px); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); } .user-item.active { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4); } .user-item .status { width: 8px; height: 8px; background: #4caf50; border-radius: 50%; margin-right: 12px; flex-shrink: 0; } .user-item.active .status { background: #fff; } .user-item .user-name { flex: 1; } /* 未读消息徽章 */ .unread-badge { margin-left: auto; background: #f44336; color: white; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; min-width: 18px; text-align: center; flex-shrink: 0; } .user-item.active .unread-badge { background: rgba(255, 255, 255, 0.3); } /* 聊天区域 */ .chat-area { flex: 1; display: flex; flex-direction: column; background: #fafafa; } .chat-header { padding: 20px 25px; background: white; border-bottom: 1px solid #e0e0e0; display: flex; justify-content: space-between; align-items: center; } .chat-header h3 { font-size: 18px; color: #333; font-weight: 600; } .logout-btn { padding: 8px 20px; background: #f44336; color: white; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; transition: all 0.3s; } .logout-btn:hover { background: #d32f2f; transform: translateY(-2px); } /* 消息区域 */ .messages { flex: 1; padding: 25px; overflow-y: auto; display: flex; flex-direction: column; } .welcome-screen { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; color: #999; } .welcome-icon { font-size: 80px; margin-bottom: 20px; animation: bounce 2s infinite; } .welcome-screen p { font-size: 16px; } /* 消息样式 */ .message { margin: 12px 0; display: flex; animation: slideIn 0.3s ease-out; } .message.sent { justify-content: flex-end; } .message.received { justify-content: flex-start; } .message-wrapper { max-width: 65%; display: flex; flex-direction: column; } .message-sender { font-size: 12px; font-weight: 600; margin-bottom: 4px; padding: 0 4px; opacity: 0.8; letter-spacing: 0.3px; } .message.sent .message-sender { text-align: right; color: #667eea; } .message.received .message-sender { text-align: left; color: #555; } .message-content { padding: 12px 16px; border-radius: 18px; word-wrap: break-word; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); position: relative; } .message.received .message-content { background: white; color: #333; border-bottom-left-radius: 4px; } .message.sent .message-content { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border-bottom-right-radius: 4px; } .message-text { font-size: 15px; line-height: 1.5; margin-bottom: 6px; } .message-info { font-size: 11px; opacity: 0.7; text-align: right; } /* 输入区域 */ .input-area { padding: 20px 25px; background: white; border-top: 1px solid #e0e0e0; display: flex; gap: 12px; align-items: center; } .input-area input { flex: 1; padding: 14px 18px; border: 2px solid #e0e0e0; border-radius: 25px; font-size: 15px; outline: none; transition: all 0.3s; } .input-area input:focus { border-color: #667eea; box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1); } .input-area input:disabled { background: #f5f5f5; cursor: not-allowed; } .input-area button { padding: 14px 32px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border: none; border-radius: 25px; cursor: pointer; font-size: 15px; font-weight: 600; transition: all 0.3s; white-space: nowrap; } .input-area button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 16px rgba(102, 126, 234, 0.3); } .input-area button:active:not(:disabled) { transform: translateY(0); } .input-area button:disabled { opacity: 0.5; cursor: not-allowed; } /* 滚动条样式 */ .user-list::-webkit-scrollbar, .messages::-webkit-scrollbar { width: 6px; } .user-list::-webkit-scrollbar-track, .messages::-webkit-scrollbar-track { background: transparent; } .user-list::-webkit-scrollbar-thumb, .messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; } .user-list::-webkit-scrollbar-thumb:hover, .messages::-webkit-scrollbar-thumb:hover { background: #999; } /* 工具类 */ .hidden { display: none !important; } /* 动画 */ @keyframes fadeIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } } @keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } } @keyframes slideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } } @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } } @keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } } /* 响应式设计 */ @media (max-width: 768px) { body { padding: 0; } .container { height: 100vh; border-radius: 0; max-width: 100%; } .sidebar { width: 250px; } .login-box { min-width: 300px; padding: 30px 25px; } .message-wrapper { max-width: 80%; } .input-area { padding: 15px; } .input-area button { padding: 14px 24px; } } @media (max-width: 480px) { .sidebar { position: absolute; left: -250px; height: 100%; z-index: 100; transition: left 0.3s; } .sidebar.show { left: 0; } .chat-header h3 { font-size: 16px; } .logout-btn { padding: 6px 16px; font-size: 13px; } } /* 文件和多媒体样式 */ .attach-btn, .voice-btn { padding: 14px 18px; background: #f5f5f5; color: #666; border: none; border-radius: 50%; cursor: pointer; font-size: 18px; transition: all 0.3s; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; } .attach-btn:hover:not(:disabled), .voice-btn:hover:not(:disabled) { background: #e0e0e0; transform: scale(1.1); } .attach-btn:disabled, .voice-btn:disabled { opacity: 0.5; cursor: not-allowed; } /* 文件消息样式 */ .message-file { display: flex; align-items: center; gap: 12px; padding: 8px; background: rgba(255, 255, 255, 0.1); border-radius: 12px; margin-bottom: 6px; } .message.received .message-file { background: #f5f5f5; } .file-icon { font-size: 32px; flex-shrink: 0; } .file-info { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; } .file-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .file-size { font-size: 12px; opacity: 0.7; } .download-btn { padding: 8px 16px; background: rgba(255, 255, 255, 0.2); color: inherit; border: 1px solid rgba(255, 255, 255, 0.3); border-radius: 8px; cursor: pointer; font-size: 13px; transition: all 0.3s; flex-shrink: 0; } .message.received .download-btn { background: white; color: #667eea; border-color: #667eea; } .download-btn:hover { transform: scale(1.05); opacity: 0.9; } /* 图片消息样式 */ .message-image { max-width: 300px; max-height: 300px; border-radius: 12px; cursor: pointer; transition: all 0.3s; display: block; margin-bottom: 8px; } .message-image:hover { transform: scale(1.02); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); } /* 视频消息样式 */ .message-video { max-width: 400px; max-height: 300px; border-radius: 12px; display: block; margin-bottom: 8px; } /* 音频消息样式 */ .message-audio { width: 300px; margin-bottom: 8px; } /* 语音消息样式 */ .message-voice { display: flex; align-items: center; gap: 12px; padding: 8px; background: rgba(255, 255, 255, 0.1); border-radius: 12px; margin-bottom: 6px; } .message.received .message-voice { background: #f5f5f5; } .voice-icon { font-size: 24px; flex-shrink: 0; } .voice-audio { flex: 1; height: 32px; } .voice-duration { font-size: 12px; opacity: 0.7; flex-shrink: 0; } /* 响应式调整 */ @media (max-width: 768px) { .message-image { max-width: 200px; max-height: 200px; } .message-video { max-width: 280px; max-height: 200px; } .message-audio { width: 220px; } .attach-btn, .voice-btn { width: 42px; height: 42px; font-size: 16px; } }