* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    overflow: hidden;
}

/* 登录页面 */
.login-container, .register-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
}

.login-box, .register-box {
    background: rgba(255,255,255,0.95);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 380px;
    text-align: center;
}

.logo {
    font-size: 48px;
    margin-bottom: 10px;
}

.login-box h1, .register-box h1 {
    margin-bottom: 30px;
    color: #333;
    font-size: 28px;
}

.input-group {
    margin-bottom: 20px;
    text-align: left;
}

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

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

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

.btn-primary, .btn-secondary {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 10px;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

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

.btn-secondary {
    background: #f5f5f5;
    color: #666;
}

.btn-secondary:hover {
    background: #e8e8e8;
    transform: translateY(-1px);
}

.server-info {
    margin-top: 20px;
    font-size: 12px;
    color: #999;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

/* 聊天容器 */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #f8f9fa;
}

/* 聊天头部 */
.chat-header {
    background: white;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    z-index: 10;
    flex-wrap: wrap;
    gap: 10px;
}

.logo-small {
    font-size: 18px;
    font-weight: bold;
    color: #667eea;
}

.room-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f0f2f5;
    padding: 5px 12px;
    border-radius: 20px;
}

#room-select {
    padding: 5px 10px;
    border: none;
    background: transparent;
    font-size: 14px;
    cursor: pointer;
    outline: none;
}

.status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.status-online {
    width: 10px;
    height: 10px;
    background: #4caf50;
    border-radius: 50%;
}

/* 按钮样式 */
.btn-refresh, .btn-history, .btn-logout, .btn-admin {
    padding: 6px 12px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-left: 8px;
    font-size: 12px;
    transition: all 0.2s;
}

.btn-refresh { background: #4caf50; color: white; }
.btn-history { background: #ff9800; color: white; }
.btn-logout { background: #f44336; color: white; }
.btn-admin { background: #9c27b0; color: white; }

.btn-refresh:hover, .btn-history:hover, .btn-logout:hover, .btn-admin:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.admin-badge {
    background: #ff9800;
    color: white;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    margin-left: 5px;
}

/* 聊天主体 */
.chat-main {
    display: flex;
    flex: 1;
    overflow: hidden;
    padding: 15px;
    gap: 15px;
}

.chat-area {
    flex: 1;
    background: white;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* 消息样式 */
.message {
    margin-bottom: 15px;
    animation: fadeIn 0.3s;
}

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

.message-header {
    display: flex;
    gap: 10px;
    margin-bottom: 5px;
    align-items: baseline;
    flex-wrap: wrap;
}

.message-time {
    font-size: 11px;
    color: #999;
}

.message-sender {
    font-weight: bold;
    font-size: 14px;
}

.message-content {
    padding: 8px 12px;
    background: #f0f2f5;
    border-radius: 12px;
    display: inline-block;
    max-width: 80%;
    word-wrap: break-word;
    line-height: 1.5;
}

.message-system {
    text-align: center;
    color: #ff9800;
    font-size: 12px;
    padding: 8px;
    background: #fff3e0;
    border-radius: 8px;
    margin: 10px 0;
}

/* 用户列表 */
.users-area {
    width: 260px;
    background: white;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.users-header {
    padding: 15px;
    border-bottom: 1px solid #e8e8e8;
    font-weight: bold;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.room-count {
    font-size: 12px;
    background: rgba(255,255,255,0.3);
    padding: 2px 8px;
    border-radius: 12px;
}

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

.user-item {
    padding: 10px 12px;
    margin: 5px 0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

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

/* 输入区域 */
.chat-input-area {
    background: white;
    padding: 15px 20px;
    border-top: 1px solid #e8e8e8;
}

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

.emoji-toggle-btn {
    padding: 8px 15px;
    background: #f0f2f5;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

.emoji-panel {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 10px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    width: 380px;
    z-index: 1000;
    display: none;
}

.emoji-header {
    display: flex;
    padding: 10px;
    border-bottom: 1px solid #e8e8e8;
    gap: 8px;
    flex-wrap: wrap;
}

.emoji-category {
    padding: 5px 12px;
    cursor: pointer;
    border-radius: 20px;
    font-size: 13px;
    background: #f5f5f5;
}

.emoji-category.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

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

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

.emoji-item:hover {
    background: #f0f2f5;
    transform: scale(1.1);
}

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

#message-input {
    flex: 1;
    padding: 12px;
    border: 2px solid #e8e8e8;
    border-radius: 12px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
}

#message-input:focus {
    outline: none;
    border-color: #667eea;
}

.btn-send {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: bold;
}

.private-target {
    margin-top: 8px;
    font-size: 12px;
    color: #ff69b4;
    padding: 5px 10px;
    background: #fff0f5;
    border-radius: 8px;
    display: inline-block;
    cursor: pointer;
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
}

.modal-content {
    background: white;
    margin: 5% auto;
    width: 80%;
    max-width: 700px;
    border-radius: 20px;
    max-height: 80%;
    display: flex;
    flex-direction: column;
}

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

.modal-header .close {
    font-size: 28px;
    cursor: pointer;
    color: #999;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.history-message {
    margin-bottom: 15px;
    padding: 12px;
    border-left: 3px solid #667eea;
    background: #f9f9f9;
    border-radius: 8px;
}

/* 公告栏 */
.announcement-bar {
    background: linear-gradient(135deg, #ff9800 0%, #ff5722 100%);
    color: white;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.announcement-icon {
    font-size: 20px;
}

.announcement-content {
    flex: 1;
    font-size: 14px;
}

.announcement-close {
    cursor: pointer;
    padding: 0 8px;
    font-size: 18px;
}

/* 折叠菜单 */
.user-area {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.menu-dropdown {
    position: relative;
    display: inline-block;
}

.menu-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 5px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
}

.menu-content {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    min-width: 140px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    border-radius: 8px;
    z-index: 1000;
    margin-top: 5px;
}

.menu-content button,
.menu-content a {
    display: block;
    width: 100%;
    padding: 8px 12px;
    text-align: left;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    text-decoration: none;
    color: #333;
}

.menu-content button:hover,
.menu-content a:hover {
    background: #f0f0f0;
}

.menu-content.show {
    display: block;
}

/* 加载动画 */
.loading-spinner {
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 移动端适配 */
@media (max-width: 768px) {
    .login-box, .register-box {
        width: 90%;
        padding: 30px 20px;
    }
    
    .chat-main {
        flex-direction: column;
        padding: 10px;
    }
    
    .users-area {
        width: 100%;
        height: 200px;
        order: -1;
    }
    
    .chat-area {
        min-height: 300px;
    }
    
    .input-wrapper {
        flex-direction: column;
    }
    
    .btn-send {
        width: 100%;
    }
    
    .chat-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .room-selector {
        justify-content: center;
    }
    
    .emoji-panel {
        width: 300px;
        right: 0;
        left: auto;
    }
    
    .emoji-content {
        grid-template-columns: repeat(7, 1fr);
    }
}

/* 滚动条 */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

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

/* 折叠菜单样式 */
.function-wrapper {
    position: relative;
    display: inline-block;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(102, 126, 234, 0.1);
    padding: 5px 12px;
    border-radius: 20px;
}

.fold-icon {
    cursor: pointer;
    font-size: 12px;
    color: #667eea;
    padding: 2px 8px;
    border-radius: 15px;
    transition: background 0.2s;
}

.fold-icon:hover {
    background: rgba(102, 126, 234, 0.2);
}

.function-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    padding: 8px;
    min-width: 150px;
    z-index: 1000;
    flex-direction: column;
    gap: 4px;
    display: none;
}

.function-menu.show {
    display: flex;
}

.func-btn {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: #f5f5f5;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    text-align: left;
    transition: all 0.2s;
    text-decoration: none;
    color: #333;
}

.func-btn:hover {
    background: #667eea;
    color: white;
    transform: translateX(3px);
}

.logout-btn:hover {
    background: #f44336;
    color: white;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .function-menu {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0;
        border-radius: 20px 20px 0 0;
        max-height: 60vh;
        overflow-y: auto;
    }
}

/* 折叠菜单样式 */
.user-area {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.menu-dropdown {
    position: relative;
    display: inline-block;
}

.menu-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 5px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
}

.menu-content {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    min-width: 140px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    border-radius: 8px;
    z-index: 1000;
    margin-top: 5px;
}

.menu-content.show {
    display: block;
}

.menu-content button,
.menu-content a {
    display: block;
    width: 100%;
    padding: 8px 12px;
    text-align: left;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    text-decoration: none;
    color: #333;
}

.menu-content button:hover,
.menu-content a:hover {
    background: #f0f0f0;
}

/* 表情面板容器 */
.emoji-panel-container {
    position: relative;
    display: inline-block;
}

.emoji-toggle-btn {
    padding: 8px 15px;
    background: #f0f2f5;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.emoji-panel {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 10px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    width: 380px;
    z-index: 1000;
    display: none;
}

.emoji-header {
    display: flex;
    padding: 10px;
    border-bottom: 1px solid #e8e8e8;
    gap: 8px;
    flex-wrap: wrap;
}

.emoji-category {
    padding: 5px 12px;
    cursor: pointer;
    border-radius: 20px;
    font-size: 13px;
    background: #f5f5f5;
}

.emoji-category.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

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

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

.emoji-item:hover {
    background: #f0f2f5;
    transform: scale(1.1);
}

/* 折叠菜单样式 */
.user-area {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.menu-dropdown {
    position: relative;
    display: inline-block;
}

.menu-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 5px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
}

.menu-content {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    min-width: 140px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    border-radius: 8px;
    z-index: 1000;
    margin-top: 5px;
}

.menu-content.show {
    display: block;
}

.menu-content button,
.menu-content a {
    display: block;
    width: 100%;
    padding: 8px 12px;
    text-align: left;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    text-decoration: none;
    color: #333;
    border-radius: 5px;
}

.menu-content button:hover,
.menu-content a:hover {
    background: #f0f0f0;
}
