/* =========================================================
   CODE EDITOR MODAL
========================================================= */

.code-editor-modal {

    position: fixed;

    inset: 0;

    z-index: 1000;

    display: flex;

    align-items: center;

    justify-content: center;

    padding: 24px;

    background: rgba(15, 23, 42, 0.42);

    opacity: 0;

    visibility: hidden;

    pointer-events: none;

    transition:
        opacity 0.18s ease,
        visibility 0.18s ease;
}


.code-editor-modal.open {

    opacity: 1;

    visibility: visible;

    pointer-events: auto;
}


/* =========================================================
   DIALOG
========================================================= */

.code-editor-dialog {

    width: min(900px, 100%);

    height: min(680px, calc(100vh - 48px));

    display: flex;

    flex-direction: column;

    overflow: hidden;

    background: #17212b;

    border: 1px solid rgba(30, 55, 80, 0.18);

    border-radius: 16px;

    box-shadow:
        0 24px 70px rgba(15, 23, 42, 0.32);
}


/* =========================================================
   HEADER
========================================================= */

.code-editor-dialog-header {

    min-height: 62px;

    flex-shrink: 0;

    display: flex;

    align-items: center;

    justify-content: space-between;

    padding: 0 17px 0 20px;

    border-bottom: 1px solid rgba(255, 255, 255, 0.08);

    background: #1e2a35;
}


.code-editor-dialog-title {

    font-size: 14px;

    font-weight: 600;

    color: #ffffff;
}


.code-editor-close {

    width: 32px;

    height: 32px;

    display: flex;

    align-items: center;

    justify-content: center;

    border: 0;

    border-radius: 7px;

    background: transparent;

    color: #92a0ad;

    font-size: 24px;

    line-height: 1;

    cursor: pointer;
}


.code-editor-close:hover {

    background: #253340;

    color: #ffffff;
}


/* =========================================================
   Python 代码编辑器弹窗
   ========================================================= */

.code-editor-dialog-body {

    flex: 1;

    min-height: 0;

    display: flex;

    flex-direction: column;

    padding: 0;

    background: #101820;

}


/* =========================================================
   Python 编辑器
   ========================================================= */

.code-editor-input {

    flex: 1;

    min-height: 0;

    display: grid;

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

    overflow: hidden;

    background: #101820;
}


.code-editor-gutter {

    min-height: 0;

    margin: 0;

    padding: 20px 8px 20px 0;

    overflow: hidden;

    border-right: 1px solid rgba(255, 255, 255, 0.04);

    background: #101820;

    color: #53616e;

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

    font-size: 13px;

    line-height: 1.8;

    text-align: right;

    user-select: none;
}


#modalPythonEditor {

    width: 100%;

    height: 100%;

    min-height: 0;

    display: block;

    resize: none;

    border: 0;

    outline: 0;

    padding: 20px 18px;

    box-sizing: border-box;

    background: #101820;

    color: #e7edf3;

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

    font-size: 13px;

    line-height: 1.8;

    tab-size: 4;

    white-space: pre;

}


/* =========================================================
   运行按钮区域
   ========================================================= */

.code-editor-run-area {

    flex: 0 0 auto;

    display: flex;

    justify-content: flex-start;

    align-items: center;

    min-height: 54px;

    padding: 9px 12px;

    background: #1b2732;

    border-top: 1px solid rgba(255, 255, 255, 0.06);
}


/* =========================================================
   运行按钮
   ========================================================= */

.code-editor-run {

    width: 100px;

    height: 34px;

    padding: 0 10px;

    display: inline-flex;

    align-items: center;

    justify-content: center;

    flex: 0 0 100px;

    gap: 6px;

    box-sizing: border-box;

    white-space: nowrap;

    border: 0;

    border-radius: 7px;

    background: #4e9f6f;

    color: #ffffff;

    font-size: 12px;

    font-weight: 700;

    cursor: pointer;

    transition:
        background 0.15s ease,
        opacity 0.15s ease;

}


.code-editor-run:hover {

    background: #41865e;

}


.code-editor-run:active {

    background: #37734f;

}


.code-editor-run:disabled {

    opacity: 0.6;

    cursor: default;

}


/* =========================================================
   输出结果区域
   ========================================================= */

.code-editor-output {

    flex: 0 0 150px;

    min-height: 0;

    display: flex;

    flex-direction: column;

    overflow: hidden;

    background: #0d141a;

    border-top: 1px solid rgba(255, 255, 255, 0.06);

}


/* =========================================================
   输出结果标题
   ========================================================= */

.code-editor-output-title {

    flex: 0 0 34px;

    display: flex;

    align-items: center;

    padding: 0 14px;

    box-sizing: border-box;

    background: #0d141a;

    border-bottom: 1px solid rgba(255, 255, 255, 0.04);

    color: #8f9ba6;

    font-size: 10px;

    font-weight: 700;

    letter-spacing: 0.7px;

}


/* =========================================================
   输出内容
   ========================================================= */

#modalPythonOutput {

    flex: 1;

    min-height: 0;

    width: 100%;

    margin: 0;

    padding: 6px 15px 15px;

    overflow: auto;

    box-sizing: border-box;

    background: #0d141a;

    color: #cdd7df;

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

    font-size: 12px;

    line-height: 1.7;

    white-space: pre-wrap;

    word-break: break-word;

}


#modalPythonOutput:empty::before {

    content: "运行代码后，输出结果会显示在这里。";

    color: #718096;

}



/* =========================================================
   FOOTER
========================================================= */

.code-editor-dialog-footer {

    height: 56px;

    flex-shrink: 0;

    display: flex;

    align-items: center;

    justify-content: flex-end;

    padding: 0 16px;

    border-top: 1px solid rgba(255, 255, 255, 0.08);

    background: #1e2a35;
}

.practice-code-example {

    margin-top: 16px;

    margin-bottom: 16px;
}


/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 640px) {

    .code-editor-modal {

        padding: 0;
    }


    .code-editor-dialog {

        width: 100%;

        height: 100%;

        max-height: none;

        border: 0;

        border-radius: 0;
    }


    .code-editor-dialog-header {

        padding-left: 16px;
    }


    #modalPythonEditor {

        padding: 16px;

        font-size: 13px;
    }

    .code-editor-gutter {

        padding: 16px 8px 16px 0;

        font-size: 13px;
    }


    .code-editor-dialog-footer {

        height: 58px;

        padding:
            0 12px env(safe-area-inset-bottom);
    }


}