* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  min-height: 100vh;
  overflow: hidden;
}

.editor-layout {
  display: flex;
  height: 100vh;
  gap: 0;
}

/* Left Panel: Inputs */
.input-panel {
  display: flex;
  flex-direction: row;
  background: #1e293b;
  border-right: 1px solid #334155;
  overflow: hidden;
  position: relative;
  transition: width 0.3s ease;
  width: 40%;
}

.input-panel.collapsed {
  width: 48px;
}

.input-panel.collapsed .panel-content {
  display: none;
}

.panel-content {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 1rem;
  gap: 1.5rem;
  flex: 1;
}

.sidebar-toggle {
  position: absolute;
  top: 1rem;
  right: 0.5rem;
  z-index: 10;
  width: 32px;
  height: 32px;
  background: #334155;
  border: 1px solid #475569;
  border-radius: 4px;
  color: #e2e8f0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.sidebar-toggle:hover {
  background: #475569;
}

.input-panel.collapsed .sidebar-toggle {
  position: static;
  margin: 0.5rem;
}

.toggle-icon {
  transition: transform 0.3s ease;
  font-size: 0.75rem;
}

.input-panel.collapsed .toggle-icon {
  transform: rotate(180deg);
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.panel-section h2 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
}

#mermaid-input {
  width: 100%;
  min-height: 200px;
  padding: 0.75rem;
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 6px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.875rem;
  line-height: 1.5;
  resize: vertical;
}

#mermaid-input:focus {
  outline: none;
  border-color: #3b82f6;
}

#mermaid-input.has-error {
  border-color: #ef4444;
}

#json-editor .CodeMirror.cm-error {
  border-color: #ef4444;
}

/* DSL Tabs */
.dsl-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.tab-btn {
  padding: 0.5rem 1rem;
  background: #334155;
  color: #e2e8f0;
  border: 1px solid #475569;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  font-size: 0.875rem;
  transition: background 0.15s;
}

.tab-btn:hover {
  background: #475569;
}

.tab-btn.active {
  background: #1e293b;
  border-bottom-color: #1e293b;
  color: #3b82f6;
}

.tab-content {
  display: none;
  flex-direction: column;
  gap: 0.5rem;
}

.tab-content.active {
  display: flex;
}

.editor-toolbar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.toolbar-btn {
  padding: 0.4rem 0.8rem;
  background: #334155;
  color: #e2e8f0;
  border: 1px solid #475569;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: background 0.15s;
}

.toolbar-btn:hover {
  background: #475569;
}

#json-editor {
  min-height: 300px;
  border: 1px solid #334155;
  border-radius: 6px;
  overflow: hidden;
}

#json-editor .CodeMirror {
  height: 100%;
  min-height: 300px;
  background: #0f172a;
  color: #e2e8f0;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.875rem;
}

#json-editor .CodeMirror-scroll {
  min-height: 300px;
}

.error-message {
  padding: 0.75rem;
  background: #7f1d1d;
  color: #fca5a5;
  border-radius: 4px;
  font-size: 0.75rem;
  display: none;
  border-left: 3px solid #ef4444;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 150px;
  overflow-y: auto;
}

.error-message.show {
  display: block;
}

.error-message .error-line {
  color: #fca5a5;
  font-weight: 600;
}

.error-message .error-details {
  color: #fca5a5;
  opacity: 0.9;
  margin-top: 0.25rem;
}

/* Right Panel: Preview */
.preview-panel {
  display: flex;
  flex-direction: column;
  background: #0f172a;
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: #1e293b;
  border-bottom: 1px solid #334155;
}

.preview-header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.preview-controls {
  display: flex;
  gap: 0.5rem;
}

.control-btn {
  padding: 0.4rem 0.8rem;
  background: #334155;
  color: #e2e8f0;
  border: 1px solid #475569;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: background 0.15s;
}

.control-btn:hover {
  background: #475569;
}

.control-btn:disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
  pointer-events: none;
}

.diagram-preview {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  padding: 1rem;
  overflow: hidden;
  position: relative;
}

/* Cursor style is handled by the camera handle's drag-to-pan functionality */

.diagram-preview .finsteps-diagram {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.diagram-preview .finsteps-diagram svg {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

.dataids-panel {
  padding: 1rem;
  background: #1e293b;
  border-top: 1px solid #334155;
  max-height: 200px;
  overflow-y: auto;
}

.dataids-panel h3 {
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #94a3b8;
}

.dataids-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.dataid-chip {
  padding: 0.25rem 0.5rem;
  background: #334155;
  color: #e2e8f0;
  border: 1px solid #475569;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.15s;
}

.dataid-chip:hover {
  background: #475569;
  border-color: #3b82f6;
}

.navigation-sidebar {
  padding: 1rem;
  background: #1e293b;
  border-top: 1px solid #334155;
  max-height: 200px;
  overflow-y: auto;
}

.navigation-sidebar h3 {
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #94a3b8;
}

.nav-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-btn {
  padding: 0.5rem;
  background: #334155;
  color: #e2e8f0;
  border: 1px solid #475569;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  text-align: left;
  transition: background 0.15s;
}

.nav-btn:hover {
  background: #475569;
}

.nav-btn.active {
  background: #3b82f6;
  border-color: #60a5fa;
  color: #fff;
}

.empty-state {
  color: #64748b;
  font-size: 0.75rem;
  font-style: italic;
  margin: 0;
}

.finsteps-highlight {
  filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.8));
}

rect.finsteps-highlight,
polygon.finsteps-highlight,
path.finsteps-highlight,
g.finsteps-highlight,
line.finsteps-highlight,
text.finsteps-highlight {
  stroke: #3b82f6 !important;
  stroke-width: 3px !important;
  stroke-opacity: 0.9 !important;
}

/* Visual Builder Styles */
.visual-builder {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  max-height: 500px;
  overflow-y: auto;
}

.builder-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.builder-header h3 {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: #e2e8f0;
}

.steps-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.actions-section {
  margin-top: 1rem;
}

.actions-section label {
  display: block;
  font-size: 0.75rem;
  color: #94a3b8;
  margin-bottom: 0.5rem;
}

.action-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
  color: #94a3b8;
}

.step-item {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 1rem;
}

.step-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.step-title {
  font-weight: 600;
  color: #e2e8f0;
}

.step-actions-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.action-item {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 4px;
  padding: 0.75rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}

.form-group label {
  font-size: 0.75rem;
  color: #94a3b8;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 0.5rem;
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 4px;
  font-size: 0.875rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #3b82f6;
}

.btn-small {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  background: #334155;
  color: #e2e8f0;
  border: 1px solid #475569;
  border-radius: 4px;
  cursor: pointer;
}

.btn-small:hover {
  background: #475569;
}

.btn-danger {
  background: #7f1d1d;
  border-color: #991b1b;
}

.btn-danger:hover {
  background: #991b1b;
}

/* Error line highlighting in CodeMirror */
.cm-error-line {
  background: rgba(239, 68, 68, 0.1) !important;
}

/* Responsive */
@media (max-width: 1024px) {
  .editor-layout {
    flex-direction: column;
  }
  
  .input-panel {
    width: 100%;
    height: 50vh;
  }
  
  .input-panel.collapsed {
    height: 48px;
    width: 100%;
  }
  
  .preview-panel {
    height: 50vh;
  }
}

/* ==================================================
   SIMPLIFIED EDITOR - LEFT COLLAPSING PANELS
   ================================================== */

/* Left panels container */
.left-panels {
  display: flex;
  flex-direction: column;
  width: 450px;
  background: #1e293b;
  border-right: 1px solid #334155;
  transition: width 0.3s ease, margin-left 0.3s ease;
  position: relative;
  overflow: hidden;
}

.left-panels.collapsed {
  width: 0;
  margin-left: -450px;
  border-right: none;
}

/* Individual panes within left panels */
.input-pane {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid #334155;
  min-height: 0;
}

.input-pane:last-child {
  border-bottom: none;
  flex: 1;
}

.pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: #1e293b;
  border-bottom: 1px solid #334155;
}

.pane-header h2 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #cbd5e1;
}

.pane-toggle {
  width: 24px;
  height: 24px;
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}

.pane-toggle:hover {
  background: #334155;
  color: #e2e8f0;
}

.toggle-icon {
  transition: transform 0.2s ease;
  font-size: 0.75rem;
}

.input-pane.collapsed .toggle-icon {
  transform: rotate(-90deg);
}

.pane-content {
  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: 0.75rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.input-pane.collapsed .pane-content {
  display: none;
}

/* Toolbar styles */
.toolbar-btn.primary {
  background: #3b82f6;
  border-color: #2563eb;
  font-weight: 500;
}

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

/* Help text */
.editor-help {
  font-size: 0.75rem;
  color: #94a3b8;
  line-height: 1.5;
  padding: 0.5rem;
  background: #0f172a;
  border-radius: 4px;
  border-left: 2px solid #475569;
}

.editor-help p {
  margin: 0;
}

/* MPD Editor specific styles */
#mpd-editor {
  min-height: 400px;
  border: 1px solid #334155;
  border-radius: 6px;
  overflow: hidden;
  flex: 1;
}

#mpd-editor .CodeMirror {
  height: 100%;
  min-height: 400px;
  max-height: 400px;
  background: #0f172a;
  color: #e2e8f0;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.875rem;
}

#mpd-editor .CodeMirror-scroll {
  max-height: 400px;
  overflow-y: auto;
}

/* Hide cursor when editor is not focused */
#mpd-editor .CodeMirror:not(.CodeMirror-focused) .CodeMirror-cursor {
  visibility: hidden;
}

/* ==================================================
   PRESENTATION CONTROLS
   ================================================== */

.presentation-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem;
  background: #0f172a;
  border-bottom: 1px solid #334155;
}

.pres-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 50%;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1.25rem;
}

.pres-btn:hover {
  background: #334155;
  border-color: #475569;
  color: #e2e8f0;
  transform: scale(1.05);
}

.pres-btn:active {
  transform: scale(0.95);
}

.pres-btn.primary {
  width: 56px;
  height: 56px;
  background: #3b82f6;
  border-color: #2563eb;
  color: white;
  font-size: 1.5rem;
}

.pres-btn.primary:hover {
  background: #2563eb;
  border-color: #1d4ed8;
}

.pres-btn.primary.playing {
  background: #ef4444;
  border-color: #dc2626;
}

.pres-btn.primary.playing:hover {
  background: #dc2626;
  border-color: #b91c1c;
}

.pres-btn:disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
  transform: none !important;
}

.btn-icon {
  display: inline-block;
  line-height: 1;
}

.step-indicator {
  margin-left: 1rem;
  padding: 0.5rem 1rem;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 6px;
  color: #94a3b8;
  font-size: 0.875rem;
  font-family: monospace;
  min-width: 120px;
  text-align: center;
}

/* Panel toggle button on collapsed state */
.panels-toggle-btn {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 64px;
  background: #1e293b;
  border: 1px solid #334155;
  border-left: none;
  border-radius: 0 6px 6px 0;
  color: #94a3b8;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: background 0.15s, color 0.15s;
}

.left-panels.collapsed + * .panels-toggle-btn,
.left-panels.collapsed ~ .panels-toggle-btn {
  display: flex;
}

.panels-toggle-btn:hover {
  background: #334155;
  color: #e2e8f0;
}

