/* Extras for the JSON / XML / HTML compare tools that tools.css has no component for:
   code textareas, the parse-error box, the JSON tree, path rows and the diff table.
   Loaded after tools.css by json-formatter, xml-to-json, json-to-xml,
   json-path-finder, json-size-calculator and html-compare. */
.tool-input-wrap textarea.is-code {
    min-height: 15rem;
    overflow: auto;
    white-space: pre;
    tab-size: 2;
}

.tool-input-wrap textarea.is-code.is-short {
    min-height: 12rem;
}

.json-tool-error {
    margin: 0 0 1.2rem;
    padding: 0.8rem 0.9rem;
    border: 1px solid #f1c4bf;
    border-left: 4px solid #b42318;
    border-radius: 9px;
    color: #7a1a12;
    background: #fdeceb;
    font-size: 0.74rem;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.json-tool-error[hidden] {
    display: none;
}

.json-tool-error p {
    margin: 0;
}

.json-tool-error-title {
    font-weight: 800;
}

.json-tool-error-snippet {
    margin: 0.6rem 0 0;
    padding: 0.55rem 0.7rem;
    overflow-x: auto;
    border: 1px solid #f1c4bf;
    border-radius: 7px;
    color: var(--color-gray-900);
    background: var(--color-white);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.72rem;
    line-height: 1.5;
    white-space: pre;
}

.json-tool-error-snippet[hidden] {
    display: none;
}

/* JSON tree (path finder) */
.json-tree {
    max-height: 32rem;
    overflow: auto;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--color-gray-200);
    border-radius: 11px;
    background: var(--color-white);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.74rem;
    line-height: 1.75;
}

.json-tree ul {
    margin: 0;
    padding-left: 1.1rem;
    border-left: 1px dashed var(--color-gray-200);
    list-style: none;
}

.json-tree ul.json-tree-root {
    padding-left: 0;
    border-left: 0;
}

.json-tree summary {
    cursor: pointer;
    list-style: none;
    white-space: nowrap;
}

.json-tree summary::-webkit-details-marker {
    display: none;
}

.json-tree summary::before {
    content: "\25B8";
    display: inline-block;
    width: 1rem;
    color: var(--color-gray-400);
}

.json-tree details[open] > summary::before {
    transform: rotate(90deg);
}

.json-tree-leaf {
    padding-left: 1rem;
    white-space: nowrap;
}

.json-tree-node {
    padding: 0 0.25rem;
    border-radius: 4px;
    cursor: pointer;
}

.json-tree-node:hover,
.json-tree-node:focus-visible {
    outline: 0;
    background: var(--color-gray-100);
}

.json-tree-node.is-hit {
    background: #fdf3e2;
}

.json-tree-node.is-selected {
    background: var(--color-gray-100);
    box-shadow: 0 0 0 1px var(--color-gold);
}

.json-tree-key { color: var(--color-gray-900); font-weight: 700; }
.json-tree-idx,
.json-tree-meta,
.json-tree-colon { color: var(--color-gray-500); }
.json-tree-meta { margin-left: 0.35rem; font-weight: 400; }
.json-tree-root-key { font-weight: 800; }
.json-tree-v.is-string { color: #2d6348; }
.json-tree-v.is-number { color: #8a5a00; }
.json-tree-v.is-boolean { color: #5b3fa8; }
.json-tree-v.is-null { color: var(--color-gray-500); font-style: italic; }

/* selected path rows */
.json-path-row {
    display: grid;
    grid-template-columns: 8.5rem minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.json-path-row > span {
    color: var(--color-gray-600);
    font-size: 0.7rem;
    font-weight: 700;
}

.json-path-row .tool-input-wrap input {
    min-height: 2.4rem;
}

.json-example {
    padding: 0.2rem 0.55rem;
    border: 1px solid var(--color-gray-200);
    border-radius: 999px;
    color: var(--color-gray-800);
    background: var(--color-white);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.68rem;
}

.json-example:hover,
.json-example:focus-visible {
    border-color: var(--color-gray-800);
    outline: 0;
}

.json-examples {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.5rem;
    color: var(--color-gray-500);
    font-size: 0.68rem;
}

.json-hit {
    padding: 0;
    border: 0;
    color: var(--color-gray-900);
    background: none;
    font: inherit;
    text-align: left;
    text-decoration: underline;
    text-decoration-color: var(--color-gold);
    text-underline-offset: 2px;
}

.json-size-share {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 8rem;
}

.json-size-share .tool-bar-track {
    flex: 1;
}

.json-pill-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.8rem;
    color: var(--color-gray-600);
    font-size: 0.74rem;
}

/* side-by-side diff */
.json-diff-wrap {
    max-height: 36rem;
    overflow: auto;
    border: 1px solid var(--color-gray-200);
    border-radius: 11px;
    background: var(--color-white);
}

.json-diff-table {
    width: 100%;
    min-width: 36rem;
    border-collapse: collapse;
    table-layout: fixed;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.72rem;
    line-height: 1.55;
}

.json-diff-table col.is-num {
    width: 2.8rem;
}

.json-diff-table td {
    padding: 0 0.5rem;
    vertical-align: top;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.json-diff-num {
    border-right: 1px solid var(--color-gray-100);
    color: var(--color-gray-400);
    background: var(--color-gray-50);
    text-align: right;
    user-select: none;
}

.json-diff-code + .json-diff-num {
    border-left: 1px solid var(--color-gray-200);
}

.json-diff-code.is-del { background: #fdeceb; }
.json-diff-code.is-add { background: #e8f6ee; }
.json-diff-code.is-empty { background: var(--color-gray-50); }
.json-diff-table del { border-radius: 2px; background: #f6c6c0; text-decoration: none; }
.json-diff-table ins { border-radius: 2px; background: #b9e4c9; text-decoration: none; }

.json-diff-table tr.is-gap td {
    color: var(--color-gray-400);
    background: var(--color-gray-50);
    text-align: center;
}

@media (max-width: 575.98px) {
    .json-path-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .json-path-row > span {
        grid-column: 1 / -1;
    }
}

.json-query-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.json-query-row .tool-input-wrap {
    flex: 1 1 16rem;
    min-width: 0;
}
