/* 智能化能源控制平台演示 DEMO 样式表 */
:root {
  --bg-base: #0b1120;
  --bg-surface: #11192c;
  --bg-elevated: #17233c;
  --bg-hover: #1e2d4d;
  --border-subtle: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(56, 189, 248, 0.35);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-cyan: #38bdf8;
  --accent-blue: #3b82f6;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --accent-purple: #a855f7;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.28);
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

html, body {
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
}

/* 顶栏 */
.topbar {
  min-height: 58px;
  background: rgba(17, 25, 44, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-shrink: 1;
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0ea5e9, #10b981);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 15px;
  flex-shrink: 0;
  box-shadow: 0 0 16px rgba(14, 165, 233, 0.35);
}

.brand-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.brand-sub {
  font-size: 11.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.topbar-controls .control-select,
.topbar-controls .btn {
  padding: 5px 9px;
  font-size: 12px;
  white-space: nowrap;
}

.sim-clock {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  padding: 4px 10px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: nowrap;
}

.sim-clock .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

.sim-clock.paused .dot {
  background: var(--accent-amber);
  box-shadow: none;
}

.control-select, .btn {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
}

.control-select:hover, .btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  border-color: transparent;
  color: #fff;
  font-weight: 500;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0369a1, #1d4ed8);
}

.btn-success {
  background: linear-gradient(135deg, #059669, #10b981);
  border-color: transparent;
  color: #fff;
  font-weight: 500;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.28);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn.active {
  background: rgba(56, 189, 248, 0.18);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

/* 主布局 */
.app-shell {
  display: flex;
  min-height: calc(100vh - 60px);
}

.sidebar {
  width: 224px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.nav-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 10px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.16s ease;
  border: 1px solid transparent;
  font-size: 13.5px;
}

.nav-item:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.32);
  color: var(--accent-cyan);
  font-weight: 500;
}

.nav-badge {
  margin-left: auto;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-secondary);
}

.sidebar-footer strong {
  color: var(--text-primary);
  display: block;
  margin-bottom: 4px;
}

/* 内容区 */
.main-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  min-width: 0;
}

.view-panel {
  display: none;
  flex-direction: column;
  gap: 18px;
}

.view-panel.active {
  display: flex;
}

/* KPI 卡片网格 */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--kpi-accent, var(--accent-cyan));
}

.kpi-label {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  font-family: var(--font-mono);
  margin: 6px 0 4px;
  letter-spacing: -0.5px;
}

.kpi-unit {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-left: 4px;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
}

.tag-green { background: rgba(16, 185, 129, 0.16); color: #34d399; }
.tag-cyan { background: rgba(56, 189, 248, 0.16); color: #7dd3fc; }
.tag-amber { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
.tag-red { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.tag-purple { background: rgba(168, 85, 247, 0.18); color: #d8b4fe; }

/* 通用卡片 */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 16px;
}

.grid-equal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* 3D 数字孪生舞台 */
.twin-stage {
  background: radial-gradient(circle at 50% 35%, #162544 0%, #0d1527 100%);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  padding: 12px;
  position: relative;
}

.twin3d-wrap {
  position: relative;
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
}

.twin3d-canvas {
  display: block;
  width: 100%;
  cursor: grab;
  user-select: none;
}

.twin3d-canvas:active {
  cursor: grabbing;
}

.twin3d-toolbar {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  z-index: 5;
  background: rgba(11, 17, 32, 0.72);
  backdrop-filter: blur(8px);
  padding: 6px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
}

.twin3d-hint {
  position: absolute;
  bottom: 10px;
  left: 12px;
  font-size: 11.5px;
  color: rgba(203, 213, 225, 0.78);
  background: rgba(11, 17, 32, 0.65);
  padding: 4px 10px;
  border-radius: 999px;
  pointer-events: none;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}

.metric-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.metric-box .label {
  font-size: 11.5px;
  color: var(--text-secondary);
}

.metric-box .val {
  font-size: 18px;
  font-weight: 600;
  font-family: var(--font-mono);
  margin-top: 2px;
}

/* 表格 */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

th {
  color: var(--text-secondary);
  font-weight: 500;
  background: rgba(23, 35, 60, 0.6);
  white-space: nowrap;
}

tr:hover td {
  background: rgba(30, 45, 77, 0.4);
}

/* LLM 调度对话区 */
.llm-chat-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.prompt-chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.16s ease;
}

.prompt-chip:hover {
  border-color: var(--accent-cyan);
  color: var(--text-primary);
}

.llm-input-row {
  display: flex;
  gap: 8px;
}

.llm-input {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 12px;
  font-size: 13.5px;
  font-family: inherit;
}

.llm-input:focus {
  outline: none;
  border-color: var(--accent-cyan);
}

.plan-card {
  background: rgba(23, 35, 60, 0.72);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rule-check-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}

.rule-item {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.28);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 12px;
  color: #a7f3d0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.rule-item.warn {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
  color: #fde68a;
}

/* 智慧会议阶段条 */
.stage-bar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.stage-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.18s ease;
}

.stage-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.stage-btn.active {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--accent-green);
  color: #6ee7b7;
  font-weight: 600;
}

.stage-btn.emergency.active {
  background: rgba(239, 68, 68, 0.18);
  border-color: var(--accent-red);
  color: #fca5a5;
}

/* 动画能流 */
@keyframes flowDash {
  to {
    stroke-dashoffset: -28;
  }
}

.flow-line {
  stroke-dasharray: 8 6;
  animation: flowDash 1.2s linear infinite;
}

.flow-line.reverse {
  animation-direction: reverse;
}

.flow-line.stopped {
  animation: none;
  stroke-dasharray: 4 6;
  opacity: 0.3;
}

/* 日志列表 */
.log-list {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.log-item {
  background: var(--bg-elevated);
  border-left: 3px solid var(--accent-cyan);
  padding: 8px 12px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 12.5px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.log-item.warn { border-left-color: var(--accent-amber); }
.log-item.success { border-left-color: var(--accent-green); }
.log-item.danger { border-left-color: var(--accent-red); }

/* 弹窗 Toast */
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: #0f172a;
  border: 1px solid var(--accent-cyan);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 200;
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition: all 0.25s ease;
  max-width: 380px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* 终端模式预览：楼层屏 & 移动端 */
body.mode-floor .sidebar {
  display: none;
}

body.mode-mobile .app-shell {
  max-width: 430px;
  margin: 16px auto;
  border: 6px solid #1e293b;
  border-radius: 28px;
  overflow: hidden;
  min-height: 780px;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}

body.mode-mobile .sidebar {
  width: 100%;
  flex-direction: row;
  overflow-x: auto;
  padding: 8px;
  border-right: none;
  border-bottom: 1px solid var(--border-subtle);
}

body.mode-mobile .nav-section-title,
body.mode-mobile .sidebar-footer {
  display: none;
}

body.mode-mobile .grid-2,
body.mode-mobile .grid-equal,
body.mode-mobile .stage-bar {
  grid-template-columns: 1fr;
}

/* 响应式 */
@media (max-width: 1080px) {
  .grid-2, .grid-equal {
    grid-template-columns: 1fr;
  }
  .stage-bar {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: 68px;
    padding: 12px 6px;
  }
  .nav-item span.nav-label,
  .nav-section-title,
  .sidebar-footer {
    display: none;
  }
}
