/* ═══════════════ Trellis Resolve — IDE Theme ═══════════════ */
/* 独特设计方向：全屏 IDE 双栏布局 + MathJax 实时预览 */

/* ── CSS 变量 ── */
:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --border: #e2e8f0;
    --text-1: #0f172a;
    --text-2: #334155;
    --text-3: #94a3b8;
    --accent: #059669;
    --accent-light: #10b981;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 4px 12px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
}

.dark {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-alt: #0f172a;
    --border: rgba(255, 255, 255, 0.08);
    --text-1: #f8fafc;
    --text-2: #cbd5e1;
    --text-3: #64748b;
    --accent: #10b981;
    --accent-light: #34d399;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* ── 全局基础 ── */
body {
    background: var(--bg);
    color: var(--text-1);
    transition: background 0.3s, color 0.3s;
}

/* ── 卡片 ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    transition: background 0.3s, border-color 0.3s;
}

/* ── 输入框/日志内嵌 ── */
.inset {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-2);
    transition: background 0.3s, border-color 0.3s;
}

.inset:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.15);
}

/* ── 文本层级 ── */
.t1 { color: var(--text-1); }
.t2 { color: var(--text-2); }
.t3 { color: var(--text-3); }

/* ── 主按钮 ── */
.btn-accent {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 20px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 1px 2px rgba(5, 150, 105, 0.2);
}

.btn-accent:hover:not(:disabled) {
    background: var(--accent-light);
}

.btn-accent:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── 幽灵按钮 ── */
.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 14px;
    color: var(--text-2);
    cursor: pointer;
    transition: all 0.15s;
}

.btn-ghost:hover {
    background: var(--surface-alt);
    border-color: var(--accent);
    color: var(--accent);
}

/* ── 步骤徽章 ── */
.step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

/* ── 精修模块边框 ── */
.refine-accent {
    border-left: 3px solid #7c3aed;
}

/* ── 白色间距 ── */
.pre-wrap { white-space: pre-wrap; }

/* ── 动画 ── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes statusPulse {
    0%, 100% { opacity: 0.8; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.05); }
}

.status-pulse {
    animation: statusPulse 2s infinite ease-in-out;
}

/* ── 进度条 ── */
#hwLogProgress {
    height: 2px;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    transition: width 0.3s ease;
    position: absolute;
    top: 0;
    left: 0;
}

/* ── IDE 专属：MathJax 预览区域样式 ── */
#mathjaxOutput h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 2rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    color: #4f46e5;
}

.dark #mathjaxOutput h2 {
    color: #818cf8;
}

#mathjaxOutput h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: #059669;
}

.dark #mathjaxOutput h3 {
    color: #34d399;
}

/* ── IDE 专属：代码编辑器标签栏 ── */
.ide-tab-active {
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    font-weight: 700;
    color: #4f46e5;
}

.dark .ide-tab-active {
    background: #334155;
    color: #818cf8;
}

.ide-tab-inactive {
    color: #94a3b8;
    font-weight: 500;
}

.ide-tab-inactive:hover {
    color: #64748b;
}

.dark .ide-tab-inactive:hover {
    color: #cbd5e1;
}

/* ── 滚动条美化 ── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.5);
}

.dark ::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.3);
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.5);
}

/* ── 拖拽上传高亮 ── */
.drag-highlight {
    outline: 2.5px dashed var(--accent) !important;
    outline-offset: -3px;
    background: rgba(5, 150, 105, 0.04) !important;
    transition: outline-color 0.2s, background 0.2s;
}

.dark .drag-highlight {
    background: rgba(16, 185, 129, 0.06) !important;
}

/* ── Toast 通知系统 ── */
#toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: toastIn 0.3s ease-out;
    max-width: 400px;
    pointer-events: auto;
}

.toast-error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.toast-success {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

.toast-info {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}

.dark .toast-error {
    background: #450a0a;
    color: #fca5a5;
    border: 1px solid #7f1d1d;
}

.dark .toast-success {
    background: #052e16;
    color: #86efac;
    border: 1px solid #14532d;
}

.dark .toast-info {
    background: #172554;
    color: #93c5fd;
    border: 1px solid #1e3a5f;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ── 中英切换（与 Landing 页统一方案） ── */
.en-text { display: none; }
body.lang-en .zh-text { display: none !important; }
body.lang-en .en-text { display: inline !important; }
body.lang-en p.en-text,
body.lang-en div.en-text { display: block !important; }
/* 预加载阶段语言切换（防止刷新时中文闪现） */
.lang-en-preload .zh-text { display: none !important; }
.lang-en-preload .en-text { display: inline !important; }
.lang-en-preload p.en-text,
.lang-en-preload div.en-text { display: block !important; }

/* 语言切换按钮样式 */
.lang-toggle {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    transition: all 0.15s;
}
.lang-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* ── Mobile safe shell: keep desktop IDE intact, reflow phones into one pane ── */
#mobilePaneTabs {
    display: none;
}

.mobile-pane-tab {
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-2);
    font-size: 12px;
    font-weight: 700;
    padding: 8px 12px;
    background: var(--surface-alt);
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.mobile-pane-tab.is-active {
    color: #fff;
    border-color: var(--accent);
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
}

.pdf-js-viewer {
    background: #e5e7eb;
    padding: 12px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.dark .pdf-js-viewer {
    background: #020617;
}

.pdf-js-page {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto 12px;
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
}

.pdf-js-page:not(.is-rendered) {
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0)),
        #f8fafc;
    background-size: 220px 100%, auto;
}

.dark .pdf-js-page:not(.is-rendered) {
    background:
        linear-gradient(90deg, rgba(15, 23, 42, 0), rgba(51, 65, 85, 0.6), rgba(15, 23, 42, 0)),
        #0f172a;
}

.pdf-js-viewer.pdf-js-readable-width {
    padding: 8px;
}

.pdf-js-viewer.pdf-js-readable-width .pdf-js-page {
    max-width: none;
    margin-left: 0;
    margin-right: 0;
}

.pdf-js-status {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
    color: #64748b;
    font-size: 13px;
    line-height: 1.6;
    padding: 24px;
}

.pdf-js-status a {
    color: #4f46e5;
    font-weight: 700;
    text-decoration: underline;
}

.dark .pdf-js-status {
    color: #94a3b8;
}

@media (max-width: 768px) {
    html,
    body {
        width: 100% !important;
        min-width: 0 !important;
        height: auto !important;
        min-height: 100dvh !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }

    body > header {
        height: auto !important;
        min-height: 56px;
        padding: 8px 12px !important;
        gap: 10px;
        flex-wrap: wrap;
    }

    body > header h1 {
        font-size: 18px;
        line-height: 1.15;
    }

    body > header h1 .text-sm {
        display: block;
        margin-top: 2px;
        font-size: 11px;
    }

    #headerActions {
        gap: 6px !important;
        margin-left: auto;
    }

    #headerActions .btn-ghost {
        padding: 6px !important;
    }

    #demoBanner {
        height: auto !important;
        min-height: 44px;
        padding: 8px 12px !important;
        gap: 6px !important;
        flex-wrap: wrap;
        text-align: center;
    }

    body.is-demo > header {
        flex-wrap: nowrap;
        min-height: 50px;
    }

    body.is-demo > header h1 .text-sm {
        display: none;
    }

    body.is-demo #btnTestAi,
    body.is-demo button[onclick="openHistoryModal()"],
    body.is-demo a[href="admin"],
    body.is-demo a[href="logout"] {
        display: none !important;
    }

    body.is-demo #demoBanner {
        min-height: 34px;
        padding: 6px 10px !important;
    }

    body.is-demo #demoBanner a {
        display: none;
    }

    #mobilePaneTabs {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
    }

    #ideWorkspace {
        display: block !important;
        flex: none !important;
        min-height: 0;
        overflow: visible !important;
    }

    #paneSplitter {
        display: none !important;
    }

    #leftPane,
    #rightPane {
        width: 100% !important;
        min-width: 0 !important;
        flex: none !important;
        height: calc(100dvh - 150px);
        min-height: 560px;
    }

    body.mobile-pane-source #rightPane,
    body.mobile-pane-log #rightPane,
    body.mobile-pane-result #leftPane {
        display: none !important;
    }

    body.mobile-pane-log #leftPane {
        display: flex !important;
        background: var(--surface);
    }

    body.mobile-pane-log #leftPane .mobile-source-toolbar,
    body.mobile-pane-log #leftPane .mobile-source-viewer {
        display: none !important;
    }

    body.mobile-pane-log #leftPane .mobile-log-section {
        display: flex;
        flex: 1 1 auto;
        min-height: 0;
        border-top: 0;
        flex-direction: column;
    }

    body.mobile-pane-log #hwLogExpanded {
        display: block !important;
        flex: 1 1 auto;
        max-height: none !important;
    }

    body.mobile-pane-log #hwLogPanel {
        font-size: 11px;
        line-height: 1.7;
    }

    #leftPane .mobile-source-toolbar,
    #rightPane > .min-h-\[4rem\] {
        padding: 8px 10px !important;
        align-items: flex-start;
        gap: 8px;
    }

    body.is-demo.mobile-pane-result #rightPane > .min-h-\[4rem\] {
        min-height: 44px;
        justify-content: center;
    }

    #leftPane .mobile-source-toolbar > div,
    #rightPane > .min-h-\[4rem\] > div {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    #hwPageRange {
        width: 72px;
    }

    #hwSliceBtn,
    #hwGenBtn,
    #userRequirementsBtn,
    #tabPreviewBtn,
    #tabCodeBtn {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    #hwLastLog {
        max-width: 220px !important;
    }

    #rightPane > .h-8 {
        height: auto !important;
        min-height: 36px;
        padding: 6px 10px !important;
        gap: 8px;
        flex-wrap: wrap;
    }

    #hwActionBtns,
    #hwDownloadLinks {
        flex-wrap: wrap;
        gap: 8px !important;
    }

    #hwActionBtns .text-gray-300 {
        display: none;
    }

    #toast-container {
        top: auto;
        right: 10px;
        left: 10px;
        bottom: 12px;
        align-items: stretch;
    }

    .toast {
        max-width: none;
        width: 100%;
    }

    #playgroundFab {
        display: none !important;
    }
}
