/* ===== 编辑器整体容器 ===== */
.editor-wrapper {
    display: flex;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    background: #1e1e2e;
    overflow: hidden;
    min-height: 340px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.6;
    position: relative;
}

/* ===== 行号区域 ===== */
.line-numbers {
    flex: 0 0 48px;
    background: #181825;
    color: #6c7086;
    padding: 12px 0;
    text-align: right;
    user-select: none;
    overflow: hidden;
    border-right: 1px solid #313244;
    font-size: 14px;
    line-height: 1.6;
    font-family: inherit;
    padding-right: 10px;
    min-height: 100%;
    counter-reset: line;
}
.line-numbers .line-num {
    display: block;
    height: 22.4px;
    padding: 0 4px 0 0;
    color: #6c7086;
    font-size: 13px;
    text-align: right;
    transition: color 0.15s;
}
.line-numbers .line-num.active {
    color: #cdd6f4;
    font-weight: 600;
}

/* ===== 代码编辑器 textarea ===== */
.code-editor {
    flex: 1;
    background: #1e1e2e;
    color: #cdd6f4;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    resize: vertical;
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.6;
    font-family: inherit;
    min-height: 340px;
    tab-size: 4;
    -moz-tab-size: 4;
    white-space: pre;
    overflow: auto;
    letter-spacing: 0.02em;
}
.code-editor:focus {
    border: none !important;
    box-shadow: none !important;
    background: #1e1e2e;
}
.code-editor::selection {
    background: #45475a;
    color: #cdd6f4;
}
.code-editor::-webkit-scrollbar,
.line-numbers::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.code-editor::-webkit-scrollbar-track,
.line-numbers::-webkit-scrollbar-track {
    background: #181825;
}
.code-editor::-webkit-scrollbar-thumb,
.line-numbers::-webkit-scrollbar-thumb {
    background: #45475a;
    border-radius: 4px;
}
.code-editor::-webkit-scrollbar-thumb:hover,
.line-numbers::-webkit-scrollbar-thumb:hover {
    background: #585b70;
}

/* ===== 输出区域 ===== */
.output-area {
    background: #0f0f1a;
    color: #cdd6f4;
    padding: 16px 20px;
    border-radius: 0.375rem;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.7;
    min-height: 120px;
    max-height: 380px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
    border: 1px solid #313244;
}
.output-area .out-stdout {
    color: #a6e3a1;
}
.output-area .out-stderr {
    color: #f38ba8;
}
.output-area .out-error {
    color: #f9e2af;
    background: #1e1e2e;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
}
.output-area .out-info {
    color: #89b4fa;
}
.output-area .out-time {
    color: #94e2d5;
    font-size: 13px;
}
.output-area .out-empty {
    color: #6c7086;
    font-style: italic;
    user-select: none;
}

/* ===== 工具栏按钮 ===== */
.toolbar-btn {
    border-radius: 6px;
    font-weight: 500;
    font-size: 13px;
    padding: 6px 16px;
    transition: all 0.2s;
}
.toolbar-btn:active {
    transform: scale(0.96);
}
.btn-run {
    background: #89b4fa;
    color: #1e1e2e;
    border: none;
}
.btn-run:hover {
    background: #74c7ec;
    color: #1e1e2e;
}
.btn-run:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
.btn-clear {
    background: #45475a;
    color: #cdd6f4;
    border: none;
}
.btn-clear:hover {
    background: #585b70;
    color: #cdd6f4;
}
.btn-example {
    background: #313244;
    color: #cdd6f4;
    border: none;
}
.btn-example:hover {
    background: #45475a;
    color: #cdd6f4;
}
.btn-copy {
    background: #313244;
    color: #cdd6f4;
    border: none;
    font-size: 13px;
    padding: 4px 14px;
    border-radius: 6px;
}
.btn-copy:hover {
    background: #45475a;
    color: #cdd6f4;
}

/* ===== 状态徽章 ===== */
.status-badge {
    font-size: 13px;
    font-weight: 500;
    padding: 4px 14px;
    border-radius: 20px;
    letter-spacing: 0.3px;
}
.status-badge.loading {
    background: #f9e2af;
    color: #1e1e2e;
}
.status-badge.ready {
    background: #a6e3a1;
    color: #1e1e2e;
}
.status-badge.error {
    background: #f38ba8;
    color: #1e1e2e;
}
.status-badge.running {
    background: #89b4fa;
    color: #1e1e2e;
    animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===== 模态框等暗色主题 ===== */
.modal-content.bg-dark {
    background-color: #1e1e2e !important;
}
.modal-content .border-secondary {
    border-color: #313244 !important;
}
.modal-content .btn-close-white {
    filter: invert(1);
}
.badge.bg-secondary.pkg-recommend {
    background-color: #45475a !important;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.4rem 0.8rem;
    transition: background 0.2s;
}
.badge.bg-secondary.pkg-recommend:hover {
    background-color: #585b70 !important;
}

/* ===== 卡片暗色 ===== */
.card-dark {
    background: #181825;
    border: 1px solid #313244;
    border-radius: 12px;
    overflow: hidden;
}
.card-dark .card-header {
    background: #1e1e2e;
    border-bottom: 1px solid #313244;
    color: #cdd6f4;
    padding: 12px 20px;
    font-weight: 500;
    font-size: 15px;
}
.card-dark .card-body {
    background: #181825;
    padding: 16px 20px 20px 20px;
}

/* ===== 提示条 ===== */
.alert-custom {
    background: #313244;
    border: none;
    color: #cdd6f4;
    border-radius: 10px;
    padding: 10px 18px;
    font-size: 14px;
}
.alert-custom a {
    color: #89b4fa;
    text-decoration: none;
}
.alert-custom a:hover {
    text-decoration: underline;
}

/* ===== 加载遮罩 ===== */
.loading-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(30, 30, 46, 0.85);
    backdrop-filter: blur(3px);
    z-index: 10;
    border-radius: 0.375rem;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    color: #cdd6f4;
    font-size: 15px;
}
.loading-overlay.show {
    display: flex;
}
.loading-overlay .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #313244;
    border-top-color: #89b4fa;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin-bottom: 16px;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== 键盘提示 ===== */
.key-hint {
    color: #6c7086;
    font-size: 12px;
    background: #313244;
    padding: 2px 10px;
    border-radius: 4px;
    font-family: monospace;
    letter-spacing: 0.5px;
}

/* ===== 文件列表样式 ===== */
.file-item {
    background: #313244;
    padding: 2px 8px 2px 10px;
    border-radius: 16px;
    font-size: 13px;
    transition: background 0.15s;
}
.file-item:hover {
    background: #45475a;
}
.file-item .file-name {
    cursor: pointer;
    color: #89b4fa;
}
.file-item .file-name:hover {
    text-decoration: underline;
}
.file-item .btn {
    padding: 0 4px;
    line-height: 1;
    background: transparent;
    border: none;
    color: #a6e3a1;
}
.file-item .btn:hover {
    opacity: 0.7;
}
.file-item .btn-delete-file {
    color: #f38ba8;
}

/* ===== 响应式 ===== */
@media (max-width: 576px) {
    .editor-wrapper {
        font-size: 12px;
        min-height: 240px;
    }
    .line-numbers {
        flex: 0 0 36px;
        font-size: 12px;
        padding-right: 6px;
    }
    .line-numbers .line-num {
        height: 19.2px;
        font-size: 11px;
    }
    .code-editor {
        font-size: 12px;
        padding: 10px 12px;
        min-height: 240px;
    }
    .output-area {
        font-size: 12px;
        padding: 12px 14px;
        min-height: 80px;
        max-height: 260px;
    }
    .toolbar-btn {
        font-size: 12px;
        padding: 4px 12px;
    }
}
