/* ============================================================
 * CARRIDE CRM - AI 助手顶栏按钮 + 侧边抽屉样式
 * 层级约定：抽屉 overlay 1200 / panel 1201，
 * 均高于主应用已有最高层（ops-modal 1000、sidebar 100、toast 80）。
 * 顶栏按钮 .ai-top-btn 位于 topbar 正常文档流内，不额外占层级。
 * ============================================================ */

/* ---- 顶栏按钮（金色高亮，位于 .who 内首个位置；仅线索/客户视图显示） ---- */
/* 注意：需压过 app.css 的 .topbar .who button（0-2-1），故用 0-3-0 特异性 */
.topbar .who .ai-top-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  border: none;
  border-radius: 18px;
  background: linear-gradient(135deg, #c4a35a, #d4b86a);
  color: #1a2332;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  padding: 6px 14px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(196, 163, 90, 0.45);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.topbar .who .ai-top-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(196, 163, 90, 0.6);
  color: #1a2332; /* 压掉 app.css .topbar .who button:hover 的红色 */
}
.topbar .who .ai-top-btn:active {
  transform: scale(0.96);
}

/* ---- 遮罩层 ---- */
.ai-drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(15, 24, 48, 0.45);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.ai-drawer-overlay.open {
  opacity: 1;
}

/* ---- 侧边抽屉（桌面半屏：50vw，最窄保底 640px；≤900px 全屏） ---- */
.ai-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1201;
  width: clamp(640px, 50vw, 100vw);
  background: #fff;
  display: none;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s ease;
  box-shadow: -8px 0 32px rgba(20, 30, 50, 0.2);
}
.ai-drawer.open {
  transform: translateX(0);
}
.ai-drawer-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #1b3a5c;
  color: #fff;
}
.ai-drawer-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.ai-drawer-close {
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease;
}
.ai-drawer-close:hover {
  background: rgba(255, 255, 255, 0.25);
}
.ai-drawer-body {
  flex: 1;
  min-height: 0;
  background: #f4f5f8;
}
.ai-drawer-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ---- 抽屉打开时锁定主应用滚动 ---- */
body.ai-drawer-lock {
  overflow: hidden;
}

/* ---- 平板/窄屏：抽屉全屏 ---- */
@media (max-width: 900px) {
  .ai-drawer {
    width: 100vw;
  }
}

/* ---- 移动端：顶栏按钮转紧凑图标形态（顶栏 ≤768px 仍显示，无需备用入口） ---- */
@media (max-width: 768px) {
  .ai-top-btn {
    padding: 6px 9px;
    font-size: 12px;
  }
  .ai-top-btn .ai-top-txt {
    display: none;
  }
}
