/* 知识库管理页面样式 */

.kb-container {
    max-width: 1400px;
    margin: 100px auto 60px;
    padding: 0 40px;
}

.kb-header {
    text-align: center;
    margin-bottom: 60px;
    animation: fadeInDown 0.6s ease;
}

.kb-title {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.kb-title i {
    color: var(--accent-color);
}

.kb-subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
}

/* 标签页 */
.kb-tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 32px;
    border-bottom: 2px solid rgba(212, 175, 55, 0.1);
    padding-bottom: 0;
}

.kb-tab {
    padding: 16px 32px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.kb-tab:hover {
    color: var(--accent-color);
    background: rgba(212, 175, 55, 0.05);
}

.kb-tab.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
    font-weight: 600;
}

.tab-badge {
    background: var(--accent-color);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 4px;
}

/* 面板 */
.kb-panel {
    display: none;
    animation: fadeIn 0.4s ease;
}

.kb-panel.active {
    display: block;
}

/* 上传区域 */
.upload-area {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 32px;
    margin-bottom: 40px;
}

.upload-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 48px 32px;
    text-align: center;
    box-shadow: var(--shadow-light);
    border: 2px solid rgba(212, 175, 55, 0.1);
    transition: all var(--transition-normal);
}

.upload-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-medium);
    border-color: rgba(212, 175, 55, 0.3);
}

.upload-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent-color) 0%, #FFD700 100%);
    border-radius: 50%;
    color: white;
    font-size: 2.5rem;
    box-shadow: 0 8px 24px rgba(212, 175, 55, 0.3);
}

.upload-card h3 {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-bottom: 12px;
}

.upload-desc {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 0.95rem;
}

.url-input-group {
    display: flex;
    gap: 12px;
    margin: 24px 0;
}

.upload-tips {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid rgba(212, 175, 55, 0.1);
    text-align: left;
}

.upload-tips p {
    color: var(--text-light);
    font-size: 0.85rem;
    margin: 8px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 按钮样式 */
.kb-btn {
    padding: 12px 28px;
    border-radius: 999px;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.kb-btn.primary {
    background: linear-gradient(135deg, var(--accent-color) 0%, #FFD700 100%);
    color: white;
    box-shadow: 0 4px 16px rgba(212, 175, 55, 0.3);
}

.kb-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(212, 175, 55, 0.4);
}

.kb-btn.secondary {
    background: var(--primary-color);
    color: white;
}

.kb-btn.secondary:hover {
    background: #2a4b6d;
}

.kb-btn.ghost {
    background: transparent;
    border: 2px solid var(--accent-color);
    color: var(--accent-color);
}

.kb-btn.ghost:hover {
    background: rgba(212, 175, 55, 0.1);
}

.kb-btn.large {
    padding: 16px 40px;
    font-size: 1.1rem;
}

.kb-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 输入框 */
.kb-input {
    width: 100%;
    padding: 12px 20px;
    border: 2px solid rgba(212, 175, 55, 0.2);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background: var(--bg-light);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.kb-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.1);
}

.kb-input.large {
    padding: 18px 24px;
    font-size: 1.1rem;
    border-radius: var(--radius-md);
}

.kb-select {
    padding: 10px 16px;
    border: 2px solid rgba(212, 175, 55, 0.2);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    background: var(--bg-light);
    color: var(--text-primary);
    cursor: pointer;
}

/* 上传进度 */
.upload-progress {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-medium);
    border: 2px solid var(--accent-color);
    margin-top: 32px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.progress-header h4 {
    color: var(--primary-color);
    font-size: 1.2rem;
}

.progress-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.progress-item {
    background: rgba(212, 175, 55, 0.05);
    padding: 16px;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--accent-color);
}

.progress-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.progress-item-name {
    font-weight: 600;
    color: var(--text-primary);
}

.progress-item-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.progress-bar {
    height: 6px;
    background: rgba(212, 175, 55, 0.2);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), #FFD700);
    border-radius: 999px;
    transition: width 0.3s ease;
}

/* 文档列表 */
.docs-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    gap: 20px;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 300px;
    position: relative;
}

.search-box i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

.search-box .kb-input {
    padding-left: 48px;
}

.filter-group {
    display: flex;
    gap: 12px;
}

.docs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

.doc-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-light);
    border: 2px solid transparent;
    transition: all var(--transition-normal);
    cursor: pointer;
}

.doc-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-medium);
    border-color: var(--accent-color);
}

.doc-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.doc-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.doc-icon.pdf { background: linear-gradient(135deg, #FF6B6B, #FF8E8E); }
.doc-icon.word { background: linear-gradient(135deg, #4A90E2, #67A3E8); }
.doc-icon.ppt { background: linear-gradient(135deg, #F5A623, #F7B955); }
.doc-icon.webpage { background: linear-gradient(135deg, #7ED321, #95DA4C); }

.doc-menu {
    position: relative;
}

.doc-menu-btn {
    background: transparent;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 4px;
    font-size: 1.2rem;
    transition: color var(--transition-fast);
}

.doc-menu-btn:hover {
    color: var(--accent-color);
}

.doc-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.doc-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.doc-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.doc-stats {
    display: flex;
    justify-content: space-between;
    padding-top: 16px;
    border-top: 1px solid rgba(212, 175, 55, 0.1);
    font-size: 0.85rem;
    color: var(--text-light);
}

.doc-stat {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 80px 20px;
}

.empty-state i {
    font-size: 4rem;
    color: var(--text-light);
    margin-bottom: 24px;
    opacity: 0.5;
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 24px;
}

/* 搜索容器 */
.search-container {
    max-width: 900px;
    margin: 0 auto;
}

.search-input-group {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.search-options {
    display: flex;
    gap: 24px;
    margin-bottom: 32px;
    padding: 16px;
    background: rgba(212, 175, 55, 0.05);
    border-radius: var(--radius-sm);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.search-results {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.result-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-light);
    border-left: 4px solid var(--accent-color);
    transition: all var(--transition-fast);
}

.result-card:hover {
    box-shadow: var(--shadow-medium);
}

.result-type {
    display: inline-block;
    padding: 4px 12px;
    background: var(--accent-color);
    color: white;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.result-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 12px;
}

.result-content {
    color: var(--text-primary);
    line-height: 1.8;
    margin-bottom: 12px;
}

.result-image {
    max-width: 100%;
    border-radius: var(--radius-sm);
    margin: 16px 0;
}

.result-meta {
    display: flex;
    gap: 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-light);
    border-radius: var(--radius-lg);
    max-width: 1000px;
    width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 24px 32px;
    border-bottom: 2px solid rgba(212, 175, 55, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    color: var(--primary-color);
    font-size: 1.5rem;
}

.btn-close {
    background: transparent;
    border: none;
    font-size: 2rem;
    color: var(--text-light);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.btn-close:hover {
    color: var(--accent-color);
    transform: rotate(90deg);
}

.modal-body {
    padding: 32px;
    overflow-y: auto;
    flex: 1;
}

.preview-toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.markdown-preview {
    background: rgba(212, 175, 55, 0.02);
    border: 1px solid rgba(212, 175, 55, 0.1);
    border-radius: var(--radius-sm);
    padding: 32px;
    line-height: 1.8;
}

.markdown-preview h1, .markdown-preview h2, .markdown-preview h3 {
    color: var(--primary-color);
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

.markdown-preview code {
    background: rgba(212, 175, 55, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.9em;
}

.markdown-preview pre {
    background: var(--bg-dark);
    color: #f8f8f2;
    padding: 16px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
}

.markdown-preview img {
    max-width: 100%;
    border-radius: var(--radius-sm);
    margin: 16px 0;
}

/* 动画 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 响应式 */
@media (max-width: 768px) {
    .kb-container {
        padding: 0 20px;
        margin-top: 80px;
    }

    .kb-title {
        font-size: 2rem;
    }

    .kb-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .kb-tab {
        padding: 12px 20px;
        white-space: nowrap;
    }

    .upload-area {
        grid-template-columns: 1fr;
    }

    .docs-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        min-width: 100%;
    }

    .docs-grid {
        grid-template-columns: 1fr;
    }

    .search-input-group {
        flex-direction: column;
    }

    .modal-content {
        width: 95%;
        max-height: 95vh;
    }

    .modal-body {
        padding: 20px;
    }
}

/* ══════════════════════════════════════════════════════════════
   视图切换 / 列表视图 / 批量操作 / Toast / 确认弹窗
   ══════════════════════════════════════════════════════════════ */

/* ── 视图切换按钮组 ─────────────────────────────────────────── */
.view-toggle {
    display: inline-flex;
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 8px;
    overflow: hidden;
}

.view-toggle-btn {
    padding: 10px 14px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 0.95rem;
}

.view-toggle-btn:hover {
    background: rgba(212, 175, 55, 0.1);
    color: var(--accent-color);
}

.view-toggle-btn.active {
    background: var(--accent-color);
    color: #fff;
}

/* ── 批量操作栏（选中时才出现） ───────────────────────────────── */
.batch-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 20px;
    margin-bottom: 20px;
    background: rgba(212, 175, 55, 0.08);
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-radius: 10px;
    animation: fadeInDown 0.25s ease;
}

.batch-bar.active {
    display: flex;
}

.batch-left .checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: var(--text-primary);
}

.batch-left strong {
    color: var(--accent-color);
}

.batch-right {
    display: flex;
    gap: 10px;
}

.kb-btn.danger {
    background: #e05555;
    color: #fff;
    border: none;
}

.kb-btn.danger:hover {
    background: #c94444;
}

/* ── 文档选择复选框 ───────────────────────────────────────────── */
.doc-select {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.doc-select input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent-color);
}

.doc-card.selected,
.doc-row.selected {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.25);
}

/* ── 列表视图 ─────────────────────────────────────────────────── */
.docs-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.doc-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: var(--card-bg, rgba(255, 255, 255, 0.6));
    border: 1px solid rgba(212, 175, 55, 0.15);
    border-radius: 10px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.doc-row:hover {
    border-color: rgba(212, 175, 55, 0.5);
    transform: translateX(3px);
}

.doc-row-icon {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(212, 175, 55, 0.12);
    color: var(--accent-color);
    font-size: 1.1rem;
}

.doc-row-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.doc-row-title {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-row-sub {
    font-size: 0.82rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-row-cell {
    flex-shrink: 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 5px;
}

.doc-row-cell.type {
    min-width: 60px;
    font-weight: 600;
    color: var(--accent-color);
}

.doc-row-cell.date {
    min-width: 90px;
    justify-content: flex-end;
}

/* 窄屏下隐藏次要列，避免挤压标题 */
@media (max-width: 900px) {
    .doc-row-sub,
    .doc-row-cell:not(.date) {
        display: none;
    }
}

/* ── Toast 通知 ───────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 90px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 240px;
    max-width: 400px;
    padding: 14px 18px;
    border-radius: 10px;
    background: #fff;
    color: #333;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
    border-left: 4px solid var(--accent-color);
    font-size: 0.95rem;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-success { border-left-color: #4caf50; }
.toast-success i { color: #4caf50; }
.toast-error   { border-left-color: #e05555; }
.toast-error   i { color: #e05555; }
.toast-info    { border-left-color: #2196f3; }
.toast-info    i { color: #2196f3; }

/* ── 确认弹窗 ─────────────────────────────────────────────────── */
.confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.confirm-modal.show {
    opacity: 1;
}

.confirm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.confirm-dialog {
    position: relative;
    width: min(420px, calc(100vw - 40px));
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    transform: scale(0.94);
    transition: transform 0.25s ease;
}

.confirm-modal.show .confirm-dialog {
    transform: scale(1);
}

.confirm-header {
    padding: 18px 24px;
    font-size: 1.05rem;
    font-weight: 600;
    color: #222;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.confirm-body {
    padding: 22px 24px;
    color: #555;
    line-height: 1.6;
}

.confirm-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 24px 20px;
}

.confirm-footer .btn {
    padding: 9px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all var(--transition-fast);
}

.confirm-footer .btn-secondary {
    background: #eee;
    color: #444;
}

.confirm-footer .btn-secondary:hover {
    background: #e0e0e0;
}

.confirm-footer .btn-danger {
    background: #e05555;
    color: #fff;
}

.confirm-footer .btn-danger:hover {
    background: #c94444;
}

/* ══════════════════════════════════════════════════════════════
   代码块复制按钮（配合 marked + hljs）
   ══════════════════════════════════════════════════════════════ */
.code-block-wrap {
    position: relative;
    margin: 1.2em 0;
}

.copy-code-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 6px 12px;
    font-size: 0.8rem;
    background: rgba(212, 175, 55, 0.15);
    color: var(--accent-color);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 1;
}

.copy-code-btn:hover {
    background: rgba(212, 175, 55, 0.25);
    border-color: var(--accent-color);
}

.copy-code-btn.copied {
    background: #4caf50;
    color: #fff;
    border-color: #4caf50;
}

.code-block-wrap pre {
    margin: 0;
}
