/* Circuit Designer Enhanced Styles */

.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

@media (max-width: 768px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}

/* 元件搜索 */
.component-search {
  margin-bottom: 16px;
}

.search-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #dee2e6;
  border-radius: 8px;
  font-size: 14px;
  background: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(248,249,250,0.9));
  transition: all 0.3s ease;
}

.search-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  background: #ffffff;
}

.search-input::placeholder {
  color: #6c757d;
  font-style: italic;
}

/* 元件库样式 */
.component-categories {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.category-tab {
  padding: 8px 16px;
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.category-tab::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  transition: left 0.5s ease;
}

.category-tab:hover {
  background: linear-gradient(135deg, #e9ecef, #dee2e6);
  border-color: #667eea;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.category-tab:hover::before {
  left: 100%;
}

.category-tab.active {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border-color: #667eea;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.components-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
  padding: 16px;
  background: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(248,249,250,0.9));
  border-radius: 12px;
  border: 1px solid #dee2e6;
}

.component-item {
  background: linear-gradient(135deg, rgba(255,255,255,0.95), rgba(248,249,250,0.95));
  border: 2px solid #dee2e6;
  border-radius: 12px;
  padding: 16px 12px;
  cursor: grab;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  text-align: center;
  position: relative;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  overflow: hidden;
}

.component-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, transparent, rgba(102, 126, 234, 0.1));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.component-item:hover {
  border-color: #667eea;
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.component-item:hover::before {
  opacity: 1;
}

.component-item:active {
  cursor: grabbing;
  transform: translateY(-2px) scale(0.98);
}

.component-item.dragging {
  opacity: 0.8;
  transform: rotate(5deg) scale(1.1);
  z-index: 1000;
  box-shadow: 0 12px 30px rgba(0,0,0,0.3);
}

.component-icon {
  font-size: 32px;
  margin-bottom: 8px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
  transition: all 0.3s ease;
}

.component-item:hover .component-icon {
  transform: scale(1.1);
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
}

.component-name {
  font-size: 12px;
  color: #2c3e50;
  font-weight: 600;
  margin-bottom: 4px;
  line-height: 1.2;
}

.component-value {
  font-size: 10px;
  color: #6c757d;
  font-family: 'Courier New', monospace;
  font-weight: 500;
  margin-bottom: 4px;
}

.component-description {
  font-size: 9px;
  color: #8e9aaf;
  line-height: 1.2;
  max-height: 24px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 元件提示框 */
.component-tooltip {
  position: fixed;
  background: linear-gradient(135deg, rgba(255,255,255,0.98), rgba(248,249,250,0.98));
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 12px;
  font-size: 12px;
  min-width: 200px;
  max-width: 300px;
  z-index: 10000;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
  backdrop-filter: blur(10px);
}

.component-tooltip.show {
  opacity: 1;
  transform: translateY(0);
}

.tooltip-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #dee2e6;
}

.tooltip-icon {
  font-size: 18px;
}

.tooltip-title {
  font-weight: 600;
  color: #2c3e50;
}

.tooltip-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tooltip-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tooltip-label {
  color: #6c757d;
  font-weight: 500;
}

.tooltip-value {
  font-family: 'Courier New', monospace;
  color: #2c3e50;
  font-weight: 600;
}

.tooltip-description {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #dee2e6;
  color: #495057;
  line-height: 1.4;
  font-style: italic;
}

/* 空状态样式 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #6c757d;
  font-size: 14px;
  min-height: 120px;
  grid-column: 1 / -1;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* 仿真控制面板 */
.simulation-controls {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px;
  background: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(248,249,250,0.9));
  border-radius: 12px;
  border: 1px solid #dee2e6;
}

.control-group {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.btn-large {
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  border: 2px solid transparent;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.btn-large::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s ease;
}

.btn-large:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-large:hover::before {
  left: 100%;
}

.btn-large:active {
  transform: translateY(0);
}

/* 画布容器 */
.canvas-container {
  position: relative;
  background: linear-gradient(135deg, #ffffff, #f8f9fa);
  border: 2px solid #dee2e6;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.1);
}

.canvas-container.drag-over {
  border-color: #28a745;
  background: linear-gradient(135deg, rgba(40, 167, 69, 0.05), rgba(40, 167, 69, 0.1));
  box-shadow: inset 0 0 30px rgba(40, 167, 69, 0.2);
}

#circuitCanvas {
  display: block;
  width: 100%;
  height: 600px;
  background: 
    radial-gradient(circle at 20px 20px, #e9ecef 1px, transparent 1px),
    linear-gradient(to right, #f1f3f4 1px, transparent 1px),
    linear-gradient(to bottom, #f1f3f4 1px, transparent 1px);
  background-size: 20px 20px, 20px 20px, 20px 20px;
  cursor: crosshair;
  max-width: 1000px;
}

/* 测量仪表 */
.instruments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.instrument {
  background: linear-gradient(135deg, rgba(255,255,255,0.95), rgba(248,249,250,0.95));
  border: 2px solid #dee2e6;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transition: all 0.3s ease;
}

.instrument:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.meter-face {
  position: relative;
  width: 90px;
  height: 90px;
  margin: 0 auto 12px;
  background: radial-gradient(circle, #f8f9fa, #e9ecef);
  border: 3px solid #2c3e50;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.1);
}

.meter-scale {
  position: absolute;
  width: 80px;
  height: 80px;
  border: 1px solid #6c757d;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #dc3545 0deg 60deg, #ffc107 60deg 120deg, #28a745 120deg 180deg);
  opacity: 0.4;
}

.meter-needle {
  position: absolute;
  width: 3px;
  height: 35px;
  background: linear-gradient(to top, #dc3545, #ff6b6b);
  transform-origin: bottom center;
  transform: rotate(-90deg);
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  border-radius: 2px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.meter-value {
  position: absolute;
  bottom: 15px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  color: #2c3e50;
  background: rgba(255,255,255,0.95);
  padding: 3px 6px;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* 示波器 */
.oscilloscope .scope-screen {
  position: relative;
  width: 140px;
  height: 90px;
  margin: 0 auto 12px;
  background: #000;
  border: 3px solid #2c3e50;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.5);
}

#oscilloscopeCanvas {
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #001100, #000800);
}

.scope-grid {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    linear-gradient(rgba(0,255,0,0.3) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,255,0,0.3) 1px, transparent 1px);
  background-size: 10px 10px;
  pointer-events: none;
}

/* 统计数据 */
.simulation-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(248,249,250,0.9));
  border: 1px solid #dee2e6;
  border-radius: 8px;
  font-size: 13px;
  transition: all 0.3s ease;
}

.stat-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.stat-label {
  color: #6c757d;
  font-weight: 600;
}

.stat-value {
  font-family: 'Courier New', monospace;
  color: #2c3e50;
  font-weight: 700;
  font-size: 14px;
}

/* 分析结果 */
.analysis-results {
  background: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(248,249,250,0.9));
  border: 1px solid #dee2e6;
  border-radius: 12px;
  padding: 20px;
  margin-top: 20px;
}

.analysis-title {
  font-size: 16px;
  font-weight: 700;
  color: #2c3e50;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.analysis-title::before {
  content: '📊';
  font-size: 20px;
}

.analysis-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.analysis-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.05), rgba(118, 75, 162, 0.05));
  border-radius: 8px;
  font-size: 13px;
  border-left: 4px solid #667eea;
}

.analysis-label {
  color: #495057;
  font-weight: 600;
}

.analysis-value {
  color: #2c3e50;
  font-family: 'Courier New', monospace;
  font-weight: 700;
}

/* 动画效果 */
.stat-item.updated {
  animation: statUpdate 0.6s ease-out;
}

@keyframes statUpdate {
  0% {
    background: linear-gradient(135deg, rgba(40, 167, 69, 0.3), rgba(40, 167, 69, 0.1));
    transform: scale(1.05);
  }
  100% {
    background: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(248,249,250,0.9));
    transform: scale(1);
  }
}

/* 搜索结果样式 */
.search-result-header {
  grid-column: 1 / -1;
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
  border-radius: 8px;
  margin-bottom: 12px;
  border-left: 4px solid #667eea;
}

.search-result-title {
  font-size: 14px;
  font-weight: 700;
  color: #2c3e50;
  margin-bottom: 4px;
}

.search-result-term {
  font-size: 12px;
  color: #667eea;
  font-weight: 600;
}

.search-category-header {
  grid-column: 1 / -1;
  padding: 8px 12px;
  background: linear-gradient(135deg, rgba(248,249,250,0.9), rgba(233,236,239,0.9));
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #495057;
  margin: 8px 0 4px 0;
  border-left: 3px solid #dee2e6;
}

.component-item.new {
  animation: componentAppear 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes componentAppear {
  from {
    opacity: 0;
    transform: scale(0.8) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Toast 通知 */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: linear-gradient(135deg, rgba(40, 167, 69, 0.95), rgba(34, 139, 34, 0.95));
  color: white;
  padding: 16px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  z-index: 10000;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 8px 25px rgba(0,0,0,0.2);
  backdrop-filter: blur(10px);
}

.toast.show {
  transform: translateX(0);
}

.toast.error {
  background: linear-gradient(135deg, rgba(220, 53, 69, 0.95), rgba(183, 28, 28, 0.95));
}

.toast.warning {
  background: linear-gradient(135deg, rgba(255, 193, 7, 0.95), rgba(255, 152, 0, 0.95));
  color: #212529;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .components-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 12px;
  }
  
  .component-item {
    min-height: 80px;
    padding: 12px 8px;
  }
  
  .component-icon {
    font-size: 24px;
  }
  
  .simulation-stats {
    grid-template-columns: 1fr;
  }
  
  .instruments-grid {
    grid-template-columns: 1fr 1fr;
  }
  
  #circuitCanvas {
    height: 400px;
  }
}

@media (max-width: 480px) {
  .components-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .component-item {
    min-height: 70px;
    padding: 8px 4px;
  }
  
  .component-icon {
    font-size: 20px;
  }
  
  .component-name {
    font-size: 11px;
  }
  
  .instruments-grid {
    grid-template-columns: 1fr;
  }
}

/* 3D元件效果 */
.component-item.resistor .component-icon {
  background: linear-gradient(45deg, #8B4513, #D2691E);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.component-item.capacitor .component-icon {
  background: linear-gradient(45deg, #4169E1, #87CEEB);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.component-item.led .component-icon {
  background: linear-gradient(45deg, #FF4500, #FFD700);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.component-item.battery .component-icon {
  background: linear-gradient(45deg, #228B22, #32CD32);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.component-properties {
  background: rgba(255,255,255,0.8);
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 12px;
  margin-top: 16px;
}

.properties-title {
  font-size: 13px;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 8px;
}

.simulation-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.control-group {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.btn-large {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
}

.simulation-speed {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.speed-controls {
  display: flex;
  gap: 4px;
}

.speed-btn {
  flex: 1;
  padding: 6px 8px;
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.speed-btn:hover {
  background: #e9ecef;
  border-color: #667eea;
}

.speed-btn.active {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border-color: #667eea;
}

.view-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.option-group input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  accent-color: #667eea;
}

.option-group label {
  font-size: 12px;
  color: #495057;
  cursor: pointer;
  user-select: none;
}

.simulation-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(255,255,255,0.8);
  border: 1px solid #dee2e6;
  border-radius: 6px;
  font-size: 12px;
}

.stat-label {
  color: #6c757d;
  font-weight: 500;
}

.stat-value {
  font-family: monospace;
  color: #2c3e50;
  font-weight: 600;
}

.canvas-container {
  position: relative;
  background: #ffffff;
  border: 2px solid #dee2e6;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.canvas-container.drag-over {
  border-color: #28a745;
  background: rgba(40, 167, 69, 0.05);
  box-shadow: inset 0 0 20px rgba(40, 167, 69, 0.1);
}

#circuitCanvas {
  display: block;
  width: 100%;
  height: 600px;
  background: 
    linear-gradient(to right, #e9ecef 1px, transparent 1px),
    linear-gradient(to bottom, #e9ecef 1px, transparent 1px),
    linear-gradient(to right, #dee2e6 1px, transparent 1px),
    linear-gradient(to bottom, #dee2e6 1px, transparent 1px);
  background-size: 20px 20px, 20px 20px, 100px 100px, 100px 100px;
  background-position: 0 0, 0 0, 0 0, 0 0;
  cursor: crosshair;
  /* 确保画布尺寸与显示尺寸一致 */
  max-width: 1000px;
}

.canvas-container.wire-mode #circuitCanvas {
  cursor: crosshair;
}

.canvas-container.select-mode #circuitCanvas {
  cursor: default;
}

.canvas-container.delete-mode #circuitCanvas {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="red" d="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z"/></svg>') 12 12, auto;
}

.canvas-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 10;
}

.canvas-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.mode-btn {
  position: relative;
}

.mode-btn.active {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border-color: #667eea;
}

.btn-small {
  padding: 4px 8px;
  font-size: 11px;
}

/* 测量仪表样式 */
.instruments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.instrument {
  background: rgba(255,255,255,0.9);
  border: 2px solid #dee2e6;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.instrument-display {
  margin-bottom: 8px;
}

.meter-face {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto 8px;
  background: radial-gradient(circle, #f8f9fa, #e9ecef);
  border: 3px solid #2c3e50;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.meter-scale {
  position: absolute;
  width: 70px;
  height: 70px;
  border: 1px solid #6c757d;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #dc3545 0deg 60deg, #ffc107 60deg 120deg, #28a745 120deg 180deg);
  opacity: 0.3;
}

.meter-needle {
  position: absolute;
  width: 2px;
  height: 30px;
  background: #dc3545;
  transform-origin: bottom center;
  transform: rotate(-90deg);
  transition: transform 0.3s ease;
  border-radius: 1px;
}

.meter-value {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 600;
  color: #2c3e50;
  background: rgba(255,255,255,0.9);
  padding: 2px 4px;
  border-radius: 2px;
}

.oscilloscope .scope-screen {
  position: relative;
  width: 120px;
  height: 80px;
  margin: 0 auto 8px;
  background: #000;
  border: 2px solid #2c3e50;
  border-radius: 4px;
  overflow: hidden;
}

#oscilloscopeCanvas {
  width: 100%;
  height: 100%;
  background: #001100;
}

.scope-grid {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    linear-gradient(rgba(0,255,0,0.2) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,255,0,0.2) 1px, transparent 1px);
  background-size: 10px 10px;
  pointer-events: none;
}

.instrument-label {
  font-size: 11px;
  color: #495057;
  font-weight: 500;
}

.analysis-results {
  background: rgba(255,255,255,0.8);
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 12px;
}

.analysis-title {
  font-size: 13px;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 8px;
}

.analysis-content {
  min-height: 100px;
}

.analysis-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.analysis-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  background: rgba(102, 126, 234, 0.05);
  border-radius: 4px;
  font-size: 11px;
}

.analysis-label {
  color: #6c757d;
  font-weight: 500;
}

.analysis-value {
  color: #2c3e50;
  font-family: monospace;
  font-weight: 600;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #6c757d;
  font-size: 12px;
  min-height: 80px;
}

.empty-state .icon {
  width: 32px;
  height: 32px;
  margin-bottom: 8px;
  opacity: 0.5;
}

/* Toast 通知样式 */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: rgba(40, 167, 69, 0.9);
  color: white;
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.toast.show {
  transform: translateX(0);
}

.toast.error {
  background: rgba(220, 53, 69, 0.9);
}

.toast.warning {
  background: rgba(255, 193, 7, 0.9);
  color: #212529;
}

/* 电路元件在画布上的样式 */
.circuit-component {
  position: absolute;
  cursor: move;
  transition: all 0.2s ease;
  user-select: none;
  border: 2px solid transparent;
  border-radius: 4px;
  padding: 2px;
}

.circuit-component:hover {
  transform: scale(1.05);
  z-index: 100;
  border-color: rgba(102, 126, 234, 0.5);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.circuit-component.selected {
  border-color: #ffc107;
  box-shadow: 0 0 0 2px rgba(255, 193, 7, 0.3);
  z-index: 200;
}

.circuit-component.dragging {
  z-index: 1000;
  transform: scale(1.1);
  opacity: 0.8;
  box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.circuit-component.preview {
  opacity: 0.6;
  border: 2px dashed #28a745;
}

/* 对齐辅助线 */
.alignment-guide {
  position: absolute;
  background: #007bff;
  z-index: 50;
  opacity: 0.7;
}

.alignment-guide.horizontal {
  height: 1px;
  width: 100%;
}

.alignment-guide.vertical {
  width: 1px;
  height: 100%;
}

/* 网格吸附指示器 */
.snap-indicator {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #28a745;
  border: 2px solid white;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  animation: snapPulse 0.3s ease-out;
}

@keyframes snapPulse {
  0% { transform: translate(-50%, -50%) scale(0); }
  50% { transform: translate(-50%, -50%) scale(1.5); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

/* LED发光效果 */
.led-glow {
  animation: ledGlow 1s ease-in-out infinite alternate;
}

@keyframes ledGlow {
  from {
    filter: drop-shadow(0 0 5px #ff4500);
  }
  to {
    filter: drop-shadow(0 0 15px #ffd700);
  }
}

/* 电流流动动画 */
.current-flow {
  stroke-dasharray: 5, 5;
  animation: currentFlow 1s linear infinite;
}

@keyframes currentFlow {
  from {
    stroke-dashoffset: 0;
  }
  to {
    stroke-dashoffset: 10;
  }
}

/* 导线样式 */
.wire {
  stroke: #2c3e50;
  stroke-width: 3;
  fill: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.wire:hover {
  stroke: #667eea;
  stroke-width: 4;
  filter: drop-shadow(0 2px 4px rgba(102, 126, 234, 0.3));
}

.wire.selected {
  stroke: #ffc107;
  stroke-width: 4;
  filter: drop-shadow(0 2px 6px rgba(255, 193, 7, 0.5));
}

.wire.preview {
  stroke: #28a745;
  stroke-width: 2;
  stroke-dasharray: 5, 5;
  opacity: 0.7;
  animation: previewPulse 1s ease-in-out infinite alternate;
}

@keyframes previewPulse {
  from { opacity: 0.5; }
  to { opacity: 0.9; }
}

/* 智能连线路径 */
.wire.orthogonal {
  stroke-linejoin: round;
  stroke-linecap: round;
}

.wire.curved {
  stroke-linecap: round;
}

/* 连线交叉点 */
.wire-junction {
  fill: #2c3e50;
  stroke: white;
  stroke-width: 1;
  r: 3;
}

.wire-junction:hover {
  fill: #667eea;
  r: 4;
}

/* 连接点样式 */
.connection-point {
  fill: #28a745;
  stroke: #ffffff;
  stroke-width: 2;
  cursor: pointer;
  transition: all 0.2s ease;
  r: 4;
}

.connection-point:hover {
  fill: #ffc107;
  r: 6;
  filter: drop-shadow(0 2px 4px rgba(255, 193, 7, 0.5));
}

.connection-point.active {
  fill: #dc3545;
  r: 6;
  animation: connectionPulse 0.8s ease-in-out infinite alternate;
}

.connection-point.connected {
  fill: #007bff;
  stroke: #ffffff;
}

.connection-point.highlighted {
  fill: #17a2b8;
  r: 7;
  stroke-width: 3;
  animation: connectionHighlight 1s ease-in-out infinite alternate;
}

@keyframes connectionPulse {
  from { 
    r: 4;
    fill-opacity: 0.8;
  }
  to { 
    r: 8;
    fill-opacity: 1;
  }
}

@keyframes connectionHighlight {
  from { 
    stroke: #ffffff;
    stroke-width: 2;
  }
  to { 
    stroke: #17a2b8;
    stroke-width: 4;
  }
}

/* 工具提示 */
.tooltip {
  position: absolute;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  pointer-events: none;
  z-index: 1000;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.tooltip.show {
  opacity: 1;
}

/* 操作提示 */
.operation-hint {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(102, 126, 234, 0.9);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  z-index: 100;
  opacity: 0;
  transition: all 0.3s ease;
}

.operation-hint.show {
  opacity: 1;
  transform: translateX(-50%) translateY(10px);
}

/* 元件信息面板 */
.component-info-panel {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 8px;
  font-size: 11px;
  min-width: 120px;
  z-index: 200;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.component-info-panel.show {
  opacity: 1;
  transform: translateY(0);
}

.component-info-title {
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 4px;
}

.component-info-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 2px;
}

.component-info-label {
  color: #6c757d;
}

.component-info-value {
  color: #2c3e50;
  font-family: monospace;
}

/* 网格控制 */
.grid-controls {
  position: absolute;
  bottom: 10px;
  left: 10px;
  display: flex;
  gap: 4px;
  z-index: 100;
}

.grid-btn {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #dee2e6;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.grid-btn:hover {
  background: #f8f9fa;
  border-color: #667eea;
}

.grid-btn.active {
  background: #667eea;
  color: white;
  border-color: #667eea;
}

/* 状态指示器 */
.status-indicator {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #dee2e6;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 10px;
  z-index: 100;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6c757d;
}

.status-dot.connected {
  background: #28a745;
  animation: statusPulse 2s ease-in-out infinite;
}

.status-dot.simulating {
  background: #007bff;
  animation: statusPulse 1s ease-in-out infinite;
}

.status-dot.error {
  background: #dc3545;
  animation: statusPulse 0.5s ease-in-out infinite;
}

@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* 动画效果 */
.stat-item.updated {
  animation: statUpdate 0.5s ease-out;
}

@keyframes statUpdate {
  0% {
    background: rgba(40, 167, 69, 0.2);
    transform: scale(1.02);
  }
  100% {
    background: rgba(255,255,255,0.8);
    transform: scale(1);
  }
}

.component-item.new {
  animation: componentAppear 0.3s ease-out;
}

@keyframes componentAppear {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .components-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .simulation-stats {
    grid-template-columns: 1fr;
  }
  
  .speed-controls {
    flex-direction: column;
  }
  
  .instruments-grid {
    grid-template-columns: 1fr;
  }
  
  .canvas-controls {
    justify-content: center;
  }
  
  #circuitCanvas {
    height: 400px;
  }
  
  .meter-face {
    width: 60px;
    height: 60px;
  }
  
  .meter-needle {
    height: 20px;
  }
}

@media (max-width: 480px) {
  .components-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .component-item {
    min-height: 60px;
    padding: 8px 4px;
  }
  
  .component-icon {
    font-size: 18px;
  }
  
  .component-name {
    font-size: 10px;
  }
  
  .view-options {
    flex-direction: row;
    flex-wrap: wrap;
  }
}