/* _12d: Sandwich半屏分割模式 (分割面板+拖拽+标签页+溢出修复) (从 _12_workflow_tchat 拆分) */

/* ============================================================================
   ηָģʽ (wf-sandwich-split-*)  DetailsϷֲ
   CHAT + ռһ룬TNO+CAD߶Աȶȹҵ
   ============================================================================ */

/* --- ģʽʱ --- */
/* transition JSд/رʱ, קڼֹ(JSֱӲstyle) */

/* ---  --- */
.wf-sandwich-split-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-bunker, var(--c-0a0d10));
    border: 2px solid var(--accent-color, var(--blue-info-dim));
    border-radius: 0;
    overflow: hidden;
    font-family: var(--tno-font-mono, monospace);
    box-shadow: inset 0 0 30px rgba(0, 212, 255, 0.03), 0 0 20px rgba(0, 0, 0, 0.4);
    position: relative;
}

/* T4 正本清源: .wf-split-resizer* 死规则已物理删除 (全仓无 JS/HTML 引用;
   生产三明治分割条唯一 class = .wf-sandwich-resizer, 见下方)。 */

/* z-index 层级宪法 (T4): .wf-sandwich-resizer = 100 — 高于面板内容(≤30), 低于弹层(500+)。
   唯一权威在本规则; JS 禁止内联覆盖。 */
.wf-sandwich-resizer { width:0.625rem; cursor: col-resize; display: flex; align-items: center; justify-content: center; z-index: 100; transition: background 0.2s; position: relative; }
.wf-sandwich-resizer::before { content: ''; position: absolute; top: 0; bottom: 0; left: 50%; transform: translateX(-50%); width:0.125rem; background: var(--border-primary, var(--bg-raised-navy)); transition: background 0.2s, width 0.2s, box-shadow 0.2s; }
.wf-sandwich-resizer:hover::before, .wf-sandwich-resizer.active::before { width:0.1875rem; background: var(--accent-color, var(--blue-info-dim)); box-shadow: 0 0 8px var(--accent-color, var(--blue-info-dim)); }
.wf-sandwich-resizer-line { width:0.25rem; height:6vh; border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.15); border: 1px solid rgba(255, 255, 255, 0.08); transition: background 0.2s, height 0.2s, border-color 0.2s, box-shadow 0.2s; z-index: 1; }
.wf-sandwich-resizer:hover .wf-sandwich-resizer-line, .wf-sandwich-resizer.active .wf-sandwich-resizer-line { background: var(--accent-color, var(--blue-info-dim)); height:8vh; border-color: transparent; box-shadow: 0 0 12px rgba(74, 144, 217, 0.4); }

.wf-sandwich-split-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 0.125rem;
    background: linear-gradient(90deg, transparent, var(--accent-color, var(--blue-info-dim)), transparent);
    z-index: 1;
}

/* --- ͷ --- */
.wf-sandwich-split-panel .wf-sandwich-header-bar {
    padding: 0.625rem 1rem;
    border-bottom: 2px solid var(--border-primary, var(--bg-raised-navy));
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    background: linear-gradient(180deg, rgba(0, 212, 255, 0.04) 0%, transparent 100%);
}

.wf-sandwich-header-info {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.wf-sandwich-header-icon {
    font-size: var(--font-lg, 1.125rem);
}

.wf-sandwich-header-title {
    font-size: var(--font-sm);
    font-weight: 700;
    color: var(--text-primary, var(--c-e0e6f0));
    letter-spacing: 0.0312rem;
    text-transform: uppercase;
}

.wf-sandwich-header-sub {
    font-size: var(--font-canvas-xxs);
    color: var(--text-secondary, var(--steel-muted));
    opacity: 0.7;
}

/* --- رհť TNO --- */
/* 居中机制归 .leucs-x-btn--text (SSOT, _17a); 此处只留 TNO 组件外观 */
.wf-sandwich-split-panel .wf-sandwich-close-btn {
    background: transparent;
    border: 2px solid var(--border-primary, var(--bg-raised-navy));
    color: var(--text-secondary, var(--steel-muted));
    font-size: var(--font-canvas-xs);
    font-weight: 600;
    cursor: pointer;
    transition: border-color var(--duration-pop) var(--ease-out), color var(--duration-pop) var(--ease-out), background var(--duration-pop) var(--ease-out), box-shadow var(--duration-pop) var(--ease-out);
    letter-spacing: 0.0312rem;
    text-transform: uppercase;
}

.wf-sandwich-split-panel .wf-sandwich-close-btn:hover {
    border-color: var(--red-led);
    color: var(--red-led);
    background: rgba(255, 68, 68, 0.08);
    box-shadow: 0 0 12px rgba(255, 68, 68, 0.15);
}

/* --- ǩҳ  ڷָģʽµʽ --- */
.wf-sandwich-split-panel .wf-sandwich-tabs {
    border-bottom: 2px solid var(--border-primary, var(--bg-raised-navy));
    padding: 0;
    background: rgba(0, 0, 0, 0.2);
}

.wf-sandwich-split-panel .wf-sandwich-tab {
    flex: 1;
    padding: 0.5rem 0.875rem;
    font-weight: 600;
    letter-spacing: 0.0187rem;
    border-bottom: 3px solid transparent;
    transition: background var(--duration-pop) var(--ease-out), color var(--duration-pop) var(--ease-out), border-bottom-color var(--duration-pop) var(--ease-out), text-shadow var(--duration-pop) var(--ease-out);
}

.wf-sandwich-split-panel .wf-sandwich-tab:hover {
    background: rgba(74, 144, 217, 0.06);
    color: var(--text-primary, var(--c-e0e6f0));
}

.wf-sandwich-split-panel .wf-sandwich-tab.active {
    color: var(--accent-color, var(--blue-info-dim));
    border-bottom-color: var(--accent-color, var(--blue-info-dim));
    background: rgba(74, 144, 217, 0.08);
    text-shadow: 0 0 8px rgba(74, 144, 217, 0.3);
}

/* --- ǩ --- */
.wf-sandwich-split-panel .wf-sandwich-tab-panels {
    flex: 1;
    overflow: hidden;              /* ڴ˹, ɸо */
    min-height: 0;
    display: flex;                 /* flex, panelͨflex:1 */
    flex-direction: column;
}

/* Phase 316: sandwich 半屏黑兜底 — 确保 split-panel 的 flex column 高度链路完整,
 *   防止 grid-area 与 inline style 在某些 viewport/动画时序下 height 计算失败导致
 *   下半部分内容被挤到 viewport 之外而显示为黑色。
 * Phase 317 加固: 用户报告 chat 一开始, sandwich 缩成原来的一半。
 *   根因: panel inline style 只设 display:flex 没设 height/min-height, 
 *   父 grid 行模板若被某子元素 intrinsic 高度撑大, 会让 1fr 行被压扁。
 *   方案: 强制 panel 占满父 row + 强制其内部 tabs 容器为 0-shrinkable flex 链。
 */
.wf-sandwich-split-panel {
    min-height: 0;
    height: 100%;
    /* 关键: 让 grid 行无视内联 grid-area 的内容 intrinsic 高度, 不被撑高 */
    align-self: stretch;
}
.wf-sandwich-split-panel .wf-sandwich-tab-panels {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.wf-sandwich-split-panel .wf-sandwich-tab-panel {
    padding: 0.75rem;
    flex: 1 1 0;                    /* 占满剩余高度 */
    min-height: 0;
    overflow-y: auto;               /* 摘要/全景 Tab 内容可滚动 */
}
/* Phase 396C-CSS: 动态摘要溢出兜底 — 补 active 态 overflow 强制滚动 */
.wf-sandwich-split-panel .wf-sandwich-tab-panels > .wf-sandwich-tab-panel.active {
    overflow-y: auto !important;
}

/* Phase 327o+ Round 4 — Defense-in-depth 兜底:
 * 探针实测 (用户截图) 证实流式期间 active panel 高度仅占 tab-cnt 的 40.2% (≈453/2),
 * 唯一物理可能是兄弟 tab-panel 也处于可见状态共占父 flex column 高度.
 * 经审计所有 JS 切换路径 (click handler / wfRestoreSandwichTab / _renderXxxSandwichTab)
 * 逻辑均正确, 必然是某竞态时序窗口 inline display 未及时清理.
 * 改用 CSS !important 从根上禁止: 非 active 必隐藏, active 必填满, 5 agent 全局生效. */
.wf-sandwich-split-panel .wf-sandwich-tab-panels > .wf-sandwich-tab-panel:not(.active) {
    display: none !important;
}
.wf-sandwich-split-panel .wf-sandwich-tab-panels > .wf-sandwich-tab-panel.active {
    flex: 1 1 0 !important;
    min-height: 0 !important;
}

/* AgentTab: SVGйӿ, paddingoverflow-y */
.wf-sandwich-split-panel #sandwich-split-tab-flow {
    padding: 0;
    overflow: hidden;
}

/* --- ģʽµPromptǿ --- */
.wf-sandwich-split-panel .wf-sandwich-layer {
    border: 2px solid var(--border-primary, var(--bg-raised-navy));
    border-radius: 0;
    margin-bottom: 0.25rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.wf-sandwich-split-panel .wf-sandwich-layer:hover {
    border-color: rgba(74, 144, 217, 0.4);
    box-shadow: 0 0 10px rgba(74, 144, 217, 0.08);
}

.wf-sandwich-split-panel .wf-sandwich-header {
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.02);
}

.wf-sandwich-split-panel .wf-sandwich-body {
    border-top: 1px solid var(--border-primary, var(--bg-raised-navy));
    font-size: var(--font-canvas-xs);
    max-height: 16vh;
}

/* --- ̬ժҪ˵ǩ --- */
.wf-sandwich-note,
.wf-detail-note {
    font-size: var(--font-canvas-xxs);
    color: var(--text-secondary, var(--steel-muted));
    margin-bottom: 0.625rem;
    padding: 0.5rem 0.75rem;
    border: 2px dashed var(--border-primary, var(--bg-raised-navy));
    background: rgba(0, 212, 255, 0.03);
    font-family: var(--tno-font-mono, monospace);
}

/* --- Userռλʽ --- */
.wf-user-placeholder {
    color: var(--text-secondary, var(--steel-muted)) !important;
    font-style: italic;
    opacity: 0.7;
}

.wf-user-preview {
    font-style: normal;
}

/* ═══════════════════════════════════════════════════════════════
   Phase 417-V9: 响应式堆叠布局 — 容器宽度不足 780px 时自动上下堆叠
   ═══════════════════════════════════════════════════════════════ */

/* 堆叠模式下 resizer 变为水平分割条 */
#leucs-module-body.leucs-sandwich-stacked .wf-sandwich-resizer {
    width: 100%;
    height: 0.375rem;
    cursor: row-resize;
}
#leucs-module-body.leucs-sandwich-stacked .wf-sandwich-resizer::before {
    top: 50%;
    left: 0;
    right: 0;
    bottom: auto;
    width: auto;
    height: 0.125rem;
    transform: translateY(-50%);
}

/* 堆叠模式下聊天块和面板上下排列
 * T4: flex 比例唯一权威在 JS _applySplitPct 引擎; 此处曾硬编码 55% 与引擎打架, 已删 */
#leucs-module-body.leucs-sandwich-stacked .wf-block[data-priority="1"] {
    min-height: 12rem;             /* 聊天区最小高度，确保消息区可见 */
}
#leucs-module-body.leucs-sandwich-stacked .wf-sandwich-split-panel {
    min-height: 11.25rem;
    max-height: 75%;
    border-top: 2px solid var(--border-primary, var(--c-2a2a4a));
}


