/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4a90e2;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #17a2b8;
    --dark-color: #343a40;
    --light-color: #f8f9fa;
    --border-color: #dee2e6;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
    --transition: all 0.3s ease;
}

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;
    color: #333;
}

/* 导航栏样式 */
.navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    cursor: pointer;
}

.brand-icon {
    font-size: 1.8rem;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 8px;
}

.nav-item {
    position: relative;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    text-decoration: none;
    color: var(--secondary-color);
    border-radius: 8px;
    transition: var(--transition);
    font-weight: 500;
}

.nav-link:hover {
    background: rgba(74, 144, 226, 0.1);
    color: var(--primary-color);
}

.nav-link .nav-icon {
    font-size: 1.2rem;
}

.nav-item.active .nav-link {
    background: var(--primary-color);
    color: white;
}

/* 主内容区 */
.main-content {
    max-width: 1400px;
    margin: 30px auto;
    padding: 0 20px;
}

.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page-header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

.page-header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.page-desc {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* 工具容器 */
.tool-container {
    background: white;
    border-radius: 16px;
    padding: 30px;
    box-shadow: var(--shadow-lg);
}

.input-section,
.output-section {
    margin-bottom: 20px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.section-header h3 {
    font-size: 1.1rem;
    color: var(--dark-color);
    font-weight: 600;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.code-input,
.code-output {
    width: 100%;
    min-height: 300px;
    padding: 16px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    resize: vertical;
    transition: var(--transition);
}

/* 拖拽文件时的样式 */
.code-input.drag-over {
    border-color: var(--primary-color);
    background: rgba(74, 144, 226, 0.05);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

/* JSON 格式化页面的输入框和输出框高度 */
#json-format .code-input,
#json-format .code-output,
#json-format .view-content {
    height: 70vh;
}

#json-format .code-input,
#json-format .code-output {
    flex: 1;
}

.code-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.code-output {
    background: #f8f9fa;
    border-color: var(--border-color);
}

/* 控制栏 */
.control-bar {
    background: white;
    padding: 20px 30px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    box-shadow: var(--shadow);
}

/* 左右分栏容器 */
.split-container {
    display: flex;
    gap: 20px;
    min-height: 500px;
}

.split-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.pane-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--light-color);
    border-bottom: 1px solid var(--border-color);
}

.pane-header h3 {
    font-size: 1rem;
    color: var(--dark-color);
    font-weight: 600;
}

.view-toggle {
    display: flex;
    gap: 4px;
}

.btn-toggle {
    padding: 6px 12px;
    font-size: 12px;
    border: 1px solid var(--border-color);
    background: white;
    color: var(--secondary-color);
}

.btn-toggle:hover {
    background: var(--light-color);
}

.btn-toggle.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* 视图内容 */
.view-content {
    display: none;
    flex: 1;
    overflow: auto;
}

.view-content.active {
    display: flex;
}

/* JSON 结构树 */
.json-tree {
    padding: 16px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
}

.tree-node {
    margin-left: 20px;
}

.tree-node.root {
    margin-left: 0;
}

.tree-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.tree-header:hover {
    background: var(--light-color);
}

.tree-toggle {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--secondary-color);
    cursor: pointer;
    user-select: none;
}

.tree-toggle.collapsed::before {
    content: '▶';
}

.tree-toggle.expanded::before {
    content: '▼';
}

.tree-key {
    color: #92278f;
    font-weight: 500;
}

.tree-type {
    color: var(--secondary-color);
    font-size: 12px;
    padding: 2px 6px;
    background: var(--light-color);
    border-radius: 3px;
    margin-left: 8px;
}

.tree-value {
    color: #008000;
}

.tree-value.string {
    color: #a31515;
}

.tree-value.number {
    color: #098658;
}

.tree-value.boolean {
    color: #0000ff;
}

.tree-value.null {
    color: #808080;
}

.tree-children {
    display: block;
}

.tree-children.collapsed {
    display: none;
}

/* 控制区域 */
.control-section {
    background: var(--light-color);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    justify-content: center;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-group label {
    font-weight: 500;
    color: var(--dark-color);
}

.control-group select {
    padding: 8px 16px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.control-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.control-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* 按钮样式 */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #357abd;
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-warning {
    background: var(--warning-color);
    color: #333;
}

.btn-warning:hover {
    background: #e0a800;
}

.btn-info {
    background: var(--info-color);
    color: white;
}

.btn-info:hover {
    background: #138496;
}

.btn-large {
    padding: 12px 28px;
    font-size: 16px;
    font-weight: 600;
}

/* 提示框 */
.toast {
    position: fixed;
    top: 80px;
    right: 20px;
    padding: 16px 24px;
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    transform: translateX(400px);
    transition: transform 0.3s ease;
    z-index: 2000;
    font-weight: 500;
}

.toast.show {
    transform: translateX(0);
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

.toast.info {
    border-left: 4px solid var(--info-color);
}

/* 底部信息栏 */
.footer {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    margin-top: 40px;
    padding: 30px 0;
}

.footer-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

.footer-content {
    text-align: center;
}

.footer-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--dark-color);
    margin-bottom: 8px;
}

.footer-desc {
    font-size: 14px;
    color: var(--secondary-color);
    opacity: 0.8;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        height: auto;
        padding: 15px;
    }

    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
        margin-top: 15px;
    }

    .nav-link {
        padding: 8px 16px;
        font-size: 14px;
    }

    .nav-link .nav-text {
        display: none;
    }

    .page-header h1 {
        font-size: 1.8rem;
    }

    .tool-container {
        padding: 20px;
    }

    /* 控制栏响应式 */
    .control-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .control-bar .btn {
        width: 100%;
        justify-content: center;
    }

    /* 左右分栏响应式 */
    .split-container {
        flex-direction: column;
    }

    .pane-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .pane-header .action-buttons {
        width: 100%;
    }

    .pane-header .action-buttons .btn {
        flex: 1;
        justify-content: center;
    }

    .view-toggle {
        width: 100%;
    }

    .view-toggle .btn {
        flex: 1;
    }

    .control-section {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-large {
        width: 100%;
        justify-content: center;
    }

    .section-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .action-buttons {
        width: 100%;
    }

    .action-buttons .btn {
        flex: 1;
        justify-content: center;
    }

    .code-input,
    .code-output {
        min-height: 200px;
    }
    
    /* 移动端调整 JSON 格式化页面高度 */
    #json-format .code-input,
    #json-format .code-output,
    #json-format .view-content {
        height: 40vh;
    }

    .footer {
        padding: 20px 0;
        margin-top: 30px;
    }

    .footer-text {
        font-size: 14px;
    }

    .footer-desc {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .nav-brand {
        font-size: 1.2rem;
    }

    .brand-icon {
        font-size: 1.4rem;
    }

    .nav-link {
        padding: 6px 12px;
    }

    .nav-link .nav-icon {
        font-size: 1rem;
    }
}
