/* ============================================================
   OfficeMind · 跨平台适配层
   由 app.js 在启动时写入 <html data-os="mac|win|linux">
   原则：只做「微调 + 降级」，不做平台专属视觉分叉
   ============================================================ */

/* ---------- 通用：标准滚动条属性（Firefox / 未来标准） ---------- */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

/* ---------- macOS：覆盖式滚动条，更细、更隐形 ---------- */
[data-os="mac"] ::-webkit-scrollbar { width: 8px; height: 8px; }
[data-os="mac"] ::-webkit-scrollbar-thumb {
  background: var(--text-mute);
  background-clip: content-box;
  border: 2px solid transparent;
  border-radius: 99px;
}
[data-os="mac"] ::-webkit-scrollbar-thumb:hover { background: var(--text-dim); background-clip: content-box; }

/* ---------- Windows / Linux：常驻滚动条，显式宽度避免布局跳动 ---------- */
[data-os="win"] ::-webkit-scrollbar,
[data-os="linux"] ::-webkit-scrollbar { width: 10px; height: 10px; }
[data-os="win"] ::-webkit-scrollbar-thumb,
[data-os="linux"] ::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  background-clip: content-box;
  border: 3px solid transparent;
  border-radius: 99px;
}
[data-os="win"] ::-webkit-scrollbar-thumb:hover,
[data-os="linux"] ::-webkit-scrollbar-thumb:hover {
  background: var(--text-mute); background-clip: content-box;
}
/* Windows 常驻滚动条会挤压内容，给滚动容器预留 gutter */
[data-os="win"] .sb-body,
[data-os="win"] .view,
[data-os="win"] .drawer-body,
[data-os="linux"] .sb-body,
[data-os="linux"] .view,
[data-os="linux"] .drawer-body { scrollbar-gutter: stable; }

/* ---------- 字体渲染微调 ---------- */
[data-os="mac"] body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
/* Windows 下 ClearType 已处理，过度 antialiased 会让中文发虚 */
[data-os="win"] body {
  -webkit-font-smoothing: auto;
  text-rendering: geometricPrecision;
}
/* Linux 字体渲染差异大，交给 fontconfig */
[data-os="linux"] body {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Windows 高对比度模式 ---------- */
@media (forced-colors: active) {
  .card, .modal, .drawer, .popover, .input, .select, .textarea, .btn {
    border: 1px solid CanvasText;
  }
  .nav-item.active { background: Highlight; color: HighlightText; }
  .badge, .status .s-dot { forced-color-adjust: none; }
}

/* ---------- 高对比度偏好 ---------- */
@media (prefers-contrast: more) {
  :root { --border: var(--border-strong); }
  body { --text-mute: var(--text-dim); }
}

/* ---------- 键盘导航：仅键盘操作时显示焦点环 ---------- */
body[data-kbd="off"] :focus:not(:focus-visible) { outline: none; }

/* ---------- 桌面壳（Tauri）微调 ---------- */
/* 桌面壳会注入 data-shell="tauri"，用于标题栏安全区 */
[data-shell="tauri"][data-os="mac"] .topbar { padding-left: 78px; }  /* 避开红绿灯 */
[data-shell="tauri"][data-os="win"] .topbar,
[data-shell="tauri"][data-os="linux"] .topbar { padding-right: 138px; } /* 避开最小化/最大化/关闭 */

/* 无边框窗口下禁止整页拖拽选中文本 */
[data-shell="tauri"] .topbar { -webkit-user-select: none; user-select: none; }

/* ---------- 打印 ---------- */
@media print {
  .sidebar, .topbar, .page-head .ph-actions { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}
