/* altcss/note-editor.css - Consolidated styles for note editor and note page */

/* Base containers */
note-editor,
note-page {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
}

note-editor {
  right: 20px;
  background: var(--bg-primary);
}

note-page {
  height: 100vh; /* Fallback for older browsers */
  height: 100dvh; /* Dynamic viewport height for mobile */
}

.note-page-container,
.note-editor-container {
  display: flex;
  flex-direction: column;
  height: 100vh; /* Fallback for older browsers */
  height: 100dvh; /* Dynamic viewport height for mobile */
  background: var(--bg-primary);
}

.note-page-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 400px;
  color: var(--text-secondary);
  font-size: 16px;
}

/* Header */
.note-editor-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--border-color);
  flex-shrink: 0;
}

.note-title-input {
  flex: 1;
  padding: 8px 12px;
  border: 2px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s;
}

.note-title-input:focus {
  border-color: var(--accent-color);
}

.note-language-select {
  padding: 8px 12px;
  border: 2px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.note-language-select:focus {
  border-color: var(--accent-color);
}

/* Buttons */
.note-save-btn,
.note-close-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.note-save-btn {
  background: var(--accent-color);
  color: white;
}

.note-save-btn:hover {
  background: var(--accent-hover);
}

.note-close-btn {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.note-close-btn:hover {
  background: var(--border-color);
}

.note-close-btn-floating {
  position: fixed;
  top: 12px;
  right: 18px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.note-close-btn-floating:hover {
  background: var(--border-color);
  transform: scale(1.1);
}

/* Split screen layout */
.note-editor-body {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: 2px;
  background: var(--border-color);
}

/* Left side - Monaco editor */
.note-editor-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  min-width: 0;
}

.monaco-container {
  flex: 1;
  min-height: 0;
  border: none;
}

/* Right side - Story preview */
.note-editor-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  min-width: 0;
}

/* Hide right side on narrow screens */
@media (max-width: 800px) {
  .note-editor-right {
    display: none;
  }
}

/* Story preview area */
.story-preview-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg-secondary);
  min-height: 0;
}

.story-preview-content {
  max-width: 800px;
  margin: 0 auto;
  opacity: 0;
  transition: opacity 0.3s ease-in;
}

.story-preview-content.is-visible {
  opacity: 1;
}

/* Markdown styling */
.story-preview-content h1,
.story-preview-content h2,
.story-preview-content h3 {
  color: var(--text-primary);
  margin-top: 24px;
  margin-bottom: 12px;
}

.story-preview-content h1 {
  font-size: 28px;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 8px;
}

.story-preview-content h2 {
  font-size: 24px;
}

.story-preview-content h3 {
  font-size: 20px;
}

.story-preview-content p {
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
}

.story-preview-content code {
  background: var(--bg-primary);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
}

.story-preview-content pre {
  background: var(--bg-primary);
  padding: 16px;
  border-radius: 6px;
  overflow-x: auto;
  border: 1px solid var(--border-color);
}

.story-preview-content pre code {
  background: none;
  padding: 0;
}

.story-preview-content ul,
.story-preview-content ol {
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
  padding-left: 24px;
  display: block;
}

.story-preview-content li {
  display: list-item;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.story-preview-content ul {
  list-style-type: disc;
}

.story-preview-content ol {
  list-style-type: decimal;
}

.story-preview-content ul ul {
  list-style-type: circle;
  margin-top: 8px;
}

.story-preview-content ul ul ul {
  list-style-type: square;
}

/* Task lists */
.story-preview-content .task-list-item {
  list-style-type: none;
  margin-left: -24px;
  padding-left: 24px;
}

.story-preview-content .task-list-item input[type="checkbox"] {
  margin-right: 8px;
  cursor: pointer;
}

.story-preview-content blockquote {
  border-left: 4px solid var(--accent-color);
  padding-left: 16px;
  margin-left: 0;
  color: var(--text-tertiary);
  font-style: italic;
}

.story-preview-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
}

.story-preview-content th,
.story-preview-content td {
  padding: 10px 12px;
  text-align: left;
  border: 1px solid var(--border-color);
}

.story-preview-content th {
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: 600;
}

.story-preview-content td {
  color: var(--text-secondary);
}

.story-preview-content tr:hover {
  background: var(--bg-secondary);
}

.story-preview-content img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 16px 0;
  border: 1px solid var(--border-color);
}

.story-preview-content hr {
  border: none;
  border-top: 2px solid var(--border-color);
  margin: 24px 0;
}

.story-preview-content a {
  color: var(--accent-color);
  text-decoration: none;
  transition: color 0.2s;
}

.story-preview-content a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.story-preview-content strong {
  color: var(--text-primary);
  font-weight: 600;
}

.story-preview-content em {
  font-style: italic;
}

.story-preview-content del {
  text-decoration: line-through;
  opacity: 0.7;
}

/* Embedded items in story */
.story-embedded-item {
  margin: 24px 0;
  padding: 16px;
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  transition: border-color 0.2s;
}

.story-embedded-item:hover {
  border-color: var(--accent-color);
}

.story-embedded-item image-card,
.story-embedded-item project-card,
.story-embedded-item note-card {
  max-width: 400px;
  margin: 0 auto;
}

/* Drop zone indicator in preview */
.story-preview-content.drag-over {
  outline: 2px dashed var(--accent-color);
  outline-offset: 8px;
}

/* Related items grid at bottom */
.related-items-section {
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-top: 2px solid var(--border-color);
  padding: 8px;
  max-height: 300px;
  display: flex;
  flex-direction: column;
  transition: max-height 0.3s ease;
}

.related-items-section.collapsed {
  max-height: 24px;
  overflow: hidden;
}

.related-items-header {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.related-items-header:hover {
  color: var(--accent-color);
}

.related-items-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}

.related-items-section.collapsed .related-items-toggle {
  transform: rotate(180deg);
}

.related-items-grid-container {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  transition: opacity 0.3s ease;
}

.related-items-section.collapsed .related-items-grid-container {
  opacity: 0;
  pointer-events: none;
}

.related-items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.related-items-grid image-card,
.related-items-grid project-card,
.related-items-grid note-card {
  cursor: grab;
}

.related-items-grid image-card:active,
.related-items-grid project-card:active,
.related-items-grid note-card:active {
  cursor: grabbing;
}

/* Footer */
.note-editor-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

/* Footer title input variant (note-page specific) */
.note-editor-footer .note-title-input {
  margin:-4px;
  flex: 0 1 auto;
  min-width: 150px;
  max-width: 300px;
  padding: 4px 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 12px;
  font-weight: normal;
}

.note-history-btn {
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.note-history-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--accent-color);
}

.note-history-btn svg {
  display: block;
}

.save-status {
  flex: 1;
  font-size: 12px;
  color: var(--text-tertiary);
}

.preview-status {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* Responsive design */
@media (max-width: 768px) {
  .note-editor-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .note-editor-header .note-title-input {
    flex: 1 1 100%;
  }
}