/* 基础样式 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    color: white;
}

header h1 {
    font-size: 1.8rem;
    margin-bottom: 8px;
}

header .subtitle {
    opacity: 0.9;
    font-size: 0.95rem;
}

/* 区块样式 */
section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

section h2 {
    font-size: 1.1rem;
    color: #444;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 表单样式 */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 6px;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-row .form-group {
    margin-bottom: 0;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-group label {
    margin-bottom: 0;
    cursor: pointer;
}

/* 按钮样式 */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: #f0f2f5;
    color: #555;
}

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

.btn-small {
    padding: 4px 12px;
    font-size: 0.8rem;
}

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

/* 会话信息 */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.info-item {
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
}

.info-item .label {
    font-size: 0.85rem;
    color: #666;
    display: block;
    margin-bottom: 4px;
}

.info-item .value {
    font-size: 0.95rem;
    font-weight: 500;
    color: #333;
    word-break: break-all;
}

.status-active {
    color: #28a745;
}

.status-ended {
    color: #dc3545;
}

/* 聊天区域 */
.chat-container {
    border: 1px solid #eee;
    border-radius: 12px;
    margin-bottom: 16px;
    background: #fafbfc;
}

.chat-messages {
    max-height: 400px;
    overflow-y: auto;
    padding: 16px;
}

.chat-messages:empty::before {
    content: "暂无消息，请先创建会话并开始对话";
    color: #999;
    display: block;
    text-align: center;
    padding: 40px;
}

.message {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
}

.message:last-child {
    margin-bottom: 0;
}

.message .role {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-block;
    width: fit-content;
}

.message.broker .role {
    background: #fff3cd;
    color: #856404;
}

.message.communicator .role {
    background: #d4edda;
    color: #155724;
}

.message.system .role {
    background: #e2e3e5;
    color: #383d41;
}

.message .content {
    padding: 12px 16px;
    border-radius: 12px;
    background: white;
    border: 1px solid #e0e0e0;
    font-size: 0.95rem;
    line-height: 1.6;
    white-space: pre-wrap;
}

.message.broker .content {
    background: #fff8e6;
    border-color: #ffe69c;
}

.message.communicator .content {
    background: #e8f5e9;
    border-color: #a5d6a7;
}

.message.system .content {
    background: #f8f9fa;
    border-color: #dee2e6;
    font-style: italic;
    color: #666;
}

/* 查询结果 */
.query-result {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px dashed #ddd;
}

.query-result h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: #555;
}

.summary-box {
    margin-top: 16px;
    padding: 16px;
    background: #e3f2fd;
    border-radius: 8px;
    border-left: 4px solid #2196f3;
}

.summary-box h4 {
    font-size: 0.9rem;
    color: #1565c0;
    margin-bottom: 8px;
}

/* 日志区域 */
.log-container {
    max-height: 300px;
    overflow-y: auto;
    background: #1e1e1e;
    border-radius: 8px;
    padding: 16px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85rem;
}

.log-entry {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #333;
}

.log-entry:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.log-entry .timestamp {
    color: #888;
    font-size: 0.8rem;
}

.log-entry .method {
    color: #4fc3f7;
    font-weight: bold;
}

.log-entry .url {
    color: #81c784;
    word-break: break-all;
}

.log-entry .status-ok {
    color: #81c784;
}

.log-entry .status-error {
    color: #ef5350;
}

.log-entry .body {
    color: #ddd;
    margin-top: 8px;
    padding: 8px;
    background: #2d2d2d;
    border-radius: 4px;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
}

/* 响应式 */
@media (max-width: 600px) {
    .container {
        padding: 12px;
    }

    section {
        padding: 16px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .button-group {
        flex-direction: column;
    }
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #fff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 输入区域 */
.input-section {
    padding-top: 16px;
    border-top: 1px solid #eee;
}

.input-section textarea {
    resize: vertical;
    min-height: 80px;
}
