/* ============================================================
 * panel.css —— 面板层：视图 / 导航 / 建筑库 / 服务器 / 导入抽屉 / 登录
 * （在 style.css 之后加载，复用其 CSS 变量）
 * ============================================================ */

.view { position: absolute; inset: 0; display: flex; flex-direction: column; min-height: 0; }

/* ------------------------- 顶部导航 ------------------------- */

.tabs { display: flex; align-items: center; gap: 4px; background: var(--panel); border: 1px solid var(--border); padding: 4px; border-radius: 11px; }
.tab {
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-size: 13px; font-weight: 550;
  color: var(--text-dim); background: none; border: none;
  padding: 7px 14px; border-radius: 8px; cursor: pointer;
  transition: color 0.16s, background 0.16s;
}
.tab svg { width: 15px; height: 15px; }
.tab:hover { color: var(--text); background: var(--panel-2); }
.tab.active { color: #04120c; background: linear-gradient(180deg, #16d295, var(--accent-dim)); box-shadow: 0 4px 14px -6px rgba(16, 185, 129, 0.8); }
.tab-badge {
  font-family: var(--mono); font-size: 10.5px; min-width: 17px; height: 17px;
  display: inline-grid; place-items: center; padding: 0 4px;
  border-radius: 999px; background: rgba(255, 255, 255, 0.14); color: inherit;
}
.tab:not(.active) .tab-badge { background: var(--border); color: var(--text-dim); }

.conn-chip {
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-size: 12px; color: var(--text-dim);
  background: var(--panel); border: 1px solid var(--border);
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
  transition: all 0.16s; max-width: 230px;
}
.conn-chip:hover { border-color: #2f3d4d; color: var(--text); }
.conn-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.conn-chip.on { color: var(--accent); border-color: rgba(16, 185, 129, 0.3); background: rgba(16, 185, 129, 0.08); }
.conn-chip.on .dot { background: var(--accent); box-shadow: 0 0 8px rgba(16, 185, 129, 0.8); }
.conn-chip.bad { color: #fca5a5; border-color: rgba(239, 68, 68, 0.35); }
.conn-chip.bad .dot { background: var(--danger); }
.conn-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: 9px;
  color: var(--text-dim); cursor: pointer; transition: all 0.16s;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { color: var(--text); border-color: #2f3d4d; background: var(--panel-2); }

/* ------------------------- 通用控件 ------------------------- */

.btn-ghost { background: var(--panel-2); color: var(--text-dim); border-color: var(--border); box-shadow: none; }
.btn-ghost:hover { color: var(--text); border-color: #33404f; }
.btn-danger { background: rgba(239, 68, 68, 0.1); color: #fca5a5; border-color: rgba(239, 68, 68, 0.35); box-shadow: none; }
.btn-danger:hover { background: rgba(239, 68, 68, 0.18); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; filter: none; transform: none; }
.btn-mini {
  font: inherit; font-size: 12px; font-weight: 550;
  padding: 6px 12px; border-radius: 8px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text-dim);
  transition: all 0.16s; white-space: nowrap;
}
.btn-mini:hover { color: var(--accent); border-color: rgba(16, 185, 129, 0.4); }
.grow { flex: 1 1 auto; }

.sel {
  font: inherit; font-size: 12.5px; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--border);
  padding: 8px 10px; border-radius: 9px; outline: none; cursor: pointer;
  max-width: 100%;
}
.sel:focus { border-color: rgba(16, 185, 129, 0.5); }

input[type="number"], input[type="text"], input[type="password"] {
  font: inherit; font-size: 13px; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--border);
  padding: 9px 11px; border-radius: 9px; outline: none; width: 100%;
  transition: border-color 0.16s;
}
input[type="number"]:focus, input[type="text"]:focus, input[type="password"]:focus { border-color: rgba(16, 185, 129, 0.55); }

.btn-import {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; margin: 14px 0 16px;
  font: inherit; font-size: 13.5px; font-weight: 600;
  padding: 12px; border-radius: 10px; cursor: pointer;
  color: #04120c; border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, #12c98b, var(--accent-dim));
  box-shadow: 0 8px 22px -10px rgba(16, 185, 129, 0.9);
  transition: all 0.18s;
}
.btn-import svg { width: 16px; height: 16px; }
.btn-import:hover { filter: brightness(1.08); transform: translateY(-1px); }

/* ------------------------- 建筑库 ------------------------- */

.lib-bar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  padding: 14px 20px; border-bottom: 1px solid var(--border-soft);
  background: rgba(16, 21, 28, 0.6);
}
.lib-search { position: relative; flex: 0 1 320px; }
.lib-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-faint); }
.lib-search input { padding-left: 33px; }
.lib-spacer { flex: 1 1 auto; }
.lib-count { font-size: 12px; color: var(--text-faint); font-family: var(--mono); white-space: nowrap; }
.lib-bar .btn { padding: 8px 16px; font-size: 12.5px; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.lib-bar .btn svg { width: 15px; height: 15px; }

.lib-body { flex: 1 1 auto; overflow-y: auto; padding: 18px 20px 34px; }
.lib-body::-webkit-scrollbar { width: 9px; }
.lib-body::-webkit-scrollbar-thumb { background: #232d3a; border-radius: 5px; }

.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(238px, 1fr)); gap: 14px; }

.bcard {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s;
}
.bcard:hover { border-color: #2f3d4d; transform: translateY(-2px); box-shadow: 0 14px 30px -18px rgba(0, 0, 0, 0.9); }
.bcard-thumb {
  position: relative; aspect-ratio: 16 / 10; background: #12161c center/cover no-repeat;
  display: grid; place-items: center; overflow: hidden;
}
.bcard-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bcard-thumb .ph { font-size: 11px; color: var(--text-faint); font-family: var(--mono); letter-spacing: 1px; }
.bcard-fmt {
  position: absolute; left: 8px; top: 8px;
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  padding: 3px 7px; border-radius: 6px;
  background: rgba(11, 15, 20, 0.78); color: var(--accent);
  border: 1px solid rgba(16, 185, 129, 0.3); backdrop-filter: blur(6px);
}
.bcard-body { padding: 11px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1 1 auto; }
.bcard-name { font-size: 13.5px; font-weight: 600; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bcard-meta { font-size: 11.5px; color: var(--text-faint); font-family: var(--mono); }
.bcard-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.bcard-tag { font-size: 10.5px; color: var(--text-dim); background: var(--panel-2); border: 1px solid var(--border-soft); padding: 2px 7px; border-radius: 999px; }
.bcard-actions { display: flex; flex-direction: column; gap: 6px; margin-top: auto; padding-top: 10px; }
.ba-row { display: flex; gap: 6px; }
.ba-row button { flex: 1 1 0; }
.ba-row.ba-sec button { font-size: 11px; padding: 4px 0; color: var(--text-faint); }
.ba-row.ba-sec button:hover { color: var(--text); }
.bcard-actions button {
  font: inherit; font-size: 11.5px; padding: 5px 9px; border-radius: 7px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text-dim);
  transition: all 0.15s; white-space: nowrap; line-height: 1.5;
}
.bcard-actions button:hover { color: var(--text); border-color: #33404f; }
.bcard-actions button[data-act="import"] { color: #04120c; background: linear-gradient(180deg, #16d295, var(--accent-dim)); border-color: transparent; font-weight: 600; }
.bcard-actions button[data-act="import"]:hover { filter: brightness(1.08); }
.bcard-actions button[data-act="delete"]:hover { color: #fca5a5; border-color: rgba(239, 68, 68, 0.4); }
.bcard-actions .sp { flex: 1 1 auto; }

.lib-empty { text-align: center; padding: 78px 20px; color: var(--text-dim); }
.lib-empty-icon { width: 62px; height: 62px; margin: 0 auto 18px; color: var(--text-faint); opacity: 0.6; }
.lib-empty-icon svg { width: 100%; height: 100%; }
.lib-empty h3 { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.lib-empty p { font-size: 12.5px; line-height: 1.75; color: var(--text-faint); margin-bottom: 20px; }

/* ------------------------- 服务器 ------------------------- */

.srv-wrap { flex: 1 1 auto; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 400px); min-height: 0; }
.srv-left { padding: 18px 20px 30px; overflow-y: auto; border-right: 1px solid var(--border-soft); }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel-head h3 { font-size: 13px; font-weight: 600; color: var(--text-dim); letter-spacing: 0.3px; }

.srv-list { display: flex; flex-direction: column; gap: 9px; }
.srv-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 11px;
  padding: 12px 14px; cursor: pointer; transition: all 0.16s;
}
.srv-item:hover { border-color: #2f3d4d; }
.srv-item.active { border-color: rgba(16, 185, 129, 0.45); background: rgba(16, 185, 129, 0.06); }
.srv-item .si-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); flex: 0 0 auto; }
.srv-item .si-dot.ok { background: var(--accent); box-shadow: 0 0 8px rgba(16, 185, 129, 0.8); }
.srv-item .si-main { flex: 1 1 auto; min-width: 0; }
.srv-item .si-name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srv-item .si-addr { font-size: 11.5px; color: var(--text-faint); font-family: var(--mono); }
.srv-item .si-msg { font-size: 11px; color: var(--text-faint); max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.srv-tip { margin-top: 26px; border-top: 1px solid var(--border-soft); padding-top: 18px; font-size: 12.5px; color: var(--text-faint); line-height: 1.8; }
.srv-tip b { display: block; color: var(--text-dim); font-size: 12.5px; margin-bottom: 8px; }
.srv-tip ol { padding-left: 18px; }
.srv-tip pre {
  font-family: var(--mono); font-size: 11.5px; color: var(--accent);
  background: var(--bg-soft); border: 1px solid var(--border-soft);
  padding: 10px 12px; border-radius: 8px; margin: 8px 0; overflow-x: auto;
}
.srv-note { margin-top: 12px; font-size: 11.5px; color: var(--text-faint); }
.srv-tip code { color: var(--accent); }
.pwd-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pwd-row .srv-note { margin: 0; }

.srv-form { padding: 18px 20px 30px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.fld { display: flex; flex-direction: column; gap: 6px; }
.fld > span { font-size: 11.5px; color: var(--text-faint); }
.fld-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fld-actions { display: flex; gap: 8px; margin-top: 4px; }
.fld-actions .btn { padding: 9px 18px; font-size: 13px; }
.srv-out {
  font-family: var(--mono); font-size: 11.5px; line-height: 1.65;
  color: var(--text-dim); background: var(--bg-soft);
  border: 1px solid var(--border-soft); border-radius: 9px;
  padding: 11px 12px; min-height: 46px; white-space: pre-wrap; word-break: break-all;
  margin: 0;
}
.srv-out.ok { color: var(--accent); border-color: rgba(16, 185, 129, 0.3); }
.srv-out.err { color: #fca5a5; border-color: rgba(239, 68, 68, 0.3); }

/* ------------------------- 导入抽屉 ------------------------- */

.scrim { position: fixed; inset: 0; background: rgba(4, 7, 10, 0.55); backdrop-filter: blur(2px); z-index: 60; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 420px; max-width: 94vw;
  background: var(--bg-soft); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 61;
  box-shadow: -30px 0 60px -30px rgba(0, 0, 0, 0.9);
  animation: slideIn 0.22s ease-out;
}
@keyframes slideIn { from { transform: translateX(28px); opacity: 0; } }
.drawer-head {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.drawer-head h3 { font-size: 14px; font-weight: 650; }
.drawer-head span { font-size: 11.5px; color: var(--text-faint); }
.drawer-body { flex: 1 1 auto; overflow-y: auto; padding: 16px 18px 26px; display: flex; flex-direction: column; gap: 16px; }
.drawer-body::-webkit-scrollbar { width: 8px; }
.drawer-body::-webkit-scrollbar-thumb { background: #232d3a; border-radius: 4px; }

.ip-block { display: flex; flex-direction: column; gap: 8px; }
.ip-label { font-size: 11.5px; color: var(--text-faint); }
.ip-row { display: flex; gap: 8px; align-items: center; }
.ip-hint { font-size: 11px; color: var(--text-faint); font-family: var(--mono); }
.ip-coords { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ip-coords label { position: relative; display: block; }
.ip-coords label span {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: 11px; color: var(--text-faint); pointer-events: none;
}
.ip-coords input { padding-left: 26px; font-family: var(--mono); }
.ip-block .btn-link { margin: 0; text-align: left; padding-left: 0; font-size: 11.5px; }

.ip-estimate {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  background: var(--panel); border: 1px solid var(--border-soft);
  border-radius: 10px; padding: 12px;
}
.ip-estimate > div { display: flex; flex-direction: column; gap: 3px; }
.ip-estimate span { font-size: 10.5px; color: var(--text-faint); }
.ip-estimate b { font-size: 13px; font-family: var(--mono); font-weight: 600; }

.ip-actions { display: flex; gap: 8px; }
.ip-actions .btn { padding: 11px 16px; }
#ipStart { padding: 11px 16px; }

.ip-progress { display: flex; flex-direction: column; gap: 7px; }
.ip-bar { height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.ip-bar i { display: block; height: 100%; width: 0; border-radius: 3px; background: linear-gradient(90deg, var(--accent-dim), #22e6a3); transition: width 0.2s; }
.ip-progress-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-faint); font-family: var(--mono); }

.ip-log {
  font-family: var(--mono); font-size: 11px; line-height: 1.7;
  background: var(--bg); border: 1px solid var(--border-soft); border-radius: 9px;
  padding: 10px 11px; height: 190px; overflow-y: auto; color: var(--text-dim);
  white-space: pre-wrap; word-break: break-all;
}
.ip-log:empty::before { content: '等待开始…'; color: var(--text-faint); }
.ip-log .l-ok { color: var(--accent); }
.ip-log .l-err { color: #fca5a5; }
.ip-log .l-dim { color: var(--text-faint); }

/* ------------------------- 登录 ------------------------- */

.gate {
  position: fixed; inset: 0; z-index: 120;
  display: grid; place-items: center;
  background: radial-gradient(700px 460px at 50% 20%, rgba(16, 185, 129, 0.09), transparent 70%), var(--bg);
}
.gate-card {
  width: 320px; max-width: 90vw;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 30px 26px 24px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.95);
}
.gate-logo { width: 46px; height: 46px; margin-bottom: 4px; }
.gate-logo svg { width: 100%; height: 100%; border-radius: 11px; box-shadow: 0 0 30px rgba(16, 185, 129, 0.3); }
.gate-card h2 { font-size: 17px; font-weight: 650; }
.gate-sub { font-size: 12px; color: var(--text-faint); margin-top: -6px; }
.gate-card .btn { padding: 11px; margin-top: 4px; }
.gate-err { font-size: 11.5px; color: #fca5a5; min-height: 15px; }

/* ------------------------- 弹窗 ------------------------- */

.modal { position: fixed; inset: 0; z-index: 130; display: grid; place-items: center; background: rgba(4, 7, 10, 0.6); backdrop-filter: blur(3px); }
.modal-card {
  width: 360px; max-width: 92vw;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 22px; display: flex; flex-direction: column; gap: 11px;
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.95);
}
.modal-card h3 { font-size: 14.5px; font-weight: 650; }
.modal-card p { font-size: 12.5px; color: var(--text-dim); line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.modal-actions .btn { padding: 8px 16px; font-size: 13px; }

@media (max-width: 1100px) {
  .srv-wrap { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .srv-left { border-right: none; border-bottom: 1px solid var(--border-soft); }
}

@media (max-width: 900px) {
  .tabs { position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 30; }
  .lib-bar { flex-wrap: wrap; }
  .lib-search { flex: 1 1 100%; }
  .footer { display: none; }
}
