/* WanLink OA · 企业AI 界面样式
   与 Studio Edition 视觉层同源：瓷白卡面、发丝线、紫蓝渐变只用于关键标记。
   只在加载 ai.css 的页面生效，不改动原有沟通页样式。 */
:has(> .ai-wrap) { --ai-gap: 14px; }
body:has(.ai-wrap) .content { max-width: 1440px; padding: 18px 22px 26px; }

.ai-wrap {
  display: grid; grid-template-columns: 272px minmax(0, 1fr);
  height: calc(100vh - 118px); min-height: 520px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.ai-side { display: flex; flex-direction: column; min-width: 0; border-right: 1px solid var(--line); background: #FBFCFE; }
.ai-side-hd { display: flex; align-items: center; justify-content: space-between; padding: 15px 14px 10px; }
.ai-brand { display: flex; align-items: center; gap: 9px; font-size: 16px; letter-spacing: -.02em; }
.ai-brand b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.ai-side-ft span { color: var(--accent-deep); }
.ai-spark { width: 32px; height: 32px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  color: #fff; background: var(--grad); box-shadow: 0 4px 12px -6px rgba(76,111,255,.7); }
/* 自定义图标：图片自身已是圆球 + AI 角标，上传时去背，不做圆形裁切以免角标被切 */
.ai-spark.has-icon, .ai-empty-mark.has-icon { border-radius: 0; background: transparent; box-shadow: none; overflow: visible; }
.ai-spark.has-icon img, .ai-empty-mark.has-icon img { display: block; width: 100%; height: 100%; object-fit: contain; }
.ai-ico { width: 32px; height: 32px; border: 0; background: transparent; color: var(--text-2);
  border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: 0 0 auto; }
.ai-ico:hover { background: var(--accent-weak); color: var(--accent-deep); }
.ai-search { padding: 0 12px 10px; }
.ai-search input { width: 100%; height: 34px; border: 1px solid var(--line); background: #fff;
  border-radius: 10px; padding: 0 11px; font-size: 12.5px; outline: none; }
.ai-search input:focus { border-color: var(--accent); box-shadow: var(--focus-ring); }
.ai-list { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.ai-item { padding: 10px 10px; border-radius: 10px; cursor: pointer; transition: background .18s; }
.ai-item:hover { background: #F1F4FA; }
.ai-item.on { background: var(--accent-weak); }
.ai-item > span:first-child { vertical-align: -3px; color: var(--accent-deep); margin-right: 6px; }
.ai-item-t { display: flex; align-items: center; gap: 4px; font-size: 13px; }
.ai-item-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.ai-item-act { color: var(--text-3); opacity: 0; display: inline-flex; transition: opacity .15s; }
.ai-item:hover .ai-item-act { opacity: 1; }
.ai-item-act:hover { color: var(--bad); }
.ai-item-p { font-size: 11.5px; color: var(--text-3); margin: 4px 0 0 22px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-side-ft { border-top: 1px solid var(--line); padding: 11px 14px; font-size: 11px; color: var(--text-3); }

.ai-main { display: flex; flex-direction: column; min-width: 0; background: #fff; }
.ai-hd { height: 56px; flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  padding: 0 18px; border-bottom: 1px solid var(--line); }
.ai-hd-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 14px; font-weight: 650; }
.ai-mob { display: none; }
.ai-model-wrap { position: relative; }
.ai-model { display: flex; align-items: center; gap: 7px; height: 34px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text);
  font-size: 12.5px; cursor: pointer; }
.ai-model:hover { border-color: var(--line-strong); background: #FAFBFE; }
.ai-model:disabled { opacity: .5; cursor: default; }
.ai-model .ic:last-child { color: var(--text-3); transform: rotate(90deg); }
.ai-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--grad); flex: 0 0 auto; }
.ai-dot.mine { background: var(--accent); }
.ai-menu { position: absolute; z-index: 30; top: 40px; right: 0; width: 268px; max-height: 60vh; overflow-y: auto;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 8px; }
.ai-menu-hd { font-size: 11px; color: var(--text-3); padding: 8px 8px 4px; letter-spacing: .06em; }
.ai-menu-row { display: flex; align-items: center; gap: 8px; padding: 9px 8px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.ai-menu-row:hover { background: var(--accent-weak); }
.ai-menu-n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-menu-s { color: var(--accent-deep); display: inline-flex; }
.ai-menu-x { color: var(--text-3); display: inline-flex; }
.ai-menu-x:hover { color: var(--bad); }
.ai-menu-add { display: flex; align-items: center; justify-content: center; gap: 7px; width: 100%;
  margin-top: 6px; padding: 9px; border: 1px dashed var(--line-strong); border-radius: 9px;
  background: #FBFCFE; color: var(--accent-deep); font-size: 12.5px; cursor: pointer; }
.ai-menu-add:hover { border-color: var(--accent); background: var(--accent-weak); }

.ai-body { flex: 1; overflow-y: auto; padding: 22px 26px 6px; background:
  radial-gradient(48% 34% at 82% 0%, rgba(124,106,255,.035), transparent 70%), #FDFEFF; }
.ai-empty { height: 100%; min-height: 260px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; }
.ai-empty-mark { width: 60px; height: 60px; border-radius: 18px; display: flex; align-items: center; justify-content: center;
  color: #fff; background: var(--grad); box-shadow: 0 12px 30px -14px rgba(76,111,255,.8); animation: ai-pop .5s var(--ease-out) both; }
.ai-empty h2 { font-size: 19px; font-weight: 650; margin: 18px 0 16px; letter-spacing: -.02em;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.ai-sugs { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.ai-sugs button { border: 1px solid var(--line); background: #fff; color: var(--text-2);
  padding: 8px 13px; border-radius: 999px; font-size: 12.5px; cursor: pointer; }
.ai-sugs button:hover { border-color: var(--accent); color: var(--accent-deep); background: var(--accent-weak); }
@keyframes ai-pop { from { opacity: 0; transform: scale(.9) translateY(8px); } to { opacity: 1; transform: none; } }

.ai-row { display: flex; gap: 10px; margin-bottom: 18px; animation: ai-rise .28s var(--ease-out) both; }
.ai-row.mine { flex-direction: row-reverse; }
@keyframes ai-rise { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
.ai-av { width: 30px; height: 30px; flex: 0 0 auto; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; background: var(--grad); }
.ai-av.user { background: #DCE5F2; color: #2C4A73; }
/* AI 回复头像：与品牌位共用自定义图标；未上传时不显示，避免写死的 "AI" 方块 */
.ai-av.ai-av-icon { width: 32px; height: 32px; background: transparent; border-radius: 0; overflow: visible; }
.ai-av.ai-av-icon img { display: block; width: 100%; height: 100%; object-fit: contain; }
.ai-bd { min-width: 0; max-width: min(780px, 82%); }
.ai-bubble { padding: 11px 14px; border: 1px solid var(--line); border-radius: 4px 14px 14px 14px;
  background: #fff; font-size: 13.5px; line-height: 1.72; color: var(--text-2); box-shadow: var(--shadow); }
.ai-row.mine .ai-bubble { background: var(--accent-weak); border-color: rgba(76,111,255,.15); border-radius: 14px 4px 14px 14px; }
.ai-bubble.pending { min-width: 64px; }
.ai-md h3, .ai-md h4 { font-size: 14px; margin: 8px 0 4px; color: var(--text); }
.ai-md .ai-li { padding-left: 14px; position: relative; }
.ai-md .ai-li::before { content: ''; position: absolute; left: 3px; top: 11px; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.ai-md a { color: var(--accent-deep); }
.ai-code { display: block; margin: 9px 0; padding: 12px 14px; border-radius: 10px; background: #121A2A;
  color: #DCE7F7; overflow-x: auto; font-size: 12px; line-height: 1.6; }
.ai-ic { padding: 1px 5px; border-radius: 4px; background: rgba(76,111,255,.1); color: var(--accent-deep); font-size: 12px; }
.ai-typing { display: flex; gap: 4px; padding: 4px 0; }
.ai-typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); opacity: .45; animation: ai-blink 1.1s infinite; }
.ai-typing i:nth-child(2) { animation-delay: .15s; }
.ai-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes ai-blink { 0%,60%,100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.ai-ops { margin-top: 6px; display: flex; justify-content: flex-start; }
.ai-row.mine .ai-ops { justify-content: flex-end; }
.ai-ops button { border: 0; background: transparent; color: var(--text-3); font-size: 11.5px; cursor: pointer; padding: 2px 4px; }
.ai-ops button:hover { color: var(--accent-deep); }
.ai-files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.ai-file { display: inline-flex; align-items: center; gap: 5px; max-width: 220px; padding: 5px 9px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--text-2); font-size: 11.5px; text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-file:hover { border-color: var(--accent); color: var(--accent-deep); }

.ai-compose { flex: 0 0 auto; padding: 12px 26px 14px; border-top: 1px solid var(--line); background: #fff; }
.ai-att { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.ai-att-i { display: inline-flex; align-items: center; gap: 6px; max-width: 240px; padding: 5px 8px;
  border-radius: 8px; background: var(--accent-weak); color: var(--accent-deep); font-size: 11.5px; }
.ai-att-i span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-att-x { cursor: pointer; font-size: 15px; line-height: 1; }
.ai-box { display: flex; align-items: flex-end; gap: 8px; padding: 7px 8px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff; }
.ai-box:focus-within { border-color: var(--accent); box-shadow: var(--focus-ring); }
.ai-box textarea { flex: 1; min-height: 34px; max-height: 150px; resize: none; border: 0; outline: none;
  padding: 8px 4px; font: inherit; font-size: 13.5px; line-height: 1.5; color: var(--text); background: transparent; }
.ai-send { width: 34px; height: 34px; flex: 0 0 auto; border: 0; border-radius: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; color: #fff; background: var(--grad); font-size: 12px; }
.ai-send:disabled { opacity: .35; cursor: default; }
.ai-tip { text-align: center; font-size: 10.5px; color: var(--text-3); margin-top: 7px; }

.ai-mask { position: fixed; inset: 0; z-index: 100; background: rgba(15,22,38,.32);
  display: flex; align-items: center; justify-content: center; padding: 18px; backdrop-filter: blur(3px); }
.ai-sheet { width: 480px; max-width: 100%; max-height: 84vh; overflow: hidden; display: flex; flex-direction: column;
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg); animation: ai-pop .25s var(--ease-out) both; }
.ai-sheet-hd { display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--line); font-size: 15px; }
.ai-sheet-bd { padding: 18px; overflow-y: auto; }
.ai-form { display: flex; flex-direction: column; gap: 13px; }
.ai-form label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-2); }
.ai-form input { height: 38px; padding: 0 11px; border: 1px solid var(--line); border-radius: 9px;
  outline: none; font: inherit; font-size: 13px; }
.ai-form input:focus { border-color: var(--accent); box-shadow: var(--focus-ring); }
.ai-mrow { display: flex; align-items: center; gap: 7px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ai-mrow > div { flex: 1; min-width: 0; font-size: 13px; }
.ai-mrow + .ai-form { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.mini { font-size: 11px; color: var(--text-3); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 900px) {
  body:has(.ai-wrap) .content { padding: 10px 10px 70px; }
  .ai-wrap { grid-template-columns: 1fr; height: calc(100vh - 104px); }
  .ai-side { position: absolute; z-index: 25; top: 68px; bottom: 74px; left: 10px; width: 270px;
    border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
    transform: translateX(-110%); transition: transform .25s var(--ease-out); }
  .ai-side.open { transform: none; }
  .ai-mob { display: inline-flex; }
  .ai-body { padding: 16px 14px 4px; }
  .ai-bd { max-width: 86%; }
  .ai-compose { padding: 10px 14px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .ai-row, .ai-empty-mark, .ai-sheet, .ai-side { animation: none !important; transition: none !important; }
  .ai-typing i { animation: none !important; }
}

/* 沟通 · 企业AI 助手：作为普通会话，文本可选中复制 */
.im-bubble { user-select: text; -webkit-user-select: text; }
.im-bubble.ai { background: linear-gradient(135deg, #f8f6ff, #f0f7ff); border-color: #e6eaf8; }
.im-ai-caret { animation: aiMiniBlink .8s steps(1) infinite; }
@keyframes aiMiniBlink { 50% { opacity: 0; } }
.im-copy { border: 0; background: transparent; color: var(--text-3); font-size: 11px; cursor: pointer; padding: 0 2px; align-self: flex-end; }
.im-copy:hover { color: var(--accent-deep); }
.im-ai-model { height: 28px; max-width: 150px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; padding: 0 6px; font-size: 12px; color: var(--text); outline: none; }
.im-ai-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding-top: 48px; }
.im-ai-empty b { font-size: 16px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.im-ai-empty p { margin: 0; font-size: 13px; color: var(--text-2); }
.im-ic.ai-icon { background: transparent; }
.im-ic.ai-icon img { display: block; width: 100%; height: 100%; object-fit: contain; }
.im-av.im-av-ai { background: transparent; border-radius: 0; overflow: visible; }
.im-av.im-av-ai img { display: block; width: 100%; height: 100%; object-fit: contain; }
.im-ai-mark { width: 52px; height: 52px; font-size: 30px; color: var(--accent);
  display: flex; align-items: center; justify-content: center; }
.im-ai-mark img { width: 100%; height: 100%; object-fit: contain; }
.im-ai-sugs { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.im-ai-sugs button { border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 7px 12px; font-size: 12px; color: var(--text-2); cursor: pointer; }
.im-ai-sugs button:hover { border-color: var(--accent); color: var(--accent-deep); }
/* 管理面板：额度判定规则说明 */
.ai-rule-box { margin: 10px 0; padding: 12px 14px; border: 1px solid #E4EDFB; border-radius: 10px;
  background: #F7FAFF; font-size: 12px; color: var(--text-2); line-height: 1.7; }
.ai-rule-box > b { display: block; font-size: 13px; color: var(--text); margin-bottom: 6px; }
.ai-rule-box ol { margin: 0 0 6px; padding-left: 18px; }
.ai-rule-box li { margin: 2px 0; }

/* 额度条：全局 + 当前模型，固定在消息区上方 */
.ai-quota-bar, .im-quota-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 7px 16px; font-size: 12px; line-height: 1.5; color: var(--text-2);
  background: #F4F8FF; border-bottom: 1px solid #E4EDFB; }
.ai-quota-bar b, .im-quota-bar b { color: var(--accent-deep); font-weight: 650; }
.ai-quota-bar .qb-label, .im-quota-bar .qb-label { font-weight: 600; color: var(--text); }
.ai-quota-bar .qb-tip, .im-quota-bar .qb-tip { margin-left: auto; color: var(--text-3); }
@media (max-width: 720px) {
  .im-ai-model { max-width: 110px; }
  .ai-quota-bar .qb-tip, .im-quota-bar .qb-tip { display: none; }
}
