/* ============================================================================
 * YSKJ 远程桌面 · 共享设计 Token 与组件样式  (yskj-tokens.css)
 * ----------------------------------------------------------------------------
 * 品牌归属：YSKJ（沿伸网络）自有远程桌面产品 UI。
 * 视觉参考：ToDesk（现代精致 / 悬浮胶囊工具栏 / 连接质量色阶）+ 向日葵（设备卡片化）。
 * ⚠️ 合规红线：本项目为自有实现，仅参考业界产品视觉，
 *    不包含任何 RustDesk 等 AGPL 项目源代码。三端（PC 客户端 / 手机 App / 网页）
 *    共用本套 token，换端只换容器、不重绘组件。
 * 使用方式：在 PC 与 APP 两版 HTML 中通过
 *    <link rel="stylesheet" href="shared/yskj-tokens.css">
 *    引入；主题切换通过给 <html> 设置 data-theme="dark" 实现。
 * 依赖：无任何外部 CDN / 字体 / 图标库，纯本地 CSS，可离线预览。
 * ========================================================================== */

/* ---------- 1. 设计 Token（亮色 / 暗色双主题） ---------- */
:root {
  /* 色彩 */
  --ys-primary: #2B5CFF;      --ys-primary-600: #1E45D6;   --ys-primary-700: #1733A8;
  --ys-accent: #00C2A8;       --ys-accent-600: #00A892;
  --ys-online: #21C17A;       --ys-online-600: #1BA868;
  --ys-offline: #FF6B6B;      --ys-offline-600: #E84F4F;
  --ys-warn: #FFB020;         --ys-warn-600: #E89A12;
  --ys-bg: #F4F6FB;           --ys-surface: #FFFFFF;       --ys-surface-2: #F8FAFD;
  --ys-text: #141A2E;         --ys-text-2: #5B6478;
  --ys-border: #E6EAF2;       --ys-border-strong: #D4DAE8;

  /* 字体 */
  --ys-font: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  --ys-fs-xs: 11px;  --ys-fs-sm: 12px;  --ys-fs-base: 14px; --ys-fs-md: 15px;
  --ys-fs-lg: 18px;  --ys-fs-xl: 20px;  --ys-fs-2xl: 24px;

  /* 间距 */
  --ys-sp-1: 4px;  --ys-sp-2: 8px;  --ys-sp-3: 12px; --ys-sp-4: 16px;
  --ys-sp-5: 24px; --ys-sp-6: 32px; --ys-sp-7: 48px;

  /* 圆角 */
  --ys-radius-sm: 10px;  --ys-radius: 14px;  --ys-radius-lg: 18px;
  --ys-radius-pill: 999px;  --ys-radius-toolbar: 22px;

  /* 阴影 */
  --ys-shadow: 0 6px 24px rgba(20, 26, 46, .10);
  --ys-shadow-sm: 0 2px 8px rgba(20, 26, 46, .06);
  --ys-shadow-lg: 0 12px 40px rgba(20, 26, 46, .16);

  /* 玻璃拟态（会话工具栏 / 质量条） */
  --ys-glass: rgba(20, 26, 46, .82);
  --ys-glass-text: #E8ECF5;
}

[data-theme="dark"] {
  --ys-primary: #4D7BFF;      --ys-primary-600: #3A63E0;   --ys-primary-700: #2C4FC4;
  --ys-accent: #1FD3B8;       --ys-accent-600: #17BBA3;
  --ys-online: #27D687;       --ys-online-600: #1FBF77;
  --ys-offline: #FF7B7B;      --ys-offline-600: #F06060;
  --ys-warn: #FFC24D;         --ys-warn-600: #F0AE33;
  --ys-bg: #0E1320;           --ys-surface: #161D2E;       --ys-surface-2: #1E273B;
  --ys-text: #E8ECF5;         --ys-text-2: #9AA4BC;
  --ys-border: #26304A;       --ys-border-strong: #33405E;
  --ys-shadow: 0 6px 24px rgba(0, 0, 0, .45);
  --ys-shadow-sm: 0 2px 8px rgba(0, 0, 0, .35);
  --ys-shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
  --ys-glass: rgba(14, 19, 32, .80);
  --ys-glass-text: #E8ECF5;
}

/* ---------- 2. 基础重置 ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--ys-font);
  background: var(--ys-bg);
  color: var(--ys-text);
  font-size: var(--ys-fs-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .25s ease, color .25s ease;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* 内联 SVG 图标（通过 <use href="#i-xxx"/> 引用，随 currentColor 换主题） */
.ys-ic {
  width: 20px; height: 20px; display: inline-block; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.ys-num { font-variant-numeric: tabular-nums; }

/* ---------- 3. 状态：在线点 / 延时标签（色阶） ---------- */
.ys-dot {
  width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .25);
}
.ys-dot--on   { background: var(--ys-online); }
.ys-dot--warn { background: var(--ys-warn); }
.ys-dot--off  { background: var(--ys-offline); }
.ys-dot--sm { width: 7px; height: 7px; }
.ys-dot--lg { width: 11px; height: 11px; }

/* 延时色阶：绿 <50ms / 黄 <150ms / 红 >150ms */
.ys-lat {
  font-variant-numeric: tabular-nums; font-weight: 600;
  font-size: var(--ys-fs-sm); display: inline-flex; align-items: center; gap: 5px;
}
.ys-lat::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.ys-lat--good { color: var(--ys-online); }
.ys-lat--warn { color: var(--ys-warn); }
.ys-lat--bad  { color: var(--ys-offline); }
.ys-lat--off  { color: var(--ys-text-2); }

/* ---------- 4. 设备卡片 ---------- */
.ys-card {
  background: var(--ys-surface);
  border: 1px solid var(--ys-border);
  border-radius: var(--ys-radius);
  overflow: hidden;
  box-shadow: var(--ys-shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  cursor: pointer;
}
.ys-card:hover { transform: translateY(-3px); box-shadow: var(--ys-shadow); border-color: var(--ys-border-strong); }
.ys-card__thumb {
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #1b2440, #2a3a66);
  position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.ys-card__thumb::after {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(45deg, rgba(255,255,255,.03) 0 14px, transparent 14px 28px);
}
.ys-card__glyph {
  font-size: 38px; opacity: .9; position: relative; z-index: 1;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .4));
}
.ys-card__os {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  font-size: var(--ys-fs-xs); background: rgba(0, 0, 0, .42); color: #fff;
  padding: 3px 9px; border-radius: 7px; backdrop-filter: blur(4px);
}
.ys-card__dot { position: absolute; top: 12px; right: 12px; z-index: 2; }
.ys-card__body { padding: 12px 14px; }
.ys-card__name {
  font-weight: 600; font-size: var(--ys-fs-base);
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.ys-card__meta {
  color: var(--ys-text-2); font-size: var(--ys-fs-sm); margin-top: 4px;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.ys-card__conn { margin-top: 12px; width: 100%; }

/* 紧凑卡片（手机端 2 列） */
.ys-card--sm .ys-card__thumb { aspect-ratio: 16 / 10; }
.ys-card--sm .ys-card__glyph { font-size: 30px; }
.ys-card--sm .ys-card__body { padding: 10px 12px; }
.ys-card--sm .ys-card__name { font-size: var(--ys-fs-sm); }

/* 缩略图按系统微调色（保持品牌蓝青调，差异轻微） */
.ys-card__thumb--win     { background: linear-gradient(135deg, #16306e, #2f5bd6); }
.ys-card__thumb--mac     { background: linear-gradient(135deg, #3a1d5e, #7b3fc4); }
.ys-card__thumb--linux   { background: linear-gradient(135deg, #153a3a, #1f9b86); }
.ys-card__thumb--android { background: linear-gradient(135deg, #1f4a1f, #37a83a); }
.ys-card__thumb--web     { background: linear-gradient(135deg, #5a2a0e, #d9772b); }

/* ---------- 5. 按钮 ---------- */
.ys-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: var(--ys-radius-sm);
  padding: 9px 16px; font-size: var(--ys-fs-base); font-weight: 600;
  color: var(--ys-text); background: var(--ys-surface-2);
  transition: background .15s ease, transform .12s ease, box-shadow .15s ease, color .15s ease;
  user-select: none; white-space: nowrap;
}
.ys-btn:hover { background: var(--ys-border); }
.ys-btn:active { transform: translateY(1px); }
.ys-btn--primary { background: var(--ys-primary); color: #fff; border-color: var(--ys-primary); }
.ys-btn--primary:hover { background: var(--ys-primary-600); border-color: var(--ys-primary-600); }
.ys-btn--ghost { background: transparent; border-color: var(--ys-border); color: var(--ys-text-2); }
.ys-btn--ghost:hover { color: var(--ys-text); background: var(--ys-surface-2); }
.ys-btn--danger { background: var(--ys-offline); color: #fff; border-color: var(--ys-offline); }
.ys-btn--danger:hover { background: var(--ys-offline-600); border-color: var(--ys-offline-600); }
.ys-btn--block { width: 100%; }
.ys-btn--sm { padding: 7px 12px; font-size: var(--ys-fs-sm); }
.ys-btn .ys-ic { width: 18px; height: 18px; }

/* ---------- 6. 会话悬浮胶囊工具栏 ---------- */
.ys-toolbar {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--ys-glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: 6px; border-radius: var(--ys-radius-toolbar);
  box-shadow: var(--ys-shadow); border: 1px solid rgba(255, 255, 255, .14);
}
.ys-toolbar__btn {
  width: 40px; height: 40px; border-radius: 50%; background: transparent;
  color: var(--ys-glass-text); display: flex; align-items: center; justify-content: center;
  transition: background .15s ease, color .15s ease;
}
.ys-toolbar__btn:hover { background: rgba(255, 255, 255, .14); }
.ys-toolbar__btn.is-active { background: var(--ys-primary); color: #fff; }
.ys-toolbar__btn.is-danger { color: #ff8a8a; }
.ys-toolbar__btn.is-danger:hover { background: rgba(255, 107, 107, .18); }
.ys-toolbar__sep { width: 1px; align-self: stretch; background: rgba(255, 255, 255, .15); margin: 6px 3px; }

/* ---------- 7. 底部 Tab 栏（手机） ---------- */
.ys-tabbar { display: flex; background: var(--ys-surface); border-top: 1px solid var(--ys-border); }
.ys-tabbar__item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 0 8px; color: var(--ys-text-2); font-size: var(--ys-fs-xs);
  cursor: pointer; transition: color .15s ease; position: relative;
}
.ys-tabbar__item.is-active { color: var(--ys-primary); }
.ys-tabbar__item.is-active::before {
  content: ""; position: absolute; top: -1px; width: 28px; height: 3px;
  border-radius: 0 0 3px 3px; background: var(--ys-primary);
}
.ys-tabbar__icon { width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; }
.ys-tabbar__icon .ys-ic { width: 22px; height: 22px; }
.ys-tabbar__label { line-height: 1; }

/* ---------- 8. 头像 / 搜索框 / 连接质量小条 ---------- */
.ys-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--ys-primary), var(--ys-accent));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: var(--ys-fs-sm); flex: none; user-select: none;
}
.ys-avatar--sm { width: 28px; height: 28px; font-size: var(--ys-fs-xs); }
.ys-avatar--lg { width: 52px; height: 52px; font-size: 20px; }

.ys-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--ys-surface); border: 1px solid var(--ys-border);
  border-radius: var(--ys-radius-pill); padding: 8px 14px;
  color: var(--ys-text-2); font-size: var(--ys-fs-sm); min-width: 200px;
}
.ys-search input { border: none; outline: none; background: transparent; color: var(--ys-text); font-size: var(--ys-fs-sm); width: 100%; }
.ys-search .ys-ic { width: 16px; height: 16px; color: var(--ys-text-2); }

.ys-qchip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--ys-glass); color: var(--ys-glass-text);
  padding: 6px 12px; border-radius: var(--ys-radius-pill);
  font-size: var(--ys-fs-sm); font-variant-numeric: tabular-nums;
  border: 1px solid rgba(255, 255, 255, .14);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.ys-qchip .ys-dot { box-shadow: none; width: 8px; height: 8px; }
.ys-qchip--on   .ys-dot { background: var(--ys-online); }
.ys-qchip--warn .ys-dot { background: var(--ys-warn); }
.ys-qchip--bad  .ys-dot { background: var(--ys-offline); }

/* ---------- 开关（主题切换，三端共用） ---------- */
.ys-switch {
  position: relative; width: 48px; height: 26px; border-radius: 999px;
  background: var(--ys-border-strong); cursor: pointer; transition: background .2s; flex: none;
}
.ys-switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}
.ys-switch.is-on { background: var(--ys-primary); }
.ys-switch.is-on::after { left: 25px; }

/* ---------- 9. 右侧面板 / 内部 Tab ---------- */
.ys-panel { background: var(--ys-surface); border-left: 1px solid var(--ys-border); display: flex; flex-direction: column; min-height: 0; }
.ys-panel__tabs { display: flex; border-bottom: 1px solid var(--ys-border); }
.ys-panel__tab {
  flex: 1; text-align: center; padding: 12px 8px; font-size: var(--ys-fs-sm);
  color: var(--ys-text-2); cursor: pointer; border-bottom: 2px solid transparent;
  transition: color .15s ease, border-color .15s ease;
}
.ys-panel__tab.is-active { color: var(--ys-primary); border-bottom-color: var(--ys-primary); font-weight: 600; }
.ys-panel__body { padding: 16px; overflow: auto; flex: 1; color: var(--ys-text-2); font-size: var(--ys-fs-sm); }

/* ---------- 10. 通用工具类 ---------- */
.ys-muted { color: var(--ys-text-2); }
.ys-row { display: flex; align-items: center; gap: 8px; }
.ys-col { display: flex; flex-direction: column; }
.ys-scroll { overflow: auto; }
@keyframes ysFade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
