/* css/style.css */
:root {
  --bg: #f5f5f5;
  --card-bg: #ffffff;
  --text: #212121;
  --text-secondary: #616161;
  --border: #e0e0e0;
  --pos-green: #e8f5e9;
  --pos-green-dark: #2e7d32;
  --neg-red: #ffebee;
  --neg-red-dark: #c62828;
  --wall-color: #424242;
  --robot-color: #1565c0;
  --collected-bg: #e0e0e0;
  --visible-glow: rgba(25, 118, 210, 0.3);
  --hidden-overlay: rgba(0, 0, 0, 0.5);
  --shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
  --radius: 4px;
  --font-mono: 'Consolas', 'Monaco', 'Courier New', monospace;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px;
  gap: 12px;
}

/* 顶部状态栏 */
.top-bar {
  display: flex;
  gap: 24px;
  align-items: center;
  background: var(--card-bg);
  padding: 10px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 14px;
  flex-shrink: 0;
}
.top-bar .stat { display: flex; gap: 6px; align-items: center; }
.top-bar .stat-label { color: var(--text-secondary); }
.top-bar .stat-value { font-weight: 600; font-family: var(--font-mono); }

/* 主体三栏 */
.main-content {
  display: flex;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

/* 左侧图例 */
.legend-panel {
  width: 120px;
  flex-shrink: 0;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-swatch { width: 16px; height: 16px; border-radius: 2px; flex-shrink: 0; }
.legend-swatch.pos { background: var(--pos-green); border: 1px solid var(--pos-green-dark); }
.legend-swatch.neg { background: var(--neg-red); border: 1px solid var(--neg-red-dark); }
.legend-swatch.wall { background: var(--wall-color); }
.legend-swatch.robot { background: var(--robot-color); border-radius: 50%; }
.legend-swatch.collected { background: var(--collected-bg); border: 1px dashed #999; }
.legend-swatch.hidden { background: var(--collected-bg); border: 1px dashed #999; }

/* 中间网格区域 */
.grid-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto;
}

.grid-container {
  display: grid;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}

.cell {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 600;
  cursor: default;
  position: relative;
  transition: background 0.2s;
  user-select: none;
}
.cell.wall { background: var(--wall-color); }
.cell.pos { background: var(--pos-green); color: var(--pos-green-dark); }
.cell.neg { background: var(--neg-red); color: var(--neg-red-dark); }
.cell.collected { background: var(--collected-bg); }
.cell.collected span { text-decoration: line-through; color: #999; }
.cell.hidden { background: var(--collected-bg); }
.cell.hidden span { display: none; }
.cell.visible { box-shadow: inset 0 0 0 2px var(--visible-glow); }
.cell.robot { box-shadow: inset 0 0 0 3px var(--robot-color); }
.cell.robot::after {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  background: var(--robot-color);
  border-radius: 50%;
}

/* 右侧面板区 */
.right-panels {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.panel {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
}
.panel-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

/* 控件 */
.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 13px;
}
.form-row label { color: var(--text-secondary); flex-shrink: 0; }
.form-row input[type="number"] {
  width: 64px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 13px;
  text-align: right;
}
.form-row select {
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  min-width: 80px;
}
input[type="range"] { width: 100px; }

/* Focus indicators */
:focus-visible {
  outline: 2px solid var(--robot-color);
  outline-offset: 2px;
}

/* Utility classes */
.form-row-inner { display: flex; gap: 4px; }
.form-row-inner input[type="number"] { width: 52px; }
.stat-label-sm { font-size: 11px; width: 40px; }
.stat-label-sm.w30 { width: 30px; }
.input-wide { width: 180px; }
.mt-4 { margin-top: 4px; }
.mt-6 { margin-top: 6px; }
.func-status { margin-top: 6px; font-size: 12px; color: var(--text-secondary); }

.btn {
  padding: 6px 12px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s;
}
.btn-primary { background: var(--robot-color); color: #fff; }
.btn-primary:hover { background: #0d47a1; }
.btn-primary:disabled { background: #90caf9; cursor: not-allowed; }
.btn-secondary { background: #e0e0e0; color: var(--text); }
.btn-secondary:hover { background: #bdbdbd; }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-danger { background: #c62828; color: #fff; }
.btn-danger:hover { background: #8e0000; }
.btn-danger:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 3px 8px; font-size: 12px; }

.btn-row { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

/* 底部日志区 */
.bottom-area {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
  height: 200px;
}
.bottom-panel {
  flex: 1;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.bottom-panel .panel-title {
  margin: 0;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
  flex-shrink: 0;
}
.log-panel {
  flex: 1;
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 8px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
}
.thought-panel {
  background: #1a1a2e;
  color: #c9d1d9;
}
.log-entry.thought.function-mode {
  color: #f0a060;
  font-style: italic;
}
.log-entry { margin-bottom: 2px; }
.log-entry.step { color: #569cd6; }
.log-entry.thought { color: #6a9955; }
.log-entry.action { color: #dcdcaa; }
.log-entry.error { color: #f44747; }
.log-entry.info { color: #9cdcfe; }
.log-entry.system { color: #ce9178; }

/* 流式输出文本 */
.streaming-text {
  color: #c9d1d9;
  white-space: pre-wrap;
  word-break: break-word;
}
.streaming-text::after {
  content: '▋';
  animation: blink 1s step-end infinite;
  color: var(--robot-color);
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* 轨迹箭头 */
.trajectory-arrow {
  position: absolute;
  pointer-events: none;
  z-index: 10;
  opacity: 0.7;
}
.trajectory-arrow line {
  stroke: var(--robot-color);
  stroke-width: 2.5;
  stroke-linecap: round;
}

/* 状态栏指示器 */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}
.status-dot.idle { background: #9e9e9e; }
.status-dot.running { background: #4caf50; }
@media (prefers-reduced-motion: no-preference) {
  .status-dot.running { animation: pulse 1s infinite; }
}
.status-dot.paused { background: #ff9800; }
.status-dot.finished { background: #1565c0; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* 高效提示 */
.efficiency-bar {
  height: 4px;
  border-radius: 2px;
  background: #e0e0e0;
  margin-top: 4px;
  overflow: hidden;
}
.efficiency-bar-fill {
  height: 100%;
  background: var(--pos-green-dark);
  transition: width 0.3s;
}

/* 响应式 */
@media (max-width: 900px) {
  .main-content { flex-direction: column; }
  .legend-panel { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .right-panels { width: 100%; }
  .bottom-area { flex-direction: column; height: auto; }
}
