/* ============================================
   GLV 动力学向量场雕刻演示 - 样式表
   ============================================ */

:root {
  /* Color Palette */
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-panel: rgba(17, 24, 39, 0.85);
  --bg-panel-hover: rgba(30, 41, 59, 0.9);
  --border-color: rgba(99, 102, 241, 0.2);
  --border-active: rgba(99, 102, 241, 0.6);

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

  --accent-blue: #00e5ff;
  --accent-orange: #ff6e40;
  --accent-yellow: #eeff41;
  --accent-purple: #e040fb;
  --accent-green: #69f0ae;
  --accent-indigo: #6366f1;

  /* Gradients */
  --gradient-header: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
  --gradient-btn: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);

  /* Typography */
  --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Spacing */
  --panel-padding: 16px;
  --border-radius: 12px;
  --border-radius-sm: 8px;
}

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

body {
  font-family: var(--font-primary);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

#app {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 280px;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "header header"
    "canvas panel"
    "controls controls";
}

/* ============================================
   Header
   ============================================ */

#header {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-panel);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  z-index: 10;
}

.header-left h1 {
  font-size: 1.15rem;
  font-weight: 700;
  background: var(--gradient-header);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.05em;
}

.mode-switcher {
  display: flex;
  gap: 4px;
  background: rgba(15, 23, 42, 0.6);
  padding: 4px;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--border-radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-primary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

.mode-btn:hover {
  color: var(--text-primary);
  background: rgba(99, 102, 241, 0.1);
}

.mode-btn.active {
  color: white;
  background: var(--gradient-btn);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

.mode-icon {
  font-size: 1rem;
}

/* ============================================
   Canvas
   ============================================ */

#canvas-container {
  grid-area: canvas;
  position: relative;
  background: radial-gradient(ellipse at center, #0f172a 0%, #0a0e17 70%);
  overflow: hidden;
}

#main-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.axis-label {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  pointer-events: none;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.8);
  font-weight: 500;
}

.axis-x { bottom: 20px; right: 48%; color: #ef4444; }
.axis-y { left: 48%; top: 20px; color: #22c55e; }
.axis-z { bottom: 20px; left: 20px; color: #3b82f6; }

/* ============================================
   Info Panel
   ============================================ */

#info-panel {
  grid-area: panel;
  padding: var(--panel-padding);
  background: var(--bg-panel);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--border-color);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 5;
}

#info-panel::-webkit-scrollbar {
  width: 4px;
}

#info-panel::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

.panel-section {
  padding: 14px;
  background: rgba(15, 23, 42, 0.5);
  border-radius: var(--border-radius-sm);
  border: 1px solid rgba(99, 102, 241, 0.1);
}

.panel-section h3 {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}

/* State Bars */
.state-display {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.state-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.state-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  width: 20px;
  flex-shrink: 0;
}

.state-bar-container {
  flex: 1;
  height: 6px;
  background: rgba(30, 41, 59, 0.8);
  border-radius: 3px;
  overflow: hidden;
}

.state-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.05s linear;
  background: var(--accent-blue);
}

.state-row:nth-child(1) .state-bar { background: linear-gradient(90deg, #ef4444, #f97316); }
.state-row:nth-child(2) .state-bar { background: linear-gradient(90deg, #22c55e, #34d399); }
.state-row:nth-child(3) .state-bar { background: linear-gradient(90deg, #3b82f6, #6366f1); }

.state-value {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-primary);
  width: 40px;
  text-align: right;
  flex-shrink: 0;
}

/* Matrix Display */
.matrix-display table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 3px;
}

.matrix-display td {
  text-align: center;
  padding: 6px 4px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 4px;
  color: var(--text-secondary);
  transition: color 0.15s, background 0.15s;
}

.matrix-display td.positive {
  color: var(--accent-green);
  background: rgba(105, 240, 174, 0.08);
}

.matrix-display td.negative {
  color: #f87171;
  background: rgba(248, 113, 113, 0.08);
}

/* Input Display */
.input-display {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.input-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.input-value {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.6);
  min-width: 50px;
  text-align: center;
}

.input-value.active {
  color: var(--accent-orange);
  background: rgba(255, 110, 64, 0.1);
  box-shadow: 0 0 8px rgba(255, 110, 64, 0.2);
}

/* Description */
.description {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ============================================
   Control Panel
   ============================================ */

#control-panel {
  grid-area: controls;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  background: var(--bg-panel);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-color);
  z-index: 10;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-group label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  font-weight: 500;
}

.control-group input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100px;
  height: 4px;
  background: rgba(30, 41, 59, 0.8);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.control-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-indigo);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.5);
  transition: transform 0.2s;
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.control-group span {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-primary);
  min-width: 32px;
}

.buttons-group {
  margin-left: auto;
  gap: 8px;
}

.ctrl-btn {
  padding: 8px 20px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-primary);
  font-family: var(--font-primary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
}

.ctrl-btn:hover {
  border-color: var(--border-active);
  background: rgba(99, 102, 241, 0.1);
}

.ctrl-btn.primary {
  background: var(--gradient-btn);
  border-color: transparent;
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.25);
}

.ctrl-btn.primary:hover {
  box-shadow: 0 0 24px rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
}

.ctrl-btn.primary.running {
  background: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.3);
}

/* ============================================
   Legend
   ============================================ */

#legend {
  position: fixed;
  bottom: 70px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 16px;
  background: var(--bg-panel);
  backdrop-filter: blur(20px);
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-color);
  z-index: 10;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.legend-color {
  width: 12px;
  height: 3px;
  border-radius: 1.5px;
  flex-shrink: 0;
}

/* ============================================
   Animations & Effects
   ============================================ */

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 8px rgba(99, 102, 241, 0.15); }
  50% { box-shadow: 0 0 20px rgba(99, 102, 241, 0.3); }
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-section {
  animation: fade-in 0.4s ease backwards;
}

.panel-section:nth-child(1) { animation-delay: 0.1s; }
.panel-section:nth-child(2) { animation-delay: 0.2s; }
.panel-section:nth-child(3) { animation-delay: 0.3s; }
.panel-section:nth-child(4) { animation-delay: 0.4s; }

/* Phase indicator for trajectory mode */
.phase-indicator {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.phase-x1 { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.phase-x2 { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.phase-x3 { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }

/* Editable Matrix */
.matrix-display table td.editable {
  cursor: text;
  background: rgba(99, 102, 241, 0.1);
  transition: all 0.2s;
}

.matrix-display table td.editable:hover {
  background: rgba(99, 102, 241, 0.2);
}

.matrix-display table td.editable:focus {
  outline: none;
  background: rgba(99, 102, 241, 0.3);
  box-shadow: inset 0 0 0 1px var(--accent-indigo);
}

/* Plane Toggle & Inputs */
.toggle-switch {
  display: flex;
  align-items: center;
  gap: 4px;
}
.toggle-switch input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--accent-indigo);
}
.toggle-switch label {
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--text-primary);
}
.plane-inputs {
  display: flex;
  gap: 4px;
}
.plane-inputs.hidden {
  display: none;
}
.mini-input {
  width: 36px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 4px;
  padding: 2px 4px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-align: center;
}
.mini-input:focus {
  outline: none;
  border-color: var(--accent-indigo);
}
