/* 企业知识库 - 自定义样式 */
:root {
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --primary: #1e3a5f;
    --primary-light: #2a5a8f;
    --sidebar-bg: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-active: #3b82f6;
}

* { box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: #f1f5f9;
    min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    overflow-y: auto; z-index: 1000;
    transition: transform .3s;
}
.sidebar-brand {
    height: var(--topbar-height);
    display: flex; align-items: center; padding: 0 20px;
    font-size: 18px; font-weight: 700; color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand img { height: 32px; margin-right: 10px; }
.sidebar-nav { padding: 12px 0; }
.sidebar-section { padding: 8px 20px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: #64748b; margin-top: 8px; }
.sidebar-link {
    display: flex; align-items: center; padding: 10px 20px; color: var(--sidebar-text);
    text-decoration: none; font-size: 14px; transition: all .15s;
    border-left: 3px solid transparent;
}
.sidebar-link:hover { background: rgba(255,255,255,.05); color: #e2e8f0; }
.sidebar-link.active { background: rgba(59,130,246,.12); color: #fff; border-left-color: var(--sidebar-active); }
.sidebar-link i { width: 20px; margin-right: 12px; font-size: 16px; text-align: center; }

/* 主内容区 */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

/* 顶部栏 */
.topbar {
    height: var(--topbar-height);
    background: #fff; border-bottom: 1px solid #e2e8f0;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px; position: sticky; top: 0; z-index: 100;
}
.topbar-title { font-size: 16px; font-weight: 600; color: #1e293b; }
.topbar-user { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.topbar-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 600;
}

/* 内容区 */
.content-wrap { padding: 24px; }

/* 统计卡片 */
.stat-card {
    background: #fff; border-radius: 12px; padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05); border: 1px solid #e2e8f0;
}
.stat-card .stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
}
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: #1e293b; }
.stat-card .stat-label { font-size: 13px; color: #64748b; }

/* 卡片容器 */
.card {
    border: 1px solid #e2e8f0; border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.card-header {
    background: #fff; border-bottom: 1px solid #e2e8f0;
    padding: 16px 20px; font-weight: 600;
    border-radius: 12px 12px 0 0 !important;
}

/* 表格 */
.table th { font-weight: 600; color: #64748b; font-size: 13px; white-space: nowrap; }
.table td { vertical-align: middle; }

/* 搜索框 */
.search-box {
    position: relative;
}
.search-box input {
    padding-left: 40px; border-radius: 8px;
    border: 1px solid #e2e8f0; background: #f8fafc;
}
.search-box i {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: #94a3b8;
}

/* AI 聊天界面 */
.chat-container {
    display: flex; flex-direction: column; height: calc(100vh - var(--topbar-height) - 48px);
}
.chat-messages {
    flex: 1; overflow-y: auto; padding: 20px;
}
.chat-message {
    margin-bottom: 16px; max-width: 80%; display: flex; gap: 12px;
}
.chat-message.user { margin-left: auto; flex-direction: row-reverse; }
.chat-bubble {
    padding: 12px 16px; border-radius: 12px; font-size: 14px; line-height: 1.6;
    word-break: break-word;
}
.chat-message.user .chat-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-message.ai .chat-bubble { background: #fff; border: 1px solid #e2e8f0; border-bottom-left-radius: 4px; }
.chat-avatar {
    width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
}
.chat-message.user .chat-avatar { background: var(--primary); color: #fff; }
.chat-message.ai .chat-avatar { background: #e2e8f0; color: #64748b; }
.chat-input-area {
    padding: 16px 20px; background: #fff; border-top: 1px solid #e2e8f0;
    display: flex; gap: 12px;
}
.chat-input-area input {
    flex: 1; border: 1px solid #e2e8f0; border-radius: 8px;
    padding: 10px 16px; font-size: 14px;
}
.chat-sources { margin-top: 8px; font-size: 12px; color: #64748b; }
.chat-sources a { color: var(--primary); text-decoration: none; }

/* 知识库浏览 */
.kb-card {
    background: #fff; border-radius: 12px; padding: 20px;
    border: 1px solid #e2e8f0; transition: all .2s;
}
.kb-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); transform: translateY(-2px); }
.kb-card .kb-title { font-size: 16px; font-weight: 600; color: #1e293b; margin-bottom: 8px; }
.kb-card .kb-summary { font-size: 13px; color: #64748b; line-height: 1.6; }
.kb-card .kb-meta { font-size: 12px; color: #94a3b8; margin-top: 12px; display: flex; gap: 16px; }

/* 知识库分类导航（白底卡片内） */
.card .sidebar-link {
    color: #475569;
    border-left-color: transparent;
}
.card .sidebar-link:hover {
    background: #f1f5f9;
    color: #1e293b;
}
.card .sidebar-link.active {
    background: rgba(59, 130, 246, .1);
    color: #2563eb;
    border-left-color: #3b82f6;
    font-weight: 600;
}

/* 文章详情 */
.article-content {
    background: #fffdf8; border-radius: 12px; padding: 32px;
    border: 1px solid #e2e8f0; line-height: 1.8; color: #2c3e50;
}
.article-content h1, .article-content h2, .article-content h3 { margin-top: 24px; margin-bottom: 12px; color: #1e293b; }
.article-content img { max-width: 100%; border-radius: 8px; }
.article-content pre { background: #f1f5f9; padding: 16px; border-radius: 8px; overflow-x: auto; }
.article-content code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: .9em; }
.article-content table { width: 100%; border-collapse: separate; border-spacing: 0; border-radius: 12px; overflow: hidden; margin: 20px 0; }
.article-content table th { background: #1a3a5c !important; color: #fff !important; font-weight: 600; padding: 12px 16px; text-align: left; border: none; }
.article-content table td { padding: 10px 16px; border-bottom: 1px solid #e8e4de; color: #2c3e50; }
.article-content table tr:nth-child(even) td { background-color: #f9f8f5; }
.article-content table tr:hover td { background-color: #f0ede6; }
.article-content mark { background: #fef08a; padding: 2px 4px; border-radius: 2px; }

/* 分类树 */
.cat-tree { list-style: none; padding-left: 0; }
.cat-tree ul { list-style: none; padding-left: 24px; }
.cat-tree-item {
    padding: 8px 12px; border-radius: 6px; cursor: pointer;
    display: flex; align-items: center; justify-content: space-between;
    transition: background .15s;
}
.cat-tree-item:hover { background: #f1f5f9; }
.cat-tree-item.active { background: rgba(59,130,246,.08); color: var(--primary); }

/* 标签 */
.badge-tag {
    display: inline-block; padding: 2px 8px; background: #e2e8f0;
    border-radius: 4px; font-size: 12px; color: #475569; margin: 2px;
}

/* Toast */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; }

/* 加载动画 */
.loading-spinner {
    display: inline-block; width: 20px; height: 20px;
    border: 2px solid #e2e8f0; border-top-color: var(--primary);
    border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 空状态 */
.empty-state {
    text-align: center; padding: 60px 20px; color: #94a3b8;
}
.empty-state i { font-size: 48px; margin-bottom: 16px; }

/* 权限复选框组 */
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }

/* 登录页面 */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, #2563eb 100%);
}
.login-card {
    background: #fff; border-radius: 16px; padding: 40px;
    width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-card h2 { text-align: center; color: var(--primary); margin-bottom: 32px; }

/* 响应式 */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .chat-message { max-width: 95%; }
}
