/* ================================================================
   菜刀客在线工具页 · json-formatter.html 私有样式
   需在 /css/common.css 之后加载。
   ================================================================ */

/* ---- 覆盖公共值：本页容器更宽 ---- */
.container {
    max-width: 1400px;
}

.footer {
    max-width: 1400px;
}

/* ---- 覆盖公共按钮：本页 btn-secondary 为深色 ---- */
.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

/* ---- 覆盖公共布局：双栏并排 ---- */
.main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* ---- 工具栏 ---- */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    align-items: center;
}

.toolbar-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.toolbar-group:not(:last-child) {
    padding-right: 15px;
    border-right: 1px solid #e5e7eb;
}

.indent-select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background: white;
}

/* ---- 面板：本页为等高列布局 ---- */
.panel {
    display: flex;
    flex-direction: column;
    height: 600px;
}

/* ---- 输入历史（工具栏下方内联区块） ---- */
.history-section {
    display: none;
    background: #fff;
    border-radius: 8px;
    margin: 15px 0 15px;
    padding: 12px 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.history-section.show {
    display: block;
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    padding-bottom: 8px;
    border-bottom: 1px solid #f3f4f6;
}

.history-clear {
    font-size: 13px;
    padding: 4px 10px;
}

.history-list {
    max-height: 260px;
    overflow: auto;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 6px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid #f3f4f6;
}

.history-item:last-child {
    border-bottom: none;
}

.history-item:hover {
    background: #f5f7ff;
}

.history-title {
    color: #374151;
}

.history-del {
    color: #9ca3af;
    padding: 0 2px;
}

.history-del:hover {
    color: #dc2626;
}

.history-empty {
    padding: 18px;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
}

.panel-header {
    border-bottom: none;
    order: 4;
    flex-shrink: 0;
}

.panel-header:first-child {
    border-top: 1px solid #e5e7eb;
}

.tab-bar {
    order: 1;
    flex-shrink: 0;
}

.tab {
    padding: 10px 20px;
    float: left;
}

.tab-content {
    display: none;
    order: 2;
    flex: 1;
    overflow: auto;
}

.tab-content.active {
    display: flex;
    flex: 1;
    overflow: auto;
}

.status-bar {
    flex-direction: column;
    align-items: stretch;
    order: 3;
    flex-shrink: 0;
}

/* ---- 输入 / 输出区 ---- */
.editor-wrap {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.line-numbers {
    flex-shrink: 0;
    min-width: 44px;
    padding: 15px 8px 15px 10px;
    background: #f9fafb;
    border-right: 1px solid #e5e7eb;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    text-align: right;
    color: #9ca3af;
    white-space: pre;
    user-select: none;
    overflow: hidden;
}

.editor-wrap textarea {
    flex: 1;
    width: auto;
    min-width: 0;
    height: auto;
}

textarea {
    width: 100%;
    height: 512px;
    padding: 15px;
    border: none;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    outline: none;
}

.output-container {
    position: relative;
    flex: 1;
    overflow: auto;
    order: 2;
}

#output {
    padding: 15px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
    flex: 1;
    overflow: auto;
    height: 450px;
}

/* ---- JSON 语法高亮 ---- */
.json-key {
    color: #881391;
}

.json-string {
    color: #0b7500;
}

.json-number {
    color: #1750eb;
}

.json-boolean {
    color: #ff6d01;
}

.json-null {
    color: #999;
}

.json-bracket {
    color: #333;
}

.json-comma {
    color: #333;
}

/* ---- 树形视图 ---- */
.tree-view {
    padding: 15px;
    flex: 1;
    overflow: auto;
    height: 450px;
}

/* ---- 代码转换 ---- */
.lang-select {
    display: none;
    margin-left: auto;
    margin-right: 10px;
    align-self: center;
    padding: 4px 8px;
    font-size: 13px;
}

.code-view {
    padding: 12px 15px;
    flex: 1;
    overflow: auto;
    height: 450px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre;
}

.code-view.wrap {
    white-space: pre-wrap;
    word-break: break-all;
}

.tree-node {
    margin-left: 20px;
}

.tree-toggle {
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: flex-start;
    gap: 4px;
    padding: 2px 0;
}

.tree-toggle:hover {
    color: #667eea;
}

.tree-arrow {
    display: inline-block;
    width: 16px;
    text-align: center;
    transition: transform 0.2s;
}

.tree-arrow.collapsed {
    transform: rotate(-90deg);
}

.tree-key {
    color: #881391;
    font-weight: 500;
}

.tree-separator {
    color: #6b7280;
}

.tree-children {
    display: block;
}

.tree-children.hidden {
    display: none;
}

/* ---- 文件上传 / 统计 ---- */
.file-input {
    display: none;
}

.stats {
    display: flex;
    gap: 20px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-label {
    color: #9ca3af;
}

.stat-value {
    font-weight: 600;
    color: #374151;
}

/* ---- 小屏：双栏改上下纵向排列 ---- */
@media (max-width: 600px) {
    .main {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .panel {
        height: auto;
    }

    .editor-wrap {
        flex: none;
    }

    .editor-wrap textarea {
        height: 220px;
    }

    textarea {
        height: auto;
        min-height: 180px;
        resize: vertical;
    }

    #output,
    .tree-view,
    .code-view {
        height: auto;
        min-height: 180px;
    }
}