/* ========================================
   DMZ 外规知识库网关 — 自定义样式
   配色方案与 prototype 保持一致
   ======================================== */

:root {
  --sidebar-w: 200px;
  --topbar-h: 52px;
  --bg: #f5f7fa;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #333639;
  --muted: #8a9eab;
  --primary: #00A2B1;
  --primary-soft: #E6F5F6;
  --danger: #d03050;
  --danger-soft: #fce8eb;
  --warning: #f0a020;
  --warning-soft: #fef5e6;
  --success: #18a058;
  --success-soft: #eaf5ec;
  --sidebar-bg: #F7F8FA;
  --sidebar-text: #333639;
  --sidebar-active: #00A2B1;
  --sidebar-active-bg: #E6F5F6;
  --sidebar-hover: #F0F2F5;
}

* { box-sizing: border-box; margin: 0; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background-color: transparent; }
::-webkit-scrollbar-thumb { background-color: #d4d9de; border-radius: 10px; min-height: 30px; border: 1px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: #b0b7be; }
::-webkit-scrollbar-corner { background-color: transparent; }

body {
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* ── Layout ── */
.app-layout { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  position: fixed; left: 0; top: 0; bottom: 0;
  overflow-y: auto; overflow-x: hidden;
  z-index: 100;
  padding: 0;
  border-right: 1px solid var(--border);
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,.12) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 4px; }

.sidebar-brand {
  height: 64px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 16px;
  font-weight: 700; font-size: 14px; color: var(--text);
  margin-bottom: 8px;
  flex-shrink: 0;
}
.sidebar-brand .brand-icon {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #00c4d6);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}

/* ── DMZ 标签 ── */
.dmz-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 4px;
  background: linear-gradient(135deg, #ff6b35, #f7534a);
  color: #fff; font-size: 10px; font-weight: 700;
  letter-spacing: 1px; margin-left: 6px;
}

/* ── Menu ── */
.menu-folder { margin-bottom: 2px; }
.menu-title {
  height: 44px; padding: 0 16px;
  display: flex; align-items: center;
  color: #333639; font-size: 13.5px; cursor: pointer;
  transition: color 0.3s; user-select: none;
}
.menu-title:hover { color: var(--primary); }
.menu-title i { font-size: 16px; margin-right: 8px; color: #606266; transition: color 0.3s; }
.menu-title:hover i { color: var(--primary); }
.menu-title .folder-arrow { margin-left: auto; margin-right: 0; font-size: 12px; transition: transform 0.3s; }
.menu-folder.expanded .folder-arrow { transform: rotate(180deg); }
.menu-folder.expanded .menu-title { color: var(--primary); }
.menu-folder.expanded .menu-title i { color: var(--primary); }

.menu-sub-list { display: none; flex-direction: column; overflow: hidden; }
.menu-folder.expanded .menu-sub-list { display: flex; }
.menu-sub-item {
  height: 38px; padding-left: 44px; margin: 2px 8px;
  display: flex; align-items: center;
  font-size: 13px; color: #333639; border-radius: 4px; cursor: pointer; text-decoration: none;
  transition: all 0.3s;
}
.menu-sub-item:hover { background: var(--sidebar-hover); color: var(--primary); }
.menu-sub-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active); font-weight: 500; }

a.menu-title.active {
  margin: 0 8px; border-radius: 4px; padding-left: 8px;
  background: var(--sidebar-active-bg); color: var(--sidebar-active); font-weight: 500;
}
a.menu-title.active i { color: var(--sidebar-active); }

/* ── Main Area ── */
.main-area { margin-left: var(--sidebar-w); flex: 1; min-width: 0; }

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: #fff; border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-size: 17px; font-weight: 700; }
.topbar-crumb { font-size: 12px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* ── Page Content ── */
.page-content { padding: 20px 24px 30px; }

/* ── Panel ── */
.panel {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px 20px;
  box-shadow: 0 2px 8px rgba(12,30,58,.04);
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.panel-title { font-size: 15px; font-weight: 700; }
.panel-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── KPI 卡片 ── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.kpi-card {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 16px 18px; background: #fff;
  transition: box-shadow 0.15s, transform 0.15s;
}
.kpi-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.06);
  transform: translateY(-1px);
}
.kpi-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; margin-bottom: 10px;
}
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value { font-size: 28px; font-weight: 700; margin-top: 4px; line-height: 1.1; }
.kpi-sub { font-size: 11px; color: var(--muted); margin-top: 6px; }

/* ── Table ── */
.table { border-collapse: separate; border-spacing: 0; }
.table thead th {
  font-size: 11.5px; color: #5a6b80; font-weight: 600;
  letter-spacing: .4px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: #f8fafb;
  white-space: nowrap;
  position: sticky; top: 0; z-index: 2;
}
.table thead th:first-child { border-radius: 8px 0 0 0; }
.table thead th:last-child { border-radius: 0 8px 0 0; }
.table td {
  font-size: 13px; vertical-align: middle;
  padding: 10px 12px;
  border-bottom: 1px solid #f0f3f7;
}
.table tbody tr { transition: background .12s; }
.table-hover tbody tr:hover { background: #f5f8fc; }
.td-name { font-weight: 600; color: var(--text); max-width: 300px; }
.td-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* ── 操作按钮 ── */
.td-actions {
  white-space: nowrap;
  display: flex;
  gap: 4px;
  align-items: center;
}
.act-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid var(--border); background: #fff;
  color: var(--muted); cursor: pointer; font-size: 13px;
  transition: all .15s;
}
.act-btn:hover { background: var(--primary-soft); color: var(--primary); border-color: #bdd3f7; }
.act-link {
  font-size: 12px; color: var(--primary); cursor: pointer;
  white-space: nowrap; background: none; border: none; padding: 4px 8px;
  border-radius: 4px; transition: background .12s;
}
.act-link:hover { background: var(--primary-soft); }

/* ── 状态标签 ── */
.status-pill {
  display: inline-block; padding: 3px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 500;
}
.status-active { background: var(--success-soft); color: var(--success); }
.status-warn { background: var(--warning-soft); color: var(--warning); }
.status-danger { background: var(--danger-soft); color: var(--danger); }
.status-info { background: var(--primary-soft); color: var(--primary); }
.status-muted { background: #f1f5f9; color: #64748b; }

/* ── 过滤栏 ── */
.filter-bar {
  display: flex; gap: 8px; flex-wrap: wrap;
  align-items: center;
  padding: 10px 16px;
  background: #fafbfd;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 14px;
}
.filter-bar .form-control {
  font-size: 12.5px; height: 34px; padding: 4px 10px;
  border-radius: 6px; border: 1px solid #d5dce6;
  background: #fff;
}
.filter-bar .form-select {
  font-size: 12.5px; height: 34px; padding: 4px 28px 4px 10px;
  border-radius: 6px; border: 1px solid #d5dce6;
  background-color: #fff;
  min-width: 110px; max-width: 150px;
}
.filter-bar .form-control { min-width: 160px; max-width: 220px; }
.filter-bar .btn {
  height: 34px; font-size: 12.5px; padding: 0 14px;
  display: inline-flex; align-items: center; gap: 4px;
}
.filter-count {
  font-size: 12px; color: var(--muted); margin-left: auto; white-space: nowrap;
}

/* ── Modal ── */
.modal-content { border-radius: 12px; border: none; box-shadow: 0 20px 60px rgba(0,0,0,.15); }
.modal-header { border-bottom: 1px solid #eef1f6; padding: 14px 20px; }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-body { padding: 0; }
.modal-footer { border-top: 1px solid #eef1f6; padding: 10px 20px; }

/* ── Detail Grid ── */
.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
}
.detail-item {
  padding: 10px 14px;
  border-bottom: 1px solid #f0f3f7;
}
.detail-item:nth-child(odd) { border-right: 1px solid #f0f3f7; }
.detail-label { font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
.detail-value { font-size: 13.5px; font-weight: 500; }
.detail-full { grid-column: 1 / -1; }
.detail-section {
  font-size: 14px; font-weight: 700; padding: 12px 14px 6px;
  border-bottom: 2px solid var(--primary-soft); color: var(--primary);
  grid-column: 1 / -1;
}

/* ── 拓扑架构图 ── */
.topo-diagram {
  display: flex; align-items: center; justify-content: center;
  gap: 0; padding: 24px 16px; flex-wrap: nowrap;
}
.topo-zone {
  display: flex; flex-direction: column; align-items: center;
  padding: 20px 24px; border-radius: 12px; min-width: 180px;
  position: relative;
}
.topo-zone.internal {
  background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
  border: 2px solid #66bb6a;
}
.topo-zone.dmz {
  background: linear-gradient(135deg, #e3f2fd, #bbdefb);
  border: 2px dashed var(--primary);
  box-shadow: 0 4px 20px rgba(0,162,177,.12);
}
.topo-zone.external {
  background: linear-gradient(135deg, #fce8eb, #f8bbd0);
  border: 2px solid #ef5350;
}
.topo-zone-label {
  font-size: 11px; font-weight: 700; padding: 2px 10px;
  border-radius: 4px; color: #fff; position: absolute; top: -10px;
}
.topo-zone.internal .topo-zone-label { background: #43a047; }
.topo-zone.dmz .topo-zone-label { background: var(--primary); }
.topo-zone.external .topo-zone-label { background: #e53935; }
.topo-zone-icon { font-size: 28px; margin-bottom: 8px; }
.topo-zone-name { font-size: 13px; font-weight: 600; }
.topo-zone-desc { font-size: 11px; color: var(--muted); margin-top: 2px; text-align: center; }
.topo-arrow {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: 0 12px; align-self: center;
}
.topo-arrow-line {
  font-size: 24px; color: var(--primary); line-height: 1;
}
.topo-arrow-label { font-size: 10px; color: var(--muted); white-space: nowrap; }

/* ── 版本时间线 ── */
.version-timeline { position: relative; padding-left: 24px; }
.version-timeline::before {
  content: ''; position: absolute; left: 8px; top: 0; bottom: 0;
  width: 2px; background: var(--border);
}
.version-item { position: relative; margin-bottom: 16px; }
.version-item::before {
  content: ''; position: absolute; left: -20px; top: 4px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--primary); border: 2px solid #fff;
}
.version-item.current::before {
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}
.version-item.obsolete::before { background: var(--muted); }
.version-date { font-size: 12px; color: var(--muted); }
.version-text { font-size: 13px; margin-top: 2px; }
.version-badge {
  display: inline-block; padding: 1px 6px; border-radius: 3px;
  font-size: 10px; font-weight: 600; margin-left: 6px;
}

/* ── 推送状态指示 ── */
.push-status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; margin-right: 6px;
}
.push-status-dot.online { background: var(--success); box-shadow: 0 0 6px var(--success); }
.push-status-dot.offline { background: var(--danger); }
.push-status-dot.pending { background: var(--warning); }

/* ── 配置面板折叠 ── */
.config-panel-body { transition: max-height 0.3s ease; }

/* ── API 文档样式 ── */
.api-endpoint {
  padding: 12px 16px; border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: 10px;
  background: #fff; transition: box-shadow 0.15s;
}
.api-endpoint:hover { box-shadow: 0 2px 8px rgba(0,0,0,.05); }
.api-method {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 700; color: #fff;
  margin-right: 8px;
}
.api-method.get { background: #2196f3; }
.api-method.post { background: #4caf50; }
.api-method.put { background: #ff9800; }
.api-method.delete { background: #f44336; }
.api-path { font-family: 'Consolas', 'Monaco', monospace; font-size: 13px; font-weight: 600; }
.api-desc { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── 连通性检测动画 ── */
@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 0 0 rgba(24, 160, 88, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(24, 160, 88, 0); }
}
.connectivity-ok { animation: pulse-green 2s infinite; }
