/* =========================================================
   JSON Formatter
========================================================= */

* {
    box-sizing: border-box;
}


html,
body {
    margin: 0;
    padding: 0;

    width: 100%;
    height: 100%;

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        "Microsoft YaHei",
        sans-serif;

    background: #f6f7f9;

    color: #202124;
}


body {
    min-height: 100vh;
}


/* =========================================================
   Main
========================================================= */

.json-tool {

    width: 100%;
    min-height: 100vh;

    padding: 28px 32px;

    display: flex;
    flex-direction: column;
}


/* =========================================================
   Header
========================================================= */

.tool-header {

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 24px;

    margin-bottom: 22px;
}


.tool-title {

    font-size: 24px;

    font-weight: 650;

    letter-spacing: -0.3px;
}


.tool-description {

    margin-top: 6px;

    font-size: 13px;

    color: #7b818a;
}


/* =========================================================
   Actions
========================================================= */

.tool-actions {

    display: flex;

    align-items: center;

    gap: 8px;
}


button {

    height: 38px;

    padding: 0 16px;

    border-radius: 8px;

    border: 1px solid #dfe2e6;

    background: #ffffff;

    color: #30343b;

    font-size: 13px;

    cursor: pointer;

    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}


button:hover {

    background: #f3f4f6;

    border-color: #cfd3d8;
}


button:active {

    transform: translateY(1px);
}


.primary-button {

    border-color: #22252a;

    background: #22252a;

    color: #ffffff;
}


.primary-button:hover {

    background: #30343a;

    border-color: #30343a;
}


/* =========================================================
   Options
========================================================= */

.tool-options {

    height: 46px;

    padding: 0 14px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    background: #ffffff;

    border: 1px solid #e4e6e9;

    border-bottom: none;

    border-radius:
        10px 10px 0 0;
}


.option-group {

    display: flex;

    align-items: center;

    gap: 10px;
}


.option-label {

    font-size: 12px;

    color: #7b818a;
}


select {

    height: 30px;

    padding: 0 10px;

    border: 1px solid #dfe2e6;

    border-radius: 6px;

    background: #ffffff;

    color: #30343b;

    outline: none;
}


.status {

    font-size: 12px;

    color: #8a9098;
}


.status.success {

    color: #2d7a52;
}


.status.warning {

    color: #9a6b00;
}


.status.error {

    color: #c23b3b;
}


/* =========================================================
   Editor Area
========================================================= */

.editor-area {

    flex: 1;

    min-height: 0;

    display: grid;

    grid-template-columns:
        minmax(0, 1fr) minmax(0, 1fr);

    gap: 14px;
}


/* =========================================================
   Editor Panel
========================================================= */

.editor-panel {

    min-width: 0;

    min-height: 500px;

    display: flex;

    flex-direction: column;

    background: #ffffff;

    border: 1px solid #e4e6e9;

    border-radius: 10px;

    overflow: hidden;

    box-shadow:
        0 2px 8px rgba(0,
            0,
            0,
            0.025);
}


.panel-header {

    height: 44px;

    padding: 0 14px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    border-bottom:
        1px solid #eceef1;

    font-size: 13px;

    font-weight: 600;
}


.panel-info {

    font-size: 11px;

    font-weight: 400;

    color: #9aa0a8;
}


/* =========================================================
   Input Textarea
========================================================= */

textarea {

    flex: 1;

    width: 100%;

    min-height: 0;

    padding: 18px;

    resize: none;

    border: none;

    outline: none;

    background: #ffffff;

    color: #292d33;

    font-family:
        "SFMono-Regular",
        Consolas,
        "Liberation Mono",
        Menlo,
        monospace;

    font-size: 13px;

    line-height: 1.7;

    tab-size: 2;
}


textarea::placeholder {

    color: #b0b5bc;
}


#inputEditor {

    overflow: auto;
}


/* =========================================================
   JSON Output
========================================================= */

/*
   右侧不能再使用 textarea。

   textarea 本身无法对不同 JSON 类型分别着色。
   这里使用 div + code 作为语法高亮输出区域。
*/

#outputEditor {

    position: relative;

    flex: 1;

    width: 100%;

    min-height: 0;

    overflow: auto;

    padding: 18px;

    background: #fafbfc;

    color: #292d33;

    font-family:
        "SFMono-Regular",
        Consolas,
        "Liberation Mono",
        Menlo,
        monospace;

    font-size: 13px;

    line-height: 1.7;

    tab-size: 2;

    white-space: pre;

    outline: none;
}


/* =========================================================
   JSON Code
========================================================= */

#outputCode {

    display: block;

    min-height: 100%;

    font-family: inherit;

    font-size: inherit;

    line-height: inherit;

    white-space: inherit;
}


/* =========================================================
   JSON Syntax Highlight
========================================================= */


/* JSON Key */

.json-key {

    color: #8e44ad;
}


/* String Value */

.json-string {

    color: #167a56;
}


/* Number */

.json-number {

    color: #1671c5;
}


/* Boolean */

.json-boolean {

    color: #c65d11;

    font-weight: 600;
}


/* null */

.json-null {

    color: #7a4cc2;

    font-weight: 600;
}


/* Brackets */

.json-bracket {

    color: #59636e;

    font-weight: 500;
}


/* =========================================================
   Output Placeholder
========================================================= */

.output-placeholder {

    position: absolute;

    top: 18px;

    left: 18px;

    color: #b0b5bc;

    font-family:
        "SFMono-Regular",
        Consolas,
        "Liberation Mono",
        Menlo,
        monospace;

    font-size: 13px;

    line-height: 1.7;

    pointer-events: none;
}


#outputEditor.has-content .output-placeholder {

    display: none;
}


/* =========================================================
   Scrollbar
========================================================= */

#inputEditor::-webkit-scrollbar,
#outputEditor::-webkit-scrollbar {

    width: 8px;

    height: 8px;
}


#inputEditor::-webkit-scrollbar-track,
#outputEditor::-webkit-scrollbar-track {

    background: transparent;
}


#inputEditor::-webkit-scrollbar-thumb,
#outputEditor::-webkit-scrollbar-thumb {

    background: #d9dde2;

    border-radius: 10px;
}


#inputEditor::-webkit-scrollbar-thumb:hover,
#outputEditor::-webkit-scrollbar-thumb:hover {

    background: #c5cad1;
}


/* =========================================================
   Footer
========================================================= */

.tool-footer {

    padding-top: 14px;

    font-size: 11px;

    color: #9aa0a8;
}


/* =========================================================
   Responsive
========================================================= */

@media (max-width: 900px) {

    .json-tool {

        padding: 20px;
    }


    .tool-header {

        align-items: flex-start;

        flex-direction: column;
    }


    .tool-actions {

        width: 100%;

        flex-wrap: wrap;
    }


    .editor-area {

        grid-template-columns: 1fr;
    }


    .editor-panel {

        min-height: 400px;
    }

}