/* WebSocket测试工具样式 - 参考HTML格式化工具风格 */
.tool-container {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.tool-info {
    flex: 1;
    min-width: 300px;
}



.result-info {
    margin-top: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;

    overflow-y: auto;
}


.tool-operation {
    flex: 2;
    min-width: 500px;
}

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

.input-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.input-group input[type="text"],
.input-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

/* 整体工具卡片样式 */
.tool-card {
    background: #ffffff;
    border: 1px solid #eaeaea;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.tool-card h3 {
    margin-top: 0;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 15px 0;
}

.connection-form {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    align-items: center;
    margin-bottom: 15px;
}

.url-input {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    width: 100%;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    font-weight: 500;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.status-connected {
    background: #28a745;
}

.status-disconnected {
    background: #dc3545;
}

.messages-panel {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.message-area {
    min-height: 500px; /* 使用最小高度而不是固定高度 */
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    overflow-y: visible; /* 改为visible，不出现滚动条 */
    background: #f8f9fa;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    flex-grow: 1;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* 结果内容区域 - 移除固定高度限制 */
.result-content {
    margin-top: -1px; /* 与标题栏无缝衔接 */
    background-color: #f8f9fa; /* 改为浅色背景以便于消息气泡显示 */
    border: 1px solid #444;
    border-top: none;
    border-radius: 0 0 8px 8px;
    overflow: visible; /* 确保内容可以自由扩展 */
    flex-grow: 1;
}

/* 消息气泡样式 - 对话式布局 */
.message {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    animation: fadeIn 0.3s ease-out;
    word-wrap: break-word;
    white-space: pre-wrap;
    font-size: 14px;
    line-height: 1.4;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    align-self: flex-start; /* 默认左对齐 */
    margin-bottom: 10px;
}

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

/* 发送的消息 - 在右边 */
.message.sent {
    background: #007bff;
    color: white;
    align-self: flex-end !important; /* 强制右对齐 */
    margin-left: auto; /* 推到右边 */
    border-bottom-right-radius: 5px;
    border-top-left-radius: 18px;
}

/* 接收的消息 - 在左边 */
.message.received {
    background: #e9ecef;
    color: #212529;
    align-self: flex-start !important; /* 确保左对齐 */
    margin-right: auto; /* 推到左边 */
    border-bottom-left-radius: 5px;
    border-top-right-radius: 18px;
}

/* 系统消息居中 */
.message.info {
    background: #17a2b8;
    color: white;
    align-self: center !important;
    text-align: center;
    font-style: italic;
    max-width: 90%;
}

.message.success {
    background: #28a745;
    color: white;
    align-self: center !important;
    text-align: center;
    max-width: 90%;
}

.message.error {
    background: #dc3545;
    color: white;
    align-self: center !important;
    text-align: center;
    max-width: 90%;
}

.message-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: vertical;
    min-height: 100px;
    margin-bottom: 10px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.send-controls {
    display: flex;
    gap: 15px;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.message-type {
    display: flex;
    gap: 15px;
    align-items: center;
}

.message-type label {
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 0;
    cursor: pointer;
    font-weight: 500;
}

.message-type input[type="radio"] {
    margin: 0;
}

/* JSON美化样式 */
.json-key {
    color: #2aa198;
    font-weight: bold;
}

.json-string {
    color: #268bd2;
}

.json-number {
    color: #d33682;
    font-weight: bold;
}

.json-boolean {
    color: #b58900;
    font-weight: bold;
}

.json-null {
    color: #dc3545;
    font-style: italic;
}

/* 操作指南样式 */
.guidance-panel {
    background: #f8f9fa;
    border-left: 4px solid #007bff;
    padding: 15px;
    margin-top: 15px;
    border-radius: 0 6px 6px 0;
    font-size: 14px;
}

.guidance-panel h4 {
    margin-top: 0;
    color: #007bff;
}

.guidance-panel ul {
    margin-bottom: 0;
    padding-left: 20px;
}

.guidance-panel li {
    margin-bottom: 5px;
}

/* 代码框标题栏 */
.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to bottom, #3c3c3c, #2c2c2c);
    color: #f8f8f2;
    padding: 10px 15px;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    border: 1px solid #444;
    border-bottom: none;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.result-content {
    margin-top: -1px; /* 与标题栏无缝衔接 */
    background-color: #f8f9fa; /* 改为浅色背景以便于消息气泡显示 */
    border: 1px solid #444;
    border-top: none;
    border-radius: 0 0 8px 8px;
    overflow: visible; /* 确保内容可以自由扩展 */
    flex-grow: 1;
}

/* 代码显示区域样式 - 修复消息气泡布局 */
#message-area {
    margin: 0;
    padding: 15px;
    background-color: #f8f9fa; /* 保持浅色背景 */
    color: #333;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    tab-size: 4;
    overflow: visible; /* 确保不出现滚动条 */
    max-height: none; /* 移除最大高度限制 */
    white-space: normal; /* 允许换行 */
    direction: ltr;
    text-align: left;
    -ms-overflow-style: none; /* 隐藏滚动条样式 */
    scrollbar-width: none; /* Firefox隐藏滚动条 */
    outline: none;
    border: none;
    border-radius: 0 0 8px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start; /* 从flex-start开始，让消息气泡可以自由定位 */
}

/* 隐藏滚动条但保留功能 */
#message-area::-webkit-scrollbar {
    display: none; /* Chrome/Safari隐藏滚动条 */
}

/* 代码编辑器滚动条样式 */
#message-area::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

#message-area::-webkit-scrollbar-track {
    background: #e9ecef;
}

#message-area::-webkit-scrollbar-thumb {
    background: #adb5bd;
    border-radius: 6px;
}

#message-area::-webkit-scrollbar-thumb:hover {
    background: #6c757d;
}

/* 代码编辑器焦点样式 */
#message-area:focus {
    outline: none;
}

.result-actions {
    margin-top: 10px;
    text-align: right;
}

.example-data {
    padding: 10px;
    background-color: #f0f8ff;
    border-radius: 4px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .tool-container {
        flex-direction: column;
    }
    
    .tool-info,
    .tool-operation {
        min-width: 100%;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    .btn-group .btn {
        width: 100%;
    }
    
    .connection-form {
        grid-template-columns: 1fr;
    }
    
    .send-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .message-type {
        justify-content: center;
    }
    
    .message {
        max-width: 85%;
    }
}
