/* web.css — 人人远控 Web 客户端(深色, 与桌面端气质一致) */

:root {
  --bg: #0b1020;
  --bg-soft: #111731;
  --card: #151c38;
  --line: #26305c;
  --fg: #e8ecff;
  --fg-dim: #9aa5d1;
  --accent: #4f7cff;
  --accent-soft: rgba(79, 124, 255, 0.16);
  --ok: #34a853;
  --bad: #ff5d5d;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* hidden 属性优先于任何显式 display(视图切换/弹层全靠它) */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.6 -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.view { min-height: 100%; display: flex; flex-direction: column; }

/* ---------- 登录卡 ---------- */
#view-login { align-items: center; justify-content: center; padding: 24px 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px;
  width: 100%;
  max-width: 380px;
}

.card h1 { margin: 0 0 4px; font-size: 22px; }
.card h2 { margin: 0 0 4px; font-size: 18px; }
.sub { margin: 0 0 18px; color: var(--fg-dim); font-size: 13px; }
.web-tag {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 1px 7px;
  vertical-align: 2px;
}
.accent { color: var(--accent); }

label { display: block; margin: 0 0 14px; font-size: 13px; color: var(--fg-dim); }

input, select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--fg);
  font-size: 15px;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); }

button {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 16px;
  background: var(--bg-soft);
  color: var(--fg);
  cursor: pointer;
}
button.primary {
  width: 100%;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}
button.primary:disabled { opacity: 0.5; cursor: default; }
button.ghost { background: transparent; }
button.ghost.danger { color: var(--bad); border-color: transparent; }
button.ghost:hover { border-color: var(--accent); }
button:not(.primary):active { transform: translateY(1px); }

.error {
  color: var(--bad);
  background: rgba(255, 93, 93, 0.1);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

.tip { color: var(--fg-dim); font-size: 12.5px; margin: 14px 0 0; }
.tip.center { text-align: center; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
}
.brand { font-weight: 700; white-space: nowrap; }
.who {
  color: var(--fg-dim);
  font-size: 13px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status { color: var(--fg-dim); font-size: 13px; white-space: nowrap; }
.status.ok { color: var(--ok); }
.status.bad { color: var(--bad); }
.topbar select { width: auto; margin: 0; padding: 6px 8px; font-size: 13px; }

/* ---------- 设备列表 ---------- */
.content { flex: 1; padding: 18px 16px; max-width: 640px; width: 100%; margin: 0 auto; }

.dev-list { display: flex; flex-direction: column; gap: 10px; }
.empty { color: var(--fg-dim); text-align: center; padding: 32px 0; }

.dev {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.dev .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #5a648f;
  flex: none;
}
.dev .dot.on { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.dev .meta { flex: 1; min-width: 0; }
.dev .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev .id { color: var(--fg-dim); font-size: 12px; font-variant-numeric: tabular-nums; }
.dev button { flex: none; font-size: 13px; padding: 7px 14px; }
.dev button:disabled { opacity: 0.45; cursor: default; }

/* ---------- 连接弹层 ---------- */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 20, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
}
.connect-card .code-input {
  font-size: 24px;
  letter-spacing: 8px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.connect-card .row { display: flex; gap: 10px; margin-top: 6px; }
.connect-card .row button { flex: 1; }

/* ---------- 观看舞台 ---------- */
.screen-view { height: 100%; }
.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #05070f;
  position: relative;
  overflow: hidden;
}
#screen {
  max-width: 100%;
  max-height: 100%;
  touch-action: none; /* 触屏拖动=鼠标事件, 别让页面滚 */
  cursor: crosshair;
}
.stage-hint {
  position: absolute;
  color: var(--fg-dim);
  font-size: 14px;
  pointer-events: none;
}

/* ---------- 轻提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  max-width: calc(100vw - 32px);
  z-index: 30;
}

@media (max-width: 480px) {
  .topbar { padding: 8px 10px; gap: 8px; }
  .topbar select { max-width: 88px; }
  .status { display: none; } /* 手机宽度收起状态字, 保住断开按钮 */
}

/* ---------- 浏览器 SSH 终端(M7 切片2) ---------- */
.term-view { height: 100%; }

.term-wrap {
  flex: 1;
  position: relative;
  min-height: 0;               /* flex 子项允许收缩, 内部滚动不撑破页面 */
  padding: 10px 14px 14px;
}

#term-mount { height: 100%; min-height: 220px; }
#term-mount .xterm { height: 100%; }
#term-mount .xterm-viewport { overflow-y: auto; }

.term-wrap .stage-hint {
  position: absolute;
  inset: 10px 14px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--bg-soft);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--fg-dim);
  padding: 16px;
}

.term-wrap .stage-hint small { display: block; margin-top: 6px; }

@media (max-width: 640px) {
  .term-wrap { padding: 8px 10px 10px; }
  .term-wrap .stage-hint { inset: 8px 10px 10px; }
  #term-profiles { max-width: 110px; }
}
