/* css/layout.css — 看板布局与响应式（沿用原版结构） */

.dashboard {
  min-height: 100vh;
  padding: 8px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 1920px;
  margin: 0 auto;
}

/* ---------- 顶栏：设备统计 / 标题 / 账号 ---------- */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr; /* 标题列始终居于页面正中 */
  align-items: center;
  gap: 12px;
  padding: 4px 0 10px;
  border-bottom: 1px solid rgba(34, 211, 238, 0.35);
  box-shadow: 0 8px 24px -12px rgba(34, 211, 238, 0.35);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-center { display: flex; justify-content: center; }

.topbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  flex-wrap: wrap;
}

.account-info {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
  text-align: right;
  white-space: nowrap;
}

.account-info span { color: var(--text); font-weight: 500; }

.account-info .logout-link {
  margin-top: 4px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  text-align: right;
}
.account-info .logout-link:hover { color: var(--cyan); }

.topbar-meta {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- 主区域：左图表 + 右栏 ---------- */
.main {
  display: grid;
  grid-template-columns: 7fr 3fr;
  gap: 12px;
  align-items: stretch;
}

.main > * { min-width: 0; }

/* 左侧面板内容垂直填满，消除底部留白 */
.chart-panel {
  display: flex;
  flex-direction: column;
}

.right-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.info-panel { flex: 0 0 auto; }
.event-panel {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 320px;
}

.event-content { flex: 1 1 auto; }

/* 图表面板内部 */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px 6px;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.custom-range {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.custom-range[hidden] { display: none; }

.range-sep { color: var(--text-secondary); }

.panel-info-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  padding: 6px 18px 0;
}

.chart-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text);
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.device-id {
  padding: 8px 18px 0;
  font-size: 14px;
  color: var(--cyan);
}

.device-id strong { color: var(--text); font-family: 'JetBrains Mono', monospace; }

.chart-wrap {
  padding: 4px 8px 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chart-container {
  position: relative;
  flex: 1 1 auto;
  min-height: 340px;
  padding: 4px 12px 10px;
}

.chart-container.detail-chart {
  flex: none;
  height: 300px;
  min-height: 0;
}

/* ---------- 指标卡片 ---------- */
.metric-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

/* ---------- 底部：详情图 + 实时数据 ---------- */
.bottom-row {
  display: grid;
  grid-template-columns: 2fr 3fr;
  gap: 12px;
  align-items: start;
}

.bottom-row > * { min-width: 0; }

.table-panel { min-height: 300px; }

/* ---------- 响应式 ---------- */
@media (max-width: 1280px) {
  /* 单列堆叠：标题置于正上方居中，左右功能区居中排布 */
  .topbar { grid-template-columns: 1fr; justify-items: center; }
  .topbar-center { order: -1; justify-content: center; }
  .topbar-left { justify-content: center; }
  .topbar-right { justify-content: center; }
  .account-info { text-align: center; }
  .account-info .logout-link { text-align: center; }
  .main { grid-template-columns: 1fr; }
  .bottom-row { grid-template-columns: 1fr; }
  .event-panel { min-height: 0; }
}

@media (max-width: 768px) {
  .dashboard { padding: 10px 10px 24px; gap: 12px; }
  .topbar-left { gap: 16px; }
  .topbar-actions { justify-content: center; }
  .chart-container { height: 260px; }
  .chart-container.detail-chart { height: 240px; }
  .toolbar { padding: 10px 12px; }
  .panel-info-row { flex-direction: column; }
  .chart-info { justify-content: flex-start; }
}

@media (max-width: 480px) {
  .metric-cards { grid-template-columns: 1fr; }
  .chart-container { height: 220px; }
}
