* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f0f1a;
  color: #e0e0e0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
header h1 { font-size: 1.3rem; display: flex; align-items: center; gap: 8px; }
.status { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #ef4444;
  transition: all 0.3s;
}
.status-dot.connected { background: #22c55e; box-shadow: 0 0 8px #22c55e; }
.controls { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
button {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}
button:hover { background: rgba(255,255,255,0.25); transform: translateY(-1px); }
button:active { transform: translateY(0); }
button.primary { background: #22c55e; border-color: #16a34a; }
button.primary:hover { background: #16a34a; }
button.danger { background: #ef4444; border-color: #dc2626; }
button.danger:hover { background: #dc2626; }
main { flex: 1; display: flex; overflow: hidden; }
#blocklyDiv { flex: 1; height: 100%; }
.sidebar {
  width: 340px;
  background: #1a1a2e;
  border-left: 1px solid #2a2a4a;
  display: flex;
  flex-direction: column;
}
.sidebar-header {
  padding: 10px 14px;
  background: #232340;
  font-weight: 600;
  font-size: 12px;
  color: #888;
  border-bottom: 1px solid #2a2a4a;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.code-output {
  flex: 1;
  padding: 12px;
  overflow: auto;
  font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  color: #a0a0c0;
  background: #12121f;
}
.console { flex: 1; border-top: 1px solid #2a2a4a; display: flex; flex-direction: column; min-height: 150px; }
.console-output {
  flex: 1; padding: 10px; overflow-y: auto;
  font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
  font-size: 11px;
  background: #0a0a14;
}
.console-output div { padding: 2px 0; border-bottom: 1px solid #1a1a2a; }
.console-output .log { color: #a0a0c0; }
.console-output .error { color: #f87171; }
.console-output .success { color: #4ade80; }
.console-output .warn { color: #fbbf24; }
.console-output .info { color: #60a5fa; }
.motor-status {
  padding: 10px;
  background: #12121f;
  border-bottom: 1px solid #2a2a4a;
  font-size: 11px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.motor-badge {
  background: #232340;
  padding: 4px 8px;
  border-radius: 4px;
  text-align: center;
}
.motor-badge.active { background: #22c55e33; border: 1px solid #22c55e; }
.motor-badge.error { background: #ef444433; border: 1px solid #ef4444; color: #f87171; }
.motor-badge span { display: block; font-size: 10px; color: #666; }
.tabs { display: flex; background: #232340; }
.tab {
  flex: 1;
  padding: 8px;
  text-align: center;
  cursor: pointer;
  font-size: 12px;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.tab:hover { background: #2a2a50; }
.tab.active { border-bottom-color: #667eea; color: #667eea; }
.tab-content { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.tab-content.active { display: flex; }

/* Blockly toolbox text fix */
.blocklyTreeLabel, .blocklyToolboxCategory {
  color: #000000 !important;
}
.blocklyTreeRow:hover {
  background-color: rgba(255,255,255,0.1) !important;
}

/* AI Assistant Styles */
.ai-assistant {
  height: 250px;
  border-top: 2px solid #667eea;
  display: flex;
  flex-direction: column;
  background: #12121f;
}
.ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #232340;
  border-bottom: 1px solid #2a2a4a;
}
.ai-header-title {
  font-size: 12px;
  font-weight: 600;
  color: #667eea;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ai-settings-btn {
  background: transparent;
  border: 1px solid #444;
  color: #888;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
  border-radius: 4px;
}
.ai-settings-btn:hover {
  background: #333;
  color: #fff;
}
.ai-chat {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  font-size: 12px;
}
.ai-message {
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  max-width: 90%;
}
.ai-message.user {
  background: #3a3a5a;
  margin-left: auto;
  color: #e0e0e0;
}
.ai-message.assistant {
  background: #1e3a5f;
  color: #a0d0ff;
}
.ai-message.error {
  background: #5f1e1e;
  color: #ffa0a0;
}
.ai-message.system {
  background: #2a2a4a;
  color: #888;
  font-style: italic;
  text-align: center;
  max-width: 100%;
}
.ai-message.code {
  background: #1a1a2e;
  border: 1px solid #3a3a5a;
  font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
  font-size: 11px;
  white-space: pre-wrap;
  color: #a0d0ff;
  max-width: 100%;
  overflow-x: auto;
}
.ai-input-area {
  display: flex;
  gap: 8px;
  padding: 10px;
  background: #1a1a2e;
  border-top: 1px solid #2a2a4a;
}
.ai-input {
  flex: 1;
  background: #232340;
  border: 1px solid #3a3a5a;
  color: #e0e0e0;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
}
.ai-input:focus {
  border-color: #667eea;
}
.ai-input::placeholder {
  color: #666;
}
.ai-send-btn {
  background: #667eea;
  border: none;
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}
.ai-send-btn:hover {
  background: #5a6fd6;
}
.ai-send-btn:disabled {
  background: #444;
  cursor: not-allowed;
}
.ai-thinking {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  color: #888;
  font-size: 12px;
}
.ai-thinking-dots {
  display: flex;
  gap: 3px;
}
.ai-thinking-dots span {
  width: 6px;
  height: 6px;
  background: #667eea;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}
.ai-thinking-dots span:nth-child(1) { animation-delay: -0.32s; }
.ai-thinking-dots span:nth-child(2) { animation-delay: -0.16s; }
.ai-thinking-dots span:nth-child(3) { animation-delay: 0s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* AI Settings Modal */
.ai-settings-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.ai-settings-modal.show {
  display: flex;
}
.ai-settings-content {
  background: #1a1a2e;
  border: 1px solid #3a3a5a;
  border-radius: 12px;
  padding: 20px;
  width: 400px;
  max-width: 90%;
}
.ai-settings-content h3 {
  margin: 0 0 16px 0;
  color: #667eea;
  font-size: 16px;
}
.ai-settings-group {
  margin-bottom: 14px;
}
.ai-settings-group label {
  display: block;
  font-size: 12px;
  color: #888;
  margin-bottom: 4px;
}
.ai-settings-group select,
.ai-settings-group input {
  width: 100%;
  background: #232340;
  border: 1px solid #3a3a5a;
  color: #e0e0e0;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
}
.ai-settings-group input::placeholder {
  color: #555;
}
.ai-settings-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}
.ai-settings-buttons button {
  padding: 8px 16px;
  font-size: 12px;
}
