/* css/mobile.css —— M8-01 移动壳（.m-* 命名空间 + [data-mobile-shell] 作用域）
 *
 * 依据：docs/24-M8-移动端优化方案.md §5（设计规范）、§4.1（390×844 线框）、§8.2 M8-01。
 * 约定：
 * - 所有规则都在 @media(max-width:640px) 内 → 桌面（≥900）与平板（641–899）零影响；
 * - 只新增 .m-* 类名，不覆盖 styles.css / css/pages*.css 的既有类；
 * - 触控目标 ≥44px、正文 ≥13px、次要信息 ≥11px；安全区用 env(safe-area-inset-*)；
 * - 断点与 js/mobile/viewport.js 的 BREAKPOINTS 一致（640 手机 / 641–899 平板 / ≥900 桌面）。
 */

@media (max-width: 640px) {
  /* —— 顶栏（替换旧 .topbar：酒店名 / 营业日 / 退出）—— */
  .m-topbar {
    position: sticky;
    top: 0;
    z-index: 13;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 54px;
    padding: calc(6px + env(safe-area-inset-top, 0px)) 12px 6px;
    background: #fff;
    border-bottom: 1px solid #e5ece8;
  }
  .m-topbar-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
    flex: 1;
  }
  .m-topbar-brand .brand-mark { width: 28px; height: 28px; }
  .m-topbar-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .m-topbar-hotel {
    display: block;
    max-width: 46vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    line-height: 1.25;
    color: #163d37;
  }
  .m-topbar-day { font-size: 11px; line-height: 1.2; color: #6f887b; white-space: nowrap; }
  .m-topbar-day b { font-weight: 800; color: #087c61; }
  .m-topbar-actions { display: flex; align-items: center; gap: 8px; flex: none; }
  .m-topbar-user { display: none; } /* 屏幕窄：操作员姓名让位给「营业日 + 退出」 */
  .m-topbar .m-logout {
    min-width: 64px;
    min-height: 44px;
    padding: 8px 12px;
    font-size: 13px;
  }

  /* —— 9 个 L1 域横滑 chips（点击复用 data-action="l1"：navigate(domain)）—— */
  .m-domain-bar {
    position: sticky;
    top: calc(54px + env(safe-area-inset-top, 0px));
    z-index: 12;
    display: flex;
    align-items: stretch;
    gap: 8px;
    padding: 8px 12px;
    background: #fff;
    border-bottom: 1px solid #edf1ee;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .m-domain-bar::-webkit-scrollbar { display: none; }
  .m-chip {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid #e0ebe4;
    border-radius: 999px;
    background: #f5faf7;
    color: #40604f;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    scroll-snap-align: start;
  }
  .m-chip:active { background: #e8f5ee; }
  .m-chip .m-chip-icon { font-size: 14px; color: #8aa79a; line-height: 1; }
  .m-chip.active {
    border-color: #087c61;
    background: #087c61;
    color: #fff;
    box-shadow: 0 4px 12px #087c6126;
  }
  .m-chip.active .m-chip-icon { color: #d8efe7; }

  /* —— 内容容器：只做「容纳」，间距/面板样式沿用既有 .workspace/.panel —— */
  .m-content { min-width: 0; }
  .m-content > * { min-width: 0; }
  .m-page { min-width: 0; }

  /* 移动壳接管时旧顶栏已被替换；这里兜底给首次渲染（壳未挂上）保留原 .topbar 的 sticky 行为 */
  [data-mobile-shell] .main > .m-topbar { display: flex; }

  /* 手机档 toast 是整宽固定在底部（styles.css 的 ≤640 规则）：不吞点击，
     否则它会盖住最后一张房卡/底部批量条，导致长按或按钮「点不动」（M8-04 手测问题） */
  .toast {
    pointer-events: none;
  }

  /* —— 懒加载页加载态（M8-11：首次进入订单/预订/客户/交班/现付账/报表/设置时的占位）——
     不依赖任何页面模块的 CSS（room 的 .m-skeleton-card 首屏才有），自包含骨架。 */
  .m-page-loading {
    display: block;
    padding: 14px 12px 24px;
    min-height: 180px;
  }
  .m-page-loading-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 88px;
    margin-bottom: 10px;
    padding: 14px 12px;
    border: 1px solid #e6eee8;
    border-radius: 14px;
    background: #fff;
  }
  .m-page-loading-card span {
    display: block;
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg, #eef4f0 25%, #f8fbf9 37%, #eef4f0 63%);
    background-size: 400% 100%;
    animation: m-page-loading-shimmer 1.4s ease infinite;
  }
  .m-page-loading-card span:nth-child(1) { width: 42%; }
  .m-page-loading-card span:nth-child(2) { width: 88%; }
  .m-page-loading-card span:nth-child(3) { width: 64%; }
  .m-page-loading-text {
    margin: 6px 0 0;
    color: #8aa196;
    font-size: 12px;
    text-align: center;
  }
  @keyframes m-page-loading-shimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
  }
  @media (prefers-reduced-motion: reduce) {
    .m-page-loading-card span { animation: none; }
  }
}
