/**
 * Enhanced Editor Styles
 * Improved styling for both CodeMirror and Monaco Editor
 */

/* Editor Container */
.latex-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  /* border-right removed — h-resizer handles visual separation */
  /* background removed - let Monaco use its native vs-dark/vs theme background */
}

.preview-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--workspace-bg-secondary);
}

/* Panel Headers — base defined in shared/collapsible-panel.css */

/* CodeMirror Enhancements */
.CodeMirror {
  font-family:
    "Monaco", "Menlo", "Ubuntu Mono", "Consolas", monospace !important;
  font-size: 13px !important;
  line-height: 1.5 !important;
  height: 100% !important;
}

.CodeMirror-linenumber {
  color: var(--text-muted);
  background: var(--workspace-bg-secondary);
}

.CodeMirror-selected {
  background: rgba(0, 123, 255, 0.15) !important;
}

.CodeMirror-cursor {
  border-left: 2px solid var(--color-accent-fg) !important;
}

/* LaTeX Editor Textarea */
.latex-editor-textarea {
  flex: 1;
  border: none;
  padding: 1rem;
  font-family: "Monaco", "Menlo", "Ubuntu Mono", "Consolas", monospace;
  font-size: 13px;
  line-height: 1.5;
  resize: none;
  background: var(--bg-page);
  color: var(--text-primary);
}

.latex-editor-textarea:focus {
  outline: none;
}

/* Text Preview */
.text-preview {
  flex: 1;
  min-height: 0; /* Allow flex shrinking */
  padding: 0; /* No padding - let PDF viewer fill entire space */
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
}

.text-preview h1,
.text-preview h2,
.text-preview h3 {
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
  font-weight: 600;
}

.text-preview h1 {
  font-size: 1.5rem;
  border-bottom: 2px solid var(--workspace-border-default);
  padding-bottom: 0.5rem;
}

.text-preview h2 {
  font-size: 1.25rem;
}

.text-preview h3 {
  font-size: 1.1rem;
}

.text-preview p {
  margin: 0.5rem 0;
}

.text-preview code {
  background: var(--bg-page);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: "Monaco", "Menlo", "Consolas", monospace;
  font-size: 0.9em;
  color: var(--color-accent-fg);
}

.text-preview blockquote {
  border-left: 3px solid var(--color-accent-fg);
  padding-left: 1rem;
  margin-left: 0;
  color: var(--text-muted);
  font-style: italic;
}

/* Split View Layout */
.editor-content-wrapper {
  flex: 1;
  display: flex;
  overflow: visible; /* Changed from hidden to visible to allow Monaco suggestions to overflow */
}

.split-view {
  display: none;
  flex: 1;
  min-width: 0;
}

.split-view.active {
  display: flex;
}

.split-view {
  gap: 0;
}

.split-view > .latex-panel,
.split-view > .preview-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: visible; /* Changed from hidden to visible to allow Monaco suggestions to overflow */
}

/* Resizer - 4px hit area, matches shared panel-resizer.css */
.split-view > .panel-resizer {
  flex: 0 0 4px;
  z-index: 5;
  position: relative;
}

/* Toolbar Styling */
.writer-toolbar-sticky {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.25rem 1rem; /* Reduced from 0.75rem to 0.25rem */
}

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

.toolbar-center {
  flex: 1;
  justify-content: center;
}

/* Button Styling - Workspace flat design */
.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  border-radius: 0; /* Flat design matching workspace */
  background: transparent;
  border: none;
  transition: all 0.15s ease;
}

.btn-sm:hover {
  background: var(--workspace-bg-tertiary);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Save Status Indicator */
.save-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--color-success-fg);
}

.save-status.unsaved {
  color: var(--status-warning);
}

.save-status i {
  animation: fadeInOut 0.5s ease-in-out;
}

@keyframes fadeInOut {
  0% {
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 1;
  }
}

/* Theme Selector */
#theme-selector {
  min-width: 140px;
  font-size: 0.85rem;
}

/* Responsive Design */
@media (max-width: 768px) {
  .latex-panel,
  .preview-panel {
    padding: 0;
  }

  .panel-header {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }

  .CodeMirror {
    font-size: 12px !important;
  }

  .text-preview {
    font-size: 13px;
    padding: 0; /* No padding on mobile either */
  }

  .writer-toolbar-sticky {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.25rem; /* Reduced from 0.5rem to 0.25rem */
  }

  .toolbar-left,
  .toolbar-center,
  .toolbar-right {
    gap: 0.35rem;
  }
}

/* Dark theme - workspace colors */
[data-theme="dark"] .preview-panel {
  background: var(--workspace-bg-primary);
}

[data-theme="dark"] .CodeMirror-linenumber {
  background: var(--workspace-bg-primary);
}

/* Print Styles */
@media print {
  .latex-editor-textarea,
  .CodeMirror,
  .writer-toolbar-sticky {
    display: none !important;
  }

  .text-preview {
    padding: 0;
    background: var(--bg-surface);
    color: var(--text-primary);
  }
}
