/* ============================================
   Agent Builder - Interactive Visual Builder
   ============================================ */

/* Builder Header */
.builder-header {
  padding: 6rem 0 3rem;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
}

.builder-header-content {
  text-align: center;
}

/* Builder Section */
.builder-section {
  padding: 0;
  background: var(--bg-secondary);
  min-height: calc(100vh - 200px);
}

.builder-container {
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  gap: 0;
  height: calc(100vh - 200px);
  max-width: 100%;
}

/* ============================================
   Left Sidebar - Components
   ============================================ */
.builder-sidebar {
  background: var(--bg-primary);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  padding: 1.5rem;
}

.sidebar-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-header h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.sidebar-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Component Groups */
.component-group {
  margin-bottom: 1.5rem;
}

.component-group-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.component-group-title svg {
  width: 14px;
  height: 14px;
}

/* Component Items */
.component-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.component-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: grab;
  transition: all 0.2s ease;
  position: relative;
}

.component-item:hover {
  background: rgba(255, 215, 18, 0.1);
  border-color: var(--primary-color);
  transform: translateX(4px);
}

.component-item:active {
  cursor: grabbing;
}

.component-item.dragging {
  opacity: 0.5;
  transform: scale(0.95);
}

.component-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.component-icon svg {
  width: 18px;
  height: 18px;
}

.component-icon.trigger {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.component-icon.thinking {
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
}

.component-icon.tool {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

.component-icon.logic {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.component-icon.integration {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.component-icon.integration.hubspot { color: #ff7a59; }
.component-icon.integration.salesforce { color: #00a1e0; }
.component-icon.integration.slack { color: #4a154b; background: rgba(74, 21, 75, 0.2); }
.component-icon.integration.google { color: #4285f4; }
.component-icon.integration.zapier { color: #ff4a00; }
.component-icon.integration.stripe { color: #635bff; }

.component-item span {
  font-size: 0.875rem;
  font-weight: 500;
}

.component-badge {
  font-size: 0.625rem;
  padding: 0.125rem 0.375rem;
  background: var(--primary-color);
  color: var(--bg-primary);
  border-radius: 4px;
  font-weight: 600;
  margin-left: auto;
}

/* ============================================
   Center Canvas
   ============================================ */
.builder-canvas-container {
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  overflow: hidden;
}

.canvas-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toolbar-btn {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.toolbar-btn:hover {
  background: rgba(255, 215, 18, 0.1);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.toolbar-btn svg {
  width: 16px;
  height: 16px;
}

.zoom-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  justify-content: center;
  font-size: 1rem;
  font-weight: 600;
}

.zoom-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

#zoomLevel {
  font-size: 0.8125rem;
  min-width: 40px;
  text-align: center;
}

/* Canvas Area */
.builder-canvas {
  flex: 1;
  position: relative;
  overflow: auto;
  background:
    radial-gradient(circle at center, rgba(255, 215, 18, 0.03) 0%, transparent 50%),
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 100% 100%, 20px 20px, 20px 20px;
}

.canvas-connections {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
  overflow: visible;
}

.canvas-content {
  position: relative;
  min-height: 100%;
  min-width: 100%;
  padding: 2rem;
  z-index: 2;
}

/* Placeholder */
.canvas-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}

.canvas-placeholder.hidden {
  display: none;
}

.placeholder-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.placeholder-content svg {
  width: 80px;
  height: 80px;
  color: var(--text-muted);
  opacity: 0.5;
}

.placeholder-content p {
  font-size: 1.125rem;
  color: var(--text-muted);
}

.placeholder-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  opacity: 0.7;
}

/* Canvas Nodes */
.canvas-node {
  position: absolute;
  min-width: 180px;
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  cursor: move;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  z-index: 10;
}

.canvas-node:hover {
  border-color: var(--primary-color);
  box-shadow: 0 0 20px rgba(255, 215, 18, 0.2);
}

.canvas-node.selected {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(255, 215, 18, 0.3);
}

.canvas-node.dragging {
  opacity: 0.8;
  z-index: 100;
}

.node-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.node-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.node-icon svg {
  width: 20px;
  height: 20px;
}

.node-title {
  font-size: 0.875rem;
  font-weight: 600;
  flex: 1;
}

.node-delete {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.2s ease;
}

.canvas-node:hover .node-delete {
  opacity: 1;
}

.node-delete:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.node-description {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Node Types */
.canvas-node.trigger .node-icon { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.canvas-node.thinking .node-icon { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }
.canvas-node.tool .node-icon { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.canvas-node.logic .node-icon { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.canvas-node.integration .node-icon { background: rgba(255, 255, 255, 0.1); }

/* Connection Points */
.node-connector {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: 50%;
  cursor: crosshair;
  transition: all 0.2s ease;
}

.node-connector.input {
  top: 50%;
  left: -6px;
  transform: translateY(-50%);
}

.node-connector.output {
  top: 50%;
  right: -6px;
  transform: translateY(-50%);
}

.node-connector:hover {
  background: var(--primary-color);
  border-color: var(--primary-color);
  transform: translateY(-50%) scale(1.3);
}

.node-connector.connector-hover {
  background: var(--candlelight);
  border-color: var(--candlelight);
  transform: translateY(-50%) scale(1.5);
  box-shadow: 0 0 10px var(--candlelight);
}

/* Connecting state */
body.connecting {
  cursor: crosshair !important;
}

body.connecting * {
  cursor: crosshair !important;
}

body.connecting .node-connector.input {
  background: rgba(255, 215, 18, 0.3);
  border-color: var(--candlelight);
}

/* Connection Lines */
.connection-line {
  stroke: var(--candlelight);
  stroke-width: 3;
  fill: none;
  cursor: pointer;
  pointer-events: auto;
}

.connection-line.active {
  opacity: 1;
  stroke-width: 3;
}

.connection-line:hover {
  stroke: var(--candlelight);
  stroke-width: 3;
  opacity: 1;
}

.connection-line.temp {
  stroke-dasharray: 8, 4;
  opacity: 0.8;
  pointer-events: none;
  animation: dashMove 0.5s linear infinite;
}

@keyframes dashMove {
  to {
    stroke-dashoffset: -12;
  }
}

/* Drop Zone Highlight */
.builder-canvas.drag-over {
  background-color: rgba(255, 215, 18, 0.05);
}

.builder-canvas.drag-over::after {
  content: '';
  position: absolute;
  inset: 1rem;
  border: 2px dashed var(--primary-color);
  border-radius: 12px;
  pointer-events: none;
  opacity: 0.5;
}

/* ============================================
   Right Sidebar - Configuration
   ============================================ */
.builder-config {
  background: var(--bg-primary);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.config-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
}

.config-tab {
  flex: 1;
  padding: 1rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.config-tab:hover {
  color: var(--text-primary);
}

.config-tab.active {
  color: var(--primary-color);
}

.config-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary-color);
}

.config-panel {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.config-panel.active {
  display: block;
}

/* Summary Panel */
.summary-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.summary-section:last-of-type {
  border-bottom: none;
}

.summary-section h4 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.summary-stat {
  background: var(--bg-glass);
  border-radius: 8px;
  padding: 0.75rem;
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
}

.stat-label {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* Thinking Summary */
.thinking-summary {
  background: var(--bg-glass);
  border-radius: 8px;
  padding: 1rem;
}

.thinking-placeholder {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-style: italic;
}

.thinking-active {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.thinking-active .thinking-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thinking-active .thinking-icon svg {
  width: 22px;
  height: 22px;
}

.thinking-active .thinking-info h5 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.thinking-active .thinking-info p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Workflow Description */
.workflow-description {
  background: var(--bg-glass);
  border-radius: 8px;
  padding: 1rem;
  font-size: 0.875rem;
  line-height: 1.6;
}

.description-placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.workflow-step {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.workflow-step:last-child {
  margin-bottom: 0;
}

.step-number {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-color);
  color: var(--bg-primary);
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-text {
  font-size: 0.8125rem;
  color: var(--text-primary);
}

/* Complexity Meter */
.complexity-meter {
  margin-bottom: 0.75rem;
}

.complexity-bar {
  height: 8px;
  background: var(--bg-glass);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.complexity-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #f59e0b, #ef4444);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.complexity-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.complexity-note {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* Estimate Display */
.estimate-display {
  background: var(--bg-glass);
  border-radius: 8px;
  padding: 1.25rem;
  text-align: center;
}

.estimate-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 0.25rem;
}

.estimate-range {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* Config Content */
.config-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  text-align: center;
  color: var(--text-muted);
}

.config-empty svg {
  width: 48px;
  height: 48px;
  opacity: 0.5;
  margin-bottom: 1rem;
}

.config-empty p {
  font-size: 0.875rem;
}

/* Config CTA */
.config-cta {
  padding: 1.5rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-glass);
}

.btn-block {
  width: 100%;
  text-align: center;
}

.cta-note {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
}

/* ============================================
   Templates Modal
   ============================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-primary);
  border-radius: 16px;
  width: 90%;
  max-width: 800px;
  max-height: 80vh;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
  color: #ef4444;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  max-height: calc(80vh - 80px);
}

/* Templates Grid */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.template-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.template-card:hover {
  border-color: var(--primary-color);
  background: rgba(255, 215, 18, 0.05);
  transform: translateY(-2px);
}

.template-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: rgba(255, 215, 18, 0.1);
  color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.template-icon svg {
  width: 24px;
  height: 24px;
}

.template-card h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.template-card p {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ============================================
   Education Tooltip
   ============================================ */
.education-tooltip {
  position: fixed;
  z-index: 1001;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  max-width: 280px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.education-tooltip.visible {
  opacity: 1;
  visibility: visible;
}

.tooltip-content h4 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.tooltip-content p {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

.tooltip-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.75rem;
}

.tooltip-meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--text-muted);
}

/* ============================================
   Sidebar Toggle Button & Backdrop
   ============================================ */
.sidebar-toggle {
  position: fixed;
  bottom: 6rem;
  left: 1rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary-color);
  border: none;
  color: var(--bg-primary);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(255, 215, 18, 0.4);
  z-index: 1001;
  transition: all 0.3s ease;
}

.sidebar-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 25px rgba(255, 215, 18, 0.6);
}

.sidebar-toggle svg {
  width: 24px;
  height: 24px;
  transition: transform 0.3s ease;
}

.sidebar-toggle.active svg {
  transform: rotate(45deg);
}

.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-backdrop.active {
  opacity: 1;
  visibility: visible;
}

/* Config Toggle Button */
.config-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary-color);
  border: none;
  color: var(--bg-primary);
  cursor: pointer;
  z-index: 1000;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(255, 215, 18, 0.4);
  align-items: center;
  justify-content: center;
}

.config-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 25px rgba(255, 215, 18, 0.6);
}

.config-toggle svg {
  width: 24px;
  height: 24px;
}

/* Config toggle for mobile */
.config-toggle {
  position: fixed;
  bottom: 6rem;
  right: 1rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-primary);
  border: 2px solid var(--primary-color);
  color: var(--primary-color);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  z-index: 1001;
  transition: all 0.3s ease;
}

.config-toggle svg {
  width: 24px;
  height: 24px;
}

.config-toggle.active {
  background: var(--primary-color);
  color: var(--bg-primary);
}

/* ============================================
   Responsive Design - Clean Implementation
   ============================================ */

/* Large tablets and small desktops */
@media (max-width: 1200px) {
  .builder-container {
    grid-template-columns: 220px 1fr 280px;
  }

  .component-item span {
    font-size: 0.8125rem;
  }
}

/* Tablets landscape - Hide sidebar, show toggle */
@media (max-width: 1024px) {
  .builder-section {
    min-height: auto;
  }

  .builder-container {
    display: grid;
    grid-template-columns: 1fr 280px;
    height: auto;
    min-height: calc(100vh - 150px);
  }

  /* Sidebar as slide-out overlay */
  .builder-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
    padding-top: 5rem;
  }

  .builder-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: flex;
  }

  .config-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-color);
    border: none;
    color: var(--bg-primary);
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(255, 215, 18, 0.4);
    align-items: center;
    justify-content: center;
  }

  .config-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(255, 215, 18, 0.6);
  }

  .config-toggle svg {
    width: 24px;
    height: 24px;
  }

  /* Canvas takes remaining space */
  .builder-canvas-container {
    min-height: 400px;
  }

  /* Config panel on right */
  .builder-config {
    border-left: 1px solid var(--border-color);
  }
}

/* Tablets portrait - Stack everything */
@media (max-width: 768px) {
  .builder-header {
    padding: 5rem 0 1.5rem;
  }

  .builder-header .page-title {
    font-size: 1.75rem;
  }

  .builder-header .page-description {
    font-size: 0.875rem;
    display: none;
  }

  .builder-container {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 100px);
  }

  /* Sidebar overlay */
  .builder-sidebar {
    width: 85%;
    max-width: 300px;
  }

  /* Canvas full width */
  .builder-canvas-container {
    flex: 1;
    min-height: 50vh;
    order: 1;
  }

  .canvas-content {
    padding: 1rem;
  }

  .canvas-toolbar {
    padding: 0.5rem;
  }

  .toolbar-btn {
    padding: 0.5rem;
    font-size: 0;
  }

  .toolbar-btn svg {
    width: 20px;
    height: 20px;
  }

  .toolbar-btn span {
    display: none;
  }

  /* Config panel as collapsible bottom sheet */
  .builder-config {
    order: 2;
    border-left: none;
    border-top: 1px solid var(--border-color);
    max-height: 35vh;
    overflow-y: auto;
    transition: max-height 0.3s ease;
  }

  .builder-config.collapsed {
    max-height: 0;
    overflow: hidden;
    border-top: none;
  }

  .config-toggle {
    display: flex;
  }

  /* Smaller nodes */
  .canvas-node {
    min-width: 140px;
    padding: 0.75rem;
  }

  .node-icon {
    width: 28px;
    height: 28px;
  }

  .node-icon svg {
    width: 16px;
    height: 16px;
  }

  .node-title {
    font-size: 0.8125rem;
  }

  .node-description {
    display: none;
  }

  .node-delete {
    opacity: 1;
    width: 32px;
    height: 32px;
  }

  /* Config panel compact */
  .config-panel {
    padding: 1rem;
  }

  .summary-stat {
    padding: 0.5rem;
  }

  .stat-value {
    font-size: 1.25rem;
  }

  .stat-label {
    font-size: 0.625rem;
  }

  /* Placeholder */
  .placeholder-content svg {
    width: 50px;
    height: 50px;
  }

  .placeholder-content p {
    font-size: 0.875rem;
  }

  .placeholder-hint {
    font-size: 0.75rem;
    padding: 0 1rem;
  }

  /* Modal */
  .modal-content {
    width: 95%;
    max-height: 85vh;
    margin: 1rem;
  }

  .templates-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .template-card {
    padding: 1rem;
  }

  .template-card h4 {
    font-size: 0.875rem;
  }

  .template-card p {
    font-size: 0.75rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

/* Mobile phones */
@media (max-width: 480px) {
  .builder-header {
    padding: 4.5rem 0 1rem;
  }

  .builder-header .page-title {
    font-size: 1.375rem;
  }

  .builder-header .badge {
    font-size: 0.625rem;
    padding: 0.25rem 0.5rem;
  }

  .builder-container {
    min-height: calc(100vh - 80px);
  }

  /* Full-width sidebar overlay */
  .builder-sidebar {
    width: 100%;
    max-width: 100%;
    padding: 4.5rem 1rem 1rem;
  }

  .sidebar-toggle {
    bottom: 5rem;
    left: 0.75rem;
    width: 48px;
    height: 48px;
  }

  .config-toggle {
    bottom: 5rem;
    right: 0.75rem;
    width: 48px;
    height: 48px;
  }

  /* Canvas */
  .builder-canvas-container {
    min-height: 55vh;
  }

  .canvas-toolbar {
    justify-content: center;
    gap: 0.25rem;
  }

  .toolbar-btn {
    min-width: 44px;
    min-height: 44px;
  }

  .zoom-btn {
    width: 36px;
    height: 36px;
  }

  .zoom-label,
  #zoomLevel {
    display: none;
  }

  /* Nodes */
  .canvas-node {
    min-width: 120px;
    padding: 0.625rem;
  }

  .node-header {
    gap: 0.5rem;
  }

  .node-icon {
    width: 24px;
    height: 24px;
  }

  .node-title {
    font-size: 0.75rem;
  }

  /* Config as minimal bottom bar */
  .builder-config {
    max-height: 30vh;
  }

  .config-tabs {
    display: none;
  }

  .config-panel {
    display: block;
    padding: 0.75rem;
  }

  .summary-section {
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
  }

  .summary-stats {
    gap: 0.25rem;
  }

  .thinking-summary,
  .workflow-section,
  .complexity-section {
    display: none;
  }

  .config-cta {
    padding: 0.75rem;
  }

  .config-cta .btn {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
  }

  .cta-note {
    display: none;
  }

  /* Templates modal */
  .modal-content {
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  .modal-header {
    padding: 1rem;
  }

  .modal-body {
    max-height: calc(100vh - 60px);
  }

  .templates-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .template-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
  }

  .template-icon {
    width: 40px;
    height: 40px;
    margin-bottom: 0;
    flex-shrink: 0;
  }

  .template-card h4 {
    margin-bottom: 0.25rem;
  }

  .template-card p {
    -webkit-line-clamp: 1;
  }
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets */
  .component-item {
    min-height: 48px;
    padding: 0.75rem;
  }

  .toolbar-btn {
    min-height: 44px;
    min-width: 44px;
  }

  /* Larger connectors for touch */
  .node-connector {
    width: 20px;
    height: 20px;
  }

  .node-connector.input {
    left: -10px;
  }

  .node-connector.output {
    right: -10px;
  }

  /* Always show delete button */
  .node-delete {
    opacity: 1;
    width: 36px;
    height: 36px;
  }

  /* Larger nodes for touch */
  .canvas-node {
    min-width: 160px;
    padding: 1rem;
  }

  /* Disable hover tooltips */
  .education-tooltip {
    display: none !important;
  }

  /* Prevent text selection during drag */
  .builder-canvas {
    -webkit-user-select: none;
    user-select: none;
    touch-action: pan-x pan-y;
  }
}

/* ============================================
   Animations
   ============================================ */
@keyframes nodeAppear {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.canvas-node {
  animation: nodeAppear 0.2s ease-out;
}

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

.node-connector:hover {
  animation: pulse 1s ease-in-out infinite;
}
