/**
 * editor.css
 * Last modified: v016.086 (2025-11-25)
 * Changes: Collapsible presets, copy buttons on AI messages
 */

/* ============================================
   Editor Modal Overlay
   Full-screen overlay for question/category editor
   ============================================ */

/**
 * Editor Overlay
 * Takes over entire screen when active
 * Hides bottom bar and main content
 */
.editor-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  background: var(--theme-bg-primary, #0a0a0a);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.editor-overlay.active {
  display: flex;
}

/**
 * Editor Header
 * Top bar with title and close button
 */
.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--theme-bg-secondary, #1a1a1a);
  border-bottom: 1px solid var(--theme-border-primary, #333);
  flex-shrink: 0;
}

.editor-header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.editor-header h1 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--theme-text-primary, #fff);
}

.editor-folder-path {
  display: inline-flex;
  align-items: center;
  background: var(--theme-bg-tertiary, #252525);
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--theme-text-secondary, #999);
  max-width: 300px;
  overflow: hidden;
}

.editor-folder-path .folder-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.editor-dirty-indicator {
  display: flex;
  align-items: center;
  color: var(--theme-accent-warning, #f59e0b);
  font-size: 0.875rem;
  font-weight: 500;
}

.editor-save-indicator {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.25rem 0.75rem;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.editor-save-indicator.saving {
  color: var(--theme-accent-action, #3b82f6);
  background: rgba(59, 130, 246, 0.1);
}

.editor-save-indicator.saved {
  color: var(--theme-accent-success, #10b981);
  background: rgba(16, 185, 129, 0.1);
}

.editor-save-indicator.error {
  color: var(--theme-accent-error, #ef4444);
  background: rgba(239, 68, 68, 0.1);
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.editor-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.editor-language-select {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  background: var(--theme-bg-tertiary, #252525);
  color: var(--theme-text-primary, #fff);
  border: 1px solid var(--theme-border-primary, #333);
  cursor: pointer;
  transition: all 0.15s ease;
}

.editor-language-select:hover {
  border-color: var(--theme-border-hover, #444);
  background: var(--theme-bg-secondary, #1a1a1a);
}

.editor-language-select:focus {
  outline: none;
  border-color: var(--theme-accent-primary, #8b5cf6);
}

.editor-title-badge {
  background: var(--theme-accent-action, #3b82f6);
  color: white;
  font-size: 0.65rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
}

.editor-btn {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  border: 1px solid transparent;
  white-space: nowrap;
}

.editor-btn-primary {
  background: var(--theme-accent-primary, #8b5cf6);
  color: white;
  border-color: var(--theme-accent-primary, #8b5cf6);
}

.editor-btn-primary:hover {
  background: var(--theme-accent-primary-hover, #7c3aed);
  border-color: var(--theme-accent-primary-hover, #7c3aed);
}

.editor-btn-secondary {
  background: transparent;
  color: var(--theme-text-primary, #fff);
  border-color: var(--theme-border-primary, #333);
}

.editor-btn-secondary:hover {
  background: var(--theme-bg-tertiary, #252525);
  border-color: var(--theme-border-hover, #444);
}

.editor-close-btn {
  background: transparent;
  border: none;
  font-size: 2rem;
  line-height: 1;
  color: var(--theme-text-secondary, #999);
  cursor: pointer;
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease;
  flex-shrink: 0;
}

.editor-close-btn:hover {
  color: var(--theme-text-primary, #fff);
  border-color: var(--theme-border-primary, #555);
}

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

/**
 * Editor Content
 * Main content area where editor loads
 */
.editor-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--theme-bg-primary, #0a0a0a);
}

.editor-loading {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--theme-text-secondary, #999);
  font-size: 1.1rem;
}

.editor-loading::after {
  content: '...';
  display: inline-block;
  animation: loading-dots 1.5s infinite;
}

@keyframes loading-dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/**
 * Editor Container
 * Container for dynamically loaded editor content
 */
.editor-container {
  flex: 1;
  overflow: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
}

/**
 * Editor Layout
 * Sidebar + Main area horizontal layout
 */
.editor-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: 100%;
}

/**
 * Editor Warning
 * Mobile warning message
 */
.editor-warning {
  background: var(--theme-accent-warning, #f59e0b);
  color: #000;
  padding: 1rem 1.5rem;
  text-align: center;
  font-weight: 500;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.editor-warning-icon {
  display: inline-block;
  margin-right: 0.5rem;
  font-size: 1.2rem;
}

/* Hide warning on desktop */
@media (min-width: 768px) {
  .editor-warning {
    display: none;
  }
}

/**
 * Editor Sidebar
 * Category list on left
 */
.editor-sidebar {
  flex: 0 0 250px;
  background: var(--theme-bg-secondary, #1a1a1a);
  border-right: 1px solid var(--theme-border-primary, #333);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.editor-intro-section {
  padding: 0.5rem;
  border-bottom: 2px solid var(--theme-border-primary, #333);
  margin-bottom: 0.5rem;
}

.editor-intro-section .editor-category-item {
  background: var(--theme-accent-action, #3b82f6);
  opacity: 0.9;
  margin: 0;
}

.editor-intro-section .editor-category-item:hover {
  opacity: 1;
}

.editor-sidebar-header {
  padding: 1rem 1.5rem;
  font-weight: 600;
  color: var(--theme-text-primary, #fff);
  border-bottom: 1px solid var(--theme-border-primary, #333);
  background: var(--theme-bg-secondary, #1a1a1a);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.editor-sidebar-header-title {
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.editor-category-list {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.editor-category-item {
  padding: 0.75rem 1rem;
  color: var(--theme-text-secondary, #999);
  border-bottom: 1px solid var(--theme-border-secondary, #222);
  transition: all 0.15s ease;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  position: relative;
}

.editor-category-main {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  cursor: pointer;
}

.editor-category-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.editor-category-label {
  flex: 1;
  font-size: 0.9rem;
}

.editor-category-count {
  font-size: 0.75rem;
  opacity: 0.6;
  flex-shrink: 0;
}

.editor-category-item:hover {
  background: var(--theme-bg-tertiary, #252525);
  color: var(--theme-text-primary, #fff);
}

.editor-category-item.active {
  background: var(--theme-accent-action, #3b82f6);
  color: white;
  font-weight: 500;
}

/**
 * Editor Main Area
 * Question list and edit forms
 */
.editor-main {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.editor-main-header {
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--theme-border-primary, #333);
  padding-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.editor-main-header h2 {
  margin: 0 0 0.25rem 0;
  color: var(--theme-text-primary, #fff);
  font-size: 1.5rem;
}

.editor-main-subtitle {
  margin: 0;
  color: var(--theme-text-secondary, #999);
  font-size: 0.9rem;
}

.editor-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 3rem;
  color: var(--theme-text-secondary, #999);
}

.editor-empty-state h2 {
  font-size: 1.5rem;
  margin: 0 0 0.5rem 0;
  color: var(--theme-text-primary, #fff);
}

.editor-empty-state p {
  font-size: 1rem;
  margin: 0;
}

.editor-question-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.editor-question-item {
  position: relative;
  background: var(--theme-bg-secondary, #1a1a1a);
  border: 1px solid var(--theme-border-primary, #333);
  border-radius: 8px;
  padding: 1rem;
  padding-left: 2.5rem;
  transition: all 0.15s ease;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.editor-question-content {
  flex: 1;
  cursor: pointer;
}

.editor-question-item:hover {
  background: var(--theme-bg-tertiary, #252525);
  border-color: var(--theme-border-secondary, #555);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.editor-question-item.active {
  border-color: var(--theme-accent-action, #3b82f6);
  background: rgba(59, 130, 246, 0.1);
}

.editor-question-title {
  font-weight: 500;
  color: var(--theme-text-primary, #fff);
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
}

.editor-question-desc {
  font-size: 0.875rem;
  color: var(--theme-text-secondary, #999);
  margin: 0.25rem 0 0.5rem 0;
  line-height: 1.4;
}

.editor-question-meta {
  font-size: 0.875rem;
  color: var(--theme-text-secondary, #999);
  display: flex;
  gap: 1rem;
  align-items: center;
}

.editor-meta-badge {
  background: var(--theme-bg-tertiary, #252525);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 500;
}

.editor-meta-perspectives {
  font-size: 0.75rem;
  opacity: 0.7;
}

/**
 * Drag Handle
 * For reordering (SortableJS)
 */
.editor-drag-handle {
  position: absolute;
  left: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  cursor: grab;
  color: var(--theme-text-tertiary, #666);
  font-size: 1.25rem;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.2s ease;
  user-select: none;
}

.editor-drag-handle:active {
  cursor: grabbing;
}

.editor-question-item:hover .editor-drag-handle,
.editor-category-item:hover .editor-drag-handle {
  opacity: 1;
}

/* Categories are draggable by entire item, add cursor hint */
.editor-category-item {
  cursor: grab;
}

.editor-category-item:active {
  cursor: grabbing;
}

.editor-question-item.sortable-ghost {
  opacity: 0.5;
  background: var(--theme-accent-action, #3b82f6);
}

.editor-question-item.sortable-chosen {
  opacity: 0.8;
}

.editor-question-item.sortable-drag {
  cursor: grabbing !important;
}

.editor-category-item.sortable-ghost {
  opacity: 0.5;
  background: var(--theme-accent-action, #3b82f6);
}

.editor-category-item.sortable-chosen {
  opacity: 0.8;
  cursor: grabbing;
}

.editor-category-item.sortable-drag {
  cursor: grabbing !important;
}

/**
 * Icon Buttons
 * Small icon-only buttons
 */
.editor-btn-icon {
  background: transparent;
  border: 1px solid var(--theme-border-primary, #333);
  border-radius: 4px;
  padding: 0.375rem;
  cursor: pointer;
  color: var(--theme-text-secondary, #999);
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.editor-btn-icon:hover {
  background: var(--theme-bg-tertiary, #252525);
  color: var(--theme-text-primary, #fff);
  border-color: var(--theme-border-hover, #444);
}

.editor-btn-delete {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.editor-category-item:hover .editor-btn-delete,
.editor-question-item:hover .editor-btn-delete {
  opacity: 1;
}

.editor-btn-delete:hover {
  background: var(--theme-accent-error, #ef4444);
  border-color: var(--theme-accent-error, #ef4444);
  color: white;
}

/**
 * Editor Modal
 * Modal dialog for editing question/category
 */
.editor-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 2rem;
}

.editor-modal.active {
  display: flex;
}

.editor-modal-dialog {
  background: var(--theme-bg-secondary, #1a1a1a);
  border: 1px solid var(--theme-border-primary, #333);
  border-radius: 12px;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

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

.editor-modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--theme-text-primary, #fff);
  margin: 0;
}

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

.editor-modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--theme-border-primary, #333);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/**
 * Editor Form
 * Form inputs for editing
 */
.editor-form-group {
  margin-bottom: 1.5rem;
}

.editor-form-group:last-child {
  margin-bottom: 0;
}

.editor-form-label {
  display: block;
  font-weight: 500;
  color: var(--theme-text-primary, #fff);
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.editor-form-input,
.editor-form-textarea,
.editor-form-select {
  width: 100%;
  background: var(--theme-bg-primary, #0a0a0a);
  border: 1px solid var(--theme-border-primary, #333);
  color: var(--theme-text-primary, #fff);
  padding: 0.75rem;
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  transition: all 0.2s ease;
}

.editor-form-input:focus,
.editor-form-textarea:focus,
.editor-form-select:focus {
  outline: none;
  border-color: var(--theme-accent-action, #3b82f6);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.editor-form-textarea {
  min-height: 100px;
  resize: vertical;
}

.editor-form-help {
  font-size: 0.875rem;
  color: var(--theme-text-tertiary, #666);
  margin-top: 0.25rem;
}

/**
 * Editor Buttons
 * Action buttons
 */
.editor-btn {
  background: var(--theme-bg-tertiary, #252525);
  border: 1px solid var(--theme-border-primary, #333);
  color: var(--theme-text-primary, #fff);
  padding: 0.625rem 1.25rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.editor-btn:hover {
  background: var(--theme-bg-secondary, #1a1a1a);
  border-color: var(--theme-border-secondary, #555);
}

.editor-btn:active {
  transform: scale(0.98);
}

.editor-btn-primary {
  background: var(--theme-accent-action, #3b82f6);
  border-color: var(--theme-accent-action, #3b82f6);
  color: white;
}

.editor-btn-primary:hover {
  background: #2563eb;
  border-color: #2563eb;
}

.editor-btn-secondary {
  background: transparent;
  border-color: var(--theme-border-primary, #333);
  color: var(--theme-text-secondary);
}

.editor-btn-secondary:hover {
  background: var(--theme-bg-hover, #2a2a2a);
  border-color: var(--theme-text-secondary);
  color: var(--theme-text-primary);
}

.editor-btn-success {
  background: #10b981;
  border-color: #10b981;
  color: white;
}

.editor-btn-success:hover {
  background: #059669;
  border-color: #059669;
}

.editor-btn-danger {
  background: var(--theme-accent-error, #ef4444);
  border-color: var(--theme-accent-error, #ef4444);
  color: white;
}

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

/**
 * Editor Notification Toast
 * Shows feedback for actions
 */
.editor-notification {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--theme-bg-secondary, #1a1a1a);
  border: 1px solid var(--theme-border-primary, #333);
  color: var(--theme-text-primary, #fff);
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  z-index: 10001;
  opacity: 0;
  transition: opacity 0.3s ease;
  font-size: 0.9rem;
  pointer-events: none;
}

.editor-notification.show {
  opacity: 1;
}

/* ============================================
   AI Assistant Panel
   Collapsible right-side panel for AI chat
   ============================================ */

.ai-panel {
  position: relative;
  width: 48px;
  min-width: 48px;
  background: var(--theme-bg-secondary, #1a1a1a);
  border-left: 1px solid var(--theme-border-primary, #333);
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease, min-width 0.3s ease;
  overflow: hidden;
}

.ai-panel.open {
  width: 380px;
  min-width: 380px;
}

.ai-panel-toggle {
  position: absolute;
  top: 0;
  left: 0;
  width: 48px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 1rem;
  gap: 0.25rem;
  cursor: pointer;
  background: var(--theme-bg-secondary, #1a1a1a);
  z-index: 2;
  transition: background 0.2s;
}

.ai-panel-toggle:hover {
  background: var(--theme-bg-tertiary, #252525);
}

.ai-toggle-icon {
  font-size: 1.5rem;
}

.ai-toggle-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--theme-text-secondary, #999);
  writing-mode: vertical-rl;
  text-orientation: mixed;
  letter-spacing: 0.1em;
}

.ai-panel.open .ai-panel-toggle {
  display: none;
}

.ai-panel-content {
  display: none;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

.ai-panel.open .ai-panel-content {
  display: flex;
}

.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--theme-border-primary, #333);
  font-weight: 600;
  color: var(--theme-text-primary, #fff);
  flex-shrink: 0;
}

.ai-header-left,
.ai-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ai-session-btn {
  background: var(--theme-bg-tertiary, #252525);
  border: 1px solid var(--theme-border-primary, #333);
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  font-size: 0.7rem;
  color: var(--theme-text-secondary, #999);
  cursor: pointer;
  transition: all 0.15s;
}

.ai-session-btn:hover {
  background: var(--theme-bg-secondary, #1a1a1a);
  color: var(--theme-text-primary, #fff);
  border-color: var(--theme-accent-primary, #8b5cf6);
}

.ai-new-session-btn,
.ai-reset-btn {
  background: var(--theme-accent-primary, #8b5cf6);
  border: none;
  border-radius: 4px;
  width: 1.5rem;
  height: 1.5rem;
  font-size: 0.9rem;
  color: white;
  cursor: pointer;
  transition: background 0.2s;
}

.ai-reset-btn {
  background: var(--theme-bg-tertiary, #252525);
  border: 1px solid var(--theme-border-primary, #333);
}

.ai-new-session-btn:hover {
  background: var(--theme-accent-secondary, #7c3aed);
}

.ai-reset-btn:hover {
  background: var(--theme-bg-secondary, #1a1a1a);
  border-color: var(--theme-accent-primary, #8b5cf6);
}

.ai-settings-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.ai-settings-btn:hover {
  opacity: 1;
}

/* Session Picker */
.ai-session-picker {
  background: var(--theme-bg-secondary, #1a1a1a);
  border-bottom: 1px solid var(--theme-border-primary, #333);
  max-height: 200px;
  overflow-y: auto;
}

.ai-session-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-bottom: 1px solid var(--theme-border-primary, #333);
}

.ai-close-sessions {
  background: none;
  border: none;
  color: var(--theme-text-secondary, #999);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 0.25rem;
}

.ai-close-sessions:hover {
  color: var(--theme-text-primary, #fff);
}

.ai-session-list {
  padding: 0.25rem;
}

.ai-session-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}

.ai-session-item:hover {
  background: var(--theme-bg-tertiary, #252525);
}

.ai-session-item.active {
  background: var(--theme-accent-primary, #8b5cf6);
  color: white;
}

.ai-session-info {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  overflow: hidden;
}

.ai-session-name {
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-session-date {
  font-size: 0.65rem;
  color: var(--theme-text-tertiary, #666);
}

.ai-session-item.active .ai-session-date {
  color: rgba(255,255,255,0.7);
}

.ai-session-delete {
  background: none;
  border: none;
  font-size: 0.8rem;
  cursor: pointer;
  opacity: 0.5;
  padding: 0.25rem;
}

.ai-session-delete:hover {
  opacity: 1;
}

.ai-no-sessions {
  padding: 1rem;
  text-align: center;
  color: var(--theme-text-tertiary, #666);
  font-size: 0.75rem;
}

/* Setup form */
.ai-setup {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ai-setup p {
  margin: 0;
  color: var(--theme-text-secondary, #999);
  font-size: 0.875rem;
}

.ai-form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.ai-form-group label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--theme-text-primary, #fff);
}

.ai-input, .ai-select, .ai-textarea {
  background: var(--theme-bg-primary, #0a0a0a);
  border: 1px solid var(--theme-border-primary, #333);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  color: var(--theme-text-primary, #fff);
  font-size: 0.875rem;
  font-family: inherit;
}

.ai-input:focus, .ai-select:focus, .ai-textarea:focus {
  outline: none;
  border-color: var(--theme-accent-primary, #8b5cf6);
}

.ai-help {
  font-size: 0.75rem;
  color: var(--theme-text-tertiary, #666);
  margin: 0;
}

.ai-btn {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--theme-border-primary, #333);
  background: var(--theme-bg-tertiary, #252525);
  color: var(--theme-text-primary, #fff);
  transition: all 0.15s;
}

.ai-btn:hover {
  background: var(--theme-bg-secondary, #1a1a1a);
}

.ai-btn-primary {
  background: var(--theme-accent-primary, #8b5cf6);
  border-color: var(--theme-accent-primary, #8b5cf6);
  color: white;
}

.ai-btn-primary:hover {
  background: var(--theme-accent-primary-hover, #7c3aed);
}

/* Presets - Collapsible */
.ai-presets-container {
  border-bottom: 1px solid var(--theme-border-primary, #333);
  flex-shrink: 0;
}

.ai-presets-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: var(--theme-bg-tertiary, #252525);
  border: none;
  color: var(--theme-text-secondary, #999);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
}

.ai-presets-toggle:hover {
  background: var(--theme-bg-hover, #2a2a2a);
  color: var(--theme-text-primary, #fff);
}

.ai-presets-content {
  display: none;
  padding: 0.5rem;
  max-height: 250px;
  overflow-y: auto;
}

.ai-presets-container.expanded .ai-presets-content {
  display: block;
}

.ai-preset-group {
  margin-bottom: 0.5rem;
}

.ai-preset-group-name {
  font-size: 0.65rem;
  color: var(--theme-text-tertiary, #666);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.25rem 0.125rem;
  margin-bottom: 0.25rem;
}

.ai-presets-content .ai-preset-group:last-child {
  margin-bottom: 0;
}

.ai-preset {
  background: var(--theme-bg-tertiary, #252525);
  border: 1px solid var(--theme-border-primary, #333);
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  font-size: 0.7rem;
  color: var(--theme-text-secondary, #999);
  cursor: pointer;
  transition: all 0.15s;
  margin: 0.125rem;
}

.ai-preset:hover {
  background: var(--theme-bg-secondary, #1a1a1a);
  color: var(--theme-text-primary, #fff);
  border-color: var(--theme-accent-primary, #8b5cf6);
}

/* Messages */
.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ai-message {
  padding: 0.625rem 0.875rem;
  border-radius: 8px;
  font-size: 0.8125rem;
  line-height: 1.5;
}

.ai-message p {
  margin: 0 0 0.5rem 0;
}

.ai-message p:last-child {
  margin-bottom: 0;
}

.ai-message.ai-system {
  background: var(--theme-bg-tertiary, #252525);
  color: var(--theme-text-secondary, #999);
  font-style: italic;
}

.ai-message.ai-user {
  background: var(--theme-accent-primary, #8b5cf6);
  color: white;
  align-self: flex-end;
  max-width: 85%;
  position: relative;
}

.ai-message.ai-user .ai-copy-btn {
  color: white;
  background: rgba(0,0,0,0.2);
}

.ai-message.ai-assistant {
  background: var(--theme-bg-primary, #0a0a0a);
  border: 1px solid var(--theme-border-primary, #333);
  color: var(--theme-text-primary, #fff);
  position: relative;
}

.ai-message-content {
  padding-right: 1.5rem;
}

.ai-copy-btn {
  position: absolute;
  top: 0.375rem;
  right: 0.375rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  opacity: 0.4;
  padding: 0.125rem;
  transition: opacity 0.15s;
}

.ai-copy-btn:hover {
  opacity: 1;
}

.ai-message:hover .ai-copy-btn {
  opacity: 0.7;
}

.ai-code {
  background: var(--theme-bg-primary, #0a0a0a);
  border: 1px solid var(--theme-border-primary, #333);
  border-radius: 4px;
  padding: 0.5rem;
  font-family: monospace;
  font-size: 0.75rem;
  overflow-x: auto;
  white-space: pre-wrap;
  margin: 0.5rem 0;
}

.ai-loading-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ai-loading {
  color: var(--theme-text-tertiary, #666);
  animation: ai-pulse 1.5s infinite;
}

.ai-stop-btn {
  background: var(--theme-accent-error, #ef4444);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.ai-stop-btn:hover {
  opacity: 1;
}

@keyframes ai-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Operations */
.ai-operation {
  background: var(--theme-accent-action, #3b82f6);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(139, 92, 246, 0.2));
  border: 1px solid var(--theme-accent-primary, #8b5cf6);
  border-radius: 8px;
  padding: 0.75rem;
  font-size: 0.8125rem;
}

.ai-op-summary {
  margin: 0.5rem 0;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  font-size: 0.8125rem;
  line-height: 1.5;
}

.ai-op-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.ai-op-buttons .ai-btn {
  flex: 1;
  padding: 0.375rem;
  font-size: 0.75rem;
}

/* Cross-language sync offer */
.ai-cross-language-offer {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(59, 130, 246, 0.2));
  border: 1px solid var(--theme-accent-success, #10b981);
  border-radius: 8px;
  padding: 0.75rem;
  margin-top: 0.5rem;
}

.ai-sync-message {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8125rem;
}

.ai-sync-message strong {
  color: var(--theme-accent-success, #10b981);
}

.ai-sync-message span {
  color: var(--theme-text-secondary, #aaa);
}

.ai-cross-language-offer .ai-op-buttons {
  margin-top: 0.75rem;
}

.ai-sync-yes {
  background: var(--theme-accent-success, #10b981) !important;
}

.ai-sync-no {
  background: transparent !important;
  border: 1px solid var(--theme-border-secondary, #555) !important;
}

/* Input area */
.ai-input-area {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--theme-border-primary, #333);
  flex-shrink: 0;
}

.ai-textarea {
  flex: 1;
  resize: none;
  min-height: 2.5rem;
  max-height: 6rem;
}

.ai-send {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 6px;
  background: var(--theme-accent-primary, #8b5cf6);
  border: none;
  color: white;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.ai-send:hover {
  background: var(--theme-accent-primary-hover, #7c3aed);
}

/* Settings overlay */
.ai-setup-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--theme-bg-primary, #121212);
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.ai-setup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  border-bottom: 1px solid var(--theme-border-primary, #333);
  flex-shrink: 0;
}

.ai-setup-header span {
  font-weight: 600;
}

.ai-close-settings {
  background: none;
  border: none;
  color: var(--theme-text-secondary, #999);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.ai-close-settings:hover {
  color: var(--theme-text-primary, #fff);
}

.ai-setup-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.ai-btn-danger {
  background: var(--theme-accent-error, #ef4444);
  border-color: var(--theme-accent-error, #ef4444);
}

.ai-btn-danger:hover {
  background: #dc2626;
}

/* Hide AI panel on mobile */
@media (max-width: 900px) {
  .ai-panel {
    display: none;
  }
}

/**
 * Responsive Layout
 * Mobile adaptations
 */
@media (max-width: 767px) {
  .editor-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--theme-border-primary, #333);
    max-height: 40vh;
  }
  
  .editor-main {
    padding: 1rem;
  }
  
  .editor-modal {
    padding: 1rem;
  }
  
  .editor-modal-dialog {
    max-width: 100%;
  }
}

/* ============================================
   Save Confirmation Dialog
   ============================================ */
.save-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.save-confirm-dialog {
  background: var(--theme-surface-primary, #1a1a1a);
  border: 1px solid var(--theme-border-primary, #333);
  border-radius: 12px;
  padding: 1.5rem 2rem;
  text-align: center;
  max-width: 320px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.save-confirm-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.save-confirm-dialog h3 {
  margin: 0 0 0.5rem;
  color: var(--theme-text-primary, #fff);
  font-size: 1.25rem;
}

.save-confirm-dialog p {
  margin: 0 0 1.25rem;
  color: var(--theme-text-secondary, #888);
  font-size: 0.875rem;
}

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

.save-confirm-buttons .save-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.save-btn.save {
  background: var(--theme-accent-primary, #8b5cf6);
  color: white;
}

.save-btn.save:hover {
  background: var(--theme-accent-secondary, #7c3aed);
}

.save-btn.discard {
  background: var(--theme-accent-error, #ef4444);
  color: white;
}

.save-btn.discard:hover {
  background: #dc2626;
}

.save-btn.cancel {
  background: var(--theme-surface-secondary, #2a2a2a);
  color: var(--theme-text-secondary, #888);
  border: 1px solid var(--theme-border-primary, #333);
}

.save-btn.cancel:hover {
  background: var(--theme-surface-tertiary, #333);
  color: var(--theme-text-primary, #fff);
}
