/* ==================== 全局样式 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    animation: fadeIn 0.5s ease-in;
}

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

/* ==================== 头部 ==================== */
header {
    text-align: center;
    margin-bottom: 25px;
    color: white;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.95;
    font-weight: 500;
}

/* ==================== 工具栏 ==================== */
.toolbar {
    background: white;
    border-radius: 15px;
    padding: 15px 20px;
    margin-bottom: 20px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 20px;
    font-size: 0.95em;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

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

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f8f9fa;
    color: #333;
    border: 2px solid #e0e0e0;
}

.btn-secondary:hover {
    background: #e9ecef;
    border-color: #667eea;
    transform: translateY(-2px);
}

.btn-view {
    background: #28a745;
    color: white;
}

.btn-view:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.4);
}

.btn:active {
    transform: translateY(0);
}

.indent-label {
    font-weight: 600;
    color: #555;
}

.indent-select {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.95em;
    cursor: pointer;
    background: white;
    transition: all 0.3s ease;
}

.indent-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ==================== 主内容区 ==================== */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.panel {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    min-height: 500px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

.panel-header label {
    font-weight: 700;
    font-size: 1.1em;
    color: #333;
}

.status-badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
}

.status-badge.waiting {
    background: #e9ecef;
    color: #6c757d;
}

.status-badge.valid {
    background: #d4edda;
    color: #155724;
}

.status-badge.invalid {
    background: #f8d7da;
    color: #721c24;
}

/* ==================== 输入区域 ==================== */
.json-textarea {
    flex: 1;
    width: 100%;
    padding: 15px;
    font-family: 'Courier New', 'Monaco', 'Menlo', monospace;
    font-size: 14px;
    line-height: 1.6;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    resize: vertical;
    transition: all 0.3s ease;
    background: #f8f9fa;
}

.json-textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    background: white;
}

.json-textarea.error {
    border-color: #dc3545;
}

.error-message {
    margin-top: 10px;
    padding: 12px;
    background: #f8d7da;
    border-left: 4px solid #dc3545;
    border-radius: 6px;
    color: #721c24;
    font-size: 0.9em;
    font-weight: 500;
    display: none;
    animation: slideIn 0.3s ease;
}

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

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

/* ==================== 输出区域 ==================== */
.copy-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    transition: all 0.3s ease;
}

.copy-btn:hover {
    background: #5568d3;
    transform: translateY(-1px);
}

.copy-btn.copied {
    background: #28a745;
}

.code-view,
.tree-view {
    flex: 1;
    overflow: auto;
}

.json-output {
    padding: 15px;
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-family: 'Courier New', 'Monaco', 'Menlo', monospace;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    min-height: 100%;
    color: #333;
}

.json-output.empty {
    color: #6c757d;
    font-style: italic;
}

/* ==================== 语法高亮 ==================== */
.json-key {
    color: #0066cc;
    font-weight: 600;
}

.json-string {
    color: #22863a;
}

.json-number {
    color: #e36209;
}

.json-boolean {
    color: #a626a4;
    font-weight: 600;
}

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

/* ==================== 树形视图 ==================== */
.json-tree {
    padding: 15px;
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-family: 'Courier New', 'Monaco', 'Menlo', monospace;
    font-size: 14px;
    line-height: 1.8;
    min-height: 100%;
}

.tree-node {
    margin-left: 20px;
    position: relative;
}

.tree-node-line {
    display: flex;
    align-items: center;
    padding: 2px 0;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.tree-node-line:hover {
    background: #e9ecef;
}

.tree-toggle {
    display: inline-block;
    width: 16px;
    text-align: center;
    cursor: pointer;
    font-size: 12px;
    color: #667eea;
    user-select: none;
}

.tree-toggle.expanded::before {
    content: '▼';
}

.tree-toggle.collapsed::before {
    content: '▶';
}

.tree-toggle.leaf {
    visibility: hidden;
}

.tree-key {
    color: #0066cc;
    font-weight: 600;
    margin-right: 6px;
}

.tree-value {
    margin-left: 6px;
}

.tree-type {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
    text-transform: uppercase;
}

.tree-type.string {
    background: #d4f4dd;
    color: #22863a;
}

.tree-type.number {
    background: #fff0e6;
    color: #e36209;
}

.tree-type.boolean {
    background: #f3e6f8;
    color: #a626a4;
}

.tree-type.null {
    background: #e9ecef;
    color: #6c757d;
}

.tree-type.object {
    background: #e3f2fd;
    color: #1976d2;
}

.tree-type.array {
    background: #fff3e0;
    color: #f57c00;
}

.tree-children {
    display: block;
}

.tree-children.collapsed {
    display: none;
}

.tree-count {
    color: #6c757d;
    font-size: 0.9em;
    margin-left: 4px;
}

/* ==================== 说明卡片 ==================== */
.info-card {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    margin-bottom: 20px;
}

.info-card h3 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.3em;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.info-item {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.info-icon {
    font-size: 2em;
    flex-shrink: 0;
}

.info-content strong {
    display: block;
    color: #667eea;
    margin-bottom: 5px;
    font-size: 1.05em;
}

.info-content p {
    color: #555;
    line-height: 1.5;
    font-size: 0.95em;
}

/* ==================== 页脚 ==================== */
footer {
    text-align: center;
    color: white;
    padding: 20px;
    opacity: 0.95;
    font-size: 0.95em;
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .panel {
        min-height: 400px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .toolbar-left,
    .toolbar-right {
        width: 100%;
        justify-content: center;
    }
    
    .btn {
        flex: 1;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
}

/* ==================== 动画效果 ==================== */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.3s ease;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.pulse {
    animation: pulse 0.3s ease;
}

/* ==================== 滚动条美化 ==================== */
.json-textarea::-webkit-scrollbar,
.json-output::-webkit-scrollbar,
.json-tree::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.json-textarea::-webkit-scrollbar-track,
.json-output::-webkit-scrollbar-track,
.json-tree::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.json-textarea::-webkit-scrollbar-thumb,
.json-output::-webkit-scrollbar-thumb,
.json-tree::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.json-textarea::-webkit-scrollbar-thumb:hover,
.json-output::-webkit-scrollbar-thumb:hover,
.json-tree::-webkit-scrollbar-thumb:hover {
    background: #555;
}

