/* ============================================================
   使用文档页面 - knowledge.css
   原创设计：分类标签页 + 即时搜索 + 右侧滑入面板
   与moban3的分类卡片+居中弹窗完全不同
   ============================================================ */

/* ====== 搜索栏 ====== */
.kb-search {
    position: relative;
    margin-bottom: 18px;
    animation: fadeUp .3s var(--ease-out) both;
}

.kb-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

.kb-search-icon svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.kb-search-input {
    width: 100%;
    height: 44px;
    padding: 0 14px 0 42px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--card-bg);
    border: 1px solid var(--divider);
    border-radius: var(--radius-md);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    box-sizing: border-box;
}

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

.kb-search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(108,92,231,.1);
}

/* ====== 分类标签栏 ====== */
.kb-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 18px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
    animation: fadeUp .3s var(--ease-out) .05s both;
}

.kb-tabs::-webkit-scrollbar { display: none; }

.kb-tab {
    padding: 7px 18px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--card-bg);
    border: 1px solid var(--divider);
    border-radius: 20px;
    cursor: pointer;
    white-space: nowrap;
    transition: all .18s var(--ease-out);
    flex-shrink: 0;
}

.kb-tab:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.kb-tab.active {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
}

.kb-tab-count {
    display: inline-block;
    margin-left: 5px;
    font-size: 11px;
    font-weight: 600;
    opacity: .6;
}

/* ====== 文章列表 ====== */
.kb-list {
    animation: fadeUp .3s var(--ease-out) .1s both;
}

.kb-article {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    background: var(--card-bg);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all .18s var(--ease-out);
    border: 1px solid transparent;
}

.kb-article:hover {
    border-color: rgba(108,92,231,.15);
    box-shadow: 0 3px 12px rgba(0,0,0,.06);
    transform: translateX(4px);
}

.kb-article-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(108,92,231,.08);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kb-article-icon svg {
    width: 18px;
    height: 18px;
    stroke: var(--accent);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.kb-article-body {
    flex: 1;
    min-width: 0;
}

.kb-article-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kb-article-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

.kb-article-cat {
    padding: 1px 8px;
    background: var(--surface-alt);
    border-radius: 8px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
}

.kb-article-arrow {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    transition: transform .18s, color .18s;
}

.kb-article-arrow svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.kb-article:hover .kb-article-arrow {
    color: var(--accent);
    transform: translateX(3px);
}

/* ====== 空状态 ====== */
.kb-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: var(--text-muted);
    animation: fadeUp .3s var(--ease-out) both;
}

.kb-empty-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--surface-alt);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

.kb-empty-icon svg {
    width: 28px;
    height: 28px;
    stroke: var(--text-muted);
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.kb-empty p {
    margin: 0;
    font-size: 14px;
}

/* ============================================================
   文档详情弹窗
   ============================================================ */
.kb-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9000;
    animation: kbOverlayIn .25s var(--ease-out);
}

@keyframes kbOverlayIn {
    from { opacity: 0; }
}

.kb-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 640px;
    max-width: calc(100% - 32px);
    max-height: 80vh;
    background: #fff;
    border-radius: var(--radius-lg);
    z-index: 9001;
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 48px rgba(0,0,0,.18);
    animation: kbModalIn .3s var(--ease-out);
}

@keyframes kbModalIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(.95); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.kb-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 24px;
    border-bottom: 1px solid var(--divider);
    flex-shrink: 0;
}

.kb-modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kb-modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--surface-alt);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
    flex-shrink: 0;
}

.kb-modal-close:hover {
    background: var(--divider);
    color: var(--text-primary);
}

.kb-modal-close svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.kb-modal-body {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    font-size: 15px;
    line-height: 1.75;
    color: var(--text-primary);
    -webkit-overflow-scrolling: touch;
}

/* 富文本样式 */
.kb-modal-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 8px 0;
}

.kb-modal-body a {
    color: var(--accent);
    text-decoration: none;
}

.kb-modal-body a:hover {
    text-decoration: underline;
}

.kb-modal-body pre {
    background: var(--surface-alt);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.6;
}

.kb-modal-body code {
    background: rgba(108,92,231,.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    color: var(--accent-dark);
}

.kb-modal-body pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

.kb-modal-body h1,
.kb-modal-body h2,
.kb-modal-body h3 {
    margin: 20px 0 10px;
    color: var(--text-primary);
}

.kb-modal-body ul,
.kb-modal-body ol {
    padding-left: 20px;
}

.kb-modal-body blockquote {
    margin: 12px 0;
    padding: 10px 16px;
    border-left: 3px solid var(--accent);
    background: rgba(108,92,231,.04);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
}

/* ====== 响应式 ====== */
@media (max-width: 768px) {
    .kb-search-input {
        height: 40px;
        font-size: 13px;
    }

    .kb-tabs {
        gap: 5px;
    }

    .kb-tab {
        padding: 6px 14px;
        font-size: 12px;
    }

    .kb-article {
        padding: 12px 14px;
        gap: 10px;
    }

    .kb-article-icon {
        width: 32px;
        height: 32px;
        border-radius: 8px;
    }

    .kb-article-icon svg {
        width: 15px;
        height: 15px;
    }

    .kb-article-title {
        font-size: 13px;
    }

    /* 手机端弹窗适配 */
    .kb-modal {
        max-height: 85vh;
    }

    .kb-modal-head {
        padding: 14px 16px;
    }

    .kb-modal-body {
        padding: 16px;
        font-size: 14px;
    }
}

@media (max-width: 380px) {
    .kb-article-icon {
        display: none;
    }

    .kb-article {
        padding: 10px 12px;
    }
}
