/* [v2.0 完全合并 / P3 STEP4] AI顾问 原生页样式 —— 移植自 adpilot static/style.css 的 chat 部分,
   全部收敛到 .ads-chat 作用域, 自带 CSS 变量 (adpilot 浅色主题), 与宿主 vvdig 深色主题隔离, 零全局污染。 */
.ads-chat {
  --brand: #5b4bdb; --brand2: #8b7cf5;
  --txt: #1f2533; --muted: #8a93a5; --line: #e6e9f0;
  --panel: #ffffff; --panel2: #f3f5f9; --bg: #f7f8fb;
  --warn: #c98a00; --ok: #1aa564; --accent: #ef5b34; --danger: #e5484d;
  /* [fix2] 填满父容器 layout-content 的真实高度(已自动扣掉 topbar + 底部 ai-activity-panel(flex-shrink:0,折叠也占36px)),
     不再用 calc(100vh-48px) 魔数 —— 那个没算活动面板, 高出约36px 把底部输入区裁掉(输入框压底/模型框看不到的真因)。 */
  height: 100%; background: var(--bg); color: var(--txt); border-radius: 10px;
  padding: 14px 16px; box-sizing: border-box; overflow: hidden;
  font-size: 14px; line-height: 1.55;
  /* flex 列: 顶部 sso-warn/mockbar 条按需占高, chat-layout 取剩余空间, 底部输入框(composer)永不被裁 */
  display: flex; flex-direction: column;
}
.ads-chat *, .ads-chat *::before, .ads-chat *::after { box-sizing: border-box; }

.ads-chat .sso-warn { padding: 6px 12px; margin-bottom: 8px; border-radius: 8px; background: #fdf6ec; color: #b88230; font-size: 12.5px; }
.ads-chat .mockbar { background: rgba(255, 211, 42, .14); border: 1px solid rgba(255, 211, 42, .45); color: var(--warn); padding: 6px 12px; border-radius: 8px; font-size: 12.5px; margin-bottom: 8px; }

.ads-chat .chat-layout { display: flex; gap: 14px; flex: 1; min-height: 0; }

/* 左:会话历史 */
.ads-chat .session-panel { width: 210px; flex: 0 0 210px; border-right: 1px solid var(--line); padding-right: 8px; display: flex; flex-direction: column; gap: 10px; overflow: hidden; }
.ads-chat .session-list { overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }
.ads-chat .sess-item { padding: 7px 8px; border-radius: 9px; cursor: pointer; font-size: 13.5px; color: #46505f; border: 1px solid transparent; display: flex; align-items: center; gap: 4px; position: relative; }
.ads-chat .sess-item:hover { background: var(--panel2); }
.ads-chat .sess-item.on { background: rgba(91, 75, 219, .12); color: var(--brand); border-color: var(--brand); font-weight: 600; }
.ads-chat .sess-item .st { overflow: hidden; flex: 1; min-width: 0; white-space: nowrap; text-overflow: ellipsis; line-height: 1.5; }
.ads-chat .sess-item .ren, .ads-chat .sess-item .del { opacity: 0; color: var(--muted); padding: 1px 4px; border-radius: 4px; cursor: pointer; }
.ads-chat .sess-item:hover .ren, .ads-chat .sess-item:hover .del { opacity: 1; }
.ads-chat .sess-item .ren:hover { color: var(--brand); }
.ads-chat .sess-item .del:hover { color: var(--danger); }

/* 中:对话主区 */
.ads-chat .chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ads-chat .chat-head { display: flex; gap: 10px; align-items: center; min-height: 22px; padding-bottom: 10px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.ads-chat .chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.ads-chat .chip { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 5px 12px; font-size: 12.5px; cursor: pointer; color: #46505f; }
.ads-chat .chip:hover { border-color: var(--brand); color: var(--brand); }
.ads-chat .messages { flex: 1; overflow: auto; padding: 6px 2px; display: flex; flex-direction: column; gap: 14px; }
.ads-chat .msg { max-width: 88%; padding: 12px 16px; border-radius: 14px; white-space: pre-wrap; font-size: 15px; }
.ads-chat .msg.user { align-self: flex-start; background: linear-gradient(135deg, #6a5cf0, #8b7cf5); color: #fff; border-bottom-left-radius: 4px; }
.ads-chat .msg.assistant { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; color: var(--txt); white-space: normal; }
.ads-chat .msg img.att-thumb { max-width: 160px; border-radius: 8px; margin-top: 8px; display: block; }
.ads-chat .msg.assistant h1, .ads-chat .msg.assistant h2, .ads-chat .msg.assistant h3 { font-size: 15px; margin: 10px 0 6px; font-weight: 700; }
.ads-chat .msg.assistant p { margin: 6px 0; }
.ads-chat .msg.assistant ul, .ads-chat .msg.assistant ol { margin: 6px 0 6px 20px; }
.ads-chat .msg.assistant li { margin: 3px 0; }
.ads-chat .msg.assistant strong { color: #111; font-weight: 700; }
.ads-chat .msg.assistant code { background: rgba(91, 75, 219, .10); color: #4a33c0; padding: 1px 6px; border-radius: 5px; font-size: 13px; }
.ads-chat .msg.assistant pre { background: #f3f5f9; border: 1px solid var(--line); padding: 10px; border-radius: 8px; overflow: auto; margin: 8px 0; }
.ads-chat .msg.assistant pre code { background: none; color: var(--txt); }
.ads-chat .msg.assistant hr { border: none; border-top: 1px solid var(--line); margin: 10px 0; }
.ads-chat .msg.assistant table { border-collapse: collapse; margin: 8px 0; font-size: 13px; }
.ads-chat .msg.assistant th, .ads-chat .msg.assistant td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; }
.ads-chat .msg.assistant th { background: var(--panel2); }
.ads-chat .cursor { display: inline-block; width: 7px; height: 14px; background: var(--brand2); animation: ads-blink 1s steps(2) infinite; vertical-align: -2px; margin-left: 2px; }
@keyframes ads-blink { 50% { opacity: 0; } }
.ads-chat .skills { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.ads-chat .tag.b { background: rgba(91, 75, 219, .12); color: var(--brand); font-size: 12px; padding: 2px 9px; border-radius: 20px; font-weight: 600; }
.ads-chat .websts { color: var(--muted); font-size: 13px; font-style: italic; padding: 2px 0; }
.ads-chat .websrc { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.ads-chat .websrc b { color: var(--brand); font-size: 12.5px; }
.ads-chat .websrc a { color: var(--brand); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ads-chat .websrc a:hover { text-decoration: underline; }
.ads-chat .danger { color: var(--danger); }
.ads-chat .msgtools { margin-top: 8px; display: flex; justify-content: flex-end; }
.ads-chat .copybtn { background: var(--panel2); border: 1px solid var(--line); color: var(--muted); border-radius: 7px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.ads-chat .copybtn:hover { color: var(--brand); border-color: var(--brand); }

/* 附图缩略 */
.ads-chat .attach-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.ads-chat .att { position: relative; }
.ads-chat .att img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.ads-chat .att .x { position: absolute; top: -6px; right: -6px; background: var(--danger); color: #fff; width: 18px; height: 18px; border-radius: 50%; font-size: 12px; line-height: 18px; text-align: center; cursor: pointer; }

/* 输入区 */
.ads-chat .composer { display: flex; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line); align-items: flex-end; }
.ads-chat .composer select { max-width: 200px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--txt); font-size: 13px; padding: 0 6px; }
.ads-chat .composer textarea { flex: 1; min-width: 220px; min-height: 46px; max-height: 140px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--txt); padding: 10px 12px; font-size: 14px; resize: vertical; font-family: inherit; }
.ads-chat .composer textarea:focus { outline: none; border-color: var(--brand); }
.ads-chat .btn { background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; border: none; border-radius: 9px; padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.ads-chat .btn:disabled { opacity: .6; cursor: default; }
.ads-chat .btn.ghost { background: var(--panel); color: var(--muted); border: 1px solid var(--line); font-weight: 500; }
.ads-chat .cbtn { align-self: stretch; font-size: 12.5px; padding: 0 9px; min-width: 0; line-height: 1; }
.ads-chat .cbtn.on { background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; border-color: transparent; }
.ads-chat .spinner { display: inline-block; width: 13px; height: 13px; border: 2px solid #fff; border-top-color: transparent; border-radius: 50%; animation: ads-spin .7s linear infinite; vertical-align: -1px; margin-right: 5px; }
@keyframes ads-spin { to { transform: rotate(360deg); } }

/* 右:专家面板 */
.ads-chat .agent-panel { width: 230px; flex: 0 0 230px; overflow-y: auto; border-left: 1px solid var(--line); padding-left: 14px; }
.ads-chat .agent-panel h4 { font-size: 13px; color: var(--muted); margin: 2px 0 12px; }
.ads-chat .agent-tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.ads-chat .agent-tabs button { flex: 1; padding: 6px 4px; font-size: 13px; border: 1px solid var(--line); background: var(--panel2); color: var(--muted); border-radius: 8px; cursor: pointer; }
.ads-chat .agent-tabs button.on { background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; border-color: transparent; font-weight: 600; }
.ads-chat .aitem { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 12px; cursor: pointer; margin-bottom: 5px; border: 1px solid transparent; }
.ads-chat .aitem:hover { background: var(--panel2); }
.ads-chat .aitem.on { background: rgba(108, 92, 231, .15); border-color: var(--brand); }
.ads-chat .avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 18px; flex: 0 0 36px; color: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, .18); }
.ads-chat .avatar img { width: 60%; height: 60%; object-fit: contain; }
.ads-chat .avatar b { font-size: 16px; font-weight: 800; }
.ads-chat .aitem .nm { font-size: 14px; font-weight: 600; line-height: 1.2; color: var(--txt); }

/* 人工审批弹窗 */
.ads-chat-modal-ov { position: fixed; inset: 0; background: rgba(20, 22, 30, .5); display: grid; place-items: center; z-index: 3000; }
.ads-chat-modal-ov .modal-card { background: #fff; color: var(--txt, #1f2533); border-radius: 14px; padding: 20px; width: min(560px, 92vw); max-height: 84vh; overflow: auto; box-shadow: 0 18px 60px rgba(0, 0, 0, .3); }
.ads-chat-modal-ov .modal-t { font-weight: 700; margin-bottom: 12px; }
.ads-chat-modal-ov .appr-item { display: flex; gap: 10px; padding: 10px; border: 1px solid #e6e9f0; border-radius: 10px; margin-bottom: 8px; cursor: pointer; }
.ads-chat-modal-ov .appr-c { color: #444; font-size: 13px; margin-top: 2px; }
.ads-chat-modal-ov .appr-r { color: #8a93a5; font-size: 12.5px; margin-top: 2px; }
.ads-chat-modal-ov .appr-tip { font-size: 12.5px; color: #8a93a5; margin: 6px 0 12px; }
.ads-chat-modal-ov .modal-btns { display: flex; gap: 10px; justify-content: flex-end; }
.ads-chat-modal-ov .appr-run { margin-top: 10px; color: var(--brand, #5b4bdb); font-size: 13px; }
