/**
 * common-sidebar.css v2 - AI剪导师 Phase2 侧栏导航样式
 * 侧栏固定左侧，不参与DOM流
 * 移动端收起60px图标栏，展开200px overlay
 */

/* ==================== 侧栏基础样式 ==================== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width, 200px);
    background: var(--sidebar-bg, #fcfbf8);
    color: #2a2520;
    border-right: 1px solid #ede9e2;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    overflow-y: auto;
    transition: width 0.3s ease, box-shadow 0.3s ease;
}

/* ==================== 品牌区 ==================== */
.sidebar-brand {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #ede9e2;
    margin-bottom: 8px;
}

.sidebar-logo {
    font-size: 24px;
    line-height: 1;
}

.sidebar-title {
    font-size: 16px;
    font-weight: 700;
    color: #1f2433;
    white-space: nowrap;
}

/* ==================== 主链接区 ==================== */
.sidebar-links {
    flex: 1;
    padding: 8px 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: var(--sidebar-text, #4a453f);
    text-decoration: none;
    border-radius: 8px;
    border-left: 3px solid transparent;
    margin: 0 8px;
    transition: all 0.2s ease;
    font-size: 14px;
}

.sidebar-link:hover {
    background: #f5f1ea;
    color: var(--sidebar-text-hover, #2a2520);
}

    .sidebar-link.active {
    background: var(--sidebar-active-bg, rgba(108, 92, 231, 0.08));
    color: #5a43d0;
    border-left: 3px solid var(--accent, #6c5ce7);
    font-weight: 600;
}

.sidebar-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
    line-height: 1;
}

.sidebar-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==================== 分隔线 ==================== */
.sidebar-divider {
    height: 1px;
    background: #ede9e2;
    margin: 8px 20px;
}

/* ==================== 底部链接区 ==================== */
.sidebar-bottom {
    padding: 8px 0;
}

/* ==================== 展开按钮（移动端） ==================== */
.sidebar-expand-btn {
    display: none;
    position: fixed;
    bottom: 20px;
    left: var(--sidebar-mobile-width, 60px);
    width: 36px;
    height: 36px;
    background: #fcfbf8;
    color: #2a2520;
    border: 1px solid #ede9e2;
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
    z-index: 1001;
    transition: left 0.3s ease, background 0.2s ease, color 0.2s ease;
}

.sidebar-expand-btn:hover {
    background: rgba(108, 92, 231, 0.1);
    color: var(--accent, #6c5ce7);
}

/* ==================== Overlay backdrop ==================== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

/* ==================== Body侧栏偏移（仅注入侧栏后生效，浮窗模式页不被推右） ==================== */
body.has-sidebar {
    padding-left: var(--sidebar-width, 200px);
    background: var(--bg-primary, #f5f5fa);
    min-height: 100vh;
}

/* ==================== Footer样式 ==================== */
.common-footer {
    text-align: center;
    padding: 24px 16px;
    margin-top: 40px;
    border-top: 1px solid #eee;
    color: var(--text-muted, #999);
    font-size: 13px;
}

.common-footer-content p {
    margin: 4px 0;
}

.common-footer-icp a {
    color: var(--text-muted, #999);
    text-decoration: none;
}

.common-footer-icp a:hover {
    color: var(--accent, #8b5cf6);
}

/* ==================== 移动端响应式（≤768px） ==================== */
@media (max-width: 768px) {
    .sidebar {
        width: var(--sidebar-mobile-width, 60px);
        padding: 12px 0;
    }

    .sidebar-brand .sidebar-title {
        display: none;
    }

    .sidebar-brand {
        padding: 12px 0;
        justify-content: center;
    }

    .sidebar-link .sidebar-label {
        display: none;
    }

    .sidebar-link {
        padding: 10px 0;
        justify-content: center;
        margin: 0 4px;
    }

    .sidebar-icon {
        font-size: 20px;
    }

    .sidebar-divider {
        margin: 4px 8px;
    }

    body.has-sidebar {
        padding-left: var(--sidebar-mobile-width, 60px);
    }

    .sidebar-expand-btn {
        display: block;
        left: var(--sidebar-mobile-width, 60px);
    }

    /* ==================== 展开状态 ==================== */
    .sidebar.expanded {
        width: 200px;
        box-shadow: 4px 0 24px rgba(30, 40, 80, 0.12);
    }

    .sidebar.expanded .sidebar-title {
        display: block;
    }

    .sidebar.expanded .sidebar-label {
        display: block;
    }

    .sidebar.expanded .sidebar-brand {
        padding: 16px 20px;
        justify-content: flex-start;
    }

    .sidebar.expanded .sidebar-link {
        padding: 12px 20px;
        justify-content: flex-start;
        margin: 0 8px;
    }
}

/* ==================== 小屏幕微调（≤480px） ==================== */
@media (max-width: 480px) {
    .sidebar {
        width: 50px;
        padding: 8px 0;
    }

    .sidebar-brand {
        padding: 8px 0;
    }

    .sidebar-logo {
        font-size: 20px;
    }

    .sidebar-link {
        padding: 8px 0;
        margin: 0 2px;
    }

    .sidebar-icon {
        font-size: 18px;
        width: 20px;
    }

    .sidebar-divider {
        margin: 2px 4px;
    }

    body.has-sidebar {
        padding-left: 50px;
    }

    .sidebar-expand-btn {
        left: 50px;
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .sidebar.expanded {
        width: 180px;
    }
}

/* ==================== 浮动知识库按钮 ==================== */
.float-kb-btn {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1100;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 999px;
    background: var(--accent-warm, linear-gradient(135deg, #8b5cf6 0%, #e8943a 100%));
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.35), 0 8px 24px rgba(232, 148, 58, 0.22);
    cursor: grab;
    user-select: none;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    font-family: var(--font-sans, "PingFang SC", "Microsoft YaHei", sans-serif);
}

.float-kb-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.42), 0 10px 30px rgba(232, 148, 58, 0.28);
}

.float-kb-btn:active {
    cursor: grabbing;
}

.float-kb-icon {
    font-size: 18px;
    line-height: 1;
}

.float-kb-label {
    white-space: nowrap;
}

/* ==================== 知识库聊天窗口 ==================== */
.float-kb-panel {
    position: fixed;
    right: 24px;
    bottom: 92px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 8px 30px rgba(44, 39, 64, 0.18), 0 2px 8px rgba(44, 39, 64, 0.08);
    border: 1px solid #ede9e2;
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 1101;
    font-family: var(--font-sans, "PingFang SC", "Microsoft YaHei", sans-serif);
}

.float-kb-panel.float-kb-open {
    display: flex;
    animation: floatKbSlideUp 0.22s ease;
}

@keyframes floatKbSlideUp {
    from { opacity: 0; transform: translateY(18px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.float-kb-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: var(--accent-warm, linear-gradient(135deg, #8b5cf6 0%, #e8943a 100%));
    color: #fff;
}

.float-kb-header-icon {
    font-size: 20px;
    line-height: 1;
}

.float-kb-header-title {
    flex: 1;
    font-size: 15px;
    font-weight: 600;
}

.float-kb-close {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.18s ease;
}

.float-kb-close:hover {
    background: rgba(255, 255, 255, 0.35);
}

.float-kb-body {
    flex: 1;
    overflow: hidden;
    background: #faf8f5;
}

.float-kb-messages {
    height: 100%;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.float-kb-msg {
    display: flex;
    width: 100%;
}

.float-kb-msg-user {
    justify-content: flex-end;
}

.float-kb-msg-bot {
    justify-content: flex-start;
}

.float-kb-bubble {
    max-width: 78%;
    padding: 11px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
}

.float-kb-msg-bot .float-kb-bubble {
    background: #fff;
    color: #2a2520;
    border: 1px solid #ede9e2;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(44, 39, 64, 0.05);
}

.float-kb-msg-user .float-kb-bubble {
    background: var(--accent-warm, linear-gradient(135deg, #8b5cf6, #e8943a));
    color: #fff;
    border-bottom-right-radius: 4px;
}

.float-kb-footer {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    background: #fff;
    border-top: 1px solid #ede9e2;
}

.float-kb-input {
    flex: 1;
    border: 1px solid #e3dcd1;
    border-radius: 999px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    background: #faf8f5;
    color: #2a2520;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.float-kb-input:focus {
    border-color: var(--accent, #8b5cf6);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12);
}

.float-kb-send {
    border: none;
    border-radius: 999px;
    padding: 0 18px;
    background: var(--accent-warm, linear-gradient(135deg, #8b5cf6, #e8943a));
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.18s ease;
}

.float-kb-send:hover {
    opacity: 0.9;
}

/* 移动端适配 */
@media (max-width: 480px) {
    .float-kb-btn {
        right: 16px;
        bottom: 16px;
        padding: 10px 16px;
        font-size: 13px;
    }

    .float-kb-panel {
        right: 12px;
        bottom: 76px;
        width: calc(100vw - 24px);
        height: 460px;
        max-height: calc(100vh - 100px);
        border-radius: 16px;
    }

    .float-kb-label {
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}
