* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    line-height: 1.6;
    background-color: #f5f5f5;
}

.container {
    max-width: 600px;
    margin: 50px auto;
    padding: 20px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
}

.join-room {
    display: flex;
    gap: 10px;
}

button {
    padding: 10px 20px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

button:hover {
    background-color: #0056b3;
}

input[type="text"] {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    flex: 1;
}

.chat-container {
    display: flex;
    width: 100%;
    height: 100vh;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.chat-sidebar {
    width: 250px;
    height: 100%;
    background: linear-gradient(135deg, #1976d2 0%, #2196f3 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    position: relative;
    z-index: 100;
}

.chat-sidebar.hidden {
    transform: translateX(-100%);
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
}

.user-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.user-list-header h3 {
    margin: 0;
    font-size: 16px;
    color: #ffffff;
    font-weight: 600;
}

.toggle-list {
    background: none;
    border: none;
    font-size: 16px;
    color: #666;
    cursor: pointer;
    padding: 5px;
    transition: transform 0.3s ease;
}

.toggle-list:hover {
    color: #333;
}

.user-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
}

.user-list.collapsed {
    max-height: 0;
    overflow: hidden;
}

.user-item {
    display: flex;
    align-items: center;
    padding: 8px;
    border-radius: 8px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.1);
    transition: background-color 0.3s ease;
}

.user-item:hover {
    background: rgba(255, 255, 255, 0.2);
}

.user-item.online {
    background: rgba(255, 255, 255, 0.15);
}

.user-item.offline {
    opacity: 0.7;
}

.user-item.online:hover {
    background-color: #e6f3ff;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 16px;
    background: linear-gradient(135deg, #1976d2 0%, #2196f3 100%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
    margin-right: 10px;
    order: 1;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 14px;
    background: linear-gradient(135deg, #1976d2 0%, #2196f3 100%);
    margin-right: 10px;
    flex-shrink: 0;
}

.user-name {
    flex: 1;
    font-size: 14px;
    color: #ffffff;
    margin-right: 10px;
}

.user-status {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    margin-left: auto;
    white-space: nowrap;
}

.user-item.online .user-status {
    color: #a5d6a7;
}

.user-item.offline .user-status {
    color: rgba(255, 255, 255, 0.5);
}

/* 添加"自己"状态的样式 */
.user-item .user-status:contains("自己") {
    color: #007bff;
    font-weight: bold;
}

.avatar:hover {
    transform: scale(1.05);
}

.message-header {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}

.sender-name {
    font-weight: 600;
    font-size: 14px;
    color: #1976d2;
    margin-right: 8px;
    order: 2;
}

.message.sent .sender-name {
    color: rgba(255, 255, 255, 0.9);
}

.message.received .sender-name {
    color: #1976d2;
}

.chat-main {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #f5f9ff;
    overflow: hidden;
    min-width: 0;
}

.chat-sidebar.hidden + .chat-main {
    margin-left: 0;
}

.chat-header {
    padding: 15px 20px;
    background: linear-gradient(135deg, #1976d2 0%, #2196f3 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.chat-header h2 {
    margin: 0;
    font-size: 18px;
    color: #ffffff;
    font-weight: 600;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f5f9ff;
}

/* 自定义滚动条样式 */
.messages::-webkit-scrollbar {
    width: 8px;
}

.messages::-webkit-scrollbar-track {
    background: #e3f2fd;
    border-radius: 4px;
}

.messages::-webkit-scrollbar-thumb {
    background: #90caf9;
    border-radius: 4px;
}

.messages::-webkit-scrollbar-thumb:hover {
    background: #64b5f6;
}

.message {
    margin-bottom: 15px;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.message.sent {
    align-items: flex-end;
}

.message.received {
    align-items: flex-start;
}

.message-content {
    max-width: 90%;
    min-width: 30%;
    padding: 8px 12px;
    margin: 0 5px;
    word-break: break-word;
}

.message.sent .message-content {
    margin-right: 5px;
    background: linear-gradient(135deg, #1976d2 0%, #2196f3 100%);
    color: white;
}

.message.received .message-content {
    margin-left: 5px;
    background-color: #ffffff;
}

.message-time {
    font-size: 12px;
    color: #90caf9;
    margin-left: auto;
    white-space: nowrap;
    order: 3;
}

.message.sent .message-time {
    color: rgba(255, 255, 255, 0.8);
    order: 3;
    margin-left: auto;
}

.message.received .message-time {
    color: #90caf9;
}

.message-text {
    font-size: 14px;
    line-height: 1.4;
    word-break: break-word;
    white-space: pre-wrap;
}

.message img {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 4px;
}

.input-area {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: linear-gradient(135deg, #1976d2, #2196f3);
    border-radius: 8px;
    margin: 10px;
}

.input-area input[type="text"] {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    font-size: 14px;
    transition: all 0.3s ease;
}

.input-area input[type="text"]::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.input-area input[type="text"]:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.2);
}

.input-area button {
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.input-area button:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.4);
}

.emoji-picker {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 100%;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    padding: 10px;
    margin-bottom: 10px;
}

.emoji-categories {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
    border-bottom: 1px solid #e3f2fd;
    padding-bottom: 10px;
    background-color: #5f9ea0;
    padding: 10px;
    border-radius: 8px 8px 0 0;
}

.emoji-category {
    padding: 5px 10px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    cursor: pointer;
    font-size: 14px;
    color: #ffffff;
    transition: all 0.3s ease;
    border-radius: 4px;
}

.emoji-category.active {
    background: rgba(255, 255, 255, 0.2);
    border-bottom: 2px solid #ffffff;
}

.emoji-category:hover {
    background: rgba(255, 255, 255, 0.3);
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 5px;
    max-height: 200px;
    overflow-y: auto;
}

.emoji-button {
    width: 30px;
    height: 30px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.emoji-button:hover {
    background-color: #e3f2fd;
}

.input-area .emoji-button {
    width: 40px;
    height: 40px;
    font-size: 24px;
}

.mention {
    background-color: #e6f3ff;
    color: #0066cc;
    padding: 2px 4px;
    border-radius: 4px;
    font-weight: bold;
}

.toggle-sidebar {
    background: none;
    border: none;
    font-size: 20px;
    color: #666;
    cursor: pointer;
    padding: 5px;
    margin-right: 10px;
}

.toggle-sidebar:hover {
    color: #333;
}

/* 移动端响应式布局 */
@media screen and (max-width: 768px) {
    .chat-container {
        height: 100vh;
    }

    .chat-sidebar {
        width: 80%;
        max-width: 300px;
    }

    .messages {
        padding: 10px;
        margin-bottom: 60px;
    }

    .input-area {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0;
        border-radius: 0;
        padding: 10px;
        z-index: 100;
    }

    .chat-header {
        padding: 10px 15px;
    }

    .chat-header h2 {
        font-size: 16px;
    }

    .input-area input[type="text"] {
        padding: 8px 12px;
    }

    .input-area button {
        padding: 8px 12px;
    }

    .emoji-picker {
        width: 100%;
        max-height: 200px;
    }

    .emoji-grid {
        grid-template-columns: repeat(8, 1fr);
    }

    .emoji-categories {
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 5px;
    }

    .emoji-category {
        padding: 5px 8px;
        font-size: 12px;
    }

    .user-item {
        padding: 6px;
    }

    .avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .user-avatar {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .user-name {
        font-size: 12px;
    }

    .user-status {
        font-size: 10px;
    }

    .user-list-header {
        padding: 8px 10px;
    }

    .user-list-header h3 {
        font-size: 14px;
    }

    .toggle-list {
        font-size: 14px;
    }

    .message-content {
        max-width: 85%;
        padding: 8px 12px;
    }

    .message.sent .message-content {
        margin-left: auto;
    }

    .message.received .message-content {
        margin-right: auto;
    }

    .message-text {
        word-break: break-word;
        overflow-wrap: break-word;
        white-space: pre-wrap;
    }

    .message-image {
        max-width: 100%;
        max-height: 200px;
        object-fit: contain;
    }

    .message-time {
        font-size: 10px;
    }
}

/* 添加触摸设备优化 */
@media (hover: none) {
    .user-item:hover {
        background-color: transparent;
    }

    .user-item.online:hover {
        background-color: #f0f8ff;
    }

    .emoji-button:hover {
        background-color: transparent;
    }
}

.image-preview {
    position: relative;
    margin-bottom: 10px;
    max-width: 200px;
}

.image-preview img {
    max-width: 100%;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.image-preview button {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ff4444;
    color: white;
    border: none;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.image-preview button:hover {
    background: #ff0000;
}

/* 移动端样式调整 */
@media screen and (max-width: 768px) {
    .image-preview {
        max-width: 150px;
    }
}

.message-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    margin-top: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

@media (max-width: 768px) {
    .message-image {
        max-height: 200px;
    }
}

.typing-indicator {
    padding: 5px 15px;
    font-size: 12px;
    color: #666;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    margin: 0 15px 5px;
    min-height: 20px;
}

@media screen and (max-width: 768px) {
    .typing-indicator {
        font-size: 11px;
        padding: 4px 12px;
        margin: 0 10px 4px;
    }
}

.image-path {
    display: inline-block;
    padding: 4px 8px;
    background-color: #f0f0f0;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
    color: #666;
    word-break: break-all;
}

@media (max-width: 768px) {
    .image-path {
        font-size: 0.8em;
        padding: 3px 6px;
    }
}

.file-link {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    background-color: #f0f0f0;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
    margin-top: 8px;
    transition: background-color 0.2s;
}

.file-link:hover {
    background-color: #e0e0e0;
}

.file-icon {
    font-size: 1.2em;
    margin-right: 8px;
}

.file-name {
    font-size: 0.9em;
    word-break: break-all;
}

@media (max-width: 768px) {
    .file-link {
        padding: 6px 10px;
    }
    
    .file-icon {
        font-size: 1.1em;
    }
    
    .file-name {
        font-size: 0.8em;
    }
}
