/* Markdown Editor Styles
   Uses site CSS variables for consistent theming */

/* ============================================================================
   Edit Modal
   ============================================================================ */

.edit-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.edit-modal {
  background: var(--bg-primary, #fff);
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.edit-modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--text-primary, #333);
}

.edit-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-secondary, #666);
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}

.edit-modal-close:hover {
  color: var(--text-primary, #333);
}

.edit-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.edit-modal-field {
  margin-bottom: 1.5rem;
}

.edit-modal-field:last-child {
  margin-bottom: 0;
}

.edit-modal-field label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-primary, #333);
}

.edit-modal-input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color, #ccc);
  border-radius: 4px;
  font-size: 1rem;
  background: var(--bg-primary, #fff);
  color: var(--text-primary, #333);
}

.edit-modal-input:focus {
  outline: none;
  border-color: var(--link-color, #0066cc);
  box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.1);
}

.edit-modal-input::placeholder {
  color: var(--text-light, #999);
}

.edit-modal-error {
  margin-top: 1rem;
  padding: 0.75rem;
  border-radius: 4px;
  background: var(--message-error-bg, #fee);
  color: var(--message-error-color, #c00);
  font-size: 0.875rem;
}

.edit-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color, #e0e0e0);
  background: var(--bg-secondary, #f9f9f9);
}

.edit-modal-btn {
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

.edit-modal-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.edit-modal-btn-cancel {
  background: var(--bg-primary, #fff);
  color: var(--text-primary, #333);
  border: 1px solid var(--border-color, #ccc);
}

.edit-modal-btn-cancel:hover:not(:disabled) {
  background: var(--bg-secondary, #f0f0f0);
}

.edit-modal-btn-save {
  background: var(--link-color, #0066cc);
  color: #fff;
}

.edit-modal-btn-save:hover:not(:disabled) {
  background: var(--link-hover, #0052a3);
}

/* ============================================================================
   Folder Title and Edit Icon
   ============================================================================ */

.folder-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.folder-title-row .folder-title {
  margin: 0;
}

.folder-edit-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-light, #999);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.folder-edit-icon:hover {
  background: var(--bg-secondary, #f0f0f0);
  color: var(--link-color, #0066cc);
}

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

/* ============================================================================
   Image Title and Edit Icon
   ============================================================================ */

.image-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.image-title-row .image-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary, #333);
}

.image-title-placeholder {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-light, #999);
  font-style: italic;
}

.image-edit-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-light, #999);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.image-edit-icon:hover {
  background: var(--bg-secondary, #f0f0f0);
  color: var(--link-color, #0066cc);
}

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

/* ============================================================================
   Markdown Editor (TipTap)
   ============================================================================ */

.markdown-editor {
  position: relative;
}

/* Mode toggle button */
.editor-mode-toggle {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.5rem;
}

.editor-mode-btn {
  padding: 0.25rem 0.625rem;
  border: 1px solid var(--border-color, #ccc);
  border-radius: 4px;
  background: var(--bg-secondary, #f5f5f5);
  color: var(--text-secondary, #666);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.editor-mode-btn:hover {
  background: var(--bg-primary, #fff);
  border-color: var(--link-color, #0066cc);
  color: var(--text-primary, #333);
}

/* Markdown textarea (raw mode) */
.markdown-editor-textarea {
  width: 100%;
  min-height: 150px;
  padding: 0.75rem;
  border: 1px solid var(--border-color, #ccc);
  border-radius: 4px;
  background: var(--bg-primary, #fff);
  color: var(--text-primary, #333);
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
  font-size: 0.875rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
}

.markdown-editor-textarea:focus {
  border-color: var(--link-color, #0066cc);
  box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.1);
}

.markdown-editor-textarea::placeholder {
  color: var(--text-light, #999);
}

.markdown-editor-content {
  min-height: 150px;
  padding: 0.75rem;
  border: 1px solid var(--border-color, #ccc);
  border-radius: 0 0 4px 4px;
  background: var(--bg-primary, #fff);
  color: var(--text-primary, #333);
  line-height: 1.6;
  outline: none;
}

.markdown-editor-content:focus {
  border-color: var(--link-color, #0066cc);
  box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.1);
}

/* Placeholder text */
.markdown-editor-content p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  color: var(--text-light, #999);
  pointer-events: none;
  position: absolute;
  height: 0;
}

/* Editor Toolbar */
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  background: var(--bg-secondary, #f5f5f5);
  border: 1px solid var(--border-color, #ccc);
  border-radius: 4px 4px 0 0;
  border-bottom: none;
}

.editor-toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--text-secondary, #666);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.editor-toolbar-btn:hover {
  background: var(--bg-primary, #fff);
  border-color: var(--border-color, #ccc);
  color: var(--text-primary, #333);
}

.editor-toolbar-btn.is-active {
  background: var(--link-color, #0066cc);
  border-color: var(--link-color, #0066cc);
  color: #fff;
}

.editor-toolbar-btn.is-active:hover {
  background: var(--link-hover, #0052a3);
  border-color: var(--link-hover, #0052a3);
}

.editor-toolbar-divider {
  width: 1px;
  height: 1.5rem;
  margin: 0.25rem 0.25rem;
  background: var(--border-color, #ccc);
}

/* Adjust editor content when toolbar is present */
.editor-toolbar + .tiptap,
.editor-toolbar + div > .tiptap {
  border-radius: 0 0 4px 4px;
}

/* Bubble menu (floating toolbar) - kept for potential future use */
.bubble-menu {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--bg-primary, #fff);
  border: 1px solid var(--border-color, #ccc);
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.bubble-menu button {
  padding: 0.25rem 0.5rem;
  border: none;
  border-radius: 2px;
  background: transparent;
  color: var(--text-primary, #333);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  min-width: 2rem;
  transition: background-color 0.15s ease;
}

.bubble-menu button:hover {
  background: var(--bg-secondary, #f0f0f0);
}

.bubble-menu button.is-active {
  background: var(--link-color, #0066cc);
  color: #fff;
}

/* Editor action buttons (when shown outside modal) */
.editor-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color, #eee);
}

.editor-save-btn,
.editor-cancel-btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

.editor-save-btn {
  background: var(--link-color, #0066cc);
  color: #fff;
}

.editor-save-btn:hover:not(:disabled) {
  background: var(--link-hover, #0052a3);
}

.editor-save-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.editor-cancel-btn {
  background: var(--bg-primary, #fff);
  color: var(--text-primary, #333);
  border: 1px solid var(--border-color, #ccc);
}

.editor-cancel-btn:hover:not(:disabled) {
  background: var(--bg-secondary, #f0f0f0);
}

.editor-cancel-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.editor-shortcuts {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-light, #999);
}

/* Error message */
.editor-error {
  margin-top: 0.5rem;
  padding: 0.5rem;
  border-radius: 4px;
  background: var(--message-error-bg, #fee);
  color: var(--message-error-color, #c00);
  font-size: 0.875rem;
}

/* ============================================================================
   TipTap ProseMirror Content Styles
   ============================================================================ */

.ProseMirror {
  outline: none;
}

.ProseMirror > * + * {
  margin-top: 0.75em;
}

.ProseMirror h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 0;
  margin-bottom: 0.75rem;
  color: var(--text-primary, #333);
}

.ProseMirror h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary, #333);
}

.ProseMirror h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary, #333);
}

.ProseMirror p {
  color: var(--text-primary, #333);
}

.ProseMirror ul,
.ProseMirror ol {
  padding-left: 1.5rem;
  color: var(--text-primary, #333);
}

.ProseMirror code {
  background: var(--code-bg, #f5f5f5);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.9em;
}

.ProseMirror pre {
  background: var(--code-bg, #f5f5f5);
  padding: 0.75rem 1rem;
  border-radius: 4px;
  overflow-x: auto;
}

.ProseMirror pre code {
  background: none;
  padding: 0;
}

.ProseMirror blockquote {
  border-left: 3px solid var(--link-color, #0066cc);
  padding-left: 1rem;
  color: var(--text-secondary, #666);
  margin-left: 0;
}

.ProseMirror a {
  color: var(--link-color, #0066cc);
  text-decoration: underline;
}

.ProseMirror a:hover {
  color: var(--link-hover, #004499);
}

/* ============================================================================
   Mobile Responsiveness
   ============================================================================ */

@media (max-width: 600px) {
  .edit-modal-overlay {
    padding: 0;
  }

  .edit-modal {
    max-height: 100vh;
    border-radius: 0;
  }

  .edit-modal-header {
    padding: 0.875rem 1rem;
  }

  .edit-modal-body {
    padding: 1rem;
  }

  .edit-modal-footer {
    padding: 0.875rem 1rem;
  }

  .edit-modal-btn {
    padding: 0.75rem 1rem;
  }
}
