* {
    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;
}

/* 登录/注册页 */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-box h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
}

.login-box input {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
}

.login-box button {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
}

.login-box button:hover {
    opacity: 0.9;
}

.error-msg {
    background: #fee;
    color: #c33;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 16px;
    text-align: center;
}

.success-msg {
    background: #efe;
    color: #3c3;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 16px;
    text-align: center;
}

/* 聊天主界面 */
.app-container {
    display: flex;
    height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    background: white;
}

/* 侧边栏 */
.sidebar {
    width: 300px;
    background: #2c3e50;
    color: white;
    display: flex;
    flex-direction: column;
}

.user-info {
    padding: 20px;
    background: #1a252f;
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 48px;
    height: 48px;
    background: #667eea;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.user-detail {
    flex: 1;
}

.user-detail strong {
    display: block;
    font-size: 16px;
}

.user-detail small {
    font-size: 12px;
    opacity: 0.7;
}

.logout-btn {
    color: #ff6b6b;
    text-decoration: none;
    font-size: 14px;
}

/* Tab 切换 */
.tabs {
    display: flex;
    border-bottom: 1px solid #34495e;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    color: #bdc3c7;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.tab-btn.active {
    color: white;
    border-bottom: 2px solid #667eea;
}

.tab-content {
    flex: 1;
    overflow-y: auto;
    display: none;
}

.tab-content.active {
    display: block;
}

/* 好友/群聊列表 */
.friends-list, .groups-list, .requests-list {
    padding: 12px;
}

.section-title {
    font-size: 12px;
    opacity: 0.6;
    margin-bottom: 8px;
    padding-left: 8px;
}

.friend-item, .group-item, .request-item {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.2s;
    margin-bottom: 2px;
}

.friend-item:hover, .group-item:hover, .request-item:hover {
    background: #34495e;
}

.friend-item.active, .group-item.active {
    background: #667eea;
}

.friend-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.friend-status.online {
    background: #2ecc71;
}

.friend-status.offline {
    background: #7f8c8d;
}

.friend-name, .group-name {
    flex: 1;
    font-size: 14px;
}

.request-badge {
    background: #e74c3c;
    color: white;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 11px;
}

/* 搜索框 */
.search-box {
    padding: 12px;
    border-bottom: 1px solid #34495e;
}

.search-box input {
    width: 100%;
    padding: 8px 12px;
    background: #34495e;
    border: none;
    border-radius: 20px;
    color: white;
    outline: none;
}

.search-box input::placeholder {
    color: #95a5a6;
}

.search-results {
    padding: 8px;
}

.search-result-item {
    padding: 8px 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.search-result-item:hover {
    background: #34495e;
}

.add-friend-btn {
    background: #667eea;
    border: none;
    color: white;
    padding: 4px 12px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 12px;
}

/* 聊天区域 */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    color: #333;
}

.group-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}

.icon-btn:hover {
    background: #e0e0e0;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f5f5f5;
}

.message {
    margin-bottom: 16px;
    display: flex;
}

.own-message {
    justify-content: flex-end;
}

.message-author {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
    padding-left: 12px;
}

.message-content {
    max-width: 70%;
    background: white;
    padding: 10px 14px;
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.own-message .message-content {
    background: #667eea;
    color: white;
}

.message-text {
    word-wrap: break-word;
    line-height: 1.4;
}

.message-time {
    font-size: 10px;
    color: #999;
    margin-top: 4px;
    text-align: right;
}

.own-message .message-time {
    color: rgba(255,255,255,0.7);
}

.voice-message {
    display: flex;
    align-items: center;
    gap: 10px;
}

.voice-message audio {
    max-width: 200px;
    height: 36px;
}

/* 输入区域 */
.input-area {
    padding: 16px;
    border-top: 1px solid #eee;
    background: white;
}

#message-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    resize: vertical;
    font-family: inherit;
}

.input-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.voice-btn, .send-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

.voice-btn {
    background: #f0f0f0;
    color: #333;
}

.voice-btn:active {
    background: #ff6b6b;
    color: white;
}

.send-btn {
    background: #667eea;
    color: white;
    flex: 1;
}

#recording-hint {
    margin-top: 10px;
    padding: 8px;
    background: #ff6b6b;
    color: white;
    border-radius: 8px;
    text-align: center;
    font-size: 14px;
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

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

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

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
}

.modal-body {
    padding: 16px;
}

.modal-body input, .modal-body textarea {
    width: 100%;
    padding: 10px;
    margin-bottom: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.modal-body button {
    width: 100%;
    padding: 10px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.member-list {
    max-height: 300px;
    overflow-y: auto;
}

.member-item {
    padding: 10px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.invite-btn {
    background: #667eea;
    border: none;
    color: white;
    padding: 4px 12px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 12px;
}