/* ===== Web终端页（对齐 Terminal.vue 样式） ===== */
.term-host { height: 100%; }
.terminal-page { display: flex; flex-direction: column; height: 100%; background: var(--bg-page); position: relative; }

/* 标签 + 工具同一行 */
.tab-bar {
  display: flex; align-items: center; justify-content: space-between;
  height: 40px; background: var(--bg-rail); border-bottom: 1px solid var(--border-soft); flex-shrink: 0;
}
.tab-list { display: flex; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tab-list::-webkit-scrollbar { display: none; }
.tab-item {
  display: flex; align-items: center; gap: 7px;
  padding: 0 12px; height: 40px; cursor: pointer; font-size: calc(13px * var(--fs, 1));
  color: var(--text-2); user-select: none; max-width: 220px;
  border-right: 1px solid var(--border-soft); transition: all .15s; flex-shrink: 0; position: relative;
}
.tab-item:hover { color: var(--text-1); background: var(--hover-overlay); }
.tab-item.active { color: var(--accent); background: var(--bg-page); box-shadow: inset 0 -2px 0 var(--accent); }
.tab-index {
  font-size: calc(11px * var(--fs, 1)); color: var(--accent); background: var(--active-overlay);
  border-radius: 4px; padding: 0 5px; line-height: 17px; min-width: 16px; text-align: center;
}
.tab-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab-close { display: flex; font-size: calc(11px * var(--fs, 1)); border-radius: 50%; padding: 2px; transition: .15s; }
.tab-close:hover { background: var(--hover-overlay); color: #f85149; }

.tab-actions { display: flex; align-items: center; gap: 3px; padding: 0 8px; flex-shrink: 0; }
.sbtn {
  width: 32px; height: 32px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-2); transition: all .15s;
}
.sbtn:hover { color: var(--text-1); background: var(--hover-overlay); }
.sbtn.on { color: var(--accent); background: var(--active-overlay); }
.sdivider { width: 1px; height: 18px; background: var(--border); margin: 0 6px; }

.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; }
.dot.ok { background: #3fb950; }
.dot.err { background: #f85149; }

/* 工具条下拉（+ / 配色） */
.edropdown-tb { position: relative; display: inline-flex; }
.edrop-menu-tb {
  position: absolute; top: 36px; left: 0; z-index: 300; min-width: 230px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 4px;
  box-shadow: 0 12px 32px 4px rgba(0,0,0,.36); padding: 6px 0; animation: popIn .12s ease;
}
.edrop-menu-tb .dd-item { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 5px 16px; }

/* 浮层 & 浮动面板 */
.panel-overlay { position: absolute; inset: 0; z-index: 90; background: transparent; }
.float-panel {
  position: absolute; top: 44px; z-index: 100;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,0.5); overflow: hidden;
}
.server-panel { left: 10px; width: min(230px, calc(100% - 20px)); }
.settings-panel { left: 196px; width: 224px; max-width: calc(100% - 20px); }

.panel-header {
  padding: 10px 14px; font-size: calc(12px * var(--fs, 1)); color: var(--text-2);
  border-bottom: 1px solid var(--border); font-weight: 600;
}
.panel-list { max-height: min(320px, calc(100vh - 150px)); overflow-y: auto; padding: 5px; }
.panel-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 7px; cursor: pointer; color: var(--text-2); transition: .15s;
}
.panel-item:hover { background: var(--hover-overlay); color: var(--text-1); }
.panel-item-info { flex: 1; min-width: 0; }
.panel-item-name { font-size: calc(13px * var(--fs, 1)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-item-ip { font-size: calc(11px * var(--fs, 1)); color: var(--text-3); }
.panel-item-badge {
  background: var(--accent); color: var(--bg-rail); font-size: calc(10px * var(--fs, 1)); font-weight: bold;
  min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.panel-empty { text-align: center; padding: 20px; color: var(--text-3); font-size: calc(12px * var(--fs, 1)); }

.panel-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 11px; }
.panel-row { display: flex; align-items: center; gap: 8px; }
.panel-label { font-size: calc(12px * var(--fs, 1)); color: var(--text-2); min-width: 44px; }
.sm-group .eb.sm { min-width: 28px; padding: 0 8px; }

/* 配色预览 */
.theme-swatch {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 16px; border-radius: 3px; border: 1px solid var(--bg-hover); vertical-align: middle; flex-shrink: 0;
}
.theme-swatch i { font-style: normal; font-size: calc(10px * var(--fs, 1)); font-weight: bold; line-height: 1; }
.theme-check { margin-left: auto; color: #3fb950; display: flex; }

/* 颜色板弹层 */
.color-pick { position: relative; display: inline-flex; }
.cpal {
  position: absolute; top: 30px; left: 0; z-index: 400; display: grid;
  grid-template-columns: repeat(4, 24px); gap: 6px; padding: 8px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 12px 32px 4px rgba(0,0,0,.36);
}
.cpal-i { width: 24px; height: 24px; border-radius: 4px; border: 1px solid var(--border); cursor: pointer; }

/* ===== 终端区 ===== */
.term-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.term-body { flex: 1; position: relative; overflow: hidden; box-sizing: border-box; min-height: 0; }
.term-wrap { position: absolute; inset: 0; }
.xterm-sim {
  position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden;
  font-family: Consolas, "Courier New", monospace; line-height: 1.35;
  padding: 6px 10px; white-space: pre-wrap; word-break: break-all; cursor: text;
}
.xterm-sim .tl { min-height: 1.35em; }
.c-green { color: #3fb950; }
.c-red { color: #f85149; }
.c-dim { color: #8a8a8a; }
.c-blue { color: #6cb6ff; }
.cursor {
  display: inline-block; width: .6em; height: 1.1em; background: currentColor;
  vertical-align: text-bottom; margin-left: 1px; animation: caret 1s steps(1) infinite;
}
@keyframes caret { 50% { opacity: 0; } }
.term-capture { position: absolute; opacity: 0; width: 1px; height: 1px; left: -20px; top: 0; }
.empty-tip {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--bg-hover); gap: 10px; font-size: calc(14px * var(--fs, 1));
}
.empty-tip .ep-i { color: #3a3a3a; }
.empty-tip .inline-icon { vertical-align: -3px; display: inline-flex; }

/* 底部状态栏 */
.status-bar {
  display: flex; align-items: center; justify-content: space-between;
  height: 28px; padding: 0 14px; background: var(--bg-rail); border-top: 1px solid var(--border-soft);
  font-size: calc(11px * var(--fs, 1)); color: var(--text-2); flex-shrink: 0;
}
.status-left, .status-right { display: flex; gap: 14px; }
.status-item { display: flex; align-items: center; gap: 5px; }
.status-item.dim { color: var(--text-3); }

/* ===== AI 助手面板 ===== */
.term-area.with-ai { margin-right: 360px; }
.ai-panel {
  position: absolute; top: 40px; right: 0; bottom: 0; width: 360px;
  background: var(--bg-panel); border-left: 1px solid var(--border-soft);
  display: flex; flex-direction: column; z-index: 80;
}
.ai-header {
  display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 8px 0 14px; flex-shrink: 0;
  border-bottom: 1px solid var(--border-soft);
}
.ai-h-ico { color: #2f81f7; }
.ai-title { font-size: calc(14px * var(--fs, 1)); font-weight: 600; color: var(--text-1); }
.ai-sub { font-size: calc(11px * var(--fs, 1)); color: var(--text-3); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-header-actions { display: flex; align-items: center; gap: 2px; }
.sbtn.sm { width: 26px; height: 26px; border-radius: 6px; }

.ai-settings { padding: 12px 14px; border-bottom: 1px solid var(--border-soft); display: flex; flex-direction: column; gap: 10px; background: var(--bg-rail); }
.ai-settings-tip { font-size: calc(11px * var(--fs, 1)); color: var(--text-3); line-height: 1.5; }

.ai-messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.ai-messages::-webkit-scrollbar { width: 6px; }
.ai-messages::-webkit-scrollbar-thumb { background: #2e2e2e; border-radius: 3px; }
.ai-empty { margin: auto; text-align: center; color: var(--text-3); display: flex; flex-direction: column; gap: 10px; padding: 0 20px; }
.ai-empty p { margin: 0; font-size: calc(14px * var(--fs, 1)); }
.ai-e-ico { color: #2f81f7; }
.ai-empty-sub { font-size: calc(12px * var(--fs, 1)) !important; color: var(--text-3); line-height: 1.6; }

.ai-msg { display: flex; }
.ai-msg.user { justify-content: flex-end; }
.ai-bubble {
  max-width: 92%; font-size: calc(13px * var(--fs, 1)); line-height: 1.65; word-break: break-word;
  padding: 9px 12px; border-radius: 10px; color: var(--text-1);
}
.ai-msg.user .ai-bubble { background: rgba(47,129,247,0.18); border: 1px solid rgba(47,129,247,0.25); border-top-right-radius: 3px; }
.ai-msg.assistant .ai-bubble { background: var(--bg-elev); border: 1px solid var(--border); border-top-left-radius: 3px; }
.ai-bubble.err { color: #f85149; border-color: rgba(248,81,73,0.3); }
.ai-bubble strong { color: var(--text-1); }
.ai-bubble code.ai-inline {
  background: var(--bg-input); border: 1px solid var(--border); border-radius: 4px;
  padding: 1px 5px; font-size: calc(12px * var(--fs, 1)); color: #79c0ff;
  font-family: Consolas, "Courier New", monospace;
}
.ai-thinking { color: var(--text-2); }
.ai-dots { display: inline-flex; gap: 3px; margin-left: 6px; }
.ai-dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); animation: ai-blink 1.2s infinite; }
.ai-dots i:nth-child(2) { animation-delay: .2s; }
.ai-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes ai-blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

.ai-input-area { flex-shrink: 0; border-top: 1px solid var(--border-soft); padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.ai-ctx-row { display: flex; align-items: center; gap: 8px; }
.ai-ctx-label { font-size: calc(11px * var(--fs, 1)); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-input-row { display: flex; align-items: flex-end; gap: 8px; }
.ai-send { height: 54px; width: 44px; border-radius: 8px; }

/* 窄屏适配 */
@media (max-width: 768px) {
  .settings-panel { left: 10px; }
  .term-area.with-ai { margin-right: 0; }
  .ai-panel { width: 100%; border-left: none; }
}
