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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  overflow: hidden;
}

/* Canvas styles */
#canvas-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  cursor: grab;
}

#canvas-container.dragging {
  cursor: grabbing;
}

#canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 30px 30px;
}

/* Node styles */
.node {
  position: absolute;
  min-width: 200px;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.95) 0%, rgba(15, 23, 42, 0.95) 100%);
  border: 2px solid rgba(148, 163, 184, 0.3);
  border-radius: 12px;
  padding: 0;
  cursor: move;
  transition: all 0.2s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
}

.node:hover {
  border-color: rgba(148, 163, 184, 0.5);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

.node.selected {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3), 0 15px 40px rgba(0, 0, 0, 0.6);
}

.node-header {
  padding: 16px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 10px 10px 0 0;
}

.node-title {
  font-weight: 600;
  font-size: 14px;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.node-category {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.node-category.mcu {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

.node-category.sensor {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
}

.node-category.led {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
}

.node-category.display {
  background: rgba(52, 152, 219, 0.2);
  color: #5dade2;
}

.node-category.motor {
  background: rgba(230, 126, 34, 0.2);
  color: #f39c12;
}

.node-category.communication {
  background: rgba(26, 188, 156, 0.2);
  color: #48c9b0;
}

.node-body {
  padding: 12px 16px;
}

.node-interfaces {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.interface-row {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.interface-row.left {
  justify-content: flex-start;
}

.interface-row.right {
  justify-content: flex-end;
}

.interface-port {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(148, 163, 184, 0.5);
  background: rgba(30, 41, 59, 0.8);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  z-index: 10;
}

.interface-port:hover {
  transform: scale(1.3);
  border-color: #3b82f6;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

.interface-port.i2c {
  background: #8b5cf6;
  border-color: #a78bfa;
}

.interface-port.gpio {
  background: #10b981;
  border-color: #34d399;
}

.interface-port.usart {
  background: #f59e0b;
  border-color: #fbbf24;
}

.interface-port.spi {
  background: #ef4444;
  border-color: #f87171;
}

.interface-port.adc {
  background: #ec4899;
  border-color: #f472b6;
}

.interface-port.wireless {
  background: #06b6d4;
  border-color: #22d3ee;
}

.interface-label {
  font-size: 12px;
  color: #cbd5e1;
  font-weight: 500;
}

.delete-node {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
}

.delete-node:hover {
  background: rgba(239, 68, 68, 0.2);
  transform: scale(1.05);
}

/* Connection lines */
#connections-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.connection-line {
  stroke-width: 3;
  fill: none;
  stroke-linecap: round;
  filter: drop-shadow(0 0 3px rgba(59, 130, 246, 0.5));
}

.connection-line.i2c {
  stroke: #8b5cf6;
}

.connection-line.gpio {
  stroke: #10b981;
}

.connection-line.usart {
  stroke: #f59e0b;
}

.connection-line.spi {
  stroke: #ef4444;
}

.connection-line.adc {
  stroke: #ec4899;
}

.connection-line.wireless {
  stroke: #06b6d4;
}

/* Toolbar */
.toolbar {
  position: fixed;
  top: 20px;
  left: 20px;
  background: rgba(30, 41, 59, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  z-index: 1000;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  width: 280px;
}

.toolbar h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.component-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.component-item {
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.component-item:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(148, 163, 184, 0.4);
  transform: translateX(4px);
}

.component-item-name {
  font-weight: 600;
  font-size: 13px;
  color: #e2e8f0;
}

.component-item-desc {
  font-size: 11px;
  color: #94a3b8;
}

/* Control panel */
.control-panel {
  position: fixed;
  top: 20px;
  right: 20px;
  background: rgba(30, 41, 59, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  z-index: 1000;
  display: flex;
  gap: 8px;
}

.control-btn {
  padding: 10px 16px;
  background: rgba(59, 130, 246, 0.1);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.control-btn:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.5);
  transform: translateY(-2px);
}

.control-btn.danger {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.control-btn.danger:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
}

.control-btn.success {
  background: rgba(34, 197, 94, 0.1);
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.3);
}

.control-btn.success:hover {
  background: rgba(34, 197, 94, 0.2);
  border-color: rgba(34, 197, 94, 0.5);
}

/* Info panel */
.info-panel {
  position: fixed;
  bottom: 20px;
  left: 20px;
  background: rgba(30, 41, 59, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  z-index: 1000;
  font-size: 12px;
  color: #94a3b8;
  display: flex;
  gap: 20px;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.info-value {
  color: #60a5fa;
  font-weight: 600;
}

/* Scrollbar styles */
.toolbar::-webkit-scrollbar {
  width: 6px;
}

.toolbar::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.toolbar::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
  border-radius: 3px;
}

.toolbar::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.5);
}

/* Zoom controls */
.zoom-controls {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: rgba(30, 41, 59, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
}

.zoom-btn {
  width: 36px;
  height: 36px;
  background: rgba(59, 130, 246, 0.1);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.zoom-btn:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.5);
  transform: translateY(-2px);
}

.zoom-display {
  font-size: 13px;
  font-weight: 600;
  color: #60a5fa;
  min-width: 50px;
  text-align: center;
}

/* Modal styles */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: rgba(30, 41, 59, 0.98);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 16px;
  padding: 24px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: #e2e8f0;
}

.modal-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

.modal-body {
  margin-bottom: 20px;
}

.modal-textarea {
  width: 100%;
  min-height: 300px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 8px;
  padding: 12px;
  color: #e2e8f0;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  resize: vertical;
}

.modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.modal-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.modal-btn.primary {
  background: #3b82f6;
  color: white;
}

.modal-btn.primary:hover {
  background: #2563eb;
}

.modal-btn.secondary {
  background: rgba(148, 163, 184, 0.2);
  color: #e2e8f0;
}

.modal-btn.secondary:hover {
  background: rgba(148, 163, 184, 0.3);
}
