* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

.container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.dialog {
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    overflow: visible;
    display: flex;
    flex-direction: column;
}

.dialog-body {
    padding: 24px;
    padding-bottom: 150px; /* 为固定在底部的按钮组和错误信息留出空间 */
    overflow-y: visible;
    flex: 1;
    position: relative;
}

.button-group.fixed {
    position: absolute;
    bottom: 70px; /* 将按钮组往上移 */
    left: 24px;
    right: 24px;
    background-color: #fff;
    padding: 8px;
    border-top: 1px solid #f0f0f0;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
    z-index: 10;
    display: flex;
    flex-wrap: nowrap; /* 强制显示在一行上 */
    gap: 8px; /* 减小按钮之间的间距 */
    margin-bottom: 0;
    overflow-x: auto; /* 当按钮太多时，允许水平滚动 */
}

/* 响应式设计中的固定按钮组 */
@media (max-width: 768px) {
    .button-group.fixed {
        flex-direction: column;
        padding: 8px;
        flex-wrap: wrap;
    }
    
    .button-group.fixed .btn {
        width: 100%;
        margin-bottom: 8px;
    }
    
    .button-group.fixed .btn:last-child {
        margin-bottom: 0;
    }
}

.dialog-header {
    background-color: #495057;
    color: #fff;
    padding: 16px 24px;
}

.dialog-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.input-section,
.output-section {
    margin-bottom: 24px;
    position: relative; /* 为绝对定位的错误信息提供定位上下文 */
}

.input-section label,
.output-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #595959;
}

.code-container {
    position: relative;
    display: flex;
    border: 1px solid #ced4da;
    border-radius: 4px;
    overflow: hidden;
}

.line-numbers {
    background-color: #e9ecef;
    border-right: 1px solid #ced4da;
    padding: 12px 8px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    color: #6c757d;
    text-align: right;
    user-select: none;
    min-width: 40px;
    white-space: pre-wrap;
    overflow-y: auto;
    height: 420px;
    flex-shrink: 0;
}

textarea {
    flex: 1;
    height: 420px; /* 20行高度：14px字体 * 1.5行高 * 20行 */
    padding: 12px;
    border: none;
    border-radius: 0;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
    transition: border-color 0.3s;
    background-color: #fff;
    overflow-y: auto;
}

textarea:focus {
    box-shadow: none;
}

.code-container:focus-within {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.error-message {
    position: absolute;
    top: calc(100% + 8px); /* 显示在输入框下方 */
    left: 0;
    right: 0;
    padding: 8px 12px;
    background-color: #fff2f0;
    border: 1px solid #ffccc7;
    border-radius: 4px;
    color: #f5222d;
    font-size: 12px;
    line-height: 1.5;
    display: none;
    z-index: 5; /* 确保错误信息显示在按钮组下方 */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.error-message.show {
    display: block;
}

.input-section {
    margin-bottom: 24px;
}

#json-output {
    background-color: #fafafa;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    outline: none;
}

.btn:hover {
    opacity: 0.85;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background-color: #007bff;
    color: #fff;
}

.btn-primary:hover {
    background-color: #0069d9;
}

.btn-secondary {
    background-color: #6c757d;
    color: #fff;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.btn-default {
    background-color: #e9ecef;
    color: #495057;
    border: 1px solid #ced4da;
}

.btn-default:hover {
    background-color: #dee2e6;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .button-group {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    textarea {
        min-height: 150px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    .dialog-body {
        padding: 16px;
    }
}