/* 重置样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', 'Segoe UI', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* 聊天容器 */
.chat-container {
    width: 100%;
    max-width: 800px;
    height: 90vh;
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 聊天头部 */
.chat-header {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h1 {
    font-size: 24px;
    font-weight: 600;
}

.user-info {
    font-size: 14px;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 12px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

/* 消息区域 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

.loading {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 20px;
}

.error {
    text-align: center;
    color: #dc3545;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    padding: 15px;
    margin: 20px;
    font-size: 14px;
}

.no-messages {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 40px 20px;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 20px;
}

/* 消息样式 */
.message {
    margin-bottom: 15px;
    max-width: 70%;
    animation: fadeIn 0.3s ease-in;
}

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

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    font-size: 12px;
    color: #666;
    gap: 10px;
}

.username {
    font-weight: 600;
    flex-shrink: 0;
}

.timestamp {
    opacity: 0.7;
    flex-shrink: 0;
}

.ip-address {
    font-size: 10px;
    color: #888;
    font-family: 'Courier New', monospace;
    background: #f8f9fa;
    padding: 1px 4px;
    border-radius: 3px;
    border: 1px solid #e9ecef;
    flex: 1;
    text-align: center;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-content {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    line-height: 1.4;
    word-wrap: break-word;
}

.message-text {
    margin-bottom: 8px;
}

.own-message .message-content {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

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

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

#message-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}

#message-input:focus {
    border-color: #4facfe;
}

#send-button {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

#send-button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 172, 254, 0.4);
}

#send-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.input-info {
    text-align: right;
    font-size: 12px;
    color: #666;
}

/* 滚动条样式 */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

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

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

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

/* 响应式设计 */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .chat-container {
        height: 95vh;
        border-radius: 10px;
    }
    
    .chat-header {
        padding: 15px;
    }
    
    .chat-header h1 {
        font-size: 20px;
    }
    
    .message {
        max-width: 85%;
    }
    
    .chat-input {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .chat-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .message {
        max-width: 90%;
    }
    
    .input-container {
        flex-direction: column;
    }
    
    #send-button {
        width: 100%;
    }
}