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

:root {
    --primary-color: #0284c7;
    --primary-hover: #0369a1;
    --secondary-color: #64748b;
    --danger-color: #e11d48;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --bg-color: #f0f4f8;
    --card-bg: #ffffff;
    --text-color: #0f172a;
    --border-color: #cbd5e1;
    --header-bg: #0f172a;
    --footer-bg: #1e293b;
    --diff-added: #d1fae5;
    --diff-removed: #ffe4e6;
    --diff-modified: #fef3c7;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

#app {
    display: flex;
    flex-direction: row;
    height: 100vh;
}

/* 侧边导航栏样式 */
.header {
    background: var(--header-bg);
    color: white;
    width: 90px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    flex-shrink: 0;
    z-index: 10;
}

.logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 15px 5px;
    cursor: help;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.logo-icon {
    width: 100%;
    max-width: 65px;
    height: auto;
    object-fit: contain;
}

.logo-text {
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
}

.nav-tabs {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px 10px;
}

.nav-tab {
    background: rgba(255,255,255,0.05);
    border: 1px solid transparent;
    border-radius: 8px;
    color: rgba(255,255,255,0.7);
    padding: 15px 5px;
    cursor: pointer;
    font-size: 13px;
    text-align: center;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.4;
    word-break: break-all;
    white-space: normal;
    aspect-ratio: 1 / 1;
}

.nav-tab:hover {
    color: white;
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.1);
}

.nav-tab.active {
    color: white;
    background: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: 0 4px 10px rgba(2, 132, 199, 0.4);
}

/* 主内容区域 */
.main-content {
    flex: 1;
    padding: 20px;
    max-width: 100%;
    width: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 面板样式 */
.panel {
    display: none;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    overflow: hidden;
    flex: 1;
    min-height: 0;
}

.panel.active {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.panel-header {
    padding: 15px 20px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #4f46e5 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    flex-shrink: 0;
}

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

.panel-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.panel-actions label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.panel-actions select,
.panel-actions input[type="text"] {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    background: rgba(255,255,255,0.9);
}

/* 按钮样式 */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: white;
    color: var(--text-color);
}

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

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #be123c;
}

/* 编辑器容器 */
.editor-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 20px;
    flex: 1;
    min-height: 0;
}

.editor-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 100%;
    min-height: 0;
}

.editor-wrapper label {
    font-weight: 600;
    color: var(--text-color);
    font-size: 14px;
    flex-shrink: 0;
}

.json-editor {
    width: 100%;
    flex: 1;
    min-height: 200px;
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    transition: border-color 0.3s ease;
}

.json-editor:focus {
    outline: none;
    border-color: var(--primary-color);
}

.json-editor[readonly] {
    background: #f8f9fa;
}

.code-output {
    background: #1e1e1e !important;
    color: #d4d4d4;
}

/* 错误信息 */
.error-message {
    padding: 0 20px 20px;
    color: var(--danger-color);
    font-size: 14px;
    white-space: pre-wrap;
    font-family: monospace;
    flex-shrink: 0;
}

.error-message:empty {
    display: none;
}

/* 树形视图 */
.tree-container {
    grid-template-columns: 1fr 1fr;
}

.tree-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 100%;
    min-height: 0;
}

.tree-wrapper label {
    font-weight: 600;
    color: var(--text-color);
    font-size: 14px;
    flex-shrink: 0;
}

.json-tree {
    flex: 1;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    min-height: 200px;
    max-height: none;
    overflow: auto;
    background: #fafafa;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
}

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

.tree-node-root {
    margin-left: 0;
}

.tree-key {
    color: #881391;
    font-weight: 600;
}

.tree-value {
    color: #0451a5;
}

.tree-value.string {
    color: #a31515;
}

.tree-value.number {
    color: #098658;
}

.tree-value.boolean {
    color: #0000ff;
}

.tree-value.null {
    color: #808080;
}

.tree-toggle {
    cursor: pointer;
    user-select: none;
    display: inline-block;
    width: 16px;
    text-align: center;
    color: #666;
    font-weight: bold;
}

.tree-toggle:hover {
    color: var(--primary-color);
}

.tree-bracket {
    color: #666;
}

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

.tree-collapsed > .tree-preview {
    display: inline;
}

.tree-preview {
    display: none;
    color: #999;
    font-style: italic;
}

/* 对比结果 */
.compare-container {
    grid-template-columns: 1fr 1fr;
    flex: 1;
    min-height: 0;
}

.compare-result {
    padding: 0 20px 20px;
    max-height: 300px;
    overflow: auto;
    flex-shrink: 0;
}

.compare-result:empty {
    display: none;
}

.diff-item {
    padding: 8px 12px;
    margin: 4px 0;
    border-radius: 4px;
    font-family: monospace;
    font-size: 13px;
}

.diff-added {
    background: var(--diff-added);
    border-left: 4px solid var(--success-color);
}

.diff-removed {
    background: var(--diff-removed);
    border-left: 4px solid var(--danger-color);
}

.diff-modified {
    background: var(--diff-modified);
    border-left: 4px solid var(--warning-color);
}

.diff-path {
    font-weight: 600;
    color: #495057;
}

.diff-value {
    margin-left: 10px;
    color: #6c757d;
}

/* 历史记录 */
.history-list {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 15px;
    margin-bottom: 10px;
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.history-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.history-content {
    flex: 1;
    overflow: hidden;
}

.history-time {
    font-size: 12px;
    color: #888;
    margin-bottom: 5px;
}

.history-preview {
    font-family: monospace;
    font-size: 13px;
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 800px;
}

.history-actions {
    display: flex;
    gap: 8px;
    margin-left: 15px;
}

.history-empty {
    text-align: center;
    padding: 40px;
    color: #888;
}

/* Toast 通知 */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--danger-color);
}

/* 底部已移除 */

/* 响应式设计 */
@media (max-width: 1024px) {
    .editor-container {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }

    .compare-container {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }

    .tree-container {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }

    .json-editor {
        min-height: 150px;
    }
}

@media (max-width: 768px) {
    #app {
        flex-direction: column;
    }

    .header {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    }

    .logo {
        flex-direction: row;
        padding: 15px;
        justify-content: flex-start;
        border-bottom: none;
    }

    .logo-icon {
        max-width: 80px;
    }

    .logo-text {
        font-size: 18px;
        text-align: left;
    }

    .nav-tabs {
        width: 100%;
        flex-direction: row;
        overflow-x: auto;
        padding: 0 10px 10px;
        gap: 8px;
    }

    .nav-tab {
        padding: 10px 15px;
        font-size: 13px;
        white-space: nowrap;
        aspect-ratio: auto;
        border-radius: 20px;
        background: rgba(255,255,255,0.05);
    }
    
    .nav-tab.active {
        background: var(--primary-color);
        box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4);
    }

    .panel-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .panel-actions {
        width: 100%;
    }

    .main-content {
        padding: 10px;
    }

    .json-editor {
        min-height: 200px;
        font-size: 13px;
    }

    .history-item {
        flex-direction: column;
    }

    .history-actions {
        margin-left: 0;
        margin-top: 10px;
    }

    .history-preview {
        max-width: 100%;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

