* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-top: 20px;
    margin-bottom: 20px;
}

header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.header-top h1 {
    color: #4a5568;
    font-size: 2.5rem;
    margin: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info span {
    font-weight: 600;
    color: #4a5568;
}

.logout-btn {
    padding: 8px 16px;
    background: #f56565;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s;
}

.logout-btn:hover {
    background: #e53e3e;
}

.header-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status {
    font-size: 1.1rem;
    padding: 8px 16px;
    border-radius: 20px;
    display: inline-block;
}

.status.connected {
    background: #48bb78;
    color: white;
}

.status.disconnected {
    background: #f56565;
    color: white;
}

.connection-info {
    color: #718096;
    font-size: 0.9rem;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

.message-section, .file-section {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

h2 {
    color: #4a5568;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

h3 {
    color: #718096;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.clear-btn {
    padding: 6px 12px;
    background: #f56565;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.3s;
}

.clear-btn:hover {
    background: #e53e3e;
}

.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

#messageInput {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

#messageInput:focus {
    outline: none;
    border-color: #667eea;
}

button, .upload-btn {
    padding: 12px 25px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s;
}

button:hover, .upload-btn:hover {
    background: #5a6fd8;
}

.upload-area {
    margin-bottom: 20px;
}

#fileInput {
    display: none;
}

.upload-btn {
    display: inline-block;
    margin-bottom: 10px;
}

#fileInfo {
    display: block;
    color: #718096;
    font-size: 0.9rem;
}

.messages-list, .files-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    padding: 15px;
}

.message-item {
    padding: 12px;
    margin-bottom: 10px;
    background: #edf2f7;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.message-meta {
    font-size: 0.8rem;
    color: #718096;
    margin-bottom: 5px;
}

.message-text {
    word-wrap: break-word;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 2px 4px;
    border-radius: 3px;
}

.message-text:hover {
    background-color: rgba(102, 126, 234, 0.1);
}

/* 移动设备触摸反馈 */
.message-text:active {
    background-color: rgba(102, 126, 234, 0.2);
    transform: scale(0.98);
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .message-text {
        -webkit-tap-highlight-color: transparent;
        user-select: none;
        -webkit-user-select: none;
    }
    
    .message-text:active {
        background-color: rgba(102, 126, 234, 0.3);
    }
}

.file-item {
    padding: 12px;
    margin-bottom: 10px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-info {
    flex: 1;
}

.file-name {
    font-weight: 600;
    color: #4a5568;
    cursor: pointer;
    text-decoration: none;
}

.file-name:hover {
    color: #667eea;
    text-decoration: underline;
}

.file-meta {
    font-size: 0.8rem;
    color: #718096;
}

.file-actions {
    display: flex;
    gap: 10px;
}

.download-btn, .preview-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
    background: #48bb78;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
}

.preview-btn {
    background: #4299e1;
}

.download-btn:hover, .preview-btn:hover {
    opacity: 0.9;
}

footer {
    text-align: center;
    padding-top: 20px;
    border-top: 2px solid #f0f0f0;
    color: #718096;
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
}

.modal-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 90%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #bbb;
}

#caption {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 700px;
    text-align: center;
    color: #ccc;
    padding: 10px 0;
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
}

/* 滚动条样式 */
.messages-list::-webkit-scrollbar,
.files-list::-webkit-scrollbar {
    width: 6px;
}

.messages-list::-webkit-scrollbar-track,
.files-list::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.messages-list::-webkit-scrollbar-thumb,
.files-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.messages-list::-webkit-scrollbar-thumb:hover,
.files-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}