/**
 * 星忆伴 · 移动端壳层布局
 * 统一固定顶栏与主内容区间距，适配真机 safe-area。
 * 全局顶栏间距对齐成长首页「语言时光机」（safe-area + 4.5rem）
 */
@import url('./jyb-responsive.css?v=20260919stu2');
@import url('../../../css/jyb-wide-layout.css');

:root {
    --jyb-safe-shift: 0px;
    --jyb-nav-inset: 0px;
    /* 默认按 Android 状态栏预留，避免壳 CSS 晚到时先 0 后 32 造成顶栏弹跳 */
    --jyb-status-inset: 32px;
    --jyb-safe-top: var(--jyb-status-inset, 32px);
    --jyb-safe-bottom: var(--jyb-nav-inset, 0px);
    --jyb-header-pad-top: calc(var(--jyb-safe-top) + var(--jyb-safe-shift, 0px) + 0.4rem);
    --jyb-header-total: calc(var(--jyb-safe-top) + var(--jyb-safe-shift, 0px) + 3.25rem);
    --jyb-header-total-tall: var(--jyb-header-total);
    --jyb-header-total-sub: var(--jyb-header-total);
    --jyb-header-total-home: var(--jyb-header-total);
    --jyb-first-block-gap: 0;
    --jyb-footer-pad-bottom: calc(var(--jyb-safe-bottom) + 0.375rem);
    /* 底栏占位：导航行（含对话凸起按钮）+ 安全区 + 内容与底栏间距 */
    --jyb-bottom-nav-bar: 5.25rem;
    --jyb-body-pad-bottom: calc(var(--jyb-bottom-nav-bar) + var(--jyb-footer-pad-bottom) + 1.25rem);
    --jyb-ime: 0px;
}

/* 键盘收起后确保输入条贴底，避免残留 --jyb-ime / inline bottom */
html:not(.jyb-ime-open) .jyb-chat-composer,
html:not(.jyb-ime-open) #jyb-chat-composer,
body:not(.jyb-ime-open) .jyb-chat-composer,
body:not(.jyb-ime-open) #jyb-chat-composer {
    bottom: 0 !important;
}

html.jyb-ime-open:not(.jyb-ime-lift):not(.jyb-ime-overlay):not(:has(body.jyb-chat-page)):not(:has(body.jyb-exam-page)),
body.jyb-ime-open:not(.jyb-ime-lift):not(.jyb-ime-overlay):not(.jyb-chat-page):not(.jyb-exam-page) {
    padding-bottom: var(--jyb-ime) !important;
}

/* 弹层输入（高情商翻译官等）：禁止抬整页，只靠弹层自身 padding */
html.jyb-ime-overlay,
body.jyb-ime-overlay,
html.jyb-ime-overlay body {
    padding-bottom: 0 !important;
    transform: none !important;
}

.eq-translator-modal.jyb-ime-active {
    transition: none !important;
    align-items: flex-start;
    overscroll-behavior: contain;
}

body.jyb-ime-open .app-footer {
    transform: translateY(110%);
    pointer-events: none;
}

.jyb-chat-composer,
#jyb-chat-composer {
    bottom: var(--jyb-ime, 0px) !important;
    transition: bottom 0.16s ease-out;
}

/* 对话输入条：安全区必须落在实色 footer 上，禁止外层透明 padding 露底 */
body.jyb-chat-page .jyb-chat-composer,
body.jyb-chat-page #jyb-chat-composer {
    padding-bottom: 0 !important;
}
body.jyb-chat-page .jyb-chat-composer > footer,
body.jyb-chat-page #jyb-chat-composer > footer {
    background-color: #fff1e6 !important;
    padding-bottom: calc(1.5rem + var(--jyb-safe-bottom, 0px)) !important;
}

html.jyb-ime-lift:not(:has(body.jyb-chat-page)) .jyb-chat-composer,
html.jyb-ime-lift:not(:has(body.jyb-chat-page)) #jyb-chat-composer {
    bottom: 0 !important;
}

/* 对话页：键盘弹出时顶栏固定，消息区和输入条一起上移 */
body.jyb-chat-page.jyb-ime-open,
html.jyb-ime-open body.jyb-chat-page {
    padding-bottom: 0 !important;
    transform: none !important;
}

body.jyb-chat-page.jyb-ime-open .app-header,
html.jyb-ime-open body.jyb-chat-page .app-header {
    transform: none !important;
    top: 0 !important;
}

body.jyb-exam-page,
html.jyb-ime-open body.jyb-exam-page {
    padding-bottom: calc(0.35rem + env(safe-area-inset-bottom, 0px)) !important;
    transform: none !important;
}

/* 考场：sub-scroll 主区自滚，键盘时上收 main，避免答题框落在键盘下 */
html.jyb-sub-scroll.jyb-ime-open body.jyb-exam-page > main,
html.jyb-ime-scroll-mode.jyb-ime-open body.jyb-exam-page > main {
    bottom: var(--jyb-ime, 0px) !important;
}

body.jyb-chat-page.jyb-ime-open .app-main.chat-scroll,
html.jyb-ime-open body.jyb-chat-page .app-main.chat-scroll {
    height: calc(100dvh - var(--jyb-ime, 0px)) !important;
    max-height: calc(100dvh - var(--jyb-ime, 0px)) !important;
}

/* 键盘未确认弹出时（jyb-ime-open 未加）：对话区不压缩，避免底部大片留白 */
body.jyb-chat-page:not(.jyb-ime-open) .app-main.chat-scroll,
html:not(.jyb-ime-open) body.jyb-chat-page .app-main.chat-scroll {
    height: 100% !important;
    max-height: 100dvh !important;
}

body.jyb-chat-page.jyb-ime-open .jyb-chat-composer,
body.jyb-chat-page.jyb-ime-open #jyb-chat-composer,
html.jyb-ime-open body.jyb-chat-page .jyb-chat-composer,
html.jyb-ime-open body.jyb-chat-page #jyb-chat-composer {
    bottom: var(--jyb-ime, 0px) !important;
}

/* —— 固定顶栏 —— */
.app-header {
    padding-top: var(--jyb-header-pad-top) !important;
    padding-bottom: 0.5rem;
    transition: none !important;
}

.app-header.fixed,
header.app-header[class*="fixed"],
.app-header[class*="fixed"] {
    padding-top: var(--jyb-header-pad-top) !important;
    padding-bottom: 0.5rem;
}

/* 顶栏头像旁：年级与名字左对齐（勿负边距左移） */
.app-header [data-jyb-profile-name] + div,
.app-header [data-jyb-profile-name] + [data-jyb-profile-grade],
.app-header .flex.flex-col > [data-jyb-profile-grade],
.app-header .flex.flex-col > div > [data-jyb-profile-grade] {
    margin-left: 0 !important;
}

/* sticky 子页顶栏：仅补安全区，内容在文档流内 */
.app-header.sticky,
header.sticky.top-0 {
    padding-top: var(--jyb-header-pad-top);
}

/* 成长页全屏详情（学情研判 / 情绪概况）：与孩子概况顶栏同一套安全区 */
.weak-modal-header,
.emotion-modal-header,
.heat-detail-modal-header {
    padding-top: var(--jyb-header-pad-top) !important;
}

/* —— 主内容区（固定顶栏页面） —— */
.app-main {
    padding-top: var(--jyb-header-total) !important;
}

.app-main > :first-child {
    margin-top: var(--jyb-first-block-gap);
}

/* 显式标记：头像顶栏（与首页同距） */
.app-main.app-main--profile-header {
    padding-top: var(--jyb-header-total) !important;
}

/* 自动检测：固定顶栏含头像（排除成长首页） */
body:has(> .app-header.fixed .border-primary-container) > .app-main:not(.app-main--home),
body:has(> .app-header[class*="fixed"] .border-primary-container) > .app-main:not(.app-main--home),
body:has(> header.app-header.fixed img) > .app-main:not(.app-main--home) {
    padding-top: var(--jyb-header-total) !important;
}

/* 学生档案：双行大号姓名顶栏 */
body:has(> .app-header .text-\[22px\]) > .app-main:not(.app-main--home) {
    padding-top: var(--jyb-header-total) !important;
}

/* 固定顶栏但未使用 app-main 类 */
body > header.fixed.top-0 + main:not(.app-main),
header.fixed.top-0 + main:not(.app-main) {
    padding-top: var(--jyb-header-total) !important;
}

body > header.fixed.top-0 + main:not(.app-main) > :first-child,
header.fixed.top-0 + main:not(.app-main) > :first-child {
    margin-top: var(--jyb-first-block-gap);
}

/* sticky 子页：顶栏在文档流内，主区不再叠加额外 top padding */
body > header.sticky + main,
body > header.sticky.top-0 + main,
body > header.subpage-header + main,
body > header.detail-header + main {
    padding-top: 0 !important;
}

body > header.sticky + main > :first-child,
body > header.sticky.top-0 + main > :first-child,
body > header.subpage-header + main > :first-child,
body > header.detail-header + main > :first-child {
    margin-top: 0 !important;
}

/* —— 绑定 / 子表单页（自定义 fixed header） —— */
.bind-page-header,
.bind-child-header {
    padding-top: var(--jyb-header-pad-top) !important;
    padding-bottom: 0.5rem;
}

.bind-main,
.bind-child-main {
    padding-top: var(--jyb-header-total) !important;
}

.bind-main > :first-child,
.bind-child-main > :first-child {
    margin-top: var(--jyb-first-block-gap);
}

/* —— 底栏 —— */
.app-footer {
    padding-bottom: var(--jyb-footer-pad-bottom) !important;
    bottom: 0;
    transition: none !important;
}

/* 底导航：禁止切换页时的位移/缩放过渡（会像顶底栏「弹一下放大」） */
.bottom-nav,
.nav-tab,
.nav-tab--active,
.nav-tab--chat,
.nav-tab:active {
    transition: none !important;
    transform: none !important;
    -webkit-transform: none !important;
}

/* 底栏留白改由 jyb-sat（html.jyb-tabbar-page）首帧钉死；此处不再 !important 抢写，避免壳 CSS 晚到「弹一下」 */
body:has(.app-footer) {
    padding-bottom: var(--jyb-body-pad-bottom);
    min-height: 100dvh !important;
}

body:has(.app-footer) > .app-main {
    padding-bottom: 0.5rem;
}

body:has(.app-footer) > .app-main.app-main--with-footer {
    padding-bottom: 0.5rem;
}

/* 家长端我的页：退出登录不被底栏遮挡 */
body.parent-profile-page:has(.app-footer) {
    padding-bottom: var(--jyb-body-pad-bottom) !important;
}

body.parent-profile-page:has(.app-footer) > .app-main {
    padding-bottom: 1.25rem !important;
}

/* 学生端我的页：让出底栏（含对话凸起）+ 一小段间距 */
body.student-profile-page:has(.app-footer) {
    padding-bottom: var(--jyb-body-pad-bottom);
}
body.student-profile-page:has(.app-footer) > .app-main {
    padding-bottom: 0.75rem !important;
}

/* 学生端档案：主区自滚时底栏留白必须落在 main 上，否则最后一栏被挡住 */
body.student-archive-page:has(.app-footer) {
    padding-bottom: var(--jyb-body-pad-bottom);
    min-height: 100dvh !important;
}
body.student-archive-page:has(.app-footer) > .app-main {
    padding-bottom: var(--jyb-body-pad-bottom, calc(5.25rem + var(--jyb-footer-pad-bottom, calc(var(--jyb-safe-bottom, 0px) + 0.375rem)) + 1.25rem)) !important;
}

body:has(.app-header):not(:has(.app-footer)) {
    min-height: 100dvh !important;
}

/* 成长首页：语言时光机（须置于末尾，避免被头像顶栏规则覆盖） */
.app-main.app-main--home,
body:has(> .app-header.fixed) > .app-main.app-main--home {
    padding-top: var(--jyb-header-total-home) !important;
}

.app-main.app-main--home > :first-child {
    margin-top: 0 !important;
}
