/* ================================================================
   数据结构与算法可视化演示系统 - 样式表
   设计要点:
     - 配色:深色页面背景 + 浅色面板,卡片化布局
     - 区域分明:输入 / 步骤说明 / 可视化 三大面板
     - 关键节点用不同颜色标识,与图例保持一致
   ================================================================ */

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

body {
  font-family: "Segoe UI", "Microsoft YaHei", -apple-system, sans-serif;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #e2e8f0;
  min-height: 100vh;
  padding-bottom: 24px;
}

/* ====== 顶部标题 ====== */
.page-header {
  text-align: center;
  padding: 28px 16px 12px;
}
.page-header h1 {
  font-size: 26px;
  color: #f1f5f9;
  letter-spacing: 1px;
}
.subtitle {
  margin-top: 6px;
  color: #94a3b8;
  font-size: 13px;
}

/* ====== 主容器,网格布局 ====== */
.container {
  max-width: 1280px;
  margin: 18px auto;
  padding: 0 16px;
  display: grid;
  grid-template-columns: 320px 1fr;
  grid-template-areas:
    "input  viz"
    "desc   viz";
  gap: 16px;
}
.input-panel { grid-area: input; }
.desc-panel  { grid-area: desc; }
.viz-panel   { grid-area: viz; }

/* 在窄屏幕上改为单列布局 */
@media (max-width: 900px) {
  .container {
    grid-template-columns: 1fr;
    grid-template-areas: "input" "desc" "viz";
  }
}

/* ====== 面板基础样式 ====== */
.panel {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 18px 18px 16px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
.panel h2 {
  font-size: 16px;
  color: #38bdf8;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px dashed #334155;
}

/* ====== 表单行 ====== */
.form-row {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-row label {
  font-size: 13px;
  color: #94a3b8;
}
.form-row input[type="text"],
.form-row select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #475569;
  border-radius: 6px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.form-row input[type="text"]:focus,
.form-row select:focus { border-color: #38bdf8; }

.btn-row {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
}

/* ====== 按钮样式 ====== */
.btn {
  flex: 1;
  min-width: 70px;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  color: #fff;
  font-weight: 500;
  transition: transform 0.05s, opacity 0.2s, filter 0.2s;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn:not(:disabled):hover { filter: brightness(1.1); }
.btn:not(:disabled):active { transform: translateY(1px); }
.btn-primary { background: #2563eb; }
.btn-warn    { background: #d97706; }
.btn-info    { background: #0891b2; }
.btn-danger  { background: #b91c1c; }

/* ====== 速度调节 ====== */
.speed-row { flex-direction: row; align-items: center; gap: 10px; }
.speed-row input[type="range"] { flex: 1; }
#speedLabel {
  font-size: 12px;
  color: #94a3b8;
  width: 70px;
  text-align: right;
}

/* ====== 连接状态指示 ====== */
.conn-row {
  margin-top: 10px;
  font-size: 12px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 6px;
}
.conn-dot {
  width: 9px; height: 9px; border-radius: 50%;
  display: inline-block;
}
.conn-on  { background: #22c55e; box-shadow: 0 0 6px #22c55e; }
.conn-off { background: #ef4444; box-shadow: 0 0 6px #ef4444; }

/* ====== 步骤说明 ====== */
.progress-bar {
  height: 8px;
  background: #0f172a;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
  cursor: pointer;
  position: relative;
  transition: height 0.15s;
}
.progress-bar:hover {
  height: 12px;
}
.progress-inner {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #38bdf8, #2563eb);
  transition: width 0.2s;
}
.progress-text {
  font-size: 12px;
  color: #94a3b8;
  text-align: right;
  margin-bottom: 10px;
}
.step-desc {
  font-size: 14px;
  line-height: 1.6;
  color: #e2e8f0;
  background: #0f172a;
  border-left: 3px solid #38bdf8;
  padding: 10px 12px;
  border-radius: 4px;
  min-height: 60px;
}
.error-msg {
  margin-top: 10px;
  font-size: 13px;
  color: #f87171;
  min-height: 18px;
}

/* ====== 可视化 SVG 区域 ====== */
.viz-panel svg {
  width: 100%;
  height: auto;
  background: #0f172a;
  border-radius: 6px;
  border: 1px solid #334155;
}

/* SVG 内部节点的样式定义,JS 通过 className 切换 */
.node-circle, .node-rect {
  fill: #475569; stroke: #64748b; stroke-width: 2;
  transition: fill 0.3s, stroke 0.3s, transform 0.3s;
}
.node-active  { fill: #ef4444 !important; stroke: #fca5a5 !important; }
.node-compare { fill: #f59e0b !important; stroke: #fcd34d !important; }
.node-swap    { fill: #d946ef !important; stroke: #f0abfc !important; }
.node-settled { fill: #22c55e !important; stroke: #86efac !important; }
.node-pivot   { fill: #06b6d4 !important; stroke: #67e8f9 !important; }
.node-visited { fill: #16a34a !important; stroke: #86efac !important; }

/* ====== 快速排序柱状图 ====== */
.bar {
  stroke-width: 1.5;
  transition: fill 0.3s, stroke 0.3s, y 0.3s, height 0.3s;
}
.bar-default { fill: #60a5fa; stroke: #3b82f6; }   /* 蓝色:普通 */
.bar-active  { fill: #ef4444; stroke: #fca5a5; }   /* 红色:当前操作 */
.bar-compare { fill: #ef4444; stroke: #fca5a5; }   /* 红色:正在比较 */
.bar-swap    { fill: #a855f7; stroke: #d8b4fe; }   /* 紫色:发生交换 */
.bar-pivot   { fill: #06b6d4; stroke: #67e8f9; }   /* 青色:基准 pivot */
.bar-settled { fill: #22c55e; stroke: #86efac; }   /* 绿色:已就位 */

.bar-value-label {
  fill: #f1f5f9;
  font-size: 16px;
  font-weight: bold;
  pointer-events: none;
}

.node-text {
  fill: #fff;
  font-size: 16px;
  font-weight: bold;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}
.node-index-text {
  fill: #94a3b8;
  font-size: 11px;
  text-anchor: middle;
  dominant-baseline: central;
}
.tree-edge {
  stroke: #64748b;
  stroke-width: 1.5;
  fill: none;
}

/* ====== 图例 ====== */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
  font-size: 12px;
  color: #94a3b8;
  justify-content: center;
}
.legend .dot {
  display: inline-block;
  width: 11px; height: 11px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.dot-default { background: #475569; }
.dot-active  { background: #ef4444; }
.dot-compare { background: #f59e0b; }
.dot-swap    { background: #d946ef; }
.dot-settled { background: #22c55e; }

/* ====== 底部 ====== */
.page-footer {
  text-align: center;
  margin-top: 20px;
  color: #64748b;
  font-size: 12px;
}
