/* fpga_ila Web — 科技感明亮主题 */
:root {
  --bg: #e4e8ed;
  --panel-bg: #f0f3f7;
  --panel-header: linear-gradient(180deg, #e8edf4 0%, #dce2ea 100%);
  --border: #c8ced6;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.10);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --text: #1e293b;
  --text-dim: #64748b;
  --text-light: #94a3b8;
  --accent: #0ea55a;
  --accent2: #2563eb;
  --accent-glow: 0 0 8px rgba(37,99,235,0.2);
  --danger: #dc2626;
  --warn: #d97706;
  --btn-bg: linear-gradient(180deg, #f8fafc 0%, #e8edf4 100%);
  --btn-hover: linear-gradient(180deg, #eff3f8 0%, #dde3ec 100%);
  --btn-active: linear-gradient(180deg, #dde3ec 0%, #cfd7e2 100%);
  --btn-primary: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
  --btn-primary-hover: linear-gradient(180deg, #3b72f2 0%, #2563eb 100%);
  --input-bg: #ffffff;
  --input-border: #c8ced6;
  --input-focus: #2563eb;
  --input-focus-glow: 0 0 0 3px rgba(37,99,235,0.12);
  --sel-bg: rgba(37,99,235,0.08);
  --wave-bg: #fafbfc;
  --radius: 6px;
  --radius-sm: 4px;
  font-family: 'Segoe UI', 'Consolas', 'Courier New', system-ui, sans-serif;
  font-size: 13px;
  color: var(--text);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); overflow: hidden; }

/* ── 工具栏 ── */
#toolbar {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 14px;
  background: linear-gradient(180deg, #f8fafc 0%, #edf1f7 100%);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  z-index: 10; position: relative;
}
#toolbar .logo {
  color: var(--accent2); font-weight: 700; font-size: 17px;
  letter-spacing: 1px;
  text-shadow: 0 1px 0 rgba(255,255,255,0.6);
}
#toolbar .sep { color: var(--border); font-size: 16px; margin: 0 2px; }
#toolbar button {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--btn-bg);
  color: var(--text);
  cursor: pointer; font-family: inherit; font-size: 12px;
  box-shadow: var(--shadow-sm);
  transition: all 0.12s;
}
#toolbar button:hover {
  background: var(--btn-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
#toolbar button:active {
  background: var(--btn-active);
  box-shadow: none;
  transform: translateY(0);
}

/* ── 主布局 ── */
#main { display: flex; height: calc(100% - 72px); }
#sidebar {
  width: 306px; min-width: 306px;
  display: flex; flex-direction: column;
  background: var(--panel-bg);
  border-right: 1px solid var(--border);
  box-shadow: 2px 0 12px rgba(0,0,0,0.04);
  overflow: hidden;
  z-index: 5;
}
#wave-area {
  flex: 1; display: flex; flex-direction: column;
  background: var(--wave-bg); overflow: hidden; position: relative;
}
#wave-container { flex: 1; overflow-x: auto; overflow-y: auto; position: relative; }
#cursor-info {
  padding: 4px 14px;
  background: linear-gradient(180deg, #f8fafc 0%, #edf1f7 100%);
  border-top: 1px solid var(--border);
  color: var(--accent2); font-size: 12px; font-weight: 600;
}

/* ── 面板 ── */
.panel {
  border-bottom: 1px solid var(--border);
  background: var(--panel-bg);
}
.panel.flex-grow { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.panel-title {
  padding: 7px 12px;
  background: var(--panel-header);
  font-weight: 700; font-size: 11px; text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent2);
  border-bottom: 1px solid var(--border);
  text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}
.panel-body { padding: 8px 12px; }
.panel-body.scrollable { overflow-y: auto; flex: 1; }

label {
  display: block; font-size: 11px; color: var(--text-dim);
  margin-top: 5px; margin-bottom: 1px; font-weight: 600;
}
input, select {
  width: 100%; padding: 5px 8px; margin-bottom: 5px;
  background: var(--input-bg); border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  color: var(--text); font-family: inherit; font-size: 12px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.04);
  transition: border 0.15s, box-shadow 0.15s;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--input-focus);
  box-shadow: var(--input-focus-glow);
}
button {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--btn-bg);
  color: var(--text);
  cursor: pointer; font-family: inherit; font-size: 12px; font-weight: 500;
  box-shadow: var(--shadow-sm);
  transition: all 0.12s;
  margin: 2px;
}
button:hover {
  background: var(--btn-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
button:active {
  background: var(--btn-active);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
  transform: translateY(0);
}
button.primary {
  background: var(--btn-primary);
  border-color: #1d4ed8;
  color: #fff;
  font-weight: 600;
}
button.primary:hover {
  background: var(--btn-primary-hover);
  box-shadow: var(--shadow-md), var(--accent-glow);
}
button.danger {
  background: linear-gradient(180deg, #fee2e2 0%, #fecaca 100%);
  border-color: #fca5a5;
  color: var(--danger);
  width: 100%; margin-top: 8px; font-weight: 600;
}
button.danger:hover {
  background: linear-gradient(180deg, #fecaca 0%, #fca5a5 100%);
}
button.toggle.active {
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
  border-color: #1d4ed8;
  color: #fff;
  box-shadow: var(--shadow-md);
}
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-row { display: flex; gap: 5px; }
.btn-row button { flex: 1; }

.hint { font-size: 11px; color: var(--text-dim); margin: 3px 0 6px; font-style: italic; }
.status-text { font-size: 12px; margin-top: 5px; font-weight: 600; }
.status-text.connected { color: var(--accent); }
.status-text.disconnected { color: var(--text-light); }
.status-text.error { color: var(--danger); }

/* ── 触发表格 ── */
#trig-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: 11px; margin-top: 5px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
#trig-table th, #trig-table td {
  padding: 3px 4px; border: 1px solid var(--border); text-align: center;
}
#trig-table th {
  background: linear-gradient(180deg, #edf1f7 0%, #e2e7ef 100%);
  color: var(--text-dim); font-weight: 600; font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
#trig-table td {
  background: #fff;
}
#trig-table td input {
  width: 100%; margin: 0; padding: 3px 4px; font-size: 11px; text-align: center;
  border: none; border-radius: 0; box-shadow: none; background: transparent;
}
#trig-table td input:focus { background: #f0f4ff; outline: none; box-shadow: none; }
#trig-table td select {
  width: 100%; margin: 0; padding: 2px 0; font-size: 10px; text-align: center;
  border: none; background: transparent;
}
#trig-table tr:hover td { background: #f8fafd; }

/* ── 右键菜单 ── */
.ctx-menu {
  position: fixed; z-index: 1000;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 190px; padding: 4px 0;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,0,0,0.03);
}
.ctx-title {
  padding: 5px 14px; font-size: 11px; color: var(--text-dim);
  font-weight: 600; pointer-events: none;
  border-bottom: 1px solid #eef1f5;
  margin-bottom: 2px;
}
.ctx-item, .ctx-sub {
  padding: 6px 14px; cursor: pointer; font-size: 12px;
  display: flex; justify-content: space-between; align-items: center;
  transition: background 0.1s;
}
.ctx-item:hover, .ctx-sub:hover {
  background: #edf2fa;
}
.ctx-item.checked { color: var(--accent2); font-weight: 600; }
.ctx-item.checked::before { content: "\25CF  "; font-size: 8px; }
.ctx-item.unchecked { color: var(--text-dim); }
.ctx-item.unchecked::before { content: "\25CB  "; font-size: 8px; }
.ctx-sep { border-top: 1px solid var(--border); margin: 3px 0; }

/* ── 状态栏 ── */
#statusbar {
  height: 26px; padding: 3px 14px;
  background: linear-gradient(180deg, #f8fafc 0%, #edf1f7 100%);
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-dim);
  display: flex; align-items: center;
  box-shadow: 0 -1px 3px rgba(0,0,0,0.04);
}

/* ── 波形缩放工具栏 ── */
#wave-toolbar {
  display: flex; gap: 3px; padding: 3px 8px;
  background: #f8fafc; border-bottom: 1px solid var(--border);
}
#wave-toolbar button {
  width: 32px; height: 26px; padding: 0; margin: 0;
  font-size: 14px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}

/* ── Canvas 波形 ── */
.wave-canvas { display: block; border-radius: 2px; }
.window-title {
  padding: 5px 14px; font-size: 12px; font-weight: 700;
  color: var(--accent2);
  background: linear-gradient(180deg, #e8edf5 0%, #dce3ed 100%);
  border-bottom: 1px solid var(--border);
  border-top: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
  letter-spacing: 0.5px;
}

/* 文件选择器隐藏 */
.hidden-file { display: none; }

/* ── 连接指示点 ── */
.conn-dot {
  display: inline-block; width: 10px; height: 10px;
  border-radius: 50%; margin: 0 4px;
  background: #c0c8d4; border: 1px solid #a0aab4;
  box-shadow: inset 0 1px 1px rgba(0,0,0,0.1);
  transition: all 0.3s;
}
.conn-dot.on {
  background: #0ea55a;
  border-color: #0a8a48;
  box-shadow: 0 0 6px rgba(14,165,90,0.5);
}

/* ── 连接弹窗 ── */
.modal-overlay {
  position: fixed; z-index: 2000; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(15,23,42,0.35);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.modal-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.05);
  min-width: 360px; max-width: 420px;
  overflow: hidden;
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-title {
  padding: 14px 20px;
  background: linear-gradient(180deg, #f0f4fa 0%, #e2e8f2 100%);
  font-weight: 700; font-size: 15px; color: #1e293b;
  border-bottom: 1px solid #d0d7de;
}
.modal-body { padding: 16px 20px; }
.modal-body label { margin-top: 6px; }
.modal-btns {
  display: flex; gap: 8px; margin-top: 16px;
  justify-content: flex-end;
}
.modal-btns button { min-width: 80px; }
