/* public/style.css */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    overflow: hidden;
}

/* 登录界面 */
.login-container {
    width: 100%;
    max-width: 400px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    padding: 40px;
    animation: fadeInUp 0.5s ease;
}

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

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    color: #333;
    font-size: 28px;
    margin-bottom: 10px;
}

.login-header p {
    color: #666;
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.3s;
    outline: none;
}

.form-group input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.login-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.login-btn:active {
    transform: translateY(0);
}

/* 聊天室界面 */
.chat-container {
    width: 100%;
    max-width: 800px;
    height: 90vh;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: fadeInUp 0.5s ease;
}

.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.chat-header h2 {
    font-size: 22px;
    font-weight: 600;
}

.chat-header .room-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.chat-header .room-info span {
    font-size: 14px;
    opacity: 0.9;
}

.chat-header .leave-btn {
    padding: 8px 16px;
    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;
}

.chat-header .leave-btn:hover {
    background: rgba(255,255,255,0.3);
}

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

.chat-header .theme-btn {
    padding: 8px 12px;
    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: 16px;
    transition: all 0.3s;
}

.chat-header .theme-btn:hover {
    background: rgba(255,255,255,0.3);
}

.chat-box {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: linear-gradient(180deg, #f5f7fa 0%, #e4e8ed 100%);
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

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

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

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

.chat-box::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

.message {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: messageSlide 0.3s ease;
}

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

.message.system {
    align-self: center;
    background: rgba(0,0,0,0.06);
    color: #666;
    font-size: 12px;
    padding: 8px 16px;
    border-radius: 20px;
}

.message.mine {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.message.others {
    align-self: flex-start;
    background: white;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.message .username {
    font-size: 12px;
    font-weight: 600;
    opacity: 0.9;
}

.message.others .username {
    color: #667eea;
}

.message.mine .username {
    color: rgba(255,255,255,0.9);
}

.message .content {
    display: block;
    margin-top: 4px;
}

.message .time {
    font-size: 11px;
    opacity: 0.7;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.input-area {
    display: flex;
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
    gap: 10px;
}

#msg-input {
    flex: 1;
    padding: 12px 18px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 14px;
    transition: all 0.3s;
    outline: none;
}

#msg-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#send-btn {
    padding: 12px 28px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
}

#send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

#send-btn:active {
    transform: translateY(0);
}

/* 隐藏类 */
.hidden {
    display: none !important;
}

/* 聊天内容区域 */
.chat-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* 用户列表样式 */
.user-list {
    width: 200px;
    background: #f8f9fa;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.user-list-header {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-list-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.user-list-header .user-count {
    background: #667eea;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}

.user-list-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.user-list-content::-webkit-scrollbar {
    width: 4px;
}

.user-list-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.user-list-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

.user-item {
    padding: 10px;
    margin-bottom: 8px;
    background: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
}

.user-item:hover {
    background: #f0f0f0;
    transform: translateX(2px);
}

.user-item.is-me {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border-left: 3px solid #667eea;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

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

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

.user-status {
    font-size: 11px;
    color: #999;
}

.user-status.online {
    color: #4caf50;
}

.user-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4caf50;
    margin-right: 4px;
}

/* 夜间模式样式 */
body.dark-mode {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

body.dark-mode .login-container {
    background: #2d2d44;
}

body.dark-mode .login-header h1 {
    color: #e0e0e0;
}

body.dark-mode .login-header p {
    color: #a0a0a0;
}

body.dark-mode .form-group label {
    color: #e0e0e0;
}

body.dark-mode .form-group input {
    background: #3d3d5c;
    border-color: #4d4d6c;
    color: #e0e0e0;
}

body.dark-mode .form-group input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

body.dark-mode .chat-container {
    background: #2d2d44;
}

body.dark-mode .user-list {
    background: #252538;
    border-right-color: #3d3d5c;
}

body.dark-mode .user-list-header {
    border-bottom-color: #3d3d5c;
}

body.dark-mode .user-list-header h3 {
    color: #e0e0e0;
}

body.dark-mode .user-item {
    background: #3d3d5c;
}

body.dark-mode .user-item:hover {
    background: #4d4d6c;
}

body.dark-mode .user-item.is-me {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
}

body.dark-mode .user-name {
    color: #e0e0e0;
}

body.dark-mode .user-status {
    color: #a0a0a0;
}

body.dark-mode .chat-box {
    background: linear-gradient(180deg, #252538 0%, #1e1e30 100%);
}

body.dark-mode .message.system {
    background: rgba(255, 255, 255, 0.06);
    color: #a0a0a0;
}

body.dark-mode .message.others {
    background: #3d3d5c;
    color: #e0e0e0;
}

body.dark-mode .message.others .username {
    color: #667eea;
}

body.dark-mode .input-area {
    background: #252538;
    border-top-color: #3d3d5c;
}

body.dark-mode #msg-input {
    background: #3d3d5c;
    border-color: #4d4d6c;
    color: #e0e0e0;
}

body.dark-mode #msg-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

body.dark-mode .user-list-content::-webkit-scrollbar-track {
    background: #252538;
}

body.dark-mode .user-list-content::-webkit-scrollbar-thumb {
    background: #4d4d6c;
}

body.dark-mode .chat-box::-webkit-scrollbar-track {
    background: #252538;
}

body.dark-mode .chat-box::-webkit-scrollbar-thumb {
    background: #4d4d6c;
}

body.dark-mode .chat-box::-webkit-scrollbar-thumb:hover {
    background: #5d5d7c;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .user-list {
        width: 150px;
    }
    
    .chat-header .room-info {
        display: none;
    }
}

@media (max-width: 600px) {
    .user-list {
        display: none;
    }
    
    .chat-header h2 {
        font-size: 18px;
    }
}