/* ========================================
   WebSocket 测试工具专用样式
   ======================================== */

/* ===== 连接管理面板 ===== */
.ws-connection-panel {
    background: #fff;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid #e9ecef;
}

/* 连接状态栏 */
.ws-status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 10px;
    margin-bottom: 20px;
    border-left: 4px solid #6c757d;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 16px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #6c757d;
    box-shadow: 0 0 8px rgba(0,0,0,0.2);
    animation: pulse 2s ease-in-out infinite;
}

/* 连接状态颜色 */
.status-dot.disconnected {
    background: #dc3545;
    box-shadow: 0 0 10px rgba(220, 53, 69, 0.5);
}

.status-dot.connecting {
    background: #ffc107;
    box-shadow: 0 0 10px rgba(255, 193, 7, 0.5);
}

.status-dot.connected {
    background: #28a745;
    box-shadow: 0 0 10px rgba(40, 167, 69, 0.5);
    animation: pulse-connected 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes pulse-connected {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.connection-stats {
    display: flex;
    gap: 10px;
    font-size: 14px;
    color: #6c757d;
}

/* 服务器配置区 */
.ws-server-config {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.config-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.config-row label {
    font-weight: 500;
    font-size: 14px;
    color: #495057;
}

.config-row input[type="text"],
.config-row input[type="number"],
.config-row select,
.config-row textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    font-family: 'Consolas', 'Monaco', monospace;
}

.config-row input[type="text"]:focus,
.config-row input[type="number"]:focus,
.config-row select:focus,
.config-row textarea:focus {
    outline: none;
    border-color: #4285f4;
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
}

.server-input-group {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 10px;
}

/* 高级选项按钮 */
.toggle-advanced {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
    color: #495057;
}

.toggle-advanced:hover {
    background: #e9ecef;
    border-color: #ced4da;
}

.toggle-advanced i {
    transition: transform 0.3s ease;
}

.toggle-advanced.active i {
    transform: rotate(180deg);
}

/* 高级选项面板 */
.advanced-options {
    display: none;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    border: 1px dashed #dee2e6;
    margin-top: 10px;
}

.advanced-options.show {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.advanced-options small {
    color: #6c757d;
    font-size: 12px;
    margin-top: 5px;
}

/* 按钮样式 */
.btn-primary,
.btn-secondary,
.btn-action {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #4285f4 0%, #357ae8 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #357ae8 0%, #2a66c9 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.3);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

.btn-action {
    background: #f8f9fa;
    color: #495057;
    border: 1px solid #dee2e6;
}

.btn-action:hover:not(:disabled) {
    background: #e9ecef;
    border-color: #ced4da;
}

.btn-primary:disabled,
.btn-secondary:disabled,
.btn-action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.config-row > div {
    display: flex;
    gap: 10px;
}

/* ===== 消息交互面板 ===== */
.ws-message-panel {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid #e9ecef;
    overflow: hidden;
}

/* 消息容器（聊天式布局） */
.ws-messages-container {
    height: 500px;
    overflow-y: auto;
    padding: 20px;
    background: linear-gradient(180deg, #f8f9fa 0%, #ffffff 100%);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ws-messages-container::-webkit-scrollbar {
    width: 8px;
}

.ws-messages-container::-webkit-scrollbar-track {
    background: #f1f3f5;
    border-radius: 4px;
}

.ws-messages-container::-webkit-scrollbar-thumb {
    background: #adb5bd;
    border-radius: 4px;
}

.ws-messages-container::-webkit-scrollbar-thumb:hover {
    background: #868e96;
}

/* 欢迎消息 */
.welcome-message {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

.welcome-message i {
    font-size: 48px;
    color: #4285f4;
    margin-bottom: 20px;
}

.welcome-message p {
    margin: 8px 0;
    font-size: 15px;
}

/* 消息气泡 */
.message-bubble {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: 75%;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 接收消息（左侧，蓝色） */
.message-bubble.received {
    align-self: flex-start;
}

.message-bubble.received .message-content {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border-left: 4px solid #2196f3;
    color: #0d47a1;
}

/* 发送消息（右侧，绿色） */
.message-bubble.sent {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-bubble.sent .message-content {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border-right: 4px solid #4caf50;
    color: #1b5e20;
}

/* 系统消息（居中，灰色） */
.message-bubble.system {
    align-self: center;
    max-width: 90%;
}

.message-bubble.system .message-content {
    background: #f8f9fa;
    border: 1px dashed #dee2e6;
    color: #6c757d;
    text-align: center;
    font-size: 13px;
}

/* 消息内容 */
.message-content {
    flex: 1;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 12px;
}

.message-type-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.message-type-badge.text {
    background: #e3f2fd;
    color: #1976d2;
}

.message-type-badge.json {
    background: #fff3e0;
    color: #f57c00;
}

.message-type-badge.binary {
    background: #f3e5f5;
    color: #7b1fa2;
}

.message-type-badge.system {
    background: #eceff1;
    color: #546e7a;
}

.message-timestamp {
    color: inherit;
    opacity: 0.7;
    font-size: 11px;
}

.message-body {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
}

.message-body.json-formatted {
    background: rgba(0,0,0,0.03);
    padding: 10px;
    border-radius: 6px;
    overflow-x: auto;
}

/* ===== 消息发送区 ===== */
.ws-send-panel {
    border-top: 2px solid #e9ecef;
    background: #fff;
}

/* 消息类型选项卡 */
.message-type-tabs {
    display: flex;
    border-bottom: 2px solid #e9ecef;
    background: #f8f9fa;
}

.tab-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #6c757d;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    background: #e9ecef;
    color: #495057;
}

.tab-btn.active {
    color: #4285f4;
    background: #fff;
    border-bottom-color: #4285f4;
}

/* 消息输入容器 */
.message-input-container {
    padding: 20px;
}

.message-input-container textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 14px;
    font-family: 'Consolas', 'Monaco', monospace;
    resize: vertical;
    min-height: 100px;
    transition: all 0.3s ease;
}

.message-input-container textarea:focus {
    outline: none;
    border-color: #4285f4;
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
}

.input-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 15px;
}

/* ===== 响应式设计 ===== */
@media (max-width: 768px) {
    .ws-connection-panel {
        padding: 15px;
    }

    .ws-status-bar {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .connection-stats {
        font-size: 12px;
    }

    .server-input-group {
        grid-template-columns: 1fr;
    }

    .config-row > div {
        flex-direction: column;
    }

    .ws-messages-container {
        height: 400px;
        padding: 15px;
    }

    .message-bubble {
        max-width: 90%;
    }

    .message-type-tabs {
        flex-wrap: wrap;
    }

    .tab-btn {
        font-size: 12px;
        padding: 10px 12px;
    }

    .message-input-container {
        padding: 15px;
    }

    .message-input-container textarea {
        min-height: 80px;
    }

    .input-actions {
        flex-wrap: wrap;
    }

    .btn-primary,
    .btn-secondary,
    .btn-action {
        padding: 10px 16px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .ws-messages-container {
        height: 350px;
    }

    .message-bubble {
        max-width: 95%;
    }

    .tab-btn {
        flex: 1 1 100%;
    }

    .input-actions {
        justify-content: stretch;
    }

    .btn-primary,
    .btn-secondary,
    .btn-action {
        flex: 1;
        justify-content: center;
    }
}

/* ===== 滚动优化 ===== */
.ws-messages-container {
    scroll-behavior: smooth;
}

/* ===== 打印样式 ===== */
@media print {
    .ws-connection-panel,
    .ws-send-panel,
    .ad-base {
        display: none;
    }

    .ws-messages-container {
        height: auto;
        overflow: visible;
    }
}
