/* ============================================================
   Mermaid 流程图编辑器 · tool.css
   迪妙网络空间安全学院 · 反钓工具箱
   说明：导航/页脚桌面端样式由 ../../style.css 统一提供，本文件
   只补充工具页专属样式与移动端断点适配（768px/1024px）。
   ============================================================ */

/* ---------- 页头补充 ---------- */
.tool-meta-badges {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
}
.tool-meta-badges .tmb {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-light);
    border: 1px solid rgba(26, 110, 255, 0.15);
    padding: 5px 14px;
    border-radius: 100px;
}

/* ---------- 引擎状态卡片 ---------- */
.engine-section {
    padding: 8px 0 16px;
    position: relative;
    z-index: 50;
}
.engine-card {
    position: sticky;
    top: 84px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 13px 20px;
    box-shadow: var(--shadow);
}
.engine-left {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 0;
}
.engine-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #f59e0b;
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.15);
    flex-shrink: 0;
    margin-top: 5px;
    animation: engPulse 1.6s ease-in-out infinite;
}
.engine-dot.ok {
    background: #16a34a;
    box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.15);
    animation: none;
}
.engine-dot.fallback {
    background: #1a6eff;
    box-shadow: 0 0 0 4px rgba(26, 110, 255, 0.15);
    animation: none;
}
@keyframes engPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}
.engine-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.4;
}
.engine-desc {
    font-size: 12px;
    color: var(--text-light);
    line-height: 1.6;
    margin-top: 2px;
}
.engine-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.engine-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 100px;
    background: var(--primary-light);
    color: var(--primary);
    white-space: nowrap;
}
.engine-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 8px;
    border: 1.5px solid var(--border);
    background: #ffffff;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.engine-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

/* ---------- 编辑器外壳 ---------- */
.editor-section {
    padding: 8px 0 48px;
}
.editor-shell {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.editor-shell:fullscreen {
    border-radius: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
}
.editor-shell:fullscreen .editor-main { flex: 1; min-height: 0; }

/* ---------- 工具栏 ---------- */
.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-warm);
}
.toolbar-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-light);
}
.tool-group {
    display: flex;
    align-items: center;
    gap: 8px;
}
.toolbar-spacer { flex: 1; }
.tbtn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 8px;
    border: 1.5px solid var(--border);
    background: #ffffff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.tbtn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}
.tbtn.primary {
    background: var(--primary-gradient);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(26, 110, 255, 0.3);
}
.tbtn.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(26, 110, 255, 0.4);
    color: #ffffff;
}
.tbtn svg {
    width: 14px;
    height: 14px;
}
.tpl-select {
    padding: 7px 12px;
    border-radius: 8px;
    border: 1.5px solid var(--border);
    font-family: inherit;
    font-size: 13px;
    background: #ffffff;
    color: var(--text);
    cursor: pointer;
    max-width: 200px;
}
.seg {
    display: flex;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.seg button {
    padding: 7px 13px;
    border: none;
    background: #ffffff;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    transition: var(--transition);
}
.seg button.active {
    background: var(--primary);
    color: #ffffff;
}

/* ---------- 移动端代码/预览标签 ---------- */
.mobile-pane-tabs {
    display: none;
}
.pane-tab {
    flex: 1;
    padding: 11px;
    border: none;
    background: transparent;
    font-family: inherit;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-light);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: var(--transition);
}
.pane-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ---------- 双栏主体 ---------- */
.editor-main {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    min-height: 560px;
}

/* ---------- 代码面板 ---------- */
.code-pane {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    min-width: 0;
}
.code-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}
.code-hint {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-light);
}
.code-editor {
    position: relative;
    display: flex;
    flex: 1;
    min-height: 500px;
    background: #0d1526;
    color: #dbe4ff;
    font-family: 'JetBrains Mono', 'SFMono-Regular', Consolas, 'Courier New', monospace;
    font-size: 13.5px;
    line-height: 1.7;
}
.line-numbers {
    width: 46px;
    padding: 14px 10px 14px 0;
    text-align: right;
    color: rgba(255, 255, 255, 0.22);
    background: #0a111f;
    user-select: none;
    overflow: hidden;
    white-space: pre;
    font-size: 12px;
    line-height: 1.7;
    flex-shrink: 0;
}
.code-area {
    position: relative;
    flex: 1;
    min-width: 0;
}
.code-area pre {
    position: absolute;
    inset: 0;
    margin: 0;
    padding: 14px 16px;
    overflow: hidden;
    white-space: pre;
    pointer-events: none;
    font: inherit;
    color: inherit;
}
.code-area textarea {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 14px 16px;
    border: 0;
    outline: 0;
    resize: none;
    background: transparent;
    color: transparent;
    caret-color: #7dd3fc;
    font: inherit;
    line-height: inherit;
    white-space: pre;
    overflow: auto;
}
.code-area textarea::selection {
    background: rgba(96, 165, 250, 0.3);
}
.code-area textarea:focus { outline: none; }

/* 语法高亮配色 */
.tok-kw   { color: #7dd3fc; font-weight: 600; }
.tok-str  { color: #fbbf24; }
.tok-com  { color: #64748b; font-style: italic; }
.tok-edge { color: #f472b6; font-weight: 600; }
.tok-fn   { color: #a78bfa; }
.tok-num  { color: #34d399; }

/* ---------- 预览面板 ---------- */
.preview-pane {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #ffffff;
}
.preview-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-warm);
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    flex-wrap: wrap;
}
.zoom-ctl {
    display: flex;
    align-items: center;
    gap: 4px;
}
.zoom-ctl button {
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    border: 1.5px solid var(--border);
    background: #ffffff;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    transition: var(--transition);
}
.zoom-ctl button:hover {
    border-color: var(--primary);
    color: var(--primary);
}
#zoomLabel {
    min-width: 46px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
}
.preview-stage {
    position: relative;
    flex: 1;
    min-height: 500px;
    overflow: hidden;
    background: #ffffff;
    cursor: grab;
    touch-action: none;
}
.preview-stage.dragging { cursor: grabbing; }
.preview-stage.dark { background: #111827; }
.preview-canvas {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    will-change: transform;
}
.preview-canvas svg { display: block; }
.preview-error {
    position: absolute;
    left: 12px;
    right: 12px;
    top: 12px;
    z-index: 6;
    display: none;
    background: var(--danger-light);
    border: 1.5px solid rgba(220, 38, 38, 0.3);
    color: #991b1b;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 12.5px;
    line-height: 1.6;
    max-height: 120px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
}
.preview-empty {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    color: var(--text-light);
    font-size: 14px;
    text-align: center;
    padding: 20px;
    pointer-events: none;
}
.preview-empty svg { opacity: 0.35; }
.preview-empty.show { display: flex; }

/* ---------- 状态栏 ---------- */
.editor-statusbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 20px;
    padding: 8px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-warm);
    font-size: 12px;
    color: var(--text-light);
}
.status-spacer { flex: 1; }

/* ---------- 历史快照抽屉 ---------- */
.history-mask {
    position: fixed;
    inset: 0;
    background: rgba(10, 15, 30, 0.35);
    backdrop-filter: blur(2px);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}
.history-mask.show {
    opacity: 1;
    visibility: visible;
}
.history-drawer {
    position: fixed;
    top: 0;
    right: -360px;
    width: 340px;
    max-width: 92vw;
    height: 100vh;
    background: #ffffff;
    z-index: 1001;
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.15);
    transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}
.history-drawer.open { right: 0; }
.history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}
.history-head h3 {
    font-size: 16px;
    font-weight: 800;
}
.history-head-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.history-close {
    width: 32px;
    height: 32px;
    border: 1.5px solid var(--border);
    background: #ffffff;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: var(--transition);
}
.history-close:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: var(--danger-light);
}
.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
}
.history-empty {
    text-align: center;
    color: var(--text-light);
    font-size: 13px;
    padding: 40px 10px;
}
.history-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 10px;
    transition: var(--transition);
}
.history-item:hover {
    border-color: rgba(26, 110, 255, 0.3);
    box-shadow: var(--shadow);
}
.history-item-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}
.history-item-time {
    font-size: 11px;
    color: var(--text-light);
    margin-bottom: 8px;
}
.history-item-actions {
    display: flex;
    gap: 6px;
}
.history-item-actions button {
    padding: 4px 12px;
    border-radius: 6px;
    border: 1.5px solid var(--border);
    background: #ffffff;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}
.history-item-actions button:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}
.history-item-actions button.danger:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: var(--danger-light);
}

/* ---------- 功能特性 ---------- */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}
.feature-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    transition: var(--transition);
}
.feature-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-4px);
    border-color: rgba(26, 110, 255, 0.2);
}
.fc-icon {
    width: 48px;
    height: 48px;
    background: var(--primary-light);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}
.fc-icon svg {
    width: 24px;
    height: 24px;
    color: var(--primary);
}
.feature-card h4 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 8px;
}
.feature-card p {
    font-size: 13.5px;
    color: var(--text-secondary);
    line-height: 1.8;
}

/* ---------- 语法速查 ---------- */
.cheat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}
.cheat-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    transition: var(--transition);
}
.cheat-card:hover {
    box-shadow: var(--shadow-hover);
    border-color: rgba(26, 110, 255, 0.2);
}
.cheat-card h4 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--primary);
}
.cheat-card pre {
    background: #0d1526;
    color: #dbe4ff;
    border-radius: 10px;
    padding: 14px 16px;
    font-size: 12.5px;
    line-height: 1.75;
    overflow-x: auto;
    font-family: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
    margin: 0;
}

/* ============================================================
   响应式适配（断点与官网一致：1024px / 768px）
   ============================================================ */
@media (max-width: 1024px) {
    .editor-main { grid-template-columns: 1fr; }
    .code-pane {
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }
    .code-editor,
    .preview-stage { min-height: 420px; }
    .feature-grid { grid-template-columns: repeat(2, 1fr); }
    .cheat-grid { grid-template-columns: 1fr; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    /* 顶部导航：与官网首页内联规则一致 —— 纵向下拉菜单 */
    .nav-links {
        display: none;
        position: absolute;
        top: 72px;
        left: 0; right: 0;
        background: white;
        flex-direction: column;
        padding: 16px 24px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
        gap: 4px;
        border-bottom: 1px solid var(--border);
        z-index: 999;
    }
    .nav-links.active { display: flex; }
    .mobile-toggle { display: flex; }

    /* 页脚单列 */
    .footer-grid { grid-template-columns: 1fr; gap: 32px; }

    .engine-card {
        position: static;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .engine-actions { width: 100%; justify-content: space-between; }

    /* 工具栏纵向紧凑 */
    .editor-toolbar { gap: 8px; }
    .toolbar-spacer { display: none; }
    .tpl-select { max-width: 160px; }

    /* 移动端 代码/预览 标签切换 */
    .mobile-pane-tabs { display: flex; }
    .editor-main { min-height: 0; display: block; }
    .editor-main .code-pane,
    .editor-main .preview-pane { display: none; }
    .editor-main:not(.show-preview) .code-pane { display: flex; }
    .editor-main.show-preview .preview-pane { display: flex; }
    .code-editor,
    .preview-stage { min-height: 60vh; }

    .feature-grid { grid-template-columns: 1fr; }
    .code-hint { display: none; }
    .history-drawer { width: 100vw; max-width: 100vw; }
}
