﻿/* ─── 基础重置 ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f1a;
  --bg2: #1a1a2e;
  --bg3: #252540;
  --text: #e0e0f0;
  --text2: #9999bb;
  --primary: #4f8cff;
  --primary-hover: #3a7aff;
  --danger: #ff4757;
  --success: #2ed573;
  --border: #2a2a45;
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── 面板 ─────────────────────────────────────────────────── */
.panel {
  max-width: 900px;
  margin: 40px auto;
  padding: 32px;
  background: var(--bg2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.panel-header { text-align: center; margin-bottom: 28px; }
.panel-header h1 { font-size: 28px; margin-bottom: 8px; }
.logo { margin-bottom: 12px; border-radius: 16px; box-shadow: 0 4px 20px rgba(79,110,247,0.3); }
.toolbar-left { display: flex; align-items: center; gap: 10px; }

.subtitle { color: var(--text2); font-size: 14px; }

/* ─── 表单控件 ─────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text2); }
.form-group input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus { border-color: var(--primary); }

/* ─── 按钮 ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 12px 24px; border: none; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: all 0.2s;
}
.btn.primary { background: var(--primary); color: white; width: 100%; justify-content: center; }
.btn.primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn.small { padding: 6px 14px; font-size: 13px; background: var(--bg3); color: var(--text); }
.btn.small:hover { background: var(--border); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: rgba(255,71,87,0.15); }

/* ─── 状态指示 ─────────────────────────────────────────────── */
.status { display: flex; align-items: center; gap: 8px; margin-top: 16px; padding: 10px 16px; background: var(--bg3); border-radius: var(--radius-sm); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #666; }
.dot.connected { background: var(--success); box-shadow: 0 0 8px var(--success); }
.dot.disconnected { background: #666; }
.dot.connecting { background: #ffa502; animation: pulse 1s infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ─── 工具栏 ───────────────────────────────────────────────── */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.toolbar h2 { font-size: 18px; }
.toolbar-right { display: flex; align-items: center; gap: 12px; }
.badge { padding: 4px 12px; background: var(--bg3); border-radius: 20px; font-size: 12px; color: var(--text2); }

/* ─── 设备网格 ─────────────────────────────────────────────── */
.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }
.device-card {
  padding: 20px; background: var(--bg3); border-radius: var(--radius-sm);
  border: 1px solid var(--border); cursor: pointer; transition: all 0.2s;
}
.device-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 4px 20px rgba(79,140,255,0.15); }
.device-card .device-name { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.device-card .device-id { font-size: 11px; color: var(--text2); font-family: monospace; }
.device-card .device-info { font-size: 12px; color: var(--text2); margin-top: 8px; }
.device-card .connect-hint { display: none; font-size: 12px; color: var(--primary); margin-top: 8px; }
.device-card:hover .connect-hint { display: block; }
.empty-state { grid-column: 1/-1; text-align: center; padding: 40px; color: var(--text2); }

/* ─── 控制视图 ─────────────────────────────────────────────── */
.control-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; flex-wrap: wrap; gap: 8px; }
.control-header strong { font-size: 16px; }
.control-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.small-badge { font-size: 11px; padding: 2px 8px; background: var(--success); color: #000; margin-left: 8px; }

#screen-container {
  position: relative; background: #000; border-radius: var(--radius-sm);
  overflow: hidden; border: 1px solid var(--border);
  aspect-ratio: 16/9; min-height: 300px;
}

#screen-wrapper { position: relative; width: 100%; height: 100%; }
#screen-img { width: 100%; height: 100%; object-fit: contain; display: block; image-rendering: auto; }
#touch-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  touch-action: none; cursor: crosshair;
}

.loading-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.7); gap: 12px;
}
.spinner { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay p { color: var(--text2); font-size: 14px; }

/* ─── 状态栏 ───────────────────────────────────────────────── */
#status-bar { display: flex; gap: 20px; margin-top: 8px; padding: 8px 12px; background: var(--bg3); border-radius: var(--radius-sm); font-size: 12px; color: var(--text2); }

/* ─── 虚拟键盘 (移动端) ────────────────────────────────────── */
#virtual-keyboard {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg2); border-top: 1px solid var(--border);
  padding: 12px; z-index: 100;
}
#virtual-keyboard.active { display: block; }
.keyboard-row { display: flex; gap: 4px; margin-bottom: 4px; justify-content: center; }
.keyboard-row .key {
  flex: 1; max-width: 60px; padding: 10px 0; text-align: center;
  background: var(--bg3); border-radius: 6px; border: 1px solid var(--border);
  color: var(--text); font-size: 14px; cursor: pointer; user-select: none;
}
.keyboard-row .key:active { background: var(--primary); }
.keyboard-row .key.key-wide { max-width: 90px; }
.keyboard-row .key.key-space { max-width: 200px; }

/* ─── 响应式 ───────────────────────────────────────────────── */
@media (max-width: 640px) {
  .panel { margin: 0; border-radius: 0; border: none; padding: 20px 16px; min-height: 100vh; }
  .device-grid { grid-template-columns: 1fr; }
  .control-header { flex-direction: column; align-items: flex-start; }
  .control-actions { width: 100%; }
  .control-actions .btn { flex: 1; justify-content: center; font-size: 12px; padding: 8px 10px; }
  #screen-container { min-height: 200px; }
}

