/* ============================================================
   在线HTML编辑器（VSCode Style）— 工具功能样式
   全部样式作用于 .vsc-window 容器内部，避免与站点样式冲突
   ============================================================ */

.vsc-window {
    --vsc-bg: #1e1e1e;
    --vsc-titlebar: #323233;
    --vsc-titlebar-active: #3c3c3c;
    --vsc-activitybar: #333333;
    --vsc-sidebar: #252526;
    --vsc-tabbar: #252526;
    --vsc-tab-active: #1e1e1e;
    --vsc-tab-inactive: #2d2d2d;
    --vsc-statusbar: #007acc;
    --vsc-panel: #1e1e1e;
    --vsc-text: #cccccc;
    --vsc-text-dim: #858585;
    --vsc-accent: #007acc;
    --vsc-accent-hover: #1177bb;
    --vsc-border: #3c3c3c;
    --vsc-button: #0e639c;
    --vsc-button-hover: #1177bb;
    --vsc-success: #4ec9b0;
    --vsc-danger: #f48771;
    --vsc-warning: #cca700;
    --vsc-modal-bg: #252526;
    --vsc-input-bg: #3c3c3c;

    margin: 0;
    padding: 0;
    box-sizing: border-box;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 660px;
    max-height: 80vh;
    width: 100%;
    background: var(--vsc-bg);
    color: var(--vsc-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    font-size: 13px;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.25);
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.18);
    text-align: left;
    line-height: 1.5;
}

.vsc-window *,
.vsc-window *::before,
.vsc-window *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ========== 顶部标题栏 ========== */
.vsc-titlebar {
    height: 34px;
    background: var(--vsc-titlebar);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px 0 0;
    user-select: none;
    border-bottom: 1px solid #1a1a1a;
    flex-shrink: 0;
}

.vsc-titlebar-left {
    display: flex;
    align-items: center;
    height: 100%;
}

.vsc-app-icon {
    width: 48px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--vsc-accent);
    color: #fff;
    font-size: 16px;
    margin-right: 10px;
    flex-shrink: 0;
}

.vsc-menubar {
    display: flex;
    align-items: center;
    height: 100%;
}

.vsc-menubar-item {
    padding: 0 10px;
    height: 100%;
    display: flex;
    align-items: center;
    color: var(--vsc-text);
    cursor: pointer;
    font-size: 12px;
    transition: background 0.15s;
}

.vsc-menubar-item:hover {
    background: #505050;
}

.vsc-titlebar-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--vsc-text-dim);
    font-size: 12px;
    pointer-events: none;
    white-space: nowrap;
}

.vsc-titlebar-center i {
    font-size: 11px;
}

.vsc-window-controls {
    display: flex;
    align-items: center;
}

.vsc-window-btn {
    width: 42px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--vsc-text);
    cursor: pointer;
    transition: background 0.15s;
    font-size: 11px;
}

.vsc-window-btn:hover {
    background: #505050;
}

.vsc-window-btn.close:hover {
    background: #e81123;
    color: #fff;
}

/* ========== 标签栏 ========== */
.vsc-tabbar {
    height: 35px;
    background: var(--vsc-tabbar);
    display: flex;
    align-items: flex-end;
    border-bottom: 1px solid #1a1a1a;
    overflow-x: auto;
    flex-shrink: 0;
}

.vsc-tabbar::-webkit-scrollbar {
    height: 0;
}

.vsc-tabs {
    display: flex;
    align-items: flex-end;
    height: 100%;
}

.vsc-tab {
    display: flex;
    align-items: center;
    padding: 0 12px;
    height: 35px;
    background: var(--vsc-tab-inactive);
    color: #969696;
    cursor: pointer;
    font-size: 13px;
    border-right: 1px solid #1a1a1a;
    gap: 8px;
    white-space: nowrap;
    transition: all 0.15s;
    max-width: 220px;
    position: relative;
    user-select: none;
}

.vsc-tab.active {
    background: var(--vsc-tab-active);
    color: var(--vsc-text);
}

.vsc-tab.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--vsc-accent);
}

.vsc-tab i.fa-html5 {
    color: #e44d26;
}

.vsc-tab i.fa-eye {
    color: var(--vsc-accent);
}

.vsc-tab .tab-close {
    display: none;
}

/* ========== 主体区域 ========== */
.vsc-main {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* ========== 活动栏 ========== */
.vsc-activitybar {
    width: 46px;
    background: var(--vsc-activitybar);
    display: flex;
    flex-direction: column;
    align-items: center;
    border-right: 1px solid #1a1a1a;
    padding-top: 6px;
    flex-shrink: 0;
}

.vsc-activity-item {
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #858585;
    cursor: pointer;
    font-size: 19px;
    position: relative;
    transition: all 0.15s;
}

.vsc-activity-item:hover {
    color: #fff;
}

.vsc-activity-item.active {
    color: #fff;
}

.vsc-activity-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 28px;
    background: var(--vsc-accent);
}

.vsc-activity-item.bottom {
    margin-top: auto;
    margin-bottom: 8px;
}

/* ========== 侧边栏（文件树） ========== */
.vsc-sidebar {
    width: 240px;
    background: var(--vsc-sidebar);
    display: flex;
    flex-direction: column;
    border-right: 1px solid #1a1a1a;
    flex-shrink: 0;
}

.vsc-sidebar-header {
    height: 35px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    font-size: 11px;
    font-weight: 600;
    color: var(--vsc-text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.vsc-sidebar-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.vsc-file-tree {
    padding: 2px 0;
}

.vsc-folder-node,
.vsc-file-node {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--vsc-text);
    transition: background 0.1s;
    user-select: none;
    white-space: nowrap;
}

.vsc-folder-node:hover,
.vsc-file-node:hover {
    background: #2a2d2e;
}

.vsc-file-node.active {
    background: #37373d;
}

.vsc-folder-icon,
.vsc-file-icon {
    width: 20px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
}

.vsc-folder-icon { color: #dcb67a; }
.vsc-file-icon.html { color: #e44d26; }
.vsc-file-icon.css { color: #2965f1; }
.vsc-file-icon.js { color: #f7df1e; }
.vsc-file-icon.json { color: #cbcb41; }
.vsc-file-icon.md { color: #519aba; }

.vsc-children {
    padding-left: 16px;
}

.vsc-children.collapsed {
    display: none;
}

/* ========== 编辑/预览区域 ========== */
.vsc-editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--vsc-panel);
    min-width: 0;
}

.vsc-breadcrumb-bar {
    height: 24px;
    background: var(--vsc-tab-active);
    border-bottom: 1px solid #1a1a1a;
    display: flex;
    align-items: center;
    padding: 0 14px;
    font-size: 12px;
    color: var(--vsc-text-dim);
    gap: 6px;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
}

.vsc-breadcrumb-bar span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.vsc-breadcrumb-bar .sep {
    color: #555;
}

.vsc-breadcrumb-bar .current {
    color: var(--vsc-text);
}

.vsc-editor-tabs-content {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

.vsc-editor-pane {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
}

.vsc-editor-pane.active {
    display: block;
}

#he-editor {
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    border-radius: 0 !important;
}

#he-viewer {
    width: 100%;
    height: 100%;
    background: #fff;
    overflow: auto;
}

#he-viewer iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* ========== 工具栏 ========== */
.vsc-toolbar {
    height: 40px;
    background: var(--vsc-tabbar);
    border-top: 1px solid #1a1a1a;
    border-bottom: 1px solid #1a1a1a;
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
    flex-shrink: 0;
    overflow-x: auto;
}

.vsc-toolbar::-webkit-scrollbar {
    height: 0;
}

.vsc-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 14px;
    background: transparent;
    border: 1px solid var(--vsc-border);
    border-radius: 2px;
    color: var(--vsc-text);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    outline: none;
    flex-shrink: 0;
}

.vsc-btn:hover {
    background: #2a2d2e;
    border-color: #505050;
}

.vsc-btn:active {
    background: #1a1a1a;
}

.vsc-btn.primary {
    background: var(--vsc-button);
    border-color: var(--vsc-button);
    color: #fff;
}

.vsc-btn.primary:hover {
    background: var(--vsc-button-hover);
    border-color: var(--vsc-button-hover);
}

.vsc-btn.success {
    color: var(--vsc-success);
    border-color: rgba(78, 201, 176, 0.3);
}

.vsc-btn.success:hover {
    background: rgba(78, 201, 176, 0.1);
    border-color: var(--vsc-success);
}

.vsc-btn.danger {
    color: var(--vsc-danger);
    border-color: rgba(244, 135, 113, 0.3);
}

.vsc-btn.danger:hover {
    background: rgba(244, 135, 113, 0.1);
    border-color: var(--vsc-danger);
}

.vsc-toolbar-divider {
    width: 1px;
    height: 20px;
    background: var(--vsc-border);
    margin: 0 4px;
    flex-shrink: 0;
}

.vsc-toolbar-spacer {
    flex: 1;
}

.vsc-toolbar-hint {
    font-size: 11px;
    color: var(--vsc-text-dim);
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.vsc-kbd {
    background: #3c3c3c;
    color: var(--vsc-text);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    border: 1px solid #555;
    font-family: Consolas, monospace;
}

/* ========== 底部终端/面板区 ========== */
.vsc-panel {
    height: 0;
    background: var(--vsc-panel);
    border-top: 1px solid #1a1a1a;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: height 0.25s ease;
    flex-shrink: 0;
}

.vsc-panel.open {
    height: 180px;
}

.vsc-panel-tabs {
    height: 35px;
    background: var(--vsc-tabbar);
    display: flex;
    align-items: flex-end;
    padding: 0 20px;
    border-bottom: 1px solid #1a1a1a;
    flex-shrink: 0;
}

.vsc-panel-tab {
    padding: 0 12px;
    height: 34px;
    display: flex;
    align-items: center;
    color: #969696;
    cursor: pointer;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 1px solid transparent;
    transition: all 0.15s;
}

.vsc-panel-tab.active {
    color: var(--vsc-text);
    border-bottom-color: var(--vsc-accent);
}

.vsc-panel-body {
    flex: 1;
    padding: 12px 20px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 13px;
    color: var(--vsc-text-dim);
    overflow-y: auto;
    line-height: 1.7;
    min-height: 0;
}

.vsc-rand-words {
    color: var(--vsc-success);
    font-style: italic;
}

.vsc-rand-words::before {
    content: '> ';
    color: var(--vsc-accent);
    font-style: normal;
}

/* ========== 状态栏 ========== */
.vsc-statusbar {
    height: 24px;
    background: var(--vsc-statusbar);
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    font-size: 12px;
    flex-shrink: 0;
    user-select: none;
    overflow: hidden;
}

.vsc-status-left,
.vsc-status-right {
    display: flex;
    align-items: center;
    height: 100%;
}

.vsc-status-item {
    display: flex;
    align-items: center;
    padding: 0 8px;
    height: 100%;
    gap: 5px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 12px;
    white-space: nowrap;
}

.vsc-status-item:hover {
    background: rgba(255, 255, 255, 0.12);
}

.vsc-status-item i {
    font-size: 11px;
}

/* ========== 模态框（替代 Bootstrap） ========== */
.he-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px);
    z-index: 100000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.he-modal-overlay.show {
    display: flex;
}

.he-modal-box {
    background: var(--vsc-modal-bg, #252526);
    color: var(--vsc-text, #cccccc);
    border: 1px solid #454545;
    border-radius: 10px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 480px;
    max-height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.he-modal-box.modal-lg {
    max-width: 760px;
}

.he-modal-header {
    background: #323233;
    border-bottom: 1px solid #454545;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.he-modal-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--vsc-text, #cccccc);
}

.he-modal-close {
    background: transparent;
    border: none;
    color: #858585;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.15s;
}

.he-modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.he-modal-body {
    padding: 20px;
    overflow-y: auto;
    min-height: 0;
}

.he-modal-footer {
    padding: 12px 20px;
    border-top: 1px solid #454545;
    background: #323233;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

.he-modal-body .he-form-label {
    color: #858585;
    font-size: 13px;
    margin-bottom: 8px;
    display: block;
}

.he-form-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}

.he-form-row .he-form-label {
    margin-bottom: 0;
    white-space: nowrap;
}

.he-form-row input[type="range"] {
    flex: 1;
    accent-color: var(--vsc-accent, #007acc);
}

.he-form-select {
    width: 100%;
    background: #3c3c3c;
    color: #cccccc;
    border: 1px solid #3c3c3c;
    border-radius: 6px;
    font-size: 13px;
    padding: 10px 12px;
    outline: none;
    cursor: pointer;
    font-family: inherit;
}

.he-form-select:focus {
    border-color: var(--vsc-accent, #007acc);
    box-shadow: 0 0 0 1px var(--vsc-accent, #007acc);
}

.he-btn {
    border-radius: 6px;
    font-size: 13px;
    padding: 8px 18px;
    border: 1px solid transparent;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}

.he-btn-primary {
    background: var(--vsc-button, #0e639c);
    border-color: var(--vsc-button, #0e639c);
    color: #fff;
}

.he-btn-primary:hover {
    background: var(--vsc-button-hover, #1177bb);
    border-color: var(--vsc-button-hover, #1177bb);
}

.he-btn-success {
    background: #2d5a3f;
    border-color: #2d5a3f;
    color: #fff;
}

.he-btn-success:hover {
    background: #3a7a5e;
    border-color: #3a7a5e;
}

#he-toTextResult {
    background: #1a1a1a;
    border: 1px solid #3c3c3c;
    border-radius: 6px;
    min-height: 200px;
    max-height: 50vh;
    overflow-y: auto;
    padding: 12px;
    font-family: Consolas, monospace;
    font-size: 13px;
    color: #cccccc;
    word-break: break-all;
    line-height: 1.7;
}

/* ========== 滚动条（仅编辑器内部） ========== */
.vsc-window ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.vsc-window ::-webkit-scrollbar-track {
    background: transparent;
}

.vsc-window ::-webkit-scrollbar-thumb {
    background: #424242;
    border-radius: 5px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.vsc-window ::-webkit-scrollbar-thumb:hover {
    background: #4f4f4f;
    border: 2px solid transparent;
    background-clip: padding-box;
}

/* ACE 覆盖：与站点全局样式隔离 */
#he-editor.ace_editor {
    font-family: "Consolas", "Monaco", "Microsoft YaHei", monospace !important;
    background-color: transparent !important;
}

#he-editor .ace_gutter {
    background: var(--vsc-bg, #1e1e1e) !important;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .vsc-sidebar,
    .vsc-titlebar-center {
        display: none;
    }
    .vsc-btn span.btn-text {
        display: none;
    }
    .vsc-btn {
        padding: 0 10px;
    }
    .vsc-window {
        height: 560px;
        max-height: 82vh;
    }
}

@media (max-width: 520px) {
    .vsc-activitybar,
    .vsc-menubar,
    .vsc-toolbar-hint {
        display: none;
    }
}

/* ========== 详情页全屏模式 ========== */
body.he-detail-full main.container {
    max-width: 100%;
    padding: 0 16px;
}

body.he-detail-full .tools-container {
    max-width: none;
    padding-left: 0;
    padding-right: 0;
}

body.he-detail-full .tool-detail-section .tools-grid {
    max-width: none;
}

body.he-detail-full .tool-detail-section .feature-card-webmaster,
body.he-detail-full .tool-detail-section .feature-card-media {
    padding: 18px 20px 20px;
}

.he-fullscreen .vsc-window {
    height: calc(100vh - 240px);
    max-height: none;
}

@media (max-width: 768px) {
    .he-fullscreen .vsc-window {
        height: calc(100vh - 180px);
    }
}

/* ========== 加载失败/重试 ========== */
#he-editor .he-error-box {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #f48771;
    font-size: 13px;
    background: #1e1e1e;
    z-index: 2;
    padding: 20px;
    text-align: center;
}

#he-editor .he-error-box .he-error-url {
    color: #858585;
    font-family: Consolas, monospace;
    font-size: 12px;
    word-break: break-all;
    max-width: 90%;
}

#he-editor .he-error-box .he-retry-btn {
    background: #0e639c;
    border: 1px solid #0e639c;
    color: #fff;
    border-radius: 4px;
    padding: 6px 22px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}

#he-editor .he-error-box .he-retry-btn:hover {
    background: #1177bb;
    border-color: #1177bb;
}
