/**
 * LISP Node Flow - Enhanced Styles
 * Visual AutoLISP Builder with full node set and group functionality
 */

:root {
  --primary-color: #3498db;
  --secondary-color: #2ecc71;
  --accent-color: #e74c3c;
  --light-gray: #ecf0f1;
  --medium-gray: #bdc3c7;
  --dark-gray: #7f8c8d;
  --node-header-height: 36px;
  --sidebar-width: 280px;
  --main-bg: #f9fafb;
  --grid-size: 20px;
  --grid-color: rgba(0, 0, 0, 0.05);
  --node-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --modal-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
  --connection-width: 3px;
  --header-height: 60px;
  --workspace-controls-height: 40px;
  
  /* Node colors */
  --blue: #3498db;
  --green: #2ecc71;
  --red: #e74c3c;
  --orange: #f39c12;
  --purple: #9b59b6;
  --teal: #1abc9c;
  --yellow: #f1c40f;
  --indigo: #5352ed;
  --blue-gray: #34495e;
}

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #333;
  background-color: var(--main-bg);
  line-height: 1.6;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

.btn {
  padding: 8px 16px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: #fff;
  border: 1px solid var(--medium-gray);
  color: #333;
}

.btn:hover {
  background-color: #f5f5f5;
}

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

.btn.primary:hover {
  background-color: #2980b9;
}

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

.btn.secondary:hover {
  background-color: #27ae60;
}

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  border: 1px solid var(--medium-gray);
  background-color: white;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background-color: #f5f5f5;
}

/* Header */
header {
  height: var(--header-height);
  background-color: white;
  border-bottom: 1px solid var(--medium-gray);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  z-index: 10;
  position: relative;
}

.header-title h1 {
  font-size: 22px;
  font-weight: 600;
  color: #333;
}

.header-title h1 span {
  color: var(--primary-color);
  font-weight: 700;
}

.header-title .subheading {
  font-size: 14px;
  color: var(--dark-gray);
  margin-top: -4px;
}

.header-actions {
  display: flex;
  gap: 10px;
}

/* Main Layout */
.main-container {
  display: flex;
  height: calc(100vh - var(--header-height));
  position: relative;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background-color: white;
  border-right: 1px solid var(--medium-gray);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 5;
}

.search-box {
  padding: 15px;
  position: relative;
  border-bottom: 1px solid var(--light-gray);
}

.search-box input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border-radius: 4px;
  border: 1px solid var(--medium-gray);
  font-size: 14px;
}

.search-box i {
  position: absolute;
  left: 25px;
  top: 23px;
  color: var(--dark-gray);
}

.node-palette {
  padding: 10px 15px;
  flex-grow: 1;
}

.category {
  margin-bottom: 15px;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  cursor: pointer;
  user-select: none;
}

.category-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.category-nodes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 8px;
  padding-left: 10px;
}

.node-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 4px;
  background-color: white;
  cursor: grab;
  transition: all 0.2s ease;
  border: 1px solid var(--light-gray);
}

.node-item:hover {
  background-color: var(--light-gray);
  transform: translateY(-2px);
}

.node-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
  flex-shrink: 0;
}

.node-name {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Node Icon Colors */
.node-icon.blue { background-color: var(--blue); }
.node-icon.green { background-color: var(--green); }
.node-icon.red { background-color: var(--red); }
.node-icon.orange { background-color: var(--orange); }
.node-icon.purple { background-color: var(--purple); }
.node-icon.teal { background-color: var(--teal); }
.node-icon.yellow { background-color: var(--yellow); }
.node-icon.indigo { background-color: var(--indigo); }
.node-icon.blue-gray { background-color: var(--blue-gray); }

/* Workspace */
.workspace {
  flex-grow: 1;
  position: relative;
  overflow: hidden;
  width: calc(100% - var(--sidebar-width));
  height: 100%;
  background-color: var(--main-bg);
}

.grid {
  position: absolute;
  width: 100%;
  height: 100%;
  background-size: var(--grid-size) var(--grid-size);
  background-image: linear-gradient(to right, var(--grid-color) 1px, transparent 1px),
                    linear-gradient(to bottom, var(--grid-color) 1px, transparent 1px);
  z-index: 0;
}

.connections-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.nodes-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  overflow: visible;
}

.groups-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
}

/* Workspace Controls */
.workspace-controls {
  position: absolute;
  bottom: 15px;
  right: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10;
}

.zoom-controls, .group-controls {
  display: flex;
  gap: 5px;
  background-color: white;
  padding: 5px;
  border-radius: 4px;
  box-shadow: var(--node-shadow);
}

/* Minimap */
.minimap {
  position: absolute;
  bottom: 15px;
  left: 15px;
  width: 180px;
  height: 120px;
  background-color: white;
  border: 1px solid var(--medium-gray);
  border-radius: 4px;
  z-index: 10;
  overflow: hidden;
  box-shadow: var(--node-shadow);
}

.minimap-title {
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  background-color: var(--light-gray);
  border-bottom: 1px solid var(--medium-gray);
}

.minimap-content {
  width: 100%;
  height: calc(100% - 25px);
  position: relative;
}

/* Node Styles */
.node {
  position: absolute;
  min-width: 220px;
  background-color: white;
  border-radius: 6px;
  box-shadow: var(--node-shadow);
  user-select: none;
  z-index: 5;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s ease, opacity 0.2s ease, transform 0.1s ease;
  overflow: visible;
  border: 1px solid rgba(0,0,0,0.1);
}

.node.selected {
  box-shadow: 0 0 0 2px var(--primary-color), var(--node-shadow);
}

.node.dragging {
  opacity: 0.9;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  transform: scale(1.02);
  cursor: grabbing;
}

.node-header {
  height: var(--node-header-height);
  border-radius: 6px 6px 0 0;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white;
  font-weight: 500;
  cursor: grab;
}

.node-header .node-icon {
  width: 24px;
  height: 24px;
  margin-right: 8px;
  background-color: rgba(255, 255, 255, 0.2);
}

.node-title {
  flex-grow: 1;
  margin-right: 10px;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.node-controls {
  display: flex;
  gap: 6px;
}

.node-controls button {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: color 0.2s ease;
  padding: 0;
  font-size: 12px;
}

.node-controls button:hover {
  color: rgba(255, 255, 255, 1);
}

.node-content {
  padding: 10px;
  border-bottom: 1px solid var(--light-gray);
  background-color: white;
}

.input-group {
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-group:last-child {
  margin-bottom: 0;
}

.input-group label {
  font-size: 12px;
  color: var(--dark-gray);
}

.input-group input,
.input-group select,
.input-group textarea {
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid var(--medium-gray);
  font-size: 13px;
  width: 100%;
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
  outline: none;
  border-color: var(--primary-color);
}

/* Node inputs and outputs */
.node-inputs, .node-outputs {
  padding: 8px 10px;
  background-color: white;
}

.node-inputs {
  border-bottom: 1px solid var(--light-gray);
}

.node-outputs {
  border-radius: 0 0 6px 6px;
}

.input, .output {
  display: flex;
  align-items: center;
  margin: 8px 0;
  height: 26px;
  font-size: 13px;
  position: relative;
}

.input {
  padding-left: 10px;
}

.output {
  justify-content: flex-end;
  padding-right: 10px;
}

.input span, .output span {
  padding: 0 8px;
  color: var(--dark-gray);
}

.input-point, .output-point {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--medium-gray);
  border: 2px solid white;
  box-shadow: 0 0 0 1px var(--medium-gray);
  cursor: pointer;
  transition: all 0.2s ease;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
}

.input .input-point {
  left: -6px;
  margin-right: 8px;
}

.output .output-point {
  right: -6px;
  margin-left: 8px;
}

/* Connection point states */
.input-point:hover,
.output-point:hover,
.input-point.highlight {
  transform: scale(1.2);
  background-color: var(--primary-color);
  box-shadow: 0 0 0 1px var(--primary-color);
}

.input-point.connected,
.output-point.connected,
.input-point.active,
.output-point.active {
  background-color: var(--primary-color);
  box-shadow: 0 0 0 1px var(--primary-color);
}

/* Node color variants */
.node-header.blue { background-color: var(--blue); }
.node-header.green { background-color: var(--green); }
.node-header.red { background-color: var(--red); }
.node-header.orange { background-color: var(--orange); }
.node-header.purple { background-color: var(--purple); }
.node-header.teal { background-color: var(--teal); }
.node-header.yellow { background-color: var(--yellow); }
.node-header.indigo { background-color: var(--indigo); }
.node-header.blue-gray { background-color: var(--blue-gray); }

/* Tooltip */
.tooltip {
  position: fixed;
  padding: 6px 10px;
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  border-radius: 4px;
  font-size: 12px;
  pointer-events: none;
  z-index: 1000;
  display: none;
  max-width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Connection Styles */
.connection path {
  pointer-events: none;
}

.connection.temp path {
  animation: dash 1s linear infinite;
}

@keyframes dash {
  to {
    stroke-dashoffset: 20;
  }
}

/* Group Styles */
.group {
  position: absolute;
  border: 2px solid transparent;
  border-radius: 8px;
  background-color: rgba(0, 0, 0, 0.04);
  z-index: 4;
  cursor: move;
  transition: background-color 0.2s ease;
}

.group:hover {
  background-color: rgba(0, 0, 0, 0.06);
}

.group.selected {
  border-color: var(--primary-color);
  background-color: rgba(52, 152, 219, 0.05);
}

.group-header {
  padding: 5px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: #555;
  cursor: move;
}

.group-title {
  max-width: 150px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.group-controls {
  display: flex;
  gap: 4px;
}

.group-controls button {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: transparent;
  border: none;
  color: #777;
  cursor: pointer;
  transition: color 0.2s ease;
}

.group-controls button:hover {
  color: #333;
}

.group-resize-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  right: -5px;
  bottom: -5px;
  cursor: nwse-resize;
  background-color: white;
  border: 1px solid var(--medium-gray);
  border-radius: 50%;
}

/* Color picker */
.color-picker {
  position: absolute;
  padding: 10px;
  background-color: white;
  border-radius: 6px;
  box-shadow: var(--modal-shadow);
  z-index: 1000;
  display: none;
}

.color-picker-header {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #333;
}

.color-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.color-option {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.2s ease;
  border: 2px solid white;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.color-option:hover {
  transform: scale(1.1);
}

/* Context Menu */
.context-menu {
  position: absolute;
  width: 150px;
  background-color: white;
  border-radius: 6px;
  box-shadow: var(--modal-shadow);
  z-index: 1000;
  display: none;
  overflow: hidden;
}

.menu-item {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

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

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  width: 80%;
  max-width: 800px;
  background-color: white;
  border-radius: 8px;
  box-shadow: var(--modal-shadow);
  overflow: hidden;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 15px 20px;
  border-bottom: 1px solid var(--light-gray);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.close-modal {
  background-color: transparent;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--dark-gray);
  padding: 0;
  line-height: 1;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex-grow: 1;
}

.modal-body pre {
  background-color: #f5f5f5;
  padding: 15px;
  border-radius: 4px;
  border: 1px solid var(--light-gray);
  white-space: pre-wrap;
  overflow-x: auto;
  font-family: Consolas, Monaco, 'Andale Mono', monospace;
  font-size: 13px;
  line-height: 1.5;
  height: 300px;
  max-height: 400px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 15px;
}

/* Help button */
.help-button {
  position: fixed;
  right: 20px;
  bottom: 100px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 100;
  transition: all 0.2s ease;
}

.help-button:hover {
  transform: scale(1.1);
}

/* Body cursor state during connections */
body.connecting * {
  cursor: crosshair !important;
}

/* Optimizations for many nodes */
.workspace, .nodes-container, .connections-container, .groups-container {
  /* Use hardware acceleration */
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000;
  will-change: transform;
}

/* Efficient handling of many connections */
.connection path {
  will-change: d;
}

/* Optimize rendering for many nodes */
.node {
  contain: layout style;
}

/* Performance mode for many nodes */
.performance-mode .node {
  transition: none;
}

.performance-mode .connection {
  transition: none;
}

/* Quick generate button animation */
.quick-gen-button {
  animation: floatAnimation 2s infinite alternate ease-in-out;
}

@keyframes floatAnimation {
  0% { transform: translateY(0); }
  100% { transform: translateY(-5px); }
}

/* Loading indicator for batch operations */
.loading-indicator {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 20px;
  border-radius: 8px;
  z-index: 1000;
  display: none;
  align-items: center;
  gap: 10px;
}

.loading-indicator.active {
  display: flex;
}

.loading-spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Media queries for responsiveness */
@media (max-width: 1200px) {
  .sidebar {
    width: 240px;
  }
  
  .workspace {
    width: calc(100% - 240px);
  }
}

@media (max-width: 992px) {
  .sidebar {
    width: 220px;
  }
  
  .workspace {
    width: calc(100% - 220px);
  }
  
  .node {
    min-width: 180px;
  }
}

@media (max-width: 768px) {
  .header-actions {
    display: none;
  }
  
  .main-container {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--medium-gray);
  }
  
  .workspace {
    width: 100%;
    height: calc(100% - 200px);
  }
  
  .workspace-controls {
    flex-direction: row;
  }
}