/* =========================================================
   传送带与长木板动力学模型 仿真与过程图交互系统
   现代科技实验室视觉风格与响应式排版
   ========================================================= */

:root {
  --bg-main: #0b0f19;
  --bg-card: rgba(15, 23, 42, 0.85);
  --bg-card-hover: rgba(30, 41, 59, 0.9);
  --border-color: rgba(51, 65, 85, 0.7);
  --border-highlight: #38bdf8;

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

  --color-slider: #38bdf8;
  --color-board: #f59e0b;
  --color-belt: #0284c7;
  --color-success: #10b981;
  --color-danger: #ef4444;
  --color-purple: #a855f7;

  --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Fira Code", Menlo, Monaco, Consolas, monospace;
}

body.light-theme {
  --bg-main: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: #ffffff;
  --border-color: #cbd5e1;
  --border-highlight: #0284c7;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* 顶部导航栏 */
.app-header {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 0.75rem 0;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.header-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  background: rgba(56, 189, 248, 0.15);
  color: var(--color-slider);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.header-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header-subtitle {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.btn-pill {
  background: rgba(30, 41, 59, 0.6);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 0.45rem 0.9rem;
  border-radius: 9999px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
}

.btn-pill:hover {
  background: rgba(51, 65, 85, 0.8);
  border-color: var(--border-highlight);
}

.btn-pill.muted {
  opacity: 0.6;
}

/* 主工作区布局 */
.main-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  padding: 1.25rem 0;
  flex: 1;
}

/* 模式选择与分段导航 */
.mode-switch-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.mode-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.mode-title {
  font-size: 1.05rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mode-segmented-tabs {
  display: flex;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 3px;
  gap: 4px;
}

.mode-tab-btn {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 0.45rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-tab-btn:hover {
  color: var(--text-primary);
}

.mode-tab-btn.active {
  background: var(--border-highlight);
  color: #0f172a;
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.3);
}

/* 4 个阶段卡片网格 */
.stage-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.65rem;
}

.stage-card {
  background: rgba(30, 41, 59, 0.4);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.stage-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(56, 189, 248, 0.5);
  transform: translateY(-2px);
}

.stage-card.active {
  border-color: var(--border-highlight);
  background: rgba(56, 189, 248, 0.12);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.2);
}

.stage-card.active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--border-highlight);
}

.stage-card-time {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-slider);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stage-card-title {
  font-size: 0.92rem;
  font-weight: 600;
  margin: 0.25rem 0 0.2rem 0;
}

.stage-card-desc {
  font-size: 0.76rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

/* 分段专属播放控制条 */
.segmented-controls-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--border-color);
  flex-wrap: wrap;
}

.btn-stage-action {
  background: rgba(56, 189, 248, 0.15);
  color: var(--color-slider);
  border: 1px solid rgba(56, 189, 248, 0.4);
  padding: 0.45rem 1.2rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-stage-action:hover {
  background: var(--border-highlight);
  color: #0f172a;
}

.btn-stage-action.playing {
  background: var(--color-board);
  color: #0f172a;
  border-color: var(--color-board);
}

/* 当前阶段提醒横幅 */
.stage-alert-banner {
  margin-top: 0.75rem;
  background: rgba(15, 23, 42, 0.6);
  border-left: 4px solid var(--border-highlight);
  padding: 0.6rem 0.9rem;
  border-radius: 4px;
}

.stage-alert-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-slider);
  margin-bottom: 0.15rem;
}

.stage-alert-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* 核心仿真画布工作区 */
.sim-grid {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 1024px) {
  .sim-grid {
    grid-template-columns: 1fr;
  }
}

.canvas-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.canvas-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.panel-title {
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.panel-toggles {
  display: flex;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  user-select: none;
}

.canvas-container {
  width: 100%;
  position: relative;
  background: #0f172a;
  border: 1px solid rgba(51, 65, 85, 0.5);
  border-radius: 8px;
  overflow: hidden;
}

.canvas-main {
  width: 100%;
  height: 380px;
  display: block;
}

.canvas-fbd {
  width: 100%;
  height: 185px;
  display: block;
}

.canvas-vt {
  width: 100%;
  height: 185px;
  display: block;
}

/* 控制栏 (播放、进度条、速度) */
.playback-bar {
  margin-top: 0.85rem;
  background: rgba(30, 41, 59, 0.5);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.timeline-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.time-slider {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  background: #334155;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.time-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--border-highlight);
  cursor: pointer;
  box-shadow: 0 0 6px var(--border-highlight);
  transition: transform 0.1s;
}

.time-slider::-webkit-slider-thumb:hover {
  transform: scale(1.25);
}

.time-display {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--color-slider);
  min-width: 110px;
  text-align: right;
  font-weight: 600;
}

.controls-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn-group {
  display: flex;
  gap: 0.35rem;
}

.btn-ctrl {
  background: rgba(30, 41, 59, 0.8);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.btn-ctrl:hover {
  background: #334155;
  border-color: var(--border-highlight);
}

.btn-ctrl.btn-primary {
  background: var(--border-highlight);
  color: #0f172a;
  border-color: var(--border-highlight);
}

.btn-ctrl.btn-primary.playing {
  background: var(--color-board);
  border-color: var(--color-board);
}

.speed-selector {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.speed-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-right: 0.2rem;
}

.btn-speed {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-speed.active {
  background: var(--border-highlight);
  color: #0f172a;
  border-color: var(--border-highlight);
  font-weight: 600;
}

/* 仪表盘数据表格 */
.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.6rem;
  margin-top: 0.85rem;
}

.tel-cell {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.45rem 0.65rem;
}

.tel-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  display: block;
}

.tel-value {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
}

.tel-value.accent-blue {
  color: var(--color-slider);
}

.tel-value.accent-orange {
  color: var(--color-board);
}

/* 题目卡片与公式推导 */
.details-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 900px) {
  .details-section {
    grid-template-columns: 1fr;
  }
}

.info-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.problem-statement {
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--text-secondary);
  background: rgba(15, 23, 42, 0.4);
  padding: 0.85rem;
  border-radius: 8px;
  margin-bottom: 0.85rem;
}

.solution-step {
  margin-bottom: 1rem;
  background: rgba(30, 41, 59, 0.3);
  border-radius: 8px;
  padding: 0.85rem;
  border-left: 3px solid var(--border-highlight);
}

.solution-step h4 {
  font-size: 0.92rem;
  color: var(--color-slider);
  margin-bottom: 0.4rem;
}

.solution-step p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.solution-formula {
  font-family: var(--font-mono);
  background: rgba(15, 23, 42, 0.7);
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  margin: 0.4rem 0;
  font-size: 0.84rem;
  color: #e2e8f0;
}

.answer-pill {
  display: inline-block;
  padding: 0.3rem 0.8rem;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid var(--color-success);
  color: var(--color-success);
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.95rem;
  margin-top: 0.3rem;
}

/* 探究沙盘 */
.sandbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.sandbox-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sandbox-field label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.sandbox-input {
  background: #1e293b;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.sandbox-input:focus {
  outline: none;
  border-color: var(--border-highlight);
}

/* 时间轴阶段指示条与选项 */
.timeline-stages-bar {
  display: flex;
  gap: 4px;
  margin-top: -0.2rem;
  margin-bottom: 0.2rem;
  padding: 0 2px;
}

.timeline-stage-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 0.72rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.timeline-stage-marker:hover {
  background: rgba(30, 41, 59, 0.9);
  border-color: var(--border-highlight);
  color: #ffffff;
}

.timeline-stage-marker.active {
  background: rgba(37, 99, 235, 0.25);
  border-color: var(--color-slider);
  color: #93c5fd;
  font-weight: 700;
  box-shadow: 0 0 8px rgba(37, 99, 235, 0.3);
}

.ts-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.playback-options {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.toggle-option {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  user-select: none;
}

.toggle-option input[type="checkbox"] {
  accent-color: var(--border-highlight);
  cursor: pointer;
}

/* 过程图全景对照看板 */
.process-matrix-section {
  margin-top: 1.5rem;
}

.process-matrix-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}

.card-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.badge-stage {
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(37, 99, 235, 0.2);
  color: #93c5fd;
  border: 1px solid rgba(147, 197, 253, 0.3);
  padding: 3px 10px;
  border-radius: 9999px;
}

.process-matrix-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

.matrix-stage-card {
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.25s;
  position: relative;
}

.matrix-stage-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-highlight);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.matrix-stage-card.active-matrix {
  border-color: var(--border-highlight);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.35);
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.7) 0%, rgba(15, 23, 42, 0.95) 100%);
}

.matrix-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.matrix-badge {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 4px;
}

.stage-1-badge { background: rgba(56, 189, 248, 0.2); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.4); }
.stage-2-badge { background: rgba(6, 182, 212, 0.2); color: #06b6d4; border: 1px solid rgba(6, 182, 212, 0.4); }
.stage-3-badge { background: rgba(245, 158, 11, 0.2); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.4); }
.stage-4-badge { background: rgba(16, 185, 129, 0.2); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.4); }

.matrix-state-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

.matrix-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.matrix-svg-box {
  background: #1e293b;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px;
  margin-bottom: 0.75rem;
}

.matrix-svg {
  width: 100%;
  height: 90px;
  display: block;
}

.matrix-body {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.78rem;
  margin-bottom: 0.85rem;
  flex: 1;
}

.matrix-row {
  display: flex;
  flex-direction: column;
  line-height: 1.4;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.06);
  padding-bottom: 0.3rem;
}

.m-label {
  color: var(--text-muted);
  font-size: 0.72rem;
}

.m-val {
  color: var(--text-primary);
  font-family: var(--font-sans);
}

.highlight-row {
  background: rgba(30, 41, 59, 0.4);
  padding: 0.35rem 0.4rem;
  border-radius: 4px;
  border-bottom: none;
}

.btn-jump-stage {
  width: 100%;
  padding: 0.5rem 0.6rem;
  background: rgba(37, 99, 235, 0.15);
  border: 1px solid rgba(37, 99, 235, 0.4);
  color: #93c5fd;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-jump-stage:hover {
  background: var(--color-slider);
  color: #ffffff;
  border-color: var(--color-slider);
}

.matrix-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.btn-jump-stage-seg {
  flex: 1;
  background: rgba(56, 189, 248, 0.12);
  color: var(--color-slider);
  border: 1px solid rgba(56, 189, 248, 0.35);
  padding: 0.42rem 0.4rem;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  white-space: nowrap;
}

.btn-jump-stage-seg:hover {
  background: var(--border-highlight);
  color: #0f172a;
}

.btn-jump-stage-cont {
  flex: 1;
  background: rgba(245, 158, 11, 0.12);
  color: var(--color-board);
  border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 0.42rem 0.4rem;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  white-space: nowrap;
}

.btn-jump-stage-cont:hover {
  background: var(--color-board);
  color: #0f172a;
}

/* 浅色主题适配 */
body.light-theme .matrix-stage-card {
  background: #ffffff;
  border-color: #e2e8f0;
}
body.light-theme .matrix-stage-card.active-matrix {
  background: #f0f9ff;
  border-color: #0284c7;
  box-shadow: 0 0 16px rgba(2, 132, 199, 0.2);
}
body.light-theme .matrix-svg-box {
  background: #f8fafc;
  border-color: #e2e8f0;
}
body.light-theme .timeline-stage-marker {
  background: #e2e8f0;
  color: #334155;
  border-color: #cbd5e1;
}
body.light-theme .timeline-stage-marker.active {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #2563eb;
}
body.light-theme .highlight-row {
  background: rgba(2, 132, 199, 0.08);
}

/* 页脚 */
.app-footer {
  text-align: center;
  padding: 1.5rem 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  margin-top: 2rem;
}
