/* Content Editor - Award-winning, intuitive editing experience */

/* Editor Overlay Base */
.content-editor-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: none;
  flex-direction: column;
  background: var(--bg-primary, #fff);
  transition: opacity 0.25s ease, transform 0.25s ease;
  opacity: 0;
  transform: translateY(20px);
}

.content-editor-overlay.active {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

/* Editor Header */
.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-secondary, #f8f9fa);
  border-bottom: 1px solid var(--border-color, #e0e0e0);
  flex-shrink: 0;
  min-height: 56px;
}

.editor-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.editor-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--fg-primary, #333);
  transition: background 0.15s ease;
  flex-shrink: 0;
}

.editor-close-btn:hover {
  background: var(--hover-bg, rgba(0,0,0,0.06));
}

.editor-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--fg-primary, #333);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.editor-content-type {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--fg-secondary, #666);
  background: var(--badge-bg, rgba(0,0,0,0.06));
  padding: 4px 8px;
  border-radius: 4px;
  flex-shrink: 0;
}

.editor-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Editor Buttons */
.editor-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.editor-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.editor-btn-icon {
  padding: 8px;
  width: 40px;
  height: 40px;
}

.editor-btn-ghost {
  background: transparent;
  color: var(--fg-primary, #333);
}

.editor-btn-ghost:hover {
  background: var(--hover-bg, rgba(0,0,0,0.06));
}

.editor-btn-outline {
  background: transparent;
  color: var(--fg-primary, #333);
  border: 1px solid var(--border-color, #e0e0e0);
}

.editor-btn-outline:hover {
  background: var(--hover-bg, rgba(0,0,0,0.04));
  border-color: var(--border-hover, #ccc);
}

.editor-btn-primary {
  background: #1d4ed8;
  color: #fff;
}

.editor-btn-primary:hover {
  background: #1e40af;
}

.editor-btn-primary:disabled {
  background: #93c5fd;
  cursor: not-allowed;
}

.editor-btn-restore {
  background: transparent;
  color: #7c3aed;
  border: 1px solid #7c3aed;
}

.editor-btn-restore:hover {
  background: rgba(124, 58, 237, 0.08);
}

.editor-btn-danger {
  background: transparent;
  color: #dc2626;
}

.editor-btn-danger:hover {
  background: rgba(220, 38, 38, 0.08);
}

/* Status Indicator */
.editor-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--fg-secondary, #666);
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--status-bg, transparent);
}

.editor-status.modified {
  color: #d97706;
  background: rgba(217, 119, 6, 0.1);
}

.editor-status.saved {
  color: #059669;
  background: rgba(5, 150, 105, 0.1);
}

.editor-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Editor Layout */
.editor-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Desktop Split View */
.editor-bible-pane {
  display: none;
  flex: 1;
  border-right: 1px solid var(--border-color, #e0e0e0);
  overflow: hidden;
  background: var(--bg-primary, #fff);
}

.editor-bible-pane iframe {
  width: 100%;
  height: 100%;
  border: none;
}

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

/* Editor Toolbar */
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: var(--bg-secondary, #f8f9fa);
  border-bottom: 1px solid var(--border-light, #eee);
  overflow-x: auto;
  flex-shrink: 0;
}

.editor-toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.editor-toolbar-separator {
  width: 1px;
  height: 24px;
  background: var(--border-color, #e0e0e0);
  margin: 0 8px;
}

.editor-toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--fg-secondary, #666);
  transition: all 0.12s ease;
}

.editor-toolbar-btn:hover {
  background: var(--hover-bg, rgba(0,0,0,0.06));
  color: var(--fg-primary, #333);
}

.editor-toolbar-btn.active {
  background: var(--active-bg, rgba(29, 78, 216, 0.12));
  color: #1d4ed8;
}

.editor-toolbar-btn svg {
  width: 18px;
  height: 18px;
}

/* Text-based toolbar buttons */
.editor-toolbar-text-btn {
  padding: 6px 12px;
  border: 1px solid var(--border-color, #e0e0e0);
  background: var(--bg-primary, #fff);
  border-radius: 6px;
  cursor: pointer;
  color: var(--fg-secondary, #666);
  font-size: 0.8125rem;
  font-weight: 500;
  transition: all 0.12s ease;
  white-space: nowrap;
}

.editor-toolbar-text-btn:hover {
  background: var(--hover-bg, rgba(0,0,0,0.04));
  color: var(--fg-primary, #333);
  border-color: var(--fg-tertiary, #999);
}

.editor-toolbar-text-btn.active {
  background: rgba(29, 78, 216, 0.1);
  color: #1d4ed8;
  border-color: #1d4ed8;
}

/* Editor Mode Toggle - Segmented Control */
.editor-mode-toggle {
  display: flex;
  align-items: center;
  background: var(--bg-tertiary, rgba(0, 0, 0, 0.06));
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

[data-theme="dark"] .editor-mode-toggle,
[data-theme="oled"] .editor-mode-toggle {
  background: rgba(255, 255, 255, 0.08);
}

.toggle-option {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-tertiary, #888);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  white-space: nowrap;
}

.toggle-option:hover {
  color: var(--fg-secondary, #666);
}

.toggle-option.active {
  background: var(--bg-primary, #fff);
  color: var(--fg-primary, #333);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .toggle-option.active,
[data-theme="oled"] .toggle-option.active {
  background: rgba(255, 255, 255, 0.15);
  color: var(--fg, #fff);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Hide old toggle elements */
.toggle-label,
.toggle-switch,
.toggle-knob {
  display: none;
}

/* Hide fullscreen button on mobile - editor is already fullscreen */
@media (max-width: 768px) {
  #editor-fullscreen-btn {
    display: none;
  }
}

/* Editor Content Area */
.editor-content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary, #fff);
}

.editor-textarea {
  flex: 1;
  width: 100%;
  padding: 24px;
  border: none;
  outline: none;
  resize: none;
  font-family: 'Georgia', 'Libre Baskerville', serif;
  font-size: 1.1rem;
  line-height: 1.8;
  color: var(--fg-primary, #333);
  background: var(--bg-primary, #fff);
  overflow-y: auto;
}

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

.editor-textarea::placeholder {
  color: var(--fg-tertiary, #999);
}

.editor-textarea.hidden {
  display: none !important;
}

/* Preview Mode */
.editor-preview {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  font-family: 'Georgia', 'Libre Baskerville', serif;
  font-size: 1.1rem;
  line-height: 1.8;
  color: var(--fg-primary, #333);
  background: var(--bg-primary, #fff);
}

.editor-preview.hidden {
  display: none !important;
}

.editor-preview h1, .editor-preview h2, .editor-preview h3 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  color: var(--fg-primary, #333);
}

.editor-preview h1 { font-size: 1.75rem; }
.editor-preview h2 { font-size: 1.5rem; }
.editor-preview h3 { font-size: 1.25rem; }

.editor-preview p {
  margin-bottom: 1em;
}

.editor-preview blockquote {
  margin: 1em 0;
  padding: 0.5em 1em;
  border-left: 3px solid #1d4ed8;
  background: rgba(29, 78, 216, 0.04);
  font-style: italic;
}

/* Restore Confirmation Dialog */
.editor-dialog-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10001;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.editor-dialog-backdrop.active {
  display: flex;
}

.editor-dialog {
  background: var(--bg-primary, #fff);
  border-radius: 16px;
  max-width: 400px;
  width: 100%;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.editor-dialog-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(124, 58, 237, 0.1);
  color: #7c3aed;
  margin: 0 auto 16px;
}

.editor-dialog-icon svg {
  width: 28px;
  height: 28px;
}

.editor-dialog-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--fg-primary, #333);
  text-align: center;
  margin: 0 0 8px;
}

.editor-dialog-message {
  font-size: 0.9375rem;
  color: var(--fg-secondary, #666);
  text-align: center;
  line-height: 1.5;
  margin: 0 0 24px;
}

.editor-dialog-actions {
  display: flex;
  gap: 12px;
}

.editor-dialog-actions .editor-btn {
  flex: 1;
  justify-content: center;
  padding: 12px 16px;
}

/* Edit Button Styles (for content overlay) */
.content-edit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: rgba(29, 78, 216, 0.1);
  color: #1d4ed8;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-left: 8px;
}

.content-edit-btn:hover {
  background: rgba(29, 78, 216, 0.18);
}

.content-edit-btn svg {
  width: 16px;
  height: 16px;
}

.content-edit-btn.hidden {
  display: none;
}

/* Fullscreen Toggle */
.editor-fullscreen-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
}

/* Loading State */
.editor-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 16px;
  color: var(--fg-secondary, #666);
}

.editor-loading.hidden {
  display: none !important;
}

.editor-content-area.hidden {
  display: none !important;
}

.editor-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color, #e0e0e0);
  border-top-color: #1d4ed8;
  border-radius: 50%;
  animation: editor-spin 0.8s linear infinite;
}

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

/* Toast Notification */
.editor-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1e293b;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.9375rem;
  font-weight: 500;
  z-index: 10002;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

.editor-toast.active {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.editor-toast.success {
  background: #059669;
}

.editor-toast.error {
  background: #dc2626;
}

/* Mobile Styles */
@media (max-width: 768px) {
  .editor-header {
    padding: 10px 12px;
    min-height: 52px;
  }
  
  .editor-title {
    font-size: 0.9375rem;
  }
  
  .editor-btn {
    padding: 8px 12px;
    font-size: 0.8125rem;
  }
  
  .editor-btn-icon {
    width: 36px;
    height: 36px;
    padding: 6px;
  }
  
  .editor-textarea {
    padding: 16px;
    font-size: 1rem;
  }
  
  .editor-preview {
    padding: 16px;
    font-size: 1rem;
  }
  
  .editor-toolbar {
    padding: 6px 8px;
  }
  
  .editor-toolbar-btn {
    width: 36px;
    height: 36px;
  }
  
  .editor-status {
    display: none;
  }
  
  .editor-btn > span {
    display: none;
  }
  
  .editor-btn-primary span,
  .editor-btn-restore span {
    display: inline;
  }
  
  .content-edit-btn span {
    display: none;
  }
}

/* Desktop Styles - Split View */
@media (min-width: 1024px) {
  .editor-layout.split-view .editor-bible-pane {
    display: block;
  }
  
  .editor-layout.split-view .editor-main-pane {
    flex: 1;
  }
}

/* Dark Mode Support */
[data-theme="dark"] .content-editor-overlay,
[data-theme="oled"] .content-editor-overlay {
  --bg-primary: #1a1a1a;
  --bg-secondary: #252525;
  --fg-primary: #e5e5e5;
  --fg-secondary: #a0a0a0;
  --fg-tertiary: #666;
  --border-color: #333;
  --border-light: #2a2a2a;
  --hover-bg: rgba(255,255,255,0.08);
  --badge-bg: rgba(255,255,255,0.1);
  --status-bg: transparent;
  --active-bg: rgba(96, 165, 250, 0.15);
}

[data-theme="oled"] .content-editor-overlay {
  --bg-primary: #000;
  --bg-secondary: #0a0a0a;
}

[data-theme="dark"] .editor-btn-primary,
[data-theme="oled"] .editor-btn-primary {
  background: #2563eb;
}

[data-theme="dark"] .editor-btn-primary:hover,
[data-theme="oled"] .editor-btn-primary:hover {
  background: #1d4ed8;
}

[data-theme="dark"] .editor-dialog,
[data-theme="oled"] .editor-dialog {
  background: #252525;
}

[data-theme="oled"] .editor-dialog {
  background: #111;
}

/* Subtle animation for edit button */
@keyframes subtle-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

.content-edit-btn:focus {
  animation: subtle-pulse 1.5s ease infinite;
  outline: none;
}
