/* Code Editor Module Styles */
.codeeditor-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.codeeditor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-xs) var(--spacing-sm);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  gap: var(--spacing-sm);
}

.codeeditor-tabs {
  display: flex;
  gap: 2px;
}

.codeeditor-tab {
  padding: var(--spacing-xs) var(--spacing-sm);
  background: var(--bg-tertiary);
  border: none;
  border-radius: 4px 4px 0 0;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.codeeditor-tab.active {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.codeeditor-actions {
  display: flex;
  gap: var(--spacing-xs);
}

.codeeditor-btn {
  padding: var(--spacing-xs) var(--spacing-sm);
  background: var(--accent-primary);
  border: none;
  border-radius: 4px;
  color: white;
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.codeeditor-btn:hover {
  opacity: 0.8;
}

.codeeditor-btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.codeeditor-main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.codeeditor-editor-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.codeeditor-editor-wrapper {
  flex: 1;
  overflow: auto;
}

.codeeditor-editor-wrapper .cm-editor {
  height: 100%;
}

.codeeditor-editor-wrapper .cm-scroller {
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.5;
}

.codeeditor-editor-wrapper .cm-content {
  padding: var(--spacing-sm) 0;
}

.codeeditor-editor-wrapper .cm-gutters {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  color: var(--text-muted);
}

.codeeditor-editor-wrapper .cm-activeLineGutter {
  background: var(--bg-tertiary);
}

.codeeditor-editor-wrapper .cm-activeLine {
  background: rgba(255, 255, 255, 0.05);
}

/* Override CodeMirror syntax colors for better legibility */
.codeeditor-editor-wrapper .cm-variableName {
  color: #e06c75;
}

.codeeditor-editor-wrapper .cm-variableName.cm-definition {
  color: #61afef;
}

.codeeditor-editor-wrapper .cm-propertyName {
  color: #e5c07b;
}

.codeeditor-editor-wrapper .cm-variableName.cm-local {
  color: #e06c75;
}

.codeeditor-divider {
  width: 4px;
  background: var(--border-color);
  cursor: col-resize;
  transition: background var(--transition-fast);
}

.codeeditor-divider:hover {
  background: var(--accent-primary);
}

.codeeditor-preview-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.codeeditor-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-xs) var(--spacing-sm);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.codeeditor-console-toggle {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.codeeditor-console-toggle:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.codeeditor-console-toggle.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

.codeeditor-preview-frame {
  flex: 1;
  border: none;
  background: white;
}

.codeeditor-hidden {
  display: none !important;
}

/* Save Dialog */
.codeeditor-save-dialog {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.codeeditor-save-dialog-content {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: var(--spacing-lg);
  min-width: 280px;
}

.codeeditor-save-dialog-content h3 {
  margin: 0 0 var(--spacing-sm) 0;
  font-size: var(--font-size-base);
  color: var(--text-primary);
}

.codeeditor-save-input {
  width: 100%;
  padding: var(--spacing-xs) var(--spacing-sm);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  margin-bottom: var(--spacing-sm);
  box-sizing: border-box;
}

.codeeditor-save-input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.codeeditor-save-actions {
  display: flex;
  gap: var(--spacing-xs);
  justify-content: flex-end;
}

/* Pages Panel */
.codeeditor-pages-panel {
  position: absolute;
  top: 40px;
  right: 8px;
  width: 240px;
  max-height: 300px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 90;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.codeeditor-pages-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-bottom: 1px solid var(--border-color);
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.codeeditor-pages-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
}

.codeeditor-pages-close:hover {
  color: var(--text-primary);
}

.codeeditor-pages-list {
  overflow-y: auto;
  flex: 1;
}

.codeeditor-pages-empty {
  padding: var(--spacing-md);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

.codeeditor-pages-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-bottom: 1px solid var(--border-color);
}

.codeeditor-pages-item.active {
  background: var(--bg-secondary);
}

.codeeditor-pages-item:last-child {
  border-bottom: none;
}

.codeeditor-pages-item-name {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.codeeditor-pages-item-actions {
  display: flex;
  gap: 4px;
  margin-left: var(--spacing-xs);
}

.codeeditor-pages-load,
.codeeditor-pages-delete {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 3px;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 6px;
}

.codeeditor-pages-load:hover {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}

.codeeditor-pages-delete:hover {
  background: var(--accent-danger, #e74c3c);
  color: white;
  border-color: var(--accent-danger, #e74c3c);
}

/* Console Panel */
.codeeditor-console {
  display: flex;
  flex-direction: column;
  height: 150px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-primary);
}

.codeeditor-console.codeeditor-hidden {
  display: none;
}

.codeeditor-console-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-xs) var(--spacing-sm);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  flex-shrink: 0;
}

.codeeditor-console-clear {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 3px;
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.codeeditor-console-clear:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.codeeditor-console-output {
  flex: 1;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: var(--spacing-xs);
}

.codeeditor-console-entry {
  display: flex;
  gap: var(--spacing-sm);
  padding: 3px var(--spacing-xs);
  border-bottom: 1px solid var(--border-color);
}

.codeeditor-console-entry:last-child {
  border-bottom: none;
}

.codeeditor-console-time {
  color: var(--text-muted);
  flex-shrink: 0;
  font-size: 11px;
}

.codeeditor-console-msg {
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-all;
}

/* Console message types */
.codeeditor-console-log .codeeditor-console-msg {
  color: var(--text-primary);
}

.codeeditor-console-info .codeeditor-console-msg {
  color: #3498db;
}

.codeeditor-console-warn {
  background: rgba(241, 196, 15, 0.1);
}

.codeeditor-console-warn .codeeditor-console-msg {
  color: #f1c40f;
}

.codeeditor-console-error {
  background: rgba(231, 76, 60, 0.1);
}

.codeeditor-console-error .codeeditor-console-msg {
  color: #e74c3c;
}
