/* Menu button and menu styles */
.menu-button {
  position: fixed;
  top: 20px;
  left: 20px;
  width: 40px;
  height: 40px;
  background-color: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 24px;
  box-shadow: 0 2px 4px var(--bubble-shadow);
  z-index: 1000;
  transition: background-color 0.2s ease;
}

.menu-button:hover {
  background-color: var(--gray-100);
}

.menu {
  position: fixed;
  top: 70px;
  left: 20px;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 4px 6px var(--bubble-shadow);
  z-index: 1000;
  overflow: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease;
  transform-origin: top left;
}

.menu.hidden {
  opacity: 0;
  transform: scale(0.95);
  pointer-events: none;
}

.menu-item {
  display: block;
  width: 100%;
  padding: 12px 20px;
  text-align: left;
  border: none;
  background: none;
  font-size: 14px;
  color: var(--gray-800);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.menu-item:hover {
  background-color: var(--gray-100);
}

.menu-item:not(:last-child) {
  border-bottom: 1px solid var(--gray-200);
}

:root {
  --primary: #3B82F6;
  --primary-light: #60A5FA;
  --primary-dark: #2563EB;
  --secondary: #8B5CF6;
  --accent: #F97316;
  --success: #10B981;
  --warning: #F59E0B;
  --error: #EF4444;
  --background: #F9FAFB;
  --foreground: #1F2937;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;
  --bubble-bg: #FFFFFF;
  --bubble-selected: rgba(59, 130, 246, 0.1);
  --bubble-border: rgba(59, 130, 246, 0.5);
  --bubble-shadow: rgba(0, 0, 0, 0.1);
  --connection-color: #9CA3AF;
  --arrow-color: #6B7280;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html, body, #app {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--background);
  color: var(--foreground);
}

#app {
  position: relative;
}

#canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  cursor: grab;
}

#canvas:active {
  cursor: grabbing;
}

#control-panel {
  position: fixed;
  bottom: 20px;
  left: 20px;
  background-color: white;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 4px 6px var(--bubble-shadow);
  z-index: 10;
  width: 320px;
  transition: opacity 0.2s ease;
}

.slider-label {
  display: block;
  font-size: 14px;
  color: var(--gray-700);
  margin-bottom: 8px;
}

.slider {
  width: 100%;
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  outline: none;
  -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--primary);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.slider::-webkit-slider-thumb:hover {
  background: var(--primary-dark);
}

.slider::-moz-range-thumb:hover {
  background: var(--primary-dark);
}

.slider:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.slider:disabled::-webkit-slider-thumb {
  cursor: not-allowed;
  background: var(--gray-400);
}

.slider:disabled::-moz-range-thumb {
  cursor: not-allowed;
  background: var(--gray-400);
}

.input-group {
  margin-bottom: 12px;
}

.button-group {
  display: flex;
  gap: 8px;
}

input[type="text"], textarea {
  width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--gray-300);
  font-size: 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  resize: vertical;
}

textarea {
  min-height: 80px;
  font-family: inherit;
  line-height: 1.5;
}

input[type="text"]:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.btn {
  padding: 8px 12px;
  border-radius: 6px;
  border: none;
  background-color: var(--gray-200);
  color: var(--gray-800);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
  flex: 1;
}

.btn:hover {
  background-color: var(--gray-300);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background-color: var(--primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--primary-dark);
}

.btn-secondary {
  background-color: var(--secondary);
  color: white;
}

.btn-secondary:hover {
  background-color: #7c3aed;
}

#dialog-container, #multi-dialog-container, #ai-api-key-dialog {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 20;
  opacity: 1;
  transition: opacity 0.2s ease;
  visibility: visible;
}

#dialog-container.hidden, #multi-dialog-container.hidden, #ai-api-key-dialog.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#dialog, #multi-dialog, #ai-api-key-dialog-content {
  background-color: white;
  border-radius: 8px;
  padding: 20px;
  width: 320px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  transform: scale(1);
  transition: transform 0.2s ease;
}

#multi-dialog {
  width: 400px;
}

#dialog-container.hidden #dialog,
#multi-dialog-container.hidden #multi-dialog,
#ai-api-key-dialog.hidden #ai-api-key-dialog-content {
  transform: scale(0.9);
}

#dialog h3, #multi-dialog h3, #ai-api-key-dialog-content h3 {
  margin-bottom: 16px;
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-800);
}

#dialog input, #multi-dialog input, #ai-api-key-dialog-content input {
  margin-bottom: 20px;
}

.dialog-buttons {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.accordion {
  margin: 16px 0;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  overflow: hidden;
}

.accordion-header {
  padding: 12px 16px;
  background-color: var(--gray-100);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.accordion-header h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
}

.accordion-toggle {
  color: var(--gray-600);
  transition: transform 0.2s ease;
}

.accordion.collapsed .accordion-toggle {
  transform: rotate(-90deg);
}

.accordion-content {
  padding: 16px;
  background-color: white;
  transition: max-height 0.3s ease;
}

.accordion.collapsed .accordion-content {
  display: none;
}

.context-hint {
  font-size: 13px;
  color: var(--gray-500);
  margin: 8px 0 16px;
  line-height: 1.4;
}

.api-key-link {
  margin: 12px 0;
  font-size: 14px;
}

.api-key-link a {
  color: #3B82F6;
  text-decoration: none;
  transition: color 0.2s ease;
}

.api-key-link a:hover {
  color: #2563EB;
  text-decoration: underline;
}

.api-key-link a:visited {
  color: #3B82F6;
}

/* Keyboard shortcuts panel */
#shortcuts-panel {
  position: absolute;
  top: 20px;
  right: 20px;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 4px 6px var(--bubble-shadow);
  z-index: 10;
  width: 280px;
  overflow: hidden;
  transition: all 0.3s ease;
}

#shortcuts-header {
  padding: 12px 16px;
  background-color: var(--gray-100);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

#shortcuts-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
  margin: 0;
}

#shortcuts-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

#shortcuts-panel.expanded #shortcuts-content {
  max-height: 260px;
  padding: 12px 16px;
}

.shortcut-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
}

.shortcut-item:last-child {
  margin-bottom: 0;
}

.shortcut-keys {
  display: flex;
  gap: 4px;
}

.key {
  background-color: var(--gray-100);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 12px;
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}

/* Bubble tooltip */
.bubble-tooltip {
  position: absolute;
  background-color: white;
  border-radius: 6px;
  padding: 8px 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  font-size: 14px;
  max-width: 300px;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  white-space: pre-wrap;
  line-height: 1.5;
}

.bubble-tooltip.visible {
  opacity: 1;
}

@media (max-width: 480px) {
  #control-panel {
    width: calc(100% - 40px);
  }
  
  #dialog, #multi-dialog {
    width: calc(100% - 40px);
    max-width: 320px;
  }
  
  #shortcuts-panel {
    width: calc(100% - 40px);
  }
}