/* 全屏对话页 */
body.ai-chat-full-page {
    overflow: hidden;
}
body.ai-chat-full-page main.main-content,
body.ai-chat-full-page .ai-chat-full-wrap {
    padding: 0 !important;
    margin: 0 !important;
    max-width: none !important;
}
body.ai-chat-full-page footer.bg-light {
    display: none;
}
.ai-layout-full {
    display: flex;
    height: calc(100vh - 56px);
    min-height: 480px;
    background: #eef1f4;
}
.ai-sidebar {
    width: 280px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
}
.ai-sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid #eee;
}
.ai-session-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}
.ai-session-item {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    border-radius: 10px;
    padding: 0.65rem 0.75rem;
    margin-bottom: 0.25rem;
    cursor: pointer;
    transition: background 0.15s;
}
.ai-session-item:hover,
.ai-session-item.active {
    background: #f0f7f1;
}
.ai-session-item .title {
    font-size: 0.9rem;
    color: #212529;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ai-session-item .time {
    font-size: 0.72rem;
    color: #6c757d;
}
.ai-main-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 0.75rem 1rem 1rem;
}
.ai-compact-hero {
    flex-shrink: 0;
    background: linear-gradient(135deg, #205A28 0%, #2d7a3d 100%);
    color: #fff;
    border-radius: 12px;
    padding: 0.85rem 1.25rem;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}
.ai-compact-hero h1 {
    font-size: 1.15rem;
    margin: 0;
}
.ai-chat-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    border: none;
    border-radius: 14px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.07);
    overflow: hidden;
    min-height: 0;
    background: #fff;
}
.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    background: #f4f6f8;
    min-height: 0;
}
.ai-msg {
    display: flex;
    margin-bottom: 1rem;
    animation: aiFadeIn 0.25s ease;
}
@keyframes aiFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
.ai-msg.user { justify-content: flex-end; }
.ai-msg-bubble {
    max-width: min(85%, 720px);
    padding: 0.75rem 1rem;
    border-radius: 14px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}
.ai-msg.user .ai-msg-bubble {
    background: #205A28;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.ai-msg.assistant .ai-msg-bubble {
    background: #fff;
    color: #212529;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 4px;
}
.ai-msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.1rem;
}
.ai-msg.user .ai-msg-avatar {
    order: 2;
    margin-left: 0.5rem;
    background: #dee2e6;
    color: #495057;
}
.ai-msg.assistant .ai-msg-avatar {
    margin-right: 0.5rem;
    background: #205A28;
    color: #fff;
}
.ai-citations {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed #dee2e6;
    font-size: 0.85rem;
}
.ai-citations a { color: #205A28; word-break: break-all; }
.ai-input-area {
    padding: 1rem 1.25rem;
    background: #fff;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}
.ai-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}
.ai-suggestion {
    font-size: 0.8rem;
    border-radius: 999px;
    border: 1px solid #ced4da;
    background: #fff;
    padding: 0.25rem 0.75rem;
    cursor: pointer;
}
.ai-suggestion:hover {
    border-color: #205A28;
    color: #205A28;
    background: #f0f7f1;
}
.ai-typing {
    display: none;
    padding: 0.5rem 1.25rem;
    color: #6c757d;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.ai-typing.show { display: block; }

/* 右下角浮动助手 */
.ai-fab {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 1060;
}
/* 与首页/图书馆等 .floating-action-buttons 错开：置于最下方搜索按钮左侧 */
body:has(.floating-action-buttons) .ai-fab {
    right: calc(30px + 56px + 15px);
    bottom: 30px;
    z-index: 99999;
}
body.ai-chat-full-page .ai-fab {
    display: none;
}
.ai-fab-btn {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #205A28 0%, #2d7a3d 100%);
    color: #fff;
    font-size: 1.5rem;
    box-shadow: 0 6px 20px rgba(32, 90, 40, 0.45);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.ai-fab-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 8px 28px rgba(32, 90, 40, 0.5);
}
.ai-fab-panel {
    position: absolute;
    right: 0;
    bottom: 72px;
    width: min(400px, calc(100vw - 32px));
    height: min(560px, calc(100vh - 100px));
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.18);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e9ecef;
}
.ai-fab-panel.open {
    display: flex;
    animation: aiPanelIn 0.22s ease;
}
@keyframes aiPanelIn {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.ai-fab-panel-header {
    background: linear-gradient(135deg, #205A28 0%, #2d7a3d 100%);
    color: #fff;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.ai-fab-panel-header .actions button {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    margin-left: 0.35rem;
    cursor: pointer;
}
.ai-fab-panel-header .actions button:hover {
    background: rgba(255,255,255,0.28);
}
.ai-fab-panel .ai-chat-card {
    flex: 1;
    border-radius: 0;
    box-shadow: none;
    min-height: 0;
}
.ai-fab-panel .ai-messages {
    height: auto;
}

@media (max-width: 768px) {
    body:has(.floating-action-buttons) .ai-fab {
        right: calc(20px + 48px + 12px);
        bottom: 20px;
    }
    body:has(.floating-action-buttons) .ai-fab-btn {
        width: 48px;
        height: 48px;
        font-size: 1.25rem;
    }
    .ai-layout-full {
        flex-direction: column;
        height: calc(100vh - 56px);
    }
    .ai-sidebar {
        width: 100%;
        max-height: 140px;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
    }
    .ai-session-list {
        display: flex;
        flex-direction: row;
        gap: 0.5rem;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 0.5rem;
    }
    .ai-session-item {
        min-width: 140px;
        flex-shrink: 0;
    }
}
