/**
 * MCU 时间线可视化系统 - 主样式
 *
 * 设计风格：Jarvis HUD 科技感 + 深色主题
 * 布局：App式布局，不滚动
 */

/* ========== 全局重置 ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #0a0a1a;
  color: #e0e0e0;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ========== 顶部工具栏 ========== */
.toolbar {
  flex-shrink: 0;
  height: 56px;
  background: linear-gradient(180deg, #12122a 0%, #0e0e22 100%);
  border-bottom: 1px solid #1e1e3e;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: relative;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

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

.toolbar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
}

.toolbar-title {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.title-main {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.5px;
}

.title-sub {
  font-size: 11px;
  color: #666;
  margin-top: 1px;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #2a2a4a;
  background: #1a1a3a;
  color: #aaa;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.toolbar-btn:hover {
  background: #25254a;
  color: #fff;
  border-color: #3a3a6a;
}

.toolbar-btn:active {
  transform: scale(0.95);
}

.toolbar-zoom-label {
  min-width: 48px;
  text-align: center;
  font-size: 12px;
  color: #888;
  font-variant-numeric: tabular-nums;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: #2a2a4a;
  margin: 0 4px;
}

/* ========== 图例面板 ========== */
.legend-panel {
  position: absolute;
  top: 64px;
  right: 16px;
  background: #151530;
  border: 1px solid #2a2a4a;
  border-radius: 12px;
  padding: 16px;
  min-width: 180px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.2s ease;
  z-index: 200;
}

.legend-panel.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.legend-title {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 13px;
  color: #ccc;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-dot.legend-event {
  background: #E23636;
  box-shadow: 0 0 8px rgba(226, 54, 54, 0.5);
}

.legend-dot.legend-character {
  background: #518CCA;
  box-shadow: 0 0 8px rgba(81, 140, 202, 0.5);
}

.legend-dot.legend-organization {
  background: #F7C93A;
  box-shadow: 0 0 8px rgba(247, 201, 58, 0.5);
}

.legend-divider {
  height: 1px;
  background: #2a2a4a;
  margin: 12px 0;
}

.legend-tip {
  font-size: 12px;
  color: #888;
  line-height: 1.8;
}

/* ========== 画布区域 ========== */
.canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 50%, #0f0f2a 0%, #0a0a1a 70%);
}

.canvas-container svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* 节点悬停效果 */
.node:hover .node-circle {
  stroke-width: 3;
}

.node.selected .node-circle {
  stroke-width: 3;
}

.node-label {
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.edge-path {
  transition: stroke 0.2s ease;
}

/* ========== 详情面板 ========== */
.detail-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 500;
}

.detail-overlay.active {
  opacity: 1;
  visibility: visible;
}

.detail-panel {
  position: fixed;
  background: #12122a;
  border: 1px solid #2a2a4a;
  z-index: 600;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

/* 桌面端：右侧侧边栏 */
@media (min-width: 768px) {
  .detail-panel {
    top: 0;
    right: 0;
    width: 360px;
    height: 100%;
    transform: translateX(100%);
    border-left: 1px solid #2a2a4a;
    border-radius: 0;
  }

  .detail-panel.active {
    transform: translateX(0);
  }

  .detail-handle {
    display: none;
  }

  .detail-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
  }
}

/* 移动端：底部抽屉 */
@media (max-width: 767px) {
  .detail-panel {
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 75vh;
    transform: translateY(100%);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    border-top: 1px solid #2a2a4a;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.5);
  }

  .detail-panel.active {
    transform: translateY(0);
  }

  .detail-close-btn {
    display: none;
  }
}

.detail-handle {
  flex-shrink: 0;
  padding: 12px 0 8px;
  display: flex;
  justify-content: center;
  cursor: grab;
}

.handle-bar {
  width: 36px;
  height: 4px;
  background: #3a3a5a;
  border-radius: 2px;
}

.detail-header {
  flex-shrink: 0;
  padding: 16px 20px;
  border-bottom: 1px solid #1e1e3e;
  position: relative;
}

.detail-close-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: #1a1a3a;
  color: #888;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.detail-close-btn:hover {
  background: #25254a;
  color: #fff;
}

.detail-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  -webkit-overflow-scrolling: touch;
}

/* 节点头部 */
.detail-node-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.detail-node-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.detail-node-title-group {
  flex: 1;
  min-width: 0;
}

.detail-node-title {
  font-size: 20px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}

.detail-node-type {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* 元信息 */
.detail-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #1e1e3e;
}

.detail-meta-label {
  font-size: 13px;
  color: #666;
}

.detail-meta-value {
  font-size: 13px;
  color: #ddd;
  font-weight: 500;
}

/* 区块 */
.detail-section {
  margin-top: 20px;
}

.detail-section-title {
  font-size: 13px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.detail-description {
  font-size: 14px;
  line-height: 1.7;
  color: #bbb;
}

/* 标签 */
.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-tag {
  padding: 6px 12px;
  background: #1a1a3a;
  border: 1px solid #2a2a4a;
  border-radius: 16px;
  font-size: 12px;
  color: #aaa;
}

/* 关联节点 */
.detail-connections {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-connection-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #151530;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.detail-connection-item:hover {
  background: #1e1e40;
}

.detail-connection-item:active {
  transform: scale(0.98);
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #518CCA;
  flex-shrink: 0;
}

.connection-name {
  font-size: 14px;
  color: #ccc;
  flex: 1;
}

/* ========== 加载/提示 ========== */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a1a;
  z-index: 1000;
}

.loading-text {
  font-size: 14px;
  color: #666;
}

/* ========== 响应式调整 ========== */
@media (max-width: 480px) {
  .toolbar {
    height: 52px;
    padding: 0 12px;
  }

  .title-sub {
    display: none;
  }

  .toolbar-zoom-label {
    display: none;
  }

  .detail-node-title {
    font-size: 18px;
  }
}

/* ========== 滚动条样式 ========== */
.detail-content::-webkit-scrollbar {
  width: 4px;
}

.detail-content::-webkit-scrollbar-track {
  background: transparent;
}

.detail-content::-webkit-scrollbar-thumb {
  background: #2a2a4a;
  border-radius: 2px;
}

/* ========== 网格背景动画 ========== */
.canvas-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image:
    linear-gradient(rgba(30, 30, 60, 0.3) 1px, transparent 1px),
    linear-gradient(90deg, rgba(30, 30, 60, 0.3) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  opacity: 0.5;
}
