/* ============================================================
   真机移动端适配 · ≤768px
   加载顺序：必须排在所有皮肤样式之后（style/tech/wechat/themes/manage/ziwei）
   设计：顶栏折叠 + 侧栏抽屉 + 内容单列全宽，不改变任何业务 DOM
   ============================================================ */

/* ---------- body 直属控件：不受 renderShell 重建影响 ---------- */
.m-menu-btn, .m-tools-btn {
  display: none;
  position: fixed; top: 9px; z-index: 85;
  width: 36px; height: 36px; padding: 0;
  align-items: center; justify-content: center;
  border-radius: 9px; cursor: pointer;
  border: 1px solid rgba(var(--c1-rgb), .45);
  background: rgba(var(--surface-rgb), .94);
  color: rgb(var(--text-rgb));
  font-size: 19px; line-height: 1;
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(8px);
}
.m-menu-btn { left: 10px; }
.m-tools-btn { right: 10px; }
.m-menu-btn i {
  display: block; position: relative;
  width: 16px; height: 2px; border-radius: 2px;
  background: currentColor;
}
.m-menu-btn i::before,
.m-menu-btn i::after {
  content: ''; display: block; position: absolute; left: 0;
  width: 16px; height: 2px; border-radius: 2px;
  background: currentColor;
}
.m-menu-btn i::before { top: -5px; }
.m-menu-btn i::after { top: 5px; }

.m-mask {
  display: none; position: fixed; inset: 0;
  background: rgba(0, 0, 0, .55);
  opacity: 0; pointer-events: none;
  transition: opacity .24s ease;
}

/* ---------- 中屏（平板 / 小窗口）：只做轻微收窄 ---------- */
@media (min-width: 769px) and (max-width: 1024px) {
  .topbar { padding: 0 16px; gap: 10px; }
  .topbar-right { gap: 8px; }
  .brand-text { font-size: 14px; }
  .mode-toggle { padding: 5px 9px; font-size: 12px; }
  .sidebar { width: 180px; }
  .main { padding: 20px 18px 32px; }
}

/* ---------- 手机真机 ---------- */
@media (max-width: 768px) {
  html, body { max-width: 100vw; overflow-x: hidden; }
  body { -webkit-text-size-adjust: 100%; }
  body.m-nav-open { overflow: hidden; }

  body.m-has-shell .m-menu-btn,
  body.m-has-shell .m-tools-btn { display: flex; }
  .m-mask { display: block; }
  body.m-nav-open .m-mask { z-index: 110; opacity: 1; pointer-events: auto; }
  body.m-tools-open .m-mask { z-index: 78; opacity: 1; pointer-events: auto; }
  body.m-nav-open .m-tools-btn { opacity: 0; pointer-events: none; }

  /* 顶栏：品牌单行 + 左汉堡 + 右工具 */
  .topbar {
    height: auto; min-height: 54px;
    padding: 7px 52px;
    gap: 8px; flex-wrap: nowrap; align-items: center;
    position: sticky !important; top: 0; z-index: 80 !important;
  }
  .brand { flex: 1 1 auto; min-width: 0; gap: 6px; overflow: hidden; }
  .brand-logo { font-size: 19px; flex: 0 0 auto; }
  .brand-text {
    font-size: 13px; white-space: nowrap; min-width: 0;
    overflow: hidden; text-overflow: ellipsis;
  }
  .client-badge { font-size: 8px; padding: 1px 5px; letter-spacing: 0; flex: 0 0 auto; }
  .ziwei-top-link { flex: 0 0 auto; max-width: 34px; overflow: hidden; padding: 0; }
  .ziwei-top-link .zw-top-text { display: none; }

  /* 工具面板：默认收起，点右上 ⋯ 展开 */
  .topbar-right { display: none; }
  body.m-tools-open .topbar-right {
    display: flex !important; position: absolute;
    top: 100%; left: 0; right: 0; z-index: 79;
    flex-wrap: wrap; align-items: center; gap: 8px;
    padding: 12px; border-radius: 0 0 12px 12px;
    border-top: 1px solid rgba(var(--c1-rgb), .22);
    border-bottom: 1px solid rgba(var(--c1-rgb), .22);
    background: rgb(var(--surface-rgb));
    box-shadow: 0 14px 30px rgba(0, 0, 0, .35);
  }
  .topbar-right .mode-toggle,
  .topbar-right a.mode-toggle { padding: 6px 11px; font-size: 12px; }
  .topbar-right .lang-switch { flex: 0 0 auto; }
  .topbar-right .admin-switch { max-width: 100%; flex: 1 1 100%; }

  /* 侧栏 → 抽屉
     tech.css 给 .layout 设了 position:relative; z-index:1，会形成层叠上下文
     把抽屉困在遮罩之下。这里解除，让抽屉与顶栏/遮罩在同一层比较。 */
  .layout {
    display: block; min-height: 0;
    position: static !important; z-index: auto !important;
  }
  .sidebar {
    position: fixed !important; top: 0; left: 0; bottom: 0;
    width: min(286px, 84vw); height: 100dvh;
    background: rgb(var(--surface-rgb)) !important;
    z-index: 120 !important; overflow-y: auto;
    transform: translateX(-103%);
    transition: transform .26s ease;
    border-right: 1px solid rgba(var(--c1-rgb), .22);
    box-shadow: 10px 0 34px rgba(0, 0, 0, .42);
    -webkit-overflow-scrolling: touch;
  }
  body.m-nav-open .sidebar { transform: none; }
  .nav-item { padding: 11px 12px; font-size: 13px; }
  .sidebar-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }

  /* 主内容全宽 */
  .main {
    width: 100%; min-width: 0; flex: 1 1 auto;
    padding: 14px 12px calc(72px + env(safe-area-inset-bottom));
  }
  .demo-bar { display: none; }

  /* 网格：统计/卡片 2 列，表单与双栏 1 列 */
  .stat-grid, .stat-grid-3, .stat-grid-4, .stat-grid-5,
  .card-grid, .card-grid-3, .card-grid-4,
  .quick-grid, .quick-grid-lg, .coupon-grid, .perm-grid,
  .room-state-grid, .ops-mini-grid, .bigscreen-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 9px !important;
  }
  .two-col, .form-grid, .booking-layout, .support-layout,
  .lead-detail, .policy-extra, .skin-grid, .filter-grid {
    grid-template-columns: 1fr !important;
  }
  .date-row { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px !important; }
  .quick-item { padding: 10px 4px !important; font-size: 10px !important; }
  .stat-card, .stat { padding: 11px !important; }
  .stat-card b, .stat b, .stat-grid b { font-size: 17px !important; }

  /* 首屏 hero：禁止大字号竖排 */
  .hero {
    min-height: 210px !important;
    padding: 20px 16px !important;
    border-radius: 14px;
  }
  .hero h1 { font-size: 25px !important; letter-spacing: 1px !important; line-height: 1.35; }
  .hero p { font-size: 12px !important; }
  .hero-badge { font-size: 10px !important; }
  .hero-actions, .hero-stats, .btn-row, .head-row, .panel-head, .section-head, .filter-bar {
    flex-wrap: wrap; gap: 8px;
  }
  .hero-stats b { font-size: 18px !important; }

  /* 房型/商品卡片底部：价格与按钮改上下排列，避免窄列挤压换行 */
  .room-foot, .product-foot {
    flex-direction: column; align-items: stretch; gap: 8px;
  }
  .room-foot .btn, .product-foot .btn { width: 100%; }
  .price { font-size: 14px !important; white-space: nowrap; }

  /* 面板 / 按钮 / 文字 */
  .panel, .card { padding: 13px !important; border-radius: 12px; }
  .panel-head h3, .section-head h2 { font-size: 15px; }
  .page-head h1 { font-size: 20px; }
  .page-head { margin-bottom: 14px; }
  .btn { font-size: 12px; padding: 8px 12px; }
  .btn-lg { font-size: 14px; padding: 10px 16px; }
  .btn-sm { font-size: 11px; padding: 5px 9px; }
  .notice { font-size: 11px; }
  .room-img, .product-img { height: 130px !important; }
  .room-row { padding: 10px; }
  .room-row h4 { font-size: 13px; }

  /* 表格横向滚动，不再挤爆容器 */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table { min-width: 520px; font-size: 11px; }
  .table th, .table td { padding: 8px 7px; }

  /* 弹窗 / 表单 */
  .modal { max-width: 94vw; max-height: 88dvh; }
  .modal-head, .modal-foot { padding: 12px 14px; }
  .modal-body { padding: 14px; }
  .modal .form-grid { grid-template-columns: 1fr !important; }
  .modal .field input, .modal .field select, .modal .field textarea { font-size: 16px; }
  .toast { bottom: calc(24px + env(safe-area-inset-bottom)); max-width: 88vw; text-align: center; }

  /* 皮肤悬浮球：手机上会压住卡片按钮，统一收进 ⋯ 工具面板。
     皮肤存于同源 localStorage，网页版切换后公众号版自动跟随。 */
  .skin-fab { display: none !important; }
  .skin-panel { padding: 16px; }

  /* 公众号版手机壳：真机安全区 */
  .wx-phone { height: 100dvh !important; width: 100vw !important; }
  .wx-navbar {
    flex: 0 0 auto !important; height: auto !important; min-height: 46px;
    padding-top: env(safe-area-inset-top);
  }
  .wx-scroll { padding: 10px 10px calc(16px + env(safe-area-inset-bottom)); }
  .wx-tabbar {
    flex: 0 0 auto !important; height: auto !important; min-height: 58px;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .wx-tabbar button small { font-size: 9px; }
  .wx-scroll .hero h1 { font-size: 23px !important; }
  .wx-page .toast { bottom: calc(78px + env(safe-area-inset-bottom)) !important; }
}
