/* === Loading Spinner === */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}
.spinner-inline {
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}

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

/* === Toast Notifications === */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--color-card);
  border: var(--border-width) solid var(--color-border);
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s;
  animation-fill-mode: forwards;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 400px;
}
.toast-success {
  border-left: 4px solid #2e7d32;
}
.toast-error {
  border-left: 4px solid var(--color-danger);
}
.toast-info {
  border-left: 4px solid var(--color-primary);
}
.toast-warning {
  border-left: 4px solid #e65100;
}

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes toastOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

/* === Empty States === */
.empty-state .empty-action {
  margin-top: 16px;
}

/* === Inline edit === */
.inline-edit-select {
  padding: 4px 8px;
  font-size: 13px;
  border-radius: 4px;
  border: var(--border-width) solid var(--color-input-border);
  background: var(--color-card);
  color: var(--color-text);
  font-family: inherit;
}

/* === Skeleton loading === */
.skeleton {
  background: linear-gradient(90deg, var(--color-border) 25%, var(--color-border-light) 50%, var(--color-border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}
.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
}
.skeleton-text:last-child {
  width: 70%;
}
.skeleton-card {
  height: 80px;
  margin-bottom: 12px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* === Checkbox styled === */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* === Color & Icon Pickers === */
.color-picker, .icon-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.15s;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: var(--color-text); box-shadow: 0 0 0 2px var(--color-focus-ring); }
.icon-swatch {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  border: var(--border-width) solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: var(--color-card);
  transition: border-color 0.15s, transform 0.15s;
}
.icon-swatch:hover { border-color: var(--color-primary); transform: scale(1.1); }
.icon-swatch.selected { border-color: var(--color-primary); box-shadow: 0 0 0 2px var(--color-focus-ring); }
.icon-swatch .material-symbols-outlined { font-size: 20px; }

/* Custom color swatch */
.color-picker-custom {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--color-text-muted);
  cursor: pointer;
}
.color-picker-custom.selected {
  border-style: solid;
  border-color: var(--color-primary);
}
.color-picker-custom input[type="color"] {
  opacity: 0;
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
}
.custom-color-plus {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text-muted);
  line-height: 1;
  pointer-events: none;
}
.color-picker-custom.selected .custom-color-plus {
  display: none;
}

/* Project color block in table */
.project-color-block {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  vertical-align: middle;
}

/* Icon picker search & scrollable grid */
.icon-picker-search {
  width: 100%;
  max-width: 300px;
}
.icon-picker-grid {
  max-height: 200px;
  overflow-y: auto;
}

/* === Info box === */
.info-box {
  padding: 12px;
  background: var(--color-info-bg);
  border-radius: 6px;
  border: var(--border-width) solid var(--color-border);
  font-size: 12px;
  color: var(--color-text-secondary);
}
.info-box strong {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--color-text-secondary);
}
.info-box code {
  font-size: 12px;
}

/* === Document Read View === */
.doc-read-wrap {
  max-width: 820px;
  margin: 0 auto;
}
.doc-read-title {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--color-text);
}
.doc-read-meta {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}
.doc-read-body {
  min-height: 200px;
}

/* === Document Editor === */
.doc-edit-wrap {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 130px);
  min-height: 400px;
}
.doc-title-bar {
  margin-bottom: 8px;
  flex-shrink: 0;
}
.doc-title-input {
  width: 100%;
  font-size: 20px;
  font-weight: 600;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--color-text);
  padding: 6px 0;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}
.doc-title-input:focus {
  border-bottom-color: var(--color-primary);
}

/* Toolbar */
.doc-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  background: var(--color-card);
  border: var(--border-width) solid var(--color-border);
  border-radius: 8px 8px 0 0;
  border-bottom: none;
  flex-shrink: 0;
}
.doc-toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.doc-toolbar-btn:hover {
  background: var(--color-bg);
  color: var(--color-text);
}
.doc-toolbar-btn .material-symbols-outlined {
  font-size: 18px;
}
.doc-toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--color-border);
  margin: 0 4px;
}

/* Split pane */
.doc-split-pane {
  display: flex;
  flex: 1;
  min-height: 0;
  border: var(--border-width) solid var(--color-border);
  border-radius: 0 0 8px 8px;
  overflow: hidden;
}
.doc-split-editor {
  flex: 1;
  display: flex;
  border-right: var(--border-width) solid var(--color-border);
  min-width: 0;
}
.doc-split-preview {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  background: var(--color-card);
  min-width: 0;
}
.doc-textarea {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0;
  background: var(--color-card);
  color: var(--color-text);
  padding: 20px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.7;
  resize: none;
  outline: none;
  overflow-y: auto;
  tab-size: 2;
}

@media (max-width: 900px) {
  .doc-split-pane {
    flex-direction: column;
  }
  .doc-split-editor {
    border-right: none;
    border-bottom: var(--border-width) solid var(--color-border);
    min-height: 250px;
  }
  .doc-split-preview {
    max-height: 300px;
  }
}

/* Markdown preview styles */
.markdown-body {
  font-size: 15px;
  line-height: 1.7;
  color: var(--color-text);
}
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  margin: 1.2em 0 0.6em;
  font-weight: 600;
  line-height: 1.3;
}
.markdown-body h1 { font-size: 1.8em; border-bottom: 1px solid var(--color-border); padding-bottom: 0.3em; }
.markdown-body h2 { font-size: 1.4em; border-bottom: 1px solid var(--color-border); padding-bottom: 0.3em; }
.markdown-body h3 { font-size: 1.2em; }
.markdown-body p { margin: 0.6em 0; }
.markdown-body pre {
  background: var(--color-bg);
  border: var(--border-width) solid var(--color-border);
  border-radius: 6px;
  padding: 16px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
}
.markdown-body code {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.9em;
  background: var(--color-bg);
  padding: 2px 6px;
  border-radius: 4px;
}
.markdown-body pre code {
  background: none;
  padding: 0;
}
.markdown-body blockquote {
  margin: 0.8em 0;
  padding: 4px 16px;
  border-left: 4px solid var(--color-primary);
  color: var(--color-text-secondary);
}
.markdown-body ul, .markdown-body ol {
  margin: 0.6em 0;
  padding-left: 2em;
}
.markdown-body li { margin: 0.3em 0; }
.markdown-body hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 1.5em 0;
}
.markdown-body a {
  color: var(--color-primary);
}
.markdown-body table {
  border-collapse: collapse;
  width: auto;
  margin: 0.8em 0;
  overflow-x: auto;
  display: block;
  max-width: 100%;
}
.markdown-body th, .markdown-body td {
  border: 1px solid var(--color-border);
  padding: 6px 13px;
  font-size: 14px;
}
.markdown-body th {
  font-weight: 600;
  background: var(--color-bg);
}
.markdown-body tr:nth-child(even) td {
  background: var(--color-bg);
}
.markdown-body strong { font-weight: 600; }
.markdown-body del { text-decoration: line-through; color: var(--color-text-muted); }
.markdown-body .checklist-group {
  list-style: none;
  padding-left: 0;
}
.markdown-body .checklist {
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.markdown-body .checklist input[type="checkbox"] {
  margin: 0;
}
.markdown-body .checklist.checked {
  color: var(--color-text-muted);
  text-decoration: line-through;
}
