/* 壳层 AI Copilot 侧栏 — @date 2026-07-21 */
/* toggle：顺应顶栏 .navbar-top-links li a 基准(46px 高/15px 纵向 padding)，
   不与顶栏对抗异常尺寸；用主色文字+图标做辨识，激活态主色实心底与顶栏 hover 灰拉开 @date 2026-08-01 */
.ai-copilot-toggle {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center;
    gap: 0;
    width: 45px;
    height: 46px;
    line-height: 46px !important;        /* 对齐顶栏其他链接(切换系统/消息/超管)垂直居中 */
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;         /* 顺应顶栏方角，不做胶囊 */
    background: transparent !important;
    color: var(--color-primary, #376aea) !important;
    font-size: 13px !important;          /* 对齐顶栏邻居(13px)，不被顶栏放大 */
    font-weight: 500;
    box-shadow: none !important;
    transition: background 0.15s ease, color 0.15s ease;
}
.ai-copilot-toggle:hover,
.ai-copilot-toggle:focus:hover {
    background: #e1e9fc !important;
    color: var(--color-primary, #376aea) !important;
}
.ai-copilot-toggle:focus {
    outline: none;
    background: transparent !important;
    color: var(--color-primary, #376aea) !important;
}
.ai-copilot-toggle.is-active,
.ai-copilot-toggle.is-active:hover {
    background: #e1e9fc !important;
    color: var(--color-primary, #376aea) !important;
}
.ai-copilot-toggle.is-active:focus {
    outline: none;
    background: #e1e9fc !important;
    color: var(--color-primary, #376aea) !important;
}
.ai-copilot-toggle .ai-copilot-toggle__icon {
    width: 28px;
    height: 28px;
    display: block;
    object-fit: contain;           /* 方形贴合原图(SVG四周留白多,contain显完整图形不裁切) */
    vertical-align: middle;
}
.ai-copilot-toggle .ai-copilot-toggle__label {
    display: none !important;
}

.theme-clean #main-navbar .right-navbar-nav > li > a.ai-copilot-toggle {
    color: rgba(255, 255, 255, 0.85) !important;
}
.theme-clean #main-navbar .right-navbar-nav > li > a.ai-copilot-toggle:focus {
    background: transparent !important;
    color: rgba(255, 255, 255, 0.85) !important;
}
.theme-clean #main-navbar .right-navbar-nav > li > a.ai-copilot-toggle.is-active,
.theme-clean #main-navbar .right-navbar-nav > li > a.ai-copilot-toggle:hover,
.theme-clean #main-navbar .right-navbar-nav > li > a.ai-copilot-toggle:focus:hover,
.theme-clean #main-navbar .right-navbar-nav > li > a.ai-copilot-toggle.is-active:focus,
.theme-clean #main-navbar .right-navbar-nav > li > a.ai-copilot-toggle.is-active:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #7aadff !important;
}

/* 默认/最大：挤压主内容区；悬浮不挤
 * 必须 !important：盖过 shell 的 #content-main.row { margin-right:0 !important } */
body.ai-copilot-open #content-main {
    margin-right: var(--ai-copilot-w, 380px) !important;
    transition: margin-right 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
body.ai-copilot-float #content-main,
body.ai-copilot-resizing #content-main {
    transition: none;
}
body.ai-copilot-float #content-main {
    margin-right: 0 !important;
}

.ai-copilot-panel {
    position: fixed;
    top: 51px;                 /* 对齐 .navbar 实际底(51px)，使 chrome 顶栏与 .content-tabs 同条带(2026-08-01)；旧值 46 是 navbar 改高前的遗留 */
    right: 0;
    bottom: 0;
    width: 0;
    z-index: 1040;
    background: #fff;
    border-left: 1px solid transparent;
    display: flex;
    flex-direction: column;
    overflow: visible;
    transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.2s ease,
                box-shadow 0.28s ease,
                border-radius 0.2s ease,
                opacity 0.15s ease;
    box-shadow: none;
}
.ai-copilot-panel.is-closed {
    width: 0 !important;
    border-left-color: transparent;
    pointer-events: none;
}
.ai-copilot-panel.is-closed .ai-copilot-resize,
.ai-copilot-panel.is-closed .ai-copilot-hist {
    display: none !important;
}
.ai-copilot-panel.is-open {
    width: var(--ai-copilot-w, 380px);
    border-left-color: #e5e7eb;
    pointer-events: auto;
}
.ai-copilot-panel.is-open.is-max {
    width: var(--ai-copilot-w, min(720px, 50vw));
}
.ai-copilot-panel.is-float {
    top: 52px;
    right: 8px;
    bottom: auto;
    height: calc(100vh - 16px);
    max-height: calc(100vh - 16px);
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    /* 悬浮阴影减一档，少抢业务区视觉 */
    box-shadow: 0 8px 20px rgba(16, 24, 40, 0.1);
    overflow: visible;
}
/* 悬浮失焦：点业务区后半透明，少挡表列 */
.ai-copilot-panel.is-float.is-dim {
    opacity: 0.52;
}
.ai-copilot-panel.is-float.is-dim:hover {
    opacity: 0.78;
}
.ai-copilot-panel.is-float.is-open {
    width: var(--ai-copilot-w, 380px);
}
.ai-copilot-panel.is-float.is-open.is-max {
    width: var(--ai-copilot-w, min(720px, 48vw));
}
/* 窄屏悬浮：默认更窄，少挡业务列表 */
@media (max-width: 1100px) {
    .ai-copilot-panel.is-float.is-open {
        width: var(--ai-copilot-w, min(340px, 42vw));
    }
    .ai-copilot-panel.is-float.is-open.is-max {
        width: var(--ai-copilot-w, min(520px, 55vw));
    }
}
.ai-copilot-panel.is-dragging,
.ai-copilot-panel.is-resizing {
    transition: none;
    user-select: none;
}
.ai-copilot-panel.is-float.is-dragging {
    opacity: 0.88;
}

/* 左缘拖宽把手 + 常驻细线（挤压档可发现，不弹居中 toast） */
.ai-copilot-resize {
    position: absolute;
    left: -4px;
    top: 0;
    bottom: 0;
    width: 8px;
    cursor: col-resize;
    z-index: 6;
    background: transparent;
}
.ai-copilot-resize::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 28%;
    bottom: 28%;
    width: 2px;
    border-radius: 1px;
    background: transparent;
    transition: background 0.15s ease, opacity 0.15s ease;
}
/* 挤压档常驻浅灰细线，提示可拖 */
.ai-copilot-panel.is-open:not(.is-float) .ai-copilot-resize::after {
    background: #d1d5db;
    opacity: 0.9;
}
.ai-copilot-resize:hover::after,
.ai-copilot-panel.is-resizing .ai-copilot-resize::after {
    background: var(--color-primary, #376aea);
    opacity: 1;
}
.ai-copilot-resize:hover,
.ai-copilot-panel.is-resizing .ai-copilot-resize {
    background: rgba(55, 106, 234, 0.12);
}
.ai-copilot-panel.is-float .ai-copilot-resize {
    border-radius: 12px 0 0 12px;
}
/* 首次悬停：贴左缘 tip，非页面正中 */
.ai-copilot-resize-tip {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 40;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(31, 41, 55, 0.92);
    color: #fff;
    font-size: 11px;
    line-height: 1.3;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(16, 24, 40, 0.18);
}

/* chrome：与左侧 .content-tabs 标签栏同条带等高(30px / line-height:30px)，视觉语言也统一——
   同色背景(#fafafa)、无顶边框(靠 navbar 阴影分隔)、保留下边框+轻阴影分隔下方内容(2026-08-01) */
.ai-copilot-panel__chrome {
    position: relative;
    flex-shrink: 0;
    height: 30px;
    line-height: 30px;
    padding: 0 6px 0 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom: 1px solid #eee;
    background: #fafafa;
    box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.1);
    /*历史下拉挂在面板标题栏内，父层必须高于透明遮罩才能接收点击*/
    z-index: 19;
    overflow: visible;
}
.ai-copilot-panel.is-float .ai-copilot-panel__chrome {
    cursor: move;
    border-radius: 12px 12px 0 0;
}
.ai-copilot-panel__title {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #1f2937;
    flex-shrink: 0;
}
.ai-copilot-panel__title svg {
    width: 14px;
    height: 14px;
    color: var(--color-primary, #376aea);
}
.ai-copilot-panel__ctx {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    font-size: 11px;
}
.ai-copilot-panel__pill {
    flex-shrink: 1;
    min-width: 0;
    max-width: 7.5em;
    background: #f5f8ff;
    border: 1px solid #c9d8f8;
    color: var(--color-primary, #376aea);
    border-radius: 999px;
    padding: 0 6px;
    font-weight: 500;
    font-size: 10px;
    line-height: 18px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ai-copilot-panel__pill.is-locked {
    background: #eef2ff;
    border-color: #a5b4fc;
    box-shadow: inset 0 0 0 1px rgba(55, 106, 234, 0.12);
}
.ai-copilot-pending-btn {
    position: relative;
}
.ai-copilot-pending-btn__badge {
    position: absolute;
    top: 1px;
    right: 1px;
    min-width: 14px;
    height: 14px;
    padding: 0 3px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    line-height: 14px;
    text-align: center;
    font-weight: 600;
}
.ai-copilot-pending {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 20;
    width: 260px;
}
.ai-copilot-pending[hidden] {
    display: none !important;
}
.ai-copilot-pending__panel {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
    overflow: hidden;
}
.ai-copilot-pending__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 600;
    border-bottom: 1px solid #f3f4f6;
}
.ai-copilot-pending__clear {
    border: 0;
    background: transparent;
    color: #6b7280;
    font-size: 11px;
    cursor: pointer;
}
.ai-copilot-pending__list {
    max-height: 220px;
    overflow: auto;
}
.ai-copilot-pending__empty {
    padding: 14px 10px;
    color: #9ca3af;
    font-size: 12px;
    text-align: center;
}
.ai-copilot-pending__item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-bottom: 1px solid #f9fafb;
    font-size: 12px;
}
.ai-copilot-pending__t {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #374151;
}
.ai-copilot-pending__item button {
    border: 0;
    background: #f3f4f6;
    color: #374151;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    cursor: pointer;
}
.ai-copilot-pending__item button[data-pending-open] {
    background: #eef2ff;
    color: var(--color-primary, #376aea);
}
.ai-copilot-panel__meta {
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 10px;
}
.ai-copilot-panel__actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    position: relative;
}
.ai-copilot-icon-btn {
    width: 26px;
    height: 26px;
    border: none;
    background: transparent;
    border-radius: 4px;
    color: #6b7280;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}
.ai-copilot-icon-btn:hover {
    background: #f3f4f6;
    color: #1f2937;
}
.ai-copilot-icon-btn.is-on {
    background: var(--color-primary-light, #E0ECFD);
    color: var(--color-primary, #376aea);
    box-shadow: inset 0 0 0 1px rgba(55, 106, 234, 0.35);
}

.ai-copilot-panel__body {
    flex: 1;
    min-height: 0;
    display: flex;
    position: relative;
    overflow: hidden;
    border-radius: 0 0 0 0;
}
.ai-copilot-panel.is-float .ai-copilot-panel__body {
    border-radius: 0 0 12px 12px;
    padding-bottom: 4px;
}

.ai-copilot-sessions {
    width: 0;
    flex-shrink: 0;
    overflow: hidden;
    border-right: 1px solid transparent;
    background: #f8fafc;
    transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}
.ai-copilot-panel.is-max .ai-copilot-sessions {
    width: 200px;
    border-right-color: #e5e7eb;
}
.ai-copilot-sessions__head {
    flex-shrink: 0;
    height: 36px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #eef0f3;
    font-size: 12px;
    font-weight: 600;
    color: #1f2937;
}
.ai-copilot-sessions__new {
    height: 22px;
    padding: 0 8px;
    border: 1px solid #e5e7eb;
    background: #fff;
    border-radius: 4px;
    font-size: 11px;
    color: #376aea;
    cursor: pointer;
}
.ai-copilot-sessions__new:hover {
    border-color: #376aea;
}
.ai-copilot-sessions__list {
    flex: 1;
    overflow: auto;
    padding: 6px;
}
.ai-copilot-sess-item {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    border-radius: 6px;
    padding: 5px 8px;
    cursor: pointer;
    margin-bottom: 1px;
}
.ai-copilot-sess-item:hover {
    background: #eef2f7;
}
.ai-copilot-sess-item.is-on {
    background: var(--color-primary-light, #E0ECFD);
}
.ai-copilot-sess-item__t {
    display: block;
    font-size: 12px;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ai-copilot-sess-item__m {
    display: block;
    font-size: 10px;
    color: #9ca3af;
    margin-top: 2px;
}
.ai-copilot-sessions__empty {
    padding: 16px 10px;
    font-size: 12px;
    color: #9ca3af;
    text-align: center;
}

.ai-copilot-panel__chat {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}
.ai-copilot-panel__frame {
    flex: 1;
    width: 100%;
    border: 0;
    background: #fafbfc;
}

/* 历史下拉 backdrop：点空白关，轻遮罩不抢戏 */
.ai-copilot-hist-backdrop {
    position: absolute;
    inset: 0;
    z-index: 18;
    background: rgba(15, 23, 42, 0.06);
    border-radius: inherit;
}
.ai-copilot-hist-backdrop[hidden] {
    display: none !important;
}

/* 默认/悬浮：历史下拉变矮（贴 chrome 历史按钮，非满屏） */
.ai-copilot-hist {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    width: 280px;
    max-height: min(240px, 38vh);
    z-index: 20;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.14);
    flex-direction: column;
    overflow: hidden;
}
.ai-copilot-hist.is-open {
    display: flex;
}
.ai-copilot-panel.is-max .ai-copilot-hist {
    display: none !important;
}
.ai-copilot-hist__panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: min(240px, 38vh);
}
.ai-copilot-hist__panel .ai-copilot-sessions__head {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #fff;
}
.ai-copilot-hist .ai-copilot-sessions__list {
    flex: 1 1 auto;
    overflow-y: auto;
    max-height: 180px;
    -webkit-overflow-scrolling: touch;
}
.ai-copilot-panel.is-max .ai-copilot-icon-btn[data-act="hist"] {
    display: none;
}

/* 贴边收条：轻把手 · 真贴右缘 · hover 外探加深 */
.ai-copilot-panel.is-float.is-docked {
    overflow: visible;
    width: 32px !important;
    height: 88px !important;
    max-height: 88px !important;
    right: 0 !important;
    left: auto !important;
    bottom: auto !important;
    border: none;
    border-radius: 10px 0 0 10px;
    box-shadow: none;
    opacity: 1 !important;
    background: transparent;
}
.ai-copilot-dock-strip {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 8;
    border: 1px solid #c9d8f8;
    border-right: none;
    border-radius: 10px 0 0 10px;
    background: #f5f8ff;
    color: var(--color-primary, #376aea);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    box-shadow: -2px 2px 8px rgba(16, 24, 40, 0.08);
    transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.ai-copilot-dock-strip__inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    pointer-events: none;
}
.ai-copilot-dock-strip__icon {
    display: block;
    flex-shrink: 0;
}
.ai-copilot-dock-strip__label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.14em;
    line-height: 1.1;
    writing-mode: vertical-rl;
    text-orientation: upright;
}
.ai-copilot-dock-strip:hover {
    background: var(--color-primary, #376aea);
    border-color: var(--color-primary, #376aea);
    color: #fff;
    transform: translateX(-4px);
    box-shadow: -4px 4px 14px rgba(55, 106, 234, 0.28);
}
.ai-copilot-panel.is-docked .ai-copilot-resize,
.ai-copilot-panel.is-docked .ai-copilot-panel__chrome,
.ai-copilot-panel.is-docked .ai-copilot-panel__body,
.ai-copilot-panel.is-docked .ai-copilot-hist,
.ai-copilot-panel.is-docked .ai-copilot-hist-backdrop {
    display: none !important;
}
.ai-copilot-panel.is-docked .ai-copilot-dock-strip {
    display: flex;
}
