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

html, body {
    height: 100%;
    font-family: 'Arial', sans-serif;
    line-height: 1.6;
    background-color: #f5f5f5;
    color: #333;
}

.container {
    max-width: 100%;
    height: 100vh;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

h1 {
    text-align: center;
    margin-bottom: 20px;
    color: #2c3e50;
}

h2 {
    margin-bottom: 10px;
    color: #2c3e50;
}

.formatter {
    display: flex;
    gap: 20px;
    flex: 1;
    margin-bottom: 10px;
    height: calc(100% - 80px);
}

@media (max-width: 768px) {
    .formatter {
        flex-direction: column;
        height: calc(100% - 60px);
    }
}

.input-section, .output-section {
    flex: 1;
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

textarea, pre {
    width: 100%;
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: 'Consolas', monospace;
    font-size: 14px;
    resize: none;
    overflow: auto;
}

pre {
    background-color: #f8f8f8;
    white-space: pre-wrap;
}

.buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

button {
    padding: 8px 16px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #2980b9;
}

#clear-btn, #download-btn {
    background-color: #7f8c8d;
}

#clear-btn:hover, #download-btn:hover {
    background-color: #6c7a7a;
}

.error-message {
    color: #e74c3c;
    text-align: center;
    margin-top: 5px;
    font-weight: bold;
    min-height: 24px;
}

/* 添加复制成功提示样式 */
.success-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(46, 204, 113, 0.9);
    color: white;
    padding: 15px 30px;
    border-radius: 8px;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    animation: fadeInOut 2s ease-in-out;
    pointer-events: none;
}

@keyframes fadeInOut {
    0% { opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

/* JSON Collapsible Styles */
.json-container {
    font-family: 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    padding: 5px;
    position: relative;
}

.json-item {
    margin-left: 24px;
    position: relative;
    padding: 2px 0;
}

.json-line {
    display: flex;
    flex-direction: column;
    position: relative;
}

.json-start {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    padding-left: 15px;
    min-height: 24px;
    position: relative;
}

.json-content-container {
    display: flex;
    flex-direction: column;
}

.json-end {
    display: inline-flex;
    align-items: center;
}

.json-value-container {
    display: inline-flex;
    align-items: center;
    padding-left: 15px;
    min-height: 24px;
}

.json-key {
    color: #881391;
    font-weight: bold;
    margin-right: 4px;
    pointer-events: none; /* 防止点击键名时触发展开/收起 */
}

.json-toggle {
    cursor: pointer;
    user-select: none;
    color: #666;
    font-weight: bold;
    margin-right: 8px;
    position: relative;
    min-width: 20px;
    min-height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.json-toggle.expanded::before {
    content: '';
    position: absolute;
    left: -15px;
    top: 50%;
    transform: translateY(-50%);
    border-left: 6px solid #999;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    transition: transform 0.2s;
    width: 0;
    height: 0;
    z-index: 2;
}

.json-toggle.collapsed::before {
    content: '';
    position: absolute;
    left: -15px;
    top: 50%;
    transform: translateY(-50%) rotate(-90deg);
    border-left: 6px solid #999;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    transition: transform 0.2s;
    width: 0;
    height: 0;
    z-index: 2;
}

/* 增加点击区域 */
.json-toggle::after {
    content: '';
    position: absolute;
    left: -25px;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    cursor: pointer;
    z-index: 1;
}

.json-count {
    color: #999;
    font-size: 12px;
    margin: 0 4px;
    pointer-events: none; /* 防止点击计数时触发展开/收起 */
}

.json-close {
    color: #666;
    font-weight: bold;
    pointer-events: none; /* 防止点击闭合括号时触发展开/收起 */
}

.json-content {
    transition: height 0.2s;
    overflow: hidden;
    margin-left: 24px;
}

.json-content.hidden {
    display: none;
}

.json-comma {
    color: #666;
    display: inline;
    margin-left: 2px;
    margin-right: 0;
}

.json-string {
    color: #22a2c9;
}

.json-number {
    color: #f5871f;
}

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

.json-null {
    color: #7f0055;
    font-weight: bold;
}

.json-collapsed-end {
    display: inline-flex;
    align-items: center;
    margin-left: 4px;
} 