:root {
    --primary: #0084ff;
    --primary-dark: #0073e6;
    --bg: #f0f2f5;
    --surface: #ffffff;
    --text: #1a1a1a;
    --text-secondary: #65676b;
    --border: #e4e6eb;
    --hover: #f2f2f2;
    --radius: 8px;
    --shadow: 0 2px 12px rgba(0,0,0,0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans SC', sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

/* Qt风格按钮 */
button, .btn {
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: #d8dadf;
}

/* 登录页面 */
#loginPage {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    width: 400px;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--primary);
}

.input-group {
    margin-bottom: 16px;
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color 0.2s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-group {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.btn-group button {
    flex: 1;
    padding: 12px;
}

/* 聊天页面布局 */
#chatPage {
    display: none;
    height: 100vh;
}

.sidebar {
    width: 280px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h3 {
    font-size: 16px;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
}

.section-title {
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.room-item, .friend-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.room-item:hover, .friend-item:hover {
    background: var(--hover);
}

.room-item.active, .friend-item.active {
    background: #e7f3ff;
}

.room-name, .friend-name {
    font-weight: 500;
}

.room-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.friend-avatar img, .small-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

/* 聊天主区域 */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--surface);
}

.chat-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h2 {
    font-size: 18px;
}

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

.message {
    margin-bottom: 16px;
    max-width: 70%;
}

.message.self {
    margin-left: auto;
}

.message.other {
    margin-right: auto;
}

.msg-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 12px;
}

.msg-user {
    font-weight: 600;
    color: var(--text-secondary);
}

.msg-time {
    color: var(--text-secondary);
}

.msg-text {
    padding: 10px 14px;
    border-radius: 16px;
    line-height: 1.4;
}

.message.self .msg-text {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.other .msg-text {
    background: var(--border);
    border-bottom-left-radius: 4px;
}

.msg-image {
    max-width: 300px;
    border-radius: var(--radius);
}

/* 输入区域 */
.input-area {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
}

.input-area input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 20px;
    font-size: 14px;
}

.input-area input:focus {
    outline: none;
    border-color: var(--primary);
}

.input-area button {
    padding: 12px 24px;
}

/* 模态框 */
.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-content {
    background: white;
    padding: 24px;
    border-radius: 16px;
    width: 400px;
    max-width: 90%;
}

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

.modal-header h3 {
    font-size: 18px;
}

.close-modal {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
}

.search-results {
    max-height: 300px;
    overflow-y: auto;
    margin-top: 16px;
}

.search-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.add-friend-btn {
    padding: 6px 12px;
    font-size: 12px;
}

/* 响应式 */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: absolute;
        z-index: 100;
        height: 100%;
        transform: translateX(-100%);
        transition: transform 0.3s;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
}
