/* ═══════════════════════════════════════ */
/* KNOWLEDGE BASE PAGES STYLES             */
/* ═══════════════════════════════════════ */

.kb-pages-container { }

/* Toolbar */
.kb-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.kb-toolbar-left { display: flex; gap: 8px; align-items: center; }
.kb-toolbar-right { display: flex; gap: 8px; }
.kb-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 9px 16px;
    min-width: 260px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.kb-search:focus-within { border-color: #0b3eae; box-shadow: 0 0 0 3px rgba(11,62,174,0.08); }
.kb-search i { color: #94a3b8; font-size: 13px; }
.kb-search input { border: none; outline: none; background: transparent; font-size: 14px; color: #1e293b; width: 100%; }
.kb-search input::placeholder { color: #cbd5e1; }

/* Tabs */
.kb-tabs {
    display: flex;
    gap: 2px;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 20px;
    overflow-x: auto;
}
.kb-tab {
    padding: 10px 18px;
    background: none;
    border: none;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.15s;
    border-radius: 6px 6px 0 0;
    white-space: nowrap;
}
.kb-tab:hover { color: #0b3eae; background: #f8fafc; }
.kb-tab.active { color: #0b3eae; background: #fff; }
.kb-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0; right: 0;
    height: 2px;
    background: #0b3eae;
    border-radius: 2px 2px 0 0;
}
.kb-tab-content { display: none; }
.kb-tab-content.active { display: block; }

/* Pages Grid */
.kb-pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

/* Page Card */
.kb-page-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.kb-page-card:hover {
    border-color: #c7d2fe;
    box-shadow: 0 4px 16px rgba(11,62,174,0.06);
    transform: translateY(-2px);
}
.kb-page-card-icon {
    font-size: 28px;
    line-height: 1;
}
.kb-page-card-title {
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.kb-page-card-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: #94a3b8;
}
.kb-page-card-meta i { font-size: 11px; }
.kb-page-card-workspace {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    background: #eef2ff;
    color: #4f46e5;
}
.kb-page-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.kb-page-card-tag {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    background: #f1f5f9;
    color: #475569;
}
.kb-page-card-bookmark {
    position: absolute;
    top: 12px;
    right: 12px;
    color: #fbbf24;
    font-size: 14px;
}

/* Tree View */
.kb-tree-container {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
}
.kb-tree-workspace {
    margin-bottom: 16px;
}
.kb-tree-workspace-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #f8fafc;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    cursor: pointer;
    transition: background 0.15s;
}
.kb-tree-workspace-header:hover { background: #eef2ff; }
.kb-tree-workspace-header i { color: #0b3eae; font-size: 13px; }
.kb-tree-items {
    padding-left: 20px;
    margin-top: 4px;
}
.kb-tree-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    color: #334155;
    cursor: pointer;
    transition: background 0.12s;
}
.kb-tree-item:hover { background: #f8fafc; }
.kb-tree-item-icon { font-size: 16px; }
.kb-tree-item-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-tree-item-children {
    padding-left: 24px;
}
.kb-tree-toggle {
    width: 18px;
    text-align: center;
    color: #94a3b8;
    font-size: 10px;
    cursor: pointer;
    flex-shrink: 0;
}

/* Tags Grid */
.kb-tags-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.kb-tag-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
}
.kb-tag-card:hover { border-color: #c7d2fe; box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
.kb-tag-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.kb-tag-name { font-size: 14px; font-weight: 600; color: #1e293b; }
.kb-tag-count { font-size: 12px; color: #94a3b8; }

/* Files Grid */
.kb-files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}
.kb-file-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
}
.kb-file-card:hover { border-color: #c7d2fe; }
.kb-file-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: #eef2ff;
    color: #0b3eae;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}
.kb-file-info { flex: 1; min-width: 0; }
.kb-file-name { font-size: 13px; font-weight: 600; color: #1e293b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-file-size { font-size: 11px; color: #94a3b8; }

/* Empty State */
.kb-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
}
.kb-empty-icon {
    font-size: 56px;
    color: #cbd5e1;
    margin-bottom: 20px;
}
.kb-empty-state h4 { margin: 0 0 8px; font-size: 18px; color: #64748b; font-weight: 700; }
.kb-empty-state p { margin: 0 0 24px; font-size: 14px; }

/* ═══════════════════════════════════════ */
/* BLOCK EDITOR (Full Screen Overlay)      */
/* ═══════════════════════════════════════ */

.kb-editor-overlay {
    position: fixed;
    inset: 0;
    background: #fff;
    z-index: 10000;
    display: none;
    flex-direction: column;
    animation: kbEditorSlideIn 0.25s ease;
}
.kb-editor-overlay[style*="display: flex"],
.kb-editor-overlay[style*="display:flex"] {
    display: flex !important;
}
@keyframes kbEditorSlideIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.kb-editor-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    padding: 0 24px;
}

/* Editor Header */
.kb-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
}
.kb-editor-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}
.kb-editor-header-right {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.kb-editor-back-btn {
    background: none;
    border: 1px solid #e2e8f0;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.12s;
    flex-shrink: 0;
}
.kb-editor-back-btn:hover { background: #f8fafc; color: #1e293b; border-color: #cbd5e1; }
.kb-editor-breadcrumb {
    font-size: 13px;
    color: #94a3b8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.kb-editor-breadcrumb span { color: #475569; font-weight: 600; }
.kb-editor-action-btn {
    background: none;
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.12s;
    font-size: 15px;
}
.kb-editor-action-btn:hover { background: #f1f5f9; color: #475569; }
.kb-editor-action-btn.bookmarked i { color: #fbbf24; }

/* More menu */
.kb-editor-more-menu { position: relative; }
.kb-more-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    padding: 6px;
    min-width: 200px;
    z-index: 100;
}
.kb-more-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    color: #475569;
    text-decoration: none;
    font-size: 13px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.1s;
}
.kb-more-dropdown a:hover { background: #f8fafc; color: #1e293b; }
.kb-more-dropdown a.kb-danger { color: #ef4444; }
.kb-more-dropdown a.kb-danger:hover { background: #fef2f2; }
.kb-dropdown-divider { height: 1px; background: #f1f5f9; margin: 4px 0; }

/* Cover */
.kb-editor-cover {
    position: relative;
    height: 200px;
    border-radius: 0 0 12px 12px;
    overflow: hidden;
    margin-bottom: 16px;
    flex-shrink: 0;
}
.kb-editor-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.kb-cover-change-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(0,0,0,0.5);
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}
.kb-editor-cover:hover .kb-cover-change-btn { opacity: 1; }

/* Title Area */
.kb-editor-title-area {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 0 8px;
    flex-shrink: 0;
}
.kb-icon-btn {
    background: none;
    border: none;
    font-size: 36px;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    border-radius: 8px;
    transition: background 0.12s;
}
.kb-icon-btn:hover { background: #f1f5f9; }
.kb-editor-title {
    flex: 1;
    border: none;
    outline: none;
    font-size: 32px;
    font-weight: 800;
    color: #0f172a;
    background: transparent;
    font-family: inherit;
    letter-spacing: -0.5px;
}
.kb-editor-title::placeholder { color: #cbd5e1; }

/* Tags in editor */
.kb-editor-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-bottom: 16px;
    flex-shrink: 0;
}
.kb-editor-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    background: #f1f5f9;
    color: #475569;
    cursor: pointer;
    transition: background 0.12s;
}
.kb-editor-tag:hover { background: #e2e8f0; }

/* Blocks Area */
.kb-editor-blocks {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 100px;
}

/* Block placeholder */
.kb-block-placeholder {
    padding: 12px 0;
    color: #cbd5e1;
    font-size: 15px;
    cursor: text;
    transition: color 0.12s;
}
.kb-block-placeholder:hover { color: #94a3b8; }

/* Individual block */
.kb-block {
    position: relative;
    padding: 4px 0;
    min-height: 28px;
    display: flex;
    align-items: flex-start;
    gap: 4px;
}
.kb-block:hover .kb-block-handle { opacity: 1; }
.kb-block-handle {
    width: 20px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #cbd5e1;
    cursor: grab;
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
    margin-top: 2px;
    font-size: 12px;
}
.kb-block-handle:hover { color: #94a3b8; }
.kb-block-content {
    flex: 1;
    min-width: 0;
    outline: none;
    font-size: 15px;
    line-height: 1.7;
    color: #334155;
}
.kb-block-content:empty::before {
    content: attr(data-placeholder);
    color: #d1d5db;
    pointer-events: none;
}
.kb-block-content[data-type="heading_1"] { font-size: 28px; font-weight: 800; color: #0f172a; line-height: 1.3; margin: 20px 0 4px; }
.kb-block-content[data-type="heading_2"] { font-size: 22px; font-weight: 700; color: #1e293b; line-height: 1.3; margin: 16px 0 4px; }
.kb-block-content[data-type="heading_3"] { font-size: 18px; font-weight: 700; color: #334155; line-height: 1.4; margin: 12px 0 4px; }
.kb-block-content[data-type="quote"] {
    border-left: 3px solid #e2e8f0;
    padding-left: 16px;
    color: #64748b;
    font-style: italic;
}
.kb-block-content[data-type="callout"] {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.kb-block-content[data-type="code"] {
    background: #1e293b;
    color: #e2e8f0;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    padding: 16px;
    border-radius: 8px;
    white-space: pre-wrap;
    overflow-x: auto;
}
.kb-block-content[data-type="divider"] {
    height: 1px;
    background: #e2e8f0;
    margin: 16px 0;
    cursor: default;
}
.kb-block-content[data-type="to_do"] {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.kb-block-content[data-type="to_do"] input[type="checkbox"] {
    margin-top: 4px;
    width: 16px;
    height: 16px;
    cursor: pointer;
}
.kb-block-content[data-type="bulleted_list"]::before { content: '•'; margin-right: 8px; color: #94a3b8; }
.kb-block-content[data-type="numbered_list"]::before { content: attr(data-number) '.'; margin-right: 8px; color: #94a3b8; font-weight: 600; }
.kb-block-content[data-type="toggle"] { cursor: pointer; }
.kb-block-content[data-type="equation"] {
    font-family: 'Times New Roman', serif;
    font-size: 18px;
    color: #475569;
    text-align: center;
    padding: 12px;
    background: #fafafa;
    border-radius: 6px;
}

/* Image block */
.kb-block-image {
    max-width: 100%;
    border-radius: 8px;
    margin: 8px 0;
}
.kb-block-image img {
    max-width: 100%;
    border-radius: 8px;
    display: block;
}

/* Embed block */
.kb-block-embed {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    margin: 8px 0;
}
.kb-block-embed iframe {
    width: 100%;
    min-height: 300px;
    border: none;
}

/* Block Type Selector (Slash Menu) */
.kb-block-selector {
    position: fixed;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.12);
    padding: 8px;
    min-width: 280px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 10001;
}
.kb-block-selector-header {
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.kb-block-selector-group { margin-bottom: 4px; }
.kb-block-selector-group-label {
    padding: 6px 12px 4px;
    font-size: 10px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.kb-block-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    width: 100%;
    background: none;
    border: none;
    font-size: 13px;
    color: #334155;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.1s;
    text-align: left;
}
.kb-block-option:hover { background: #f0f4ff; color: #0b3eae; }
.kb-block-option i { width: 18px; text-align: center; color: #64748b; font-size: 14px; }
.kb-block-option:hover i { color: #0b3eae; }

/* Version history list */
.kb-history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.12s;
}
.kb-history-item:hover { background: #f8fafc; }
.kb-history-item:last-child { border-bottom: none; }
.kb-history-info {
    flex: 1;
}
.kb-history-info strong { color: #1e293b; font-size: 14px; }
.kb-history-info small { color: #94a3b8; font-size: 12px; display: block; margin-top: 2px; }
.kb-history-actions {
    display: flex;
    gap: 6px;
}
.kb-history-restore-btn {
    padding: 6px 12px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    transition: all 0.12s;
}
.kb-history-restore-btn:hover { background: #eef2ff; border-color: #c7d2fe; color: #0b3eae; }

@media (max-width: 768px) {
    .kb-toolbar { flex-direction: column; }
    .kb-pages-grid { grid-template-columns: 1fr; }
    .kb-editor-container { padding: 0 12px; }
    .kb-editor-title { font-size: 24px; }
    .kb-tabs { gap: 0; }
    .kb-tab { padding: 8px 12px; font-size: 12px; }
}