/* =============================================================
 * 共享样式：暗色 / 简洁 / 现代
 * 控制端与被控端两个页面共用，class 命名保持一致。
 * ============================================================= */

:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --border: #2a2f3a;
  --text: #e6e8ee;
  --text-dim: #9aa3b2;
  --brand: #4f8cff;
  --brand-hover: #6b9dff;
  --ok: #29c26a;
  --busy: #f2b23c;
  --err: #ff5f56;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei',
    Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- 布局骨架 ---------- */
.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* ---------- 状态徽标 ---------- */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 13px;
  white-space: nowrap;
}

.status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status.is-idle { color: var(--text-dim); }
.status.is-busy { color: var(--busy); }
.status.is-ok   { color: var(--ok); }
.status.is-err  { color: var(--err); }

/* ---------- 面板 / 表单 ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

input[type='text'] {
  flex: 1 1 200px;
  min-width: 160px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 16px;
  letter-spacing: 2px;
  outline: none;
}

input[type='text']:focus {
  border-color: var(--brand);
}

.btn {
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.btn:hover:not(:disabled) {
  border-color: var(--brand);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}

.btn.primary:hover:not(:disabled) {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
}

.btn.danger {
  border-color: #5a2b2b;
  color: #ff8a80;
}

.hint {
  margin: 10px 0 0;
  color: var(--text-dim);
  font-size: 12px;
}

/* ---------- 提示条（如 TURN 不可用已降级为 STUN） ---------- */
.notice {
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid #5a4a1e;
  background: rgba(242, 178, 60, 0.12);
  color: #f2c96b;
  font-size: 13px;
  line-height: 1.6;
}

/* ---------- 视频舞台 ---------- */
.stage {
  position: relative;
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 220px;
}

.video {
  display: block;
  width: 100%;
  max-height: 60vh;
  background: #000;
}

.video.small {
  max-height: 220px;
}

.placeholder {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

.latency {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.6);
  color: #d8dee9;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* ---------- 画面工具栏（阶段 A：全屏 / 独立窗口） ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.toolbar-tip {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.5;
}

/* 全屏态：铺满屏幕、画面最大化（保持比例不拉伸）、延迟角标继续保留。
   注意 :fullscreen 与 :-webkit-full-screen 必须分开写，
   合并成一条选择器时，浏览器遇到不认识的那一条会把整条规则丢弃。 */
.stage:fullscreen {
  border: none;
  border-radius: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.stage:fullscreen .video {
  width: 100%;
  height: 100%;
  max-height: 100vh;
  object-fit: contain;
}

.stage:-webkit-full-screen {
  border: none;
  border-radius: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.stage:-webkit-full-screen .video {
  width: 100%;
  height: 100%;
  max-height: 100vh;
  object-fit: contain;
}

/* ---------- 虚拟屏幕（阶段 B · 被控端可视化控制通路） ---------- */
.vscreen {
  position: relative;
  width: 80%;
  margin: 14px auto 0;
  aspect-ratio: 16 / 9;
  min-height: 180px;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

/* 光标：用 left/top 百分比定位，尺寸随容器自适应 */
.vcursor {
  position: absolute;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px; /* 让圆心正好落在坐标点上 */
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85), 0 0 10px rgba(79, 140, 255, 0.8);
  pointer-events: none;
}

/* 点击 / 滚轮的瞬时提示（1 秒后自动消失） */
.vtoast {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 8px 14px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
}

/* 当前按住的按键 */
.vkeys {
  position: absolute;
  left: 10px;
  bottom: 10px;
  max-width: 90%;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.6);
  color: #d8dee9;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
  pointer-events: none;
}

.vrow {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* ---------- 控制端：画面处于可控状态时的高亮 ---------- */
.video.is-control-active {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
  cursor: crosshair;
}

/* ---------- 访问码大字展示（host 端） ---------- */
.code-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 16px;
  background: var(--panel-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.code-label {
  color: var(--text-dim);
  font-size: 12px;
}

.code-value {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: 6px;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}

.code-value.empty {
  color: var(--text-dim);
  letter-spacing: normal;
  font-size: 20px;
  font-weight: 500;
}

/* ---------- 日志 ---------- */
.logwrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.loghead {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12px;
}

.log {
  max-height: 200px;
  overflow-y: auto;
  padding: 10px 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--text-dim);
}

.log div {
  padding: 2px 0;
  word-break: break-all;
}

.log .l-ok { color: var(--ok); }
.log .l-err { color: var(--err); }
.log .l-warn { color: var(--busy); }

/* ---------- 工具类 ---------- */
.hidden {
  display: none !important;
}
