/* EdgeFT · 布局层（第 2 层）：页面骨架（iOS 27 风格）
   只管大块容器"占多大、在哪、滚不滚"。
   iOS PWA 关键决策：
   - 移动端 .chat-box = fixed 全屏滚动层，内容在顶栏、输入栏和主标签栏下方滚动。
   - 顶栏 fixed 在屏幕顶部（见 components/top-bar.css），
     z-index 约定：消息流 1 < 顶栏 6 < 输入栏 7 < 主标签栏 9 < 浮层 20+。
   - html/body 用 100dvh 动态视口（base.css），容器一律百分比高度，
     不再混用 100vh（iOS Safari 地址栏收展时 100vh 会溢出）。
   - 桌面端与移动端共用三标签单栏结构。
   全局地基见 base.css，组件外观见 components/*.css。 */

/* ---------- 应用外壳 ---------- */
.wrap {
  height: 100%;
}

/* ---------- 自定义元素：不额外产生盒 ----------
   login-page 例外：它自身带 .view，必须是真实 flex 容器（见 pages/login-page.css） */
top-bar,
input-area,
drop-confirm,
action-sheet,
toast-el,
file-card {
  display: contents;
}

/* ---------- 会话视图：桌面卡片两栏 ---------- */
#view-room.active {
  width: min(960px, calc(100% - 40px));
  max-width: 960px;
  margin: 20px auto;
  height: calc(100% - 40px);
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-card);
  border: 0.5px solid var(--ios-separator);
  overflow: hidden;
}

/* ---------- 中间聊天区（桌面：卡片内垂直三段） ---------- */
.chat-pane {
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: 0;
  max-width: none;
  display: flex;
  flex-direction: column;
}
.chat-main {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- 视图面板（消息流 / 文件 / 图片 / 文档 / 收藏） ---------- */
.view-pane {
  display: none;
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  overflow-y: auto;
  overscroll-behavior: contain;
}
/* tab 切换淡入淡出：display:none → block 时 CSS 动画自动重放（iOS 标签页切换手感，非硬切） */
.view-pane.active {
  display: block;
  animation: pane-in 0.25s var(--ease-out) both;
}
@keyframes pane-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .view-pane.active {
    animation-duration: 0.01ms;
  }
}

/* 文件/收藏页占位（内容已清理，仅保留底部导航按钮） */
.pane-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 100%;
  min-height: 260px;
  color: var(--timestamp, #9ca3af);
}
.pane-placeholder svg {
  opacity: 0.55;
}
.pane-placeholder p {
  margin: 0;
  font-size: 13px;
}

/* 消息流滚动容器（桌面：卡片内滚动） */
#view-chat {
  overflow: hidden;
}
.chat-box {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: auto;
  overscroll-behavior: contain;
  padding: 20px 24px;
}

/* ---------- 聊天主体内的拖放遮罩（铺满 .chat-main） ---------- */
.drop-overlay {
  position: absolute;
  inset: 0;
  width: 100vw;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
  pointer-events: none;
}
.drop-overlay.over {
  display: flex;
}

/* ---------- 底部固定区（输入栏上方：队列 / 提示 / 日志） ---------- */
#txList {
  padding: 0 20px 8px;
}
#bigHint,
.hint {
  margin: 0 20px 8px;
  padding: 8px 12px;
}
/* 连接日志：当前整体隐藏（日志写入逻辑保留） */
.log-collapse {
  display: none;
}

/* ==================================================================
   移动端：固定导航与聊天工作区
   ================================================================== */
@media (max-width: 720px) {
  .wrap {
    height: 100%;
  }
  #view-room.active {
    margin: 0;
    max-width: none;
    width: 100%;
    height: 100%;
    border-radius: 0;
    box-shadow: none;
    overscroll-behavior: none;
    overflow: hidden;
    position: relative;
  }
  #view-room.active {
    width: 100%;
  }
  .chat-pane {
    width: 100%;
    max-width: none;
    height: 100%;
    padding: 0;
    overflow: hidden;
  }
  /* 消息流保持在工作区内滚动，顶栏和输入区始终不被键盘/滚动带走。 */
  .chat-box {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: auto;
    width: 100vw;
    height: 100dvh;
    z-index: 1;
    overflow-y: auto;
    scroll-behavior: auto;
    overscroll-behavior: contain;
    padding: calc(var(--sat) + 64px) 12px calc(136px + var(--sab));
    /* 键盘弹出时消息流底部留白平滑上弹（padding-bottom 由 viewport.ts 控制） */
    transition: padding-bottom 250ms var(--ease-spring);
  }

  .chat-skeleton {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px 8px;
  }
  .skeleton-row {
    display: flex;
  }
  .skeleton-row.mine {
    justify-content: flex-end;
  }
  .skeleton-bubble {
    display: block;
    width: min(62vw, 260px);
    height: 48px;
    border-radius: var(--radius-bubble);
    background: var(--ios-fill);
    animation: chat-skeleton-shimmer 1.2s ease-in-out infinite;
  }
  .skeleton-row:nth-child(2) .skeleton-bubble,
  .skeleton-row:nth-child(4) .skeleton-bubble {
    width: min(76vw, 320px);
  }
  @keyframes chat-skeleton-shimmer {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
  }
  @media (prefers-reduced-motion: reduce) {
    .skeleton-bubble {
      animation: none;
    }
  }

  /* 非聊天视图：文档流内，起点避开 fixed 悬浮顶栏（顶栏实际高 calc(var(--sat) + 56px)，padding 必须与其一致，否则顶栏与工具栏之间露灰缝） */
  #view-files,
  #view-collections {
    padding-top: calc(var(--sat) + 56px);
    padding-bottom: calc(76px + var(--sab));
    height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  #txList {
    padding: 0 16px 8px;
  }
  #bigHint,
  .hint {
    margin: 0 16px 8px;
  }
}

/* ---------- 横屏矮窗：收紧消息区上下留白 ---------- */
@media (max-width: 720px) and (max-height: 500px) and (orientation: landscape) {
  .chat-box {
    padding-top: calc(52px + var(--sat));
    padding-bottom: calc(136px + var(--sab));
  }
  /* 横屏下顶栏高 calc(var(--sat) + 40px)，文件/收藏页避让同步 */
  #view-files,
  #view-collections {
    padding-top: calc(var(--sat) + 40px);
  }
}
