/**
 * TASKMATE - Knowledge Wiki Styles
 * =================================
 * Wiki-Layout: Sidebar-Baum + Content-Bereich
 */

.view-knowledge {
  padding: 0;
  height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
}

.knowledge-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Sidebar */
.knowledge-sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.knowledge-sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.knowledge-sidebar-search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px var(--spacing-sm);
}

.knowledge-sidebar-search svg { flex-shrink: 0; color: var(--text-muted); }

.knowledge-sidebar-search input {
  flex: 1; border: none; background: transparent;
  font-size: 0.85rem; color: var(--text-primary); outline: none; min-width: 0;
}

.knowledge-sidebar-search input::placeholder { color: var(--text-muted); }

.knowledge-sidebar-header .btn-sm {
  flex-shrink: 0; width: 32px; height: 32px; padding: 0;
  display: flex; align-items: center; justify-content: center;
}

/* Baum-Navigation */
.knowledge-tree {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-xs) 0;
}

.knowledge-tree::-webkit-scrollbar { width: 6px; }
.knowledge-tree::-webkit-scrollbar-track { background: transparent; }
.knowledge-tree::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }

.knowledge-tree-category { margin-bottom: 2px; }

.knowledge-tree-category-header {
  display: flex; align-items: center; gap: var(--spacing-xs);
  padding: 6px var(--spacing-md); cursor: pointer;
  user-select: none; transition: background 0.1s; position: relative;
}

.knowledge-tree-category-header:hover { background: var(--bg-hover); }

.knowledge-tree-chevron {
  width: 16px; height: 16px; flex-shrink: 0; color: var(--text-muted);
  transition: transform 0.15s ease; display: flex; align-items: center; justify-content: center;
}

.knowledge-tree-category.expanded .knowledge-tree-chevron { transform: rotate(90deg); }

.knowledge-tree-category-icon { font-size: 1rem; flex-shrink: 0; width: 20px; text-align: center; }

.knowledge-tree-category-name {
  flex: 1; font-size: 0.85rem; font-weight: 600; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}

.knowledge-tree-category-count {
  font-size: 0.7rem; color: var(--text-muted); background: var(--bg-tertiary);
  padding: 1px 6px; border-radius: var(--radius-full); flex-shrink: 0;
}

.knowledge-tree-category-actions {
  display: flex; gap: 2px; opacity: 0; transition: opacity 0.15s; flex-shrink: 0;
}

.knowledge-tree-category-header:hover .knowledge-tree-category-actions { opacity: 1; }

.knowledge-tree-category-actions .btn-icon {
  width: 22px; height: 22px; padding: 0; background: transparent;
  border: none; border-radius: var(--radius-sm); cursor: pointer; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center; transition: all 0.15s;
}

.knowledge-tree-category-actions .btn-icon:hover { background: var(--bg-secondary); color: var(--text-primary); }
.knowledge-tree-category-actions .btn-icon.btn-danger-hover:hover { background: var(--danger-bg); color: var(--danger); }

.knowledge-tree-entries { display: none; padding-left: 20px; }
.knowledge-tree-category.expanded .knowledge-tree-entries { display: block; }

.knowledge-tree-entry {
  display: flex; align-items: center; gap: var(--spacing-xs);
  padding: 5px var(--spacing-md) 5px var(--spacing-sm);
  cursor: pointer; font-size: 0.83rem; color: var(--text-secondary);
  transition: all 0.1s; border-left: 2px solid transparent;
}

.knowledge-tree-entry:hover { background: var(--bg-hover); color: var(--text-primary); }

.knowledge-tree-entry.active {
  background: var(--primary-light); color: var(--text-primary);
  border-left-color: var(--primary); font-weight: 500;
}

.knowledge-tree-entry-icon { flex-shrink: 0; color: var(--text-muted); display: flex; align-items: center; }
.knowledge-tree-entry-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.knowledge-tree-new-entry {
  display: flex; align-items: center; gap: var(--spacing-xs);
  padding: 5px var(--spacing-md) 5px var(--spacing-sm);
  cursor: pointer; font-size: 0.8rem; color: var(--text-muted); transition: all 0.1s;
}

.knowledge-tree-new-entry:hover { color: var(--primary); background: var(--bg-hover); }
.knowledge-tree-new-entry svg { flex-shrink: 0; }

.knowledge-sidebar-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: var(--spacing-xl); color: var(--text-muted); text-align: center; flex: 1;
}

.knowledge-sidebar-empty svg { opacity: 0.4; margin-bottom: var(--spacing-sm); }
.knowledge-sidebar-empty p { margin: 0; font-size: 0.85rem; }

/* Content */
.knowledge-content {
  overflow-y: auto; display: flex; flex-direction: column; min-height: 0;
}

.knowledge-empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; padding: var(--spacing-xxl); text-align: center; color: var(--text-muted);
}

.knowledge-empty-state svg { opacity: 0.3; margin-bottom: var(--spacing-md); }
.knowledge-empty-state h3 { font-size: 1.2rem; font-weight: 600; color: var(--text-secondary); margin: 0 0 var(--spacing-xs) 0; }
.knowledge-empty-state p { font-size: 0.95rem; margin: 0; }

/* Reader */
.knowledge-reader {
  padding: var(--spacing-xl) var(--spacing-xxl);
  max-width: 800px; width: 100%; margin: 0 auto;
}

.knowledge-reader-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: var(--spacing-md); margin-bottom: var(--spacing-md);
}

.knowledge-reader-header h1 {
  font-size: 1.75rem; font-weight: 700; color: var(--text-primary);
  margin: 0; line-height: 1.3; flex: 1;
}

.knowledge-reader-actions { display: flex; gap: var(--spacing-sm); flex-shrink: 0; }

.knowledge-reader-meta {
  font-size: 0.85rem; color: var(--text-muted); margin-bottom: var(--spacing-lg);
  display: flex; align-items: center; gap: var(--spacing-md); flex-wrap: wrap;
}

.knowledge-reader-meta-item { display: flex; align-items: center; gap: 4px; }

.knowledge-reader-meta-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: var(--radius-full);
  font-size: 0.75rem; font-weight: 500; color: white;
}

.knowledge-reader-url { margin-bottom: var(--spacing-lg); }

.knowledge-reader-url a {
  display: inline-flex; align-items: center; gap: var(--spacing-xs);
  color: var(--primary); text-decoration: none; font-size: 0.9rem; word-break: break-all;
}

.knowledge-reader-url a:hover { text-decoration: underline; }
.knowledge-reader-url a svg { flex-shrink: 0; color: var(--text-muted); }

.knowledge-reader-body { font-size: 0.95rem; color: var(--text-secondary); line-height: 1.7; }

.knowledge-reader-body h1 {
  font-size: 1.4rem; font-weight: 700; color: var(--text-primary);
  margin: 1.5rem 0 0.5rem 0; padding-bottom: 0.3rem; border-bottom: 1px solid var(--border-color);
}

.knowledge-reader-body h2 { font-size: 1.2rem; font-weight: 600; color: var(--text-primary); margin: 1.2rem 0 0.4rem 0; }
.knowledge-reader-body h3 { font-size: 1.05rem; font-weight: 600; color: var(--text-primary); margin: 1rem 0 0.3rem 0; }
.knowledge-reader-body p { margin: 0.5rem 0; }

.knowledge-reader-body code {
  background: var(--bg-tertiary); padding: 2px 6px;
  border-radius: var(--radius-sm); font-family: 'Courier New', monospace; font-size: 0.85em;
}

.knowledge-reader-body pre {
  background: var(--bg-tertiary); padding: var(--spacing-md);
  border-radius: var(--radius-md); overflow-x: auto; margin: 0.75rem 0;
}

.knowledge-reader-body pre code { background: transparent; padding: 0; border-radius: 0; font-size: 0.85rem; line-height: 1.5; }
.knowledge-reader-body ul, .knowledge-reader-body ol { padding-left: 1.5rem; margin: 0.5rem 0; }
.knowledge-reader-body li { margin: 0.2rem 0; }
.knowledge-reader-body a { color: var(--primary); text-decoration: underline; }
.knowledge-reader-body a:hover { opacity: 0.8; }
.knowledge-reader-body strong { font-weight: 700; color: var(--text-primary); }
.knowledge-reader-body em { font-style: italic; }

.knowledge-reader-attachments {
  margin-top: var(--spacing-xl); padding-top: var(--spacing-lg); border-top: 1px solid var(--border-color);
}

.knowledge-reader-attachments h3 { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); margin: 0 0 var(--spacing-sm) 0; }
.knowledge-reader-attachment-list { display: flex; flex-direction: column; gap: var(--spacing-xs); }

.knowledge-reader-attachment-item {
  display: flex; align-items: center; gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); text-decoration: none; color: var(--text-primary); transition: all 0.15s;
}

.knowledge-reader-attachment-item:hover { border-color: var(--primary); background: var(--bg-hover); }
.knowledge-reader-attachment-item svg { flex-shrink: 0; color: var(--text-muted); }
.knowledge-reader-attachment-info { flex: 1; min-width: 0; }
.knowledge-reader-attachment-name { font-size: 0.9rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.knowledge-reader-attachment-size { font-size: 0.75rem; color: var(--text-muted); }

/* Editor */
.knowledge-editor {
  padding: var(--spacing-xl) var(--spacing-xxl);
  max-width: 800px; width: 100%; margin: 0 auto;
}

.knowledge-editor-header { margin-bottom: var(--spacing-lg); }
.knowledge-editor-header h2 { font-size: 1.3rem; font-weight: 600; color: var(--text-primary); margin: 0; }
.knowledge-editor-form .form-group { margin-bottom: var(--spacing-md); }
.knowledge-editor-form label { display: block; font-size: 0.85rem; font-weight: 500; color: var(--text-secondary); margin-bottom: var(--spacing-xs); }

.knowledge-editor-form .form-control-lg {
  font-size: 1.2rem; padding: var(--spacing-sm) var(--spacing-md); font-weight: 600;
}

.knowledge-editor-textarea {
  min-height: 400px; font-family: 'Courier New', monospace;
  font-size: 0.9rem; line-height: 1.6; resize: vertical;
}

.knowledge-editor-buttons { display: flex; gap: var(--spacing-sm); margin-top: var(--spacing-lg); }

.knowledge-editor-attachments { margin-top: var(--spacing-md); padding-top: var(--spacing-md); border-top: 1px solid var(--border-color); }
.knowledge-editor-attachments > label { display: block; font-size: 0.85rem; font-weight: 500; color: var(--text-secondary); margin-bottom: var(--spacing-sm); }

.knowledge-editor-attachment-item {
  display: flex; align-items: center; gap: var(--spacing-sm);
  padding: var(--spacing-xs) var(--spacing-sm);
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); margin-bottom: var(--spacing-xs);
}

.knowledge-editor-attachment-item svg { flex-shrink: 0; color: var(--text-muted); }
.knowledge-editor-attachment-info { flex: 1; min-width: 0; }
.knowledge-editor-attachment-name { font-size: 0.85rem; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.knowledge-editor-attachment-size { font-size: 0.75rem; color: var(--text-muted); }

.knowledge-editor-attachment-delete {
  width: 24px; height: 24px; padding: 0; background: transparent; border: none;
  cursor: pointer; color: var(--text-muted); display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); transition: all 0.15s;
}

.knowledge-editor-attachment-delete:hover { background: var(--danger-bg); color: var(--danger); }
.knowledge-editor-file-upload { margin-top: var(--spacing-sm); }

/* Mobile Chips */
.knowledge-mobile-categories {
  display: none; gap: var(--spacing-sm); padding: var(--spacing-sm);
  overflow-x: auto; flex-shrink: 0; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}

.knowledge-mobile-categories::-webkit-scrollbar { display: none; }

.knowledge-mobile-chip {
  display: flex; align-items: center; gap: var(--spacing-xs);
  padding: var(--spacing-xs) var(--spacing-md);
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: var(--radius-full); cursor: pointer; white-space: nowrap;
  font-size: 0.85rem; color: var(--text-secondary); transition: all 0.15s; flex-shrink: 0;
}

.knowledge-mobile-chip:hover { background: var(--bg-hover); border-color: var(--primary); }
.knowledge-mobile-chip.active { background: var(--primary); border-color: var(--primary); color: white; }
.knowledge-mobile-chip .chip-icon { font-size: 1rem; }
.knowledge-mobile-chip .chip-count { font-size: 0.75rem; opacity: 0.8; }
.knowledge-mobile-add { background: var(--primary); border-color: var(--primary); color: white; }

/* Attachments (Modal - beibehalten fuer Kategorie-Modal) */
.knowledge-attachments-container { display: flex; flex-direction: column; gap: var(--spacing-xs); margin-bottom: var(--spacing-sm); }

.knowledge-attachment-item {
  display: flex; align-items: center; gap: var(--spacing-sm);
  padding: var(--spacing-xs) var(--spacing-sm);
  background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-sm);
}

.knowledge-attachment-item svg { flex-shrink: 0; color: var(--text-muted); }
.knowledge-attachment-info { flex: 1; min-width: 0; }
.knowledge-attachment-name { font-size: 0.9rem; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.knowledge-attachment-size { font-size: 0.8rem; color: var(--text-muted); }
.knowledge-attachment-actions { display: flex; gap: var(--spacing-xs); }

.knowledge-attachment-actions .btn-icon {
  width: 24px; height: 24px; padding: 0; background: transparent; border: none;
  cursor: pointer; color: var(--text-muted); display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); transition: all 0.15s;
}

.knowledge-attachment-actions .btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }
.knowledge-attachment-actions .btn-icon.btn-danger-hover:hover { background: var(--danger-bg); color: var(--danger); }

/* Icon Picker */
.icon-picker-container { display: flex; align-items: center; gap: var(--spacing-sm); }

.icon-picker-preview {
  display: flex; align-items: center; gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-secondary); border: 2px solid var(--border-color);
  border-radius: var(--radius-md); cursor: pointer; transition: all 0.2s ease;
}

.icon-picker-preview:hover { border-color: var(--primary); background: var(--bg-hover); }
.icon-preview-emoji { font-size: 1.75rem; line-height: 1; }
.icon-preview-label { font-size: 0.8rem; color: var(--text-secondary); }
.icon-picker-section { margin-top: var(--spacing-md); padding-top: var(--spacing-md); border-top: 1px solid var(--border-color); }
.icon-picker-tabs { display: flex; flex-wrap: wrap; gap: var(--spacing-xs); margin-bottom: var(--spacing-md); }

.icon-tab {
  padding: var(--spacing-xs) var(--spacing-sm); background: var(--bg-secondary);
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  font-size: 0.8rem; cursor: pointer; transition: all 0.2s ease; white-space: nowrap;
}

.icon-tab:hover { background: var(--bg-hover); border-color: var(--primary); }
.icon-tab.active { background: var(--primary); color: white; border-color: var(--primary); }

.icon-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: var(--spacing-xs); max-height: 200px; overflow-y: auto;
  padding: var(--spacing-xs); background: var(--bg-tertiary); border-radius: var(--radius-md);
}

.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; background: var(--bg-primary);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font-size: 1.25rem; cursor: pointer; transition: all 0.15s ease;
}

.icon-btn:hover { background: var(--bg-hover); border-color: var(--primary); transform: scale(1.1); }
.icon-btn.selected { background: var(--primary-light); border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }

.icon-grid::-webkit-scrollbar { width: 6px; }
.icon-grid::-webkit-scrollbar-track { background: var(--bg-tertiary); border-radius: 3px; }
.icon-grid::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
.icon-grid::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Responsive */
@media (max-width: 768px) {
  .view-knowledge { height: calc(100vh - 60px); }
  .knowledge-layout { grid-template-columns: 1fr; }
  .knowledge-sidebar { display: none; }
  .knowledge-mobile-categories { display: flex; }
  .knowledge-reader { padding: var(--spacing-md); }
  .knowledge-editor { padding: var(--spacing-md); }
  .knowledge-reader-header { flex-direction: column; gap: var(--spacing-sm); }
  .knowledge-reader-header h1 { font-size: 1.3rem; }
  .knowledge-reader-actions { align-self: flex-start; }
  .knowledge-editor-textarea { min-height: 250px; }
}

@media (max-width: 480px) {
  .knowledge-reader { padding: var(--spacing-sm); }
  .knowledge-editor { padding: var(--spacing-sm); }
  .knowledge-reader-header h1 { font-size: 1.1rem; }
}
