/* ============ 全局 AI 智能助手浮窗 (Global AI Assistant) Shared CSS ============ */

/* --- Floating Button with star-trail glow --- */
.gai-fab { position:fixed; bottom:28px; right:28px; width:56px; height:56px;
  background:radial-gradient(circle at 30% 30%, #6B8AFF 0%, #2E5BFF 45%, #1E3A8A 100%);
  border-radius:50%; z-index:999; border:none; outline:none; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 8px 32px rgba(46,91,255,0.45), 0 2px 8px rgba(46,91,255,0.25),
    inset 0 1px 0 rgba(255,255,255,0.2);
  transition:all 0.3s cubic-bezier(.34,1.56,.64,1); }
.gai-fab:hover { transform:translateY(-2px) scale(1.06);
  box-shadow:0 12px 40px rgba(46,91,255,0.55), 0 4px 12px rgba(46,91,255,0.3),
    inset 0 1px 0 rgba(255,255,255,0.3); }
.gai-fab:active { transform:translateY(0) scale(0.96); }
.gai-fab::before { content:''; position:absolute; inset:-4px; border-radius:50%;
  background:radial-gradient(circle, rgba(46,91,255,0.35) 0%, transparent 70%);
  animation:gaiFabHalo 2.5s ease-in-out infinite; z-index:-1; }
.gai-fab::after { content:''; position:absolute; inset:0; border-radius:50%;
  background:linear-gradient(135deg, rgba(255,255,255,0.25) 0%, transparent 50%);
  pointer-events:none; }
@keyframes gaiFabHalo { 0%,100%{transform:scale(1);opacity:0.6} 50%{transform:scale(1.25);opacity:0.3} }
.gai-fab-icon { position:relative; width:26px; height:26px; color:#fff;
  filter:drop-shadow(0 1px 2px rgba(0,0,0,0.2)); }

/* --- Tooltip --- */
.gai-tooltip { position:fixed; bottom:94px; right:30px; background:#1D2129; color:#fff;
  padding:9px 14px; border-radius:8px; font-size:12px; white-space:nowrap;
  opacity:0; pointer-events:none; transition:opacity 0.3s,transform 0.3s;
  transform:translateY(6px); z-index:999; font-weight:500; letter-spacing:0.2px;
  box-shadow:0 4px 16px rgba(0,0,0,0.2); }
.gai-tooltip.show { opacity:1; transform:translateY(0); }
.gai-tooltip::after { content:''; position:absolute; top:100%; right:22px;
  border:5px solid transparent; border-top-color:#1D2129; }

/* --- Overlay --- */
.gai-overlay { position:fixed; inset:0;
  background:radial-gradient(ellipse at 70% 30%, rgba(30,58,138,0.15) 0%, rgba(0,0,0,0.4) 100%);
  z-index:9998; opacity:0; pointer-events:none; transition:opacity 0.4s ease; }
.gai-overlay.show { opacity:1; pointer-events:auto; }

/* --- Drawer --- */
.gai-drawer { position:fixed; top:0; right:0; width:80vw; max-width:1140px; min-width:600px; height:100vh;
  background:linear-gradient(180deg, #FAFBFF 0%, #FFFFFF 200px); z-index:9999;
  display:flex; flex-direction:row;
  box-shadow:-12px 0 48px rgba(15,23,42,0.18), -2px 0 0 rgba(46,91,255,0.08);
  transform:translateX(100%);
  transition:transform 0.4s cubic-bezier(.32,.72,0,1); }
.gai-drawer.show { transform:translateX(0); }

/* --- Sidebar (历史对话) --- */
.gai-sidebar { width:240px; flex-shrink:0; background:#F7F8FA; border-right:1px solid #E5E6EB;
  display:flex; flex-direction:column; overflow:hidden; }
.gai-sidebar-header { display:flex; align-items:center; justify-content:space-between;
  padding:16px 14px 10px; flex-shrink:0; }
.gai-sidebar-title { font-size:13px; font-weight:600; color:#1D2129; letter-spacing:0.3px; }
.gai-sidebar-new { display:flex; align-items:center; gap:4px; height:26px; padding:0 10px;
  border:1px solid #C7DDFF; background:#EFF4FF; border-radius:13px;
  font-size:12px; font-weight:500; color:#165DFF; cursor:pointer;
  font-family:inherit; transition:all 0.15s; white-space:nowrap; }
.gai-sidebar-new:hover { background:#165DFF; border-color:#165DFF; color:#fff; }
.gai-sidebar-new svg { flex-shrink:0; }
.gai-sidebar-search { position:relative; padding:0 10px 10px; flex-shrink:0; }
.gai-sidebar-search-icon { position:absolute; left:18px; top:50%; transform:translateY(-50%);
  width:14px; height:14px; color:#A0A8B3; pointer-events:none; }
.gai-sidebar-search-input { width:100%; box-sizing:border-box; height:30px; padding:0 10px 0 30px;
  border:1px solid #E5E6EB; border-radius:6px; background:#fff; font-size:12px;
  font-family:inherit; color:#1D2129; outline:none; transition:all 0.15s; }
.gai-sidebar-search-input:focus { border-color:#165DFF; box-shadow:0 0 0 3px rgba(22,93,255,0.08); }
.gai-sidebar-search-input::placeholder { color:#A0A8B3; }
.gai-sidebar-list { flex:1; overflow-y:auto; padding:0 8px 16px; }
.gai-sidebar-list::-webkit-scrollbar { width:4px; }
.gai-sidebar-list::-webkit-scrollbar-thumb { background:#D9D9D9; border-radius:2px; }
.gai-sidebar-list::-webkit-scrollbar-track { background:transparent; }
.gai-history-group { margin-top:8px; }
.gai-history-group-title { font-size:11px; font-weight:600; color:#86909C; letter-spacing:0.3px;
  padding:8px 8px 6px; text-transform:uppercase; }
.gai-history-item { position:relative; padding:10px 12px; border-radius:8px; cursor:pointer;
  margin-bottom:2px; transition:background 0.15s; }
.gai-history-item:hover { background:#EEF0F3; }
.gai-history-item.active { background:#E8F3FF; }
.gai-history-item.active::before { content:''; position:absolute; left:0; top:50%; transform:translateY(-50%);
  width:3px; height:18px; background:#165DFF; border-radius:0 2px 2px 0; }
.gai-history-item-title { font-size:13px; color:#1D2129; line-height:1.5; overflow:hidden;
  text-overflow:ellipsis; white-space:nowrap; padding-right:20px; }
.gai-history-item.active .gai-history-item-title { color:#165DFF; font-weight:500; }
.gai-history-item-time { font-size:11px; color:#A0A8B3; margin-top:4px; }
.gai-history-item-del { position:absolute; right:8px; top:50%; transform:translateY(-50%);
  width:22px; height:22px; border:none; background:transparent; color:#A0A8B3;
  border-radius:4px; cursor:pointer; display:none; align-items:center; justify-content:center;
  transition:all 0.15s; }
.gai-history-item:hover .gai-history-item-del { display:flex; }
.gai-history-item-del:hover { background:#FFECE8; color:#F53F3F; }
.gai-history-empty { text-align:center; padding:40px 12px; color:#A0A8B3; font-size:12px; line-height:1.6; }
.gai-history-empty-icon { width:40px; height:40px; margin:0 auto 10px; opacity:0.4; }
.gai-history-search-empty { text-align:center; padding:30px 12px; color:#A0A8B3; font-size:12px; }

/* --- Main (右侧主区) --- */
.gai-main { flex:1; display:flex; flex-direction:column; min-width:0; min-height:0; }

/* --- Header with gradient accent --- */
.gai-header { display:flex; align-items:center; justify-content:space-between;
  padding:18px 20px 16px; flex-shrink:0;
  background:linear-gradient(180deg, #F0F4FF 0%, rgba(240,244,255,0) 100%);
  border-bottom:1px solid rgba(46,91,255,0.08); }
.gai-header-left { display:flex; align-items:center; gap:12px; }
.gai-header-avatar { position:relative; width:40px; height:40px; flex-shrink:0; }
.gai-header-avatar-inner { width:40px; height:40px; border-radius:50%;
  background:linear-gradient(135deg, #6B8AFF 0%, #2E5BFF 50%, #1E3A8A 100%);
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 4px 12px rgba(46,91,255,0.4), inset 0 1px 0 rgba(255,255,255,0.3); }
.gai-header-avatar-inner svg { width:20px; height:20px; color:#fff; }
.gai-header-dot { position:absolute; bottom:0; right:0; width:12px; height:12px;
  background:#00B42A; border-radius:50%; border:2px solid #FAFBFF;
  box-shadow:0 0 0 2px rgba(0,180,42,0.2); }
.gai-header-title { font-size:16px; font-weight:700; color:#1D2129; letter-spacing:0.2px; }
.gai-header-subtitle { font-size:12px; color:#4E5969; margin-top:2px;
  display:flex; align-items:center; gap:5px; }
.gai-header-subtitle::before { content:''; display:inline-block; width:6px; height:6px;
  background:#00B42A; border-radius:50%; box-shadow:0 0 4px rgba(0,180,42,0.5); }
.gai-header-right { display:flex; gap:6px; }
.gai-header-btn { width:34px; height:34px; border:none; background:#fff;
  border-radius:10px; display:flex; align-items:center; justify-content:center;
  color:#4E5969; cursor:pointer; transition:all 0.2s;
  border:1px solid #E5E8F0; }
.gai-header-btn:hover { background:#F0F4FF; border-color:#2E5BFF; color:#2E5BFF; }
.gai-close-btn:hover { background:#FFF1F0 !important; border-color:#F53F3F !important; color:#F53F3F !important; }

/* --- KB Selector Bar --- */
.gai-kb-bar { flex-shrink:0; padding:6px 18px 8px; background:#fff;
  border-bottom:1px solid #E5E8F0; }
.gai-kb-select { position:relative; }
.gai-kb-trigger { display:inline-flex; align-items:center; gap:6px; height:30px;
  padding:0 10px; border:1px solid #E5E8F0; border-radius:8px; background:#F7F8FA;
  font-size:12px; color:#1D2129; cursor:pointer; transition:all 0.2s; }
.gai-kb-trigger:hover { border-color:#2E5BFF; background:#F0F4FF; }
.gai-kb-trigger-icon { width:14px; height:14px; color:#86909C; flex-shrink:0; }
.gai-kb-trigger-text { max-width:180px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.gai-kb-trigger-arrow { width:12px; height:12px; color:#86909C; flex-shrink:0; transition:transform 0.2s; }
.gai-kb-trigger-count { display:inline-flex; align-items:center; justify-content:center;
  min-width:18px; height:18px; padding:0 5px; border-radius:9px; background:#2E5BFF;
  color:#fff; font-size:10px; font-weight:600; line-height:1; }
.gai-kb-select.open .gai-kb-trigger-arrow { transform:rotate(180deg); }
.gai-kb-select.open .gai-kb-trigger { border-color:#2E5BFF; background:#F0F4FF; }
.gai-kb-drop { position:absolute; top:calc(100% + 6px); left:0; min-width:280px; max-height:400px;
  overflow-y:auto; background:#fff; border-radius:10px;
  box-shadow:0 8px 32px rgba(15,23,42,0.14), 0 2px 8px rgba(15,23,42,0.08);
  border:1px solid #E5E8F0; padding:6px; z-index:10; display:none;
  animation:gaiKbDropIn 0.2s cubic-bezier(.32,.72,0,1); }
.gai-kb-drop::-webkit-scrollbar { width:4px; }
.gai-kb-drop::-webkit-scrollbar-thumb { background:#D9D9D9; border-radius:2px; }
.gai-kb-select.open .gai-kb-drop { display:block; }
@keyframes gaiKbDropIn { from{opacity:0;transform:translateY(-6px)} to{opacity:1;transform:translateY(0)} }
/* --- KB Search --- */
.gai-kb-search { position:sticky; top:0; z-index:1; padding:0 0 6px; background:#fff; }
.gai-kb-search-input { width:100%; height:32px; padding:0 32px 0 10px;
  border:1px solid #E5E8F0; border-radius:6px; font-size:12px; color:#1D2129;
  outline:none; background:#F7F8FA; box-sizing:border-box; transition:all 0.2s; }
.gai-kb-search-input:focus { border-color:#2E5BFF; background:#fff; }
.gai-kb-search-input::placeholder { color:#86909C; }
.gai-kb-search-icon { position:absolute; right:8px; top:50%; transform:translateY(-50%);
  width:14px; height:14px; color:#86909C; pointer-events:none; }
.gai-kb-search-wrap { position:relative; }
.gai-kb-no-result { padding:16px 10px; text-align:center; font-size:12px; color:#86909C;
  display:none; }
.gai-kb-drop-item { display:flex; align-items:center; gap:8px; padding:7px 10px;
  border-radius:6px; cursor:pointer; font-size:13px; color:#1D2129; transition:background 0.15s;
  white-space:nowrap; }
.gai-kb-drop-item:hover { background:#F0F4FF; }
.gai-kb-drop-item.active { background:#E8F3FF; color:#165DFF; font-weight:500; }
.gai-kb-drop-check { width:16px; height:16px; border-radius:4px; border:2px solid #C9CDD4;
  flex-shrink:0; display:flex; align-items:center; justify-content:center; transition:all 0.15s; }
.gai-kb-drop-item.active .gai-kb-drop-check { border-color:#2E5BFF; background:#2E5BFF; }
.gai-kb-drop-item.active .gai-kb-drop-check::after { content:''; display:block; width:8px; height:5px;
  border-left:1.5px solid #fff; border-bottom:1.5px solid #fff; transform:rotate(-45deg) translateY(-1px); }
.gai-kb-drop-check.partial { border-color:#2E5BFF; background:#fff; }
.gai-kb-drop-check.partial::after { content:''; display:block; width:8px; height:2px;
  background:#2E5BFF; border:none; transform:none; border-radius:1px; }
.gai-kb-drop-divider { height:1px; background:#F0F0F0; margin:4px 0; }
.gai-kb-drop-group { margin-bottom:2px; }
.gai-kb-drop-group-head { display:flex; align-items:center; gap:8px; padding:7px 10px;
  border-radius:6px; cursor:pointer; font-size:13px; font-weight:600; color:#1D2129;
  transition:background 0.15s; }
.gai-kb-drop-group-head:hover { background:#F7F8FA; }
.gai-kb-drop-group-arrow { width:14px; height:14px; color:#86909C; flex-shrink:0;
  transition:transform 0.2s; }
.gai-kb-drop-group.open .gai-kb-drop-group-arrow { transform:rotate(90deg); }
.gai-kb-drop-group-children { display:none; padding-left:8px; }
.gai-kb-drop-group.open .gai-kb-drop-group-children { display:block; }
.gai-kb-drop-group-child { padding-left:20px; }

/* --- Body --- */
.gai-body { flex:1; overflow-y:auto; padding:18px 20px 20px; display:flex;
  flex-direction:column; gap:16px; }
.gai-body::-webkit-scrollbar { width:4px; }
.gai-body::-webkit-scrollbar-thumb { background:#D9D9D9; border-radius:2px; }
.gai-body::-webkit-scrollbar-track { background:transparent; }

/* --- Empty state with glow --- */
.gai-empty { flex:1; display:flex; flex-direction:column; align-items:center;
  justify-content:center; text-align:center; gap:12px; padding-bottom:40px; }
.gai-empty-icon-wrap { position:relative; width:72px; height:72px; margin-bottom:4px; }
.gai-empty-icon-glow { position:absolute; inset:0; border-radius:50%;
  background:radial-gradient(circle, rgba(46,91,255,0.3) 0%, transparent 70%);
  animation:gaiEmptyGlow 3s ease-in-out infinite; }
@keyframes gaiEmptyGlow { 0%,100%{transform:scale(1);opacity:0.6} 50%{transform:scale(1.2);opacity:0.3} }
.gai-empty-icon { position:absolute; inset:8px; border-radius:50%;
  background:linear-gradient(135deg, #6B8AFF 0%, #2E5BFF 50%, #1E3A8A 100%);
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 8px 24px rgba(46,91,255,0.35), inset 0 1px 0 rgba(255,255,255,0.3); }
.gai-empty-icon svg { width:32px; height:32px; color:#fff; }
.gai-empty-title { font-size:17px; font-weight:700; color:#1D2129; letter-spacing:0.3px; }
.gai-empty-desc { font-size:13px; color:#86909C; max-width:260px; line-height:1.7; }

/* --- Messages --- */
.gai-msg { display:flex; gap:10px; animation:gaiMsgIn 0.35s cubic-bezier(.22,.61,.36,1); }
@keyframes gaiMsgIn { from{opacity:0;transform:translateY(10px) scale(0.98)} to{opacity:1;transform:translateY(0) scale(1)} }
.gai-msg-icon { width:32px; height:32px; border-radius:50%; display:flex; align-items:center;
  justify-content:center; font-size:12px; font-weight:700; color:#fff; flex-shrink:0;
  margin-top:2px; }
.gai-msg-icon.user { background:linear-gradient(135deg, #5B8FF9, #2E5BFF);
  box-shadow:0 2px 8px rgba(46,91,255,0.3); }
.gai-msg-icon.ai { background:linear-gradient(135deg, #6B8AFF 0%, #2E5BFF 50%, #1E3A8A 100%);
  box-shadow:0 2px 8px rgba(46,91,255,0.3); }
.gai-msg-icon.ai svg { width:16px; height:16px; }
.gai-msg-content { max-width:calc(100% - 46px); min-width:0; }
.gai-msg-bubble { padding:10px 14px; border-radius:14px; font-size:13.5px;
  line-height:1.7; color:#1D2129; word-break:break-word; }
.gai-msg.user { flex-direction:row-reverse; }
.gai-msg.user .gai-msg-content { text-align:right; }
.gai-msg.user .gai-msg-bubble { background:linear-gradient(135deg, #2E5BFF 0%, #1E3A8A 100%);
  color:#fff; border-bottom-right-radius:4px; box-shadow:0 2px 8px rgba(46,91,255,0.2);
  display:inline-block; text-align:left; }
.gai-msg.user .gai-msg-bubble strong { color:#BFDBFE; }
.gai-msg.ai .gai-msg-bubble { background:#F0F4FF; border-bottom-left-radius:4px;
  border:1px solid rgba(46,91,255,0.08); }
.gai-msg-bubble p { margin:0 0 6px; }
.gai-msg-bubble p:last-child { margin:0; }
.gai-msg-bubble strong { color:#1E40AF; font-weight:600; }

.gai-sources { display:flex; flex-wrap:wrap; gap:6px; margin-top:10px; padding-top:10px; border-top:1px dashed #E0E7FF; }
.gai-sources-title { width:100%; font-size:11px; font-weight:600; color:#6B7280; margin-bottom:2px; }
.gai-source { display:inline-flex; align-items:center; gap:5px; padding:4px 10px;
  background:#fff; border:1px solid #E0E7FF; border-radius:20px; font-size:11px;
  color:#2E5BFF; cursor:pointer; transition:all 0.2s; font-weight:500; }
.gai-source:hover { background:#EEF2FF; border-color:#2E5BFF; transform:translateY(-1px); }

/* --- Typing --- */
.gai-typing { display:none; align-items:flex-start; gap:10px; padding:2px 0; }
.gai-typing.active { display:flex; }
.gai-typing-bubble { display:flex; align-items:center; gap:8px; padding:12px 16px;
  background:#F0F4FF; border-radius:14px; border-bottom-left-radius:4px;
  border:1px solid rgba(46,91,255,0.08); }
.gai-typing-dots { display:flex; gap:5px; }
.gai-typing-dots span { width:7px; height:7px; background:#2E5BFF; border-radius:50%;
  animation:gaiDot 1.2s infinite cubic-bezier(.4,.0,.6,1); }
.gai-typing-dots span:nth-child(2) { animation-delay:0.15s; }
.gai-typing-dots span:nth-child(3) { animation-delay:0.3s; }
@keyframes gaiDot { 0%,80%,100%{transform:translateY(0) scale(0.7);opacity:0.4} 40%{transform:translateY(-4px) scale(1.1);opacity:1} }
.gai-typing-label { font-size:11px; color:#6B7280; margin-left:2px; }

/* --- Footer --- */
.gai-footer { padding:14px 20px 20px; flex-shrink:0;
  background:linear-gradient(0deg, #F8FAFF 0%, rgba(255,255,255,0) 100%);
  border-top:1px solid rgba(46,91,255,0.08); }
.gai-input-wrap { min-height:42px; max-height:140px; padding:10px 16px 10px 16px;
  border:1.5px solid #E0E7FF; border-radius:22px; font-size:13.5px; line-height:1.6;
  outline:none; color:#1D2129; overflow-y:auto; word-break:break-all;
  transition:all 0.2s; background:#fff; }
.gai-input-wrap:focus { border-color:#2E5BFF; box-shadow:0 0 0 4px rgba(46,91,255,0.1);
  background:#F8FAFF; }
.gai-input-wrap[data-placeholder]:empty:before {
  content:attr(data-placeholder); color:#9CA3AF; pointer-events:none; }
.gai-send-btn { position:absolute; right:6px; top:50%; transform:translateY(-50%);
  width:34px; height:34px;
  border:none; background:linear-gradient(135deg, #2E5BFF, #1E3A8A);
  border-radius:50%; color:#fff; cursor:pointer; display:flex; align-items:center;
  justify-content:center; flex-shrink:0; transition:all 0.2s;
  box-shadow:0 3px 10px rgba(46,91,255,0.4); }
.gai-send-btn:hover { background:linear-gradient(135deg, #3B6FFF, #2E5BFF);
  transform:scale(1.08); box-shadow:0 4px 14px rgba(46,91,255,0.5); }
.gai-send-btn:active { transform:scale(0.92); }
.gai-send-btn svg { width:15px; height:15px; }
.gai-input-row { position:relative; }
.gai-disclaimer { text-align:center; font-size:10.5px; color:#9CA3AF; margin-top:10px;
  display:flex; align-items:center; justify-content:center; gap:4px; }
.gai-disclaimer::before { content:'ⓘ'; font-size:10px; }
