/* ========== 研知创学术 · 静态页面样式 ========== */
:root {
    --brand: #2f6bff;
    --brand-dark: #1f56e0;
    --brand-light: #eef4ff;
    --bg: #e9eef7;
    --sidebar-bg: #f4f7fc;
    --card: #ffffff;
    --text: #1c2433;
    --text-2: #5c6678;
    --text-3: #97a0b3;
    --border: #e6ebf4;
    --shadow-card: 0 8px 30px rgba(31, 66, 138, 0.08);
    --radius: 18px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
}

.app { display: flex; height: 100vh; overflow: hidden; }

/* ================= 左侧边栏 ================= */
.sidebar {
    width: 216px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
    transition: width .25s ease;
}
.sidebar.collapsed { width: 68px; }
.sidebar.collapsed .logo-wrap,
.sidebar.collapsed .logo-name,
.sidebar.collapsed .side-search span,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .side-section,
.sidebar.collapsed .new-chat-btn span,
.sidebar.collapsed .user-info,
.sidebar.collapsed .user-setting { display: none; }
.sidebar.collapsed .side-search { justify-content: center; padding: 10px; }
.sidebar.collapsed .sidebar-logo { justify-content: center; }
.sidebar.collapsed .new-chat-btn { justify-content: center; }
.sidebar.collapsed .side-user { justify-content: center; }

/* Logo */
.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 6px 16px;
}
.logo-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; }
.logo-mark {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 9px;
    object-fit: cover;
    display: block;
}
.logo-name { font-size: 17px; font-weight: 700; white-space: nowrap; color: #000; }
.collapse-btn {
    border: none; background: none; color: var(--text-3);
    cursor: pointer; padding: 6px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
}
.collapse-btn:hover { background: #e6ecf7; color: var(--text-2); }

/* 侧边搜索框 */
.side-search {
    display: flex; align-items: center; gap: 9px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 13px;
    color: var(--text-2);
    margin-bottom: 14px;
    cursor: text;
}
.side-search:hover { border-color: var(--brand); }

/* 导航 */
.side-nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 11px;
    border-radius: 9px;
    color: var(--text);
    text-decoration: none;
    font-size: 13.5px;
    transition: background .15s;
}
.nav-item svg { flex-shrink: 0; color: var(--text-2); }
.nav-item:hover { background: #e9eef9; }
.nav-item.active {
    background: var(--brand-light);
    color: var(--brand);
    font-weight: 600;
}
.nav-item.active svg { color: var(--brand); }

/* 二级导航 */
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-arrow {
    margin-left: auto;
    color: var(--text-3);
    transition: transform .2s;
}
.nav-group.open .nav-arrow { transform: rotate(90deg); }
.nav-sub {
    display: none;
    flex-direction: column;
    gap: 2px;
    padding-left: 20px;
}
.nav-group.open .nav-sub { display: flex; }
.nav-sub-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border-radius: 8px;
    color: var(--text-2);
    text-decoration: none;
    font-size: 13px;
    white-space: nowrap;
    transition: background .15s;
}
.nav-sub-item svg { flex-shrink: 0; color: var(--text-3); }
.nav-sub-item:hover { background: #e9eef9; color: var(--text); }
.nav-sub-item.active { color: var(--brand); font-weight: 600; }
.nav-sub-item.active svg { color: var(--brand); }
.sidebar.collapsed .nav-sub,
.sidebar.collapsed .nav-arrow { display: none; }



/* ================= 右侧区域 ================= */
.main-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 顶部导航栏：独立容器，通栏贴顶，与侧边栏 Logo 区等高对齐 */
.topbar {
    flex-shrink: 0;
    height: 54px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 22px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border);
}

/* 手机端菜单按钮：桌面隐藏，≤640px 由响应式显示 */
.menu-toggle { display: none; }
/* 手机端顶栏品牌 / 导航按钮 / 抽屉头部：桌面隐藏 */
.topbar-brand, .topbar-head, .nav-toggle { display: none; }
/* 导航链接容器：桌面端 contents，子元素直接参与 .topbar 布局；≤640px 变为右侧抽屉 */
.topbar-nav { display: contents; }
/* 抽屉遮罩：由 main.js 动态创建，仅手机端 .show 时显示 */
.sidebar-mask { display: none; }

/* ================= 主内容区 ================= */
.main {
    flex: 1;
    overflow-y: auto;
    padding: 18px 22px;
}
.topbar-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    border-radius: 9px;
    color: var(--text-2);
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
    transition: background .15s, color .15s;
}
.topbar-group { position: relative; }
.topbar-parent .nav-arrow { transition: transform .15s; color: var(--text-3); }
.topbar-group:hover .nav-arrow { transform: rotate(90deg); }
.topbar-sub {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 120px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-card);
    padding: 6px;
    display: none;
    z-index: 200;
}
/* 透明桥接 6px 间隙，防止鼠标移动时下拉闪断 */
.topbar-sub::before { content: ''; position: absolute; top: -6px; left: 0; right: 0; height: 6px; }
.topbar-group:hover .topbar-sub { display: block; }
.topbar-sub a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--text-2);
    text-decoration: none;
    font-size: 13.5px;
}
.topbar-sub a:hover { background: #f1f4fb; color: var(--text); }
.topbar-item:hover {
    background: #e9eef9;
    color: var(--text);
}
.topbar-item.active {
    background: var(--brand-light);
    color: var(--brand);
    font-weight: 600;
}
.chat-card {
    max-width: 1080px;
    margin: 0 auto;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 34px 40px 40px;
}

/* 欢迎区 */
.welcome-title {
    font-size: 26px;
    font-weight: 800;
    text-align: center;
    letter-spacing: .5px;
}
.welcome-title em {
    font-style: normal;
    background: linear-gradient(90deg, #2f6bff, #6a4bff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.welcome-desc {
    text-align: center;
    color: var(--text-2);
    font-size: 13.5px;
    margin: 10px 0 22px;
}

/* 提问输入框 */
.ask-box {
    border: 1.5px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px 10px;
    transition: border-color .2s, box-shadow .2s;
}
.ask-box:focus-within {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(47, 107, 255, .1);
}
.ask-input {
    width: 100%;
    border: none; outline: none; resize: none;
    font-size: 14px; line-height: 1.6;
    font-family: inherit;
    color: var(--text);
    background: transparent;
}
.ask-input::placeholder { color: var(--text-3); }
.ask-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 8px;
}
.ask-tools { display: flex; gap: 8px; }
.tool-chip {
    display: inline-flex; align-items: center; gap: 5px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 12.5px;
    color: var(--text-2);
    cursor: pointer;
}
.tool-chip:hover { border-color: var(--brand); color: var(--brand); }
.send-btn {
    width: 36px; height: 36px;
    border: none; border-radius: 50%;
    background: linear-gradient(135deg, #2f6bff, #5a4bff);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(47, 107, 255, .35);
}
.send-btn:hover { filter: brightness(1.08); }

/* 快捷功能 */
.quick-row {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 18px;
}
.quick-chips { display: flex; gap: 9px; flex-wrap: wrap; }
.quick-chip {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 999px;
    padding: 6px 16px;
    font-size: 13px;
    color: var(--text-2);
    cursor: pointer;
    transition: all .15s;
}
.quick-chip:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-light); }
.ai-avatar {
    width: 42px; height: 42px; flex-shrink: 0;
    border-radius: 50%;
    background: #2b3245;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700;
    box-shadow: 0 4px 12px rgba(43, 50, 69, .25);
}

/* 筛选条 */
.filter-bar {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--brand-light);
    border-radius: 12px;
    padding: 10px 14px;
    margin: 26px 0 8px;
}
.filter-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-chip {
    display: inline-flex; align-items: center; gap: 4px;
    border: none;
    background: transparent;
    border-radius: 999px;
    padding: 6px 13px;
    font-size: 13px;
    color: var(--text-2);
    cursor: pointer;
    font-family: inherit;
}
.filter-chip svg { color: var(--text-3); }
.filter-chip:hover { background: #dde9ff; }
.filter-chip.active {
    background: var(--brand);
    color: #fff;
    font-weight: 600;
}
.filter-chip.active svg { color: #fff; }
.search-papers-btn {
    display: inline-flex; align-items: center; gap: 6px;
    border: none;
    background: var(--brand);
    color: #fff;
    font-size: 13px; font-weight: 600;
    border-radius: 999px;
    padding: 8px 18px;
    cursor: pointer;
    font-family: inherit;
    flex-shrink: 0;
}
.search-papers-btn:hover { background: var(--brand-dark); }

/* 文献列表 */
.paper-list-title {
    font-size: 16px; font-weight: 700;
    margin: 20px 0 4px;
}
.paper-card {
    display: flex; gap: 20px;
    padding: 20px 4px;
    border-bottom: 1px solid var(--border);
}
.paper-card:last-child { border-bottom: none; }
.paper-main { flex: 1; min-width: 0; }
.paper-title {
    font-size: 16px; font-weight: 700;
    color: var(--text);
    line-height: 1.5;
    cursor: pointer;
}
.paper-title:hover { color: var(--brand); }
.paper-meta {
    display: flex; align-items: center; gap: 10px;
    flex-wrap: wrap;
    margin: 8px 0;
    font-size: 12.5px;
    color: var(--text-3);
}
.paper-authors { color: var(--text-2); }
.journal-tag {
    background: var(--brand-light);
    color: var(--brand);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
}
.paper-abstract {
    font-size: 13px;
    color: var(--text-2);
    line-height: 1.75;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.paper-actions { display: flex; gap: 10px; }
.paper-btn {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 8px;
    padding: 6px 15px;
    font-size: 12.5px;
    color: var(--text-2);
    cursor: pointer;
    font-family: inherit;
}
.paper-btn:hover { border-color: var(--brand); color: var(--brand); }
.paper-btn.primary {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}
.paper-btn.primary:hover { background: var(--brand-dark); }

/* 二维码 */
.paper-qr {
    width: 92px; height: 92px;
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px;
    background: #fff;
}
.paper-qr svg { display: block; width: 100%; height: 100%; }

/* 空状态 */
.empty-tip {
    text-align: center;
    color: var(--text-3);
    font-size: 13px;
    padding: 40px 0;
}

/* ================= 响应式 ================= */
/* 平板（≤900px）：整体收紧 */
@media (max-width: 900px) {
    .topbar { padding: 0 14px; }
    .main { padding: 16px; }
    .chat-card { padding: 24px 20px 28px; }
    .welcome-title { font-size: 21px; }
    .paper-qr { display: none; }
}
/* 中屏（641–900px）：侧栏收成图标栏（≤640px 走手机抽屉方案，不做图标栏） */
@media (max-width: 900px) and (min-width: 641px) {
    .sidebar { width: 60px; }
    .sidebar .logo-name,
    .sidebar .side-search span,
    .sidebar .nav-item span,
    .sidebar .side-section,
    .sidebar .new-chat-btn span,
    .sidebar .user-info,
    .sidebar .user-setting { display: none; }
    .sidebar .side-search { justify-content: center; padding: 10px; }
    .sidebar .new-chat-btn { justify-content: center; }
}

/* 手机（≤640px）：侧栏抽屉化 + 顶栏收纳 + 内容纵向堆叠 */
@media (max-width: 640px) {
    /* 侧栏改为抽屉：固定定位滑出，脱离 flex 文档流；同时兜底用户此前手动折叠的 .collapsed 状态 */
    .sidebar,
    .sidebar.collapsed {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1000;
        width: 268px;
        max-width: 84vw;
        padding: 16px 14px;
        overflow-y: auto;
        transform: translateX(-104%);
        transition: transform .28s ease;
    }
    .sidebar.mobile-open,
    .sidebar.collapsed.mobile-open {
        transform: none;
        box-shadow: 16px 0 48px rgba(31, 66, 138, .2);
    }
    .sidebar.collapsed .logo-name,
    .sidebar.collapsed .side-search span,
    .sidebar.collapsed .nav-item span,
    .sidebar.collapsed .side-section,
    .sidebar.collapsed .new-chat-btn span,
    .sidebar.collapsed .user-info,
    .sidebar.collapsed .user-setting { display: initial; }
    .sidebar.collapsed .sidebar-logo { justify-content: space-between; }
    .sidebar.collapsed .side-search { justify-content: flex-start; padding: 10px 13px; }
    .sidebar.collapsed .new-chat-btn { justify-content: flex-start; }
    .sidebar.collapsed .side-user { justify-content: flex-start; }
    .sidebar.collapsed .nav-sub { display: flex; }
    .sidebar.collapsed .nav-arrow { display: initial; }

    /* 抽屉遮罩（元素由 main.js 按需创建） */
    .sidebar-mask.show {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 999;
        background: rgba(28, 36, 51, .45);
    }

    /* 顶栏：左右两个抽屉按钮 + 中部品牌 */
    .topbar {
        justify-content: space-between;
        padding: 0 10px;
        gap: 2px;
        overflow: visible;
    }
    .menu-toggle,
    .nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 34px;
        height: 34px;
        flex-shrink: 0;
        border: none;
        border-radius: 9px;
        background: transparent;
        color: var(--text-2);
        cursor: pointer;
    }
    .menu-toggle:active,
    .nav-toggle:active { background: #e9eef9; }
    .menu-toggle { margin-right: 2px; }
    .topbar-brand {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        text-decoration: none;
        color: var(--text);
        font-weight: 700;
        font-size: 16px;
    }
    .topbar-brand img { display: block; width: 24px; height: 24px; }

    /* 顶部导航链接改为右侧抽屉：固定定位滑出，脱离顶栏文档流 */
    .topbar-nav {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: 1000;
        width: 264px;
        max-width: 84vw;
        padding: 16px 14px;
        overflow-y: auto;
        background: var(--card);
        transform: translateX(104%);
        transition: transform .28s ease;
    }
    .topbar-nav.mobile-open {
        transform: none;
        box-shadow: -16px 0 48px rgba(31, 66, 138, .2);
    }
    /* 抽屉头部：Logo + 网站名称 */
    .topbar-head {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 2px 6px 14px;
        margin-bottom: 10px;
        border-bottom: 1px solid var(--border);
        color: var(--text);
        font-weight: 700;
        font-size: 16px;
    }
    .topbar-head img { display: block; width: 26px; height: 26px; }
    /* 导航组纵向铺开，二级菜单直接展开（手机端无 hover） */
    .topbar-group { position: static; }
    .topbar-item {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 11px 12px;
        font-size: 14px;
    }
    .topbar-sub {
        display: block;
        position: static;
        min-width: 0;
        background: transparent;
        border: none;
        border-radius: 0;
        box-shadow: none;
        padding: 0 0 6px 12px;
    }
    .topbar-sub::before { display: none; }
    .topbar-sub a { padding: 9px 10px; }

    /* 内容区收紧 */
    .main { padding: 14px 12px; }
    .chat-card { padding: 22px 16px 26px; border-radius: 14px; }
    .welcome-title { font-size: 20px; letter-spacing: 0; }
    .welcome-desc { margin: 8px 0 18px; }
    .ask-box { padding: 12px 13px 9px; }
    .ask-tools { flex-wrap: wrap; }
    .quick-row { flex-wrap: wrap; gap: 12px; }
    .ai-avatar { width: 36px; height: 36px; }

    /* 筛选条：上下两行 */
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        margin-top: 18px;
    }
    .search-papers-btn { justify-content: center; }

    /* 文献卡片：纵向排列 */
    .paper-card { flex-direction: column; gap: 12px; padding: 16px 2px; }
    .paper-title { font-size: 15px; }
    .paper-actions { flex-wrap: wrap; }
}
