/* ============================================================
   AI 智能对话推荐 · 悬浮模块（政务科技风：白底 + 蓝主色 + 浅灰分区）
   与 gov.css 的主题变量对齐，不覆写站点既有样式
   命名空间：.aiw-   z-index 95+（高于 .float-service 的 60）
   ============================================================ */

.aiw-root {
  --aiw-blue: #1B5CFF;
  --aiw-blue-2: #3D77FF;
  --aiw-navy: #0E2A4F;
  --aiw-ink: #1B2A3D;
  --aiw-muted: #5B6B80;
  --aiw-muted-2: #8593A6;
  --aiw-line: #E6ECF5;
  --aiw-line-blue: #C7D6F5;
  --aiw-bg: #F7F9FC;
  --aiw-w: 396px;
  --aiw-h: min(640px, calc(100vh - 132px));
  font-family: var(--sans);
  color: var(--aiw-ink);
}

/* ---------------- 悬浮球 ---------------- */
.aiw-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 95;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(27, 92, 255, .18);
  background: linear-gradient(145deg, #2F6BFF, #1B5CFF 58%, #1450E6);
  color: #fff;
  cursor: pointer;
  box-shadow:
    0 8px 22px rgba(27, 92, 255, .34),
    0 2px 6px rgba(16, 42, 82, .16),
    inset 0 1px 0 rgba(255, 255, 255, .22);
  transition: transform .22s cubic-bezier(.22, .61, .36, 1), box-shadow .22s ease;
}

.aiw-launcher:hover {
  transform: translateY(-2px);
  box-shadow:
    0 12px 28px rgba(27, 92, 255, .42),
    0 2px 6px rgba(16, 42, 82, .18),
    inset 0 1px 0 rgba(255, 255, 255, .24);
}

.aiw-launcher:active { transform: translateY(0) scale(.97); }

.aiw-launcher svg { width: 26px; height: 26px; flex: none; }

/* 呼吸光环 */
.aiw-launcher::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  border: 2px solid rgba(27, 92, 255, .5);
  animation: aiw-pulse 3.6s cubic-bezier(.22, .61, .36, 1) infinite;
  pointer-events: none;
}

@keyframes aiw-pulse {
  0% { transform: scale(1); opacity: .5; }
  70% { transform: scale(1.26); opacity: 0; }
  100% { transform: scale(1.26); opacity: 0; }
}

.aiw-launcher-tip {
  position: absolute;
  right: 68px;
  top: 50%;
  transform: translate(6px, -50%);
  white-space: nowrap;
  font-size: 12px;
  letter-spacing: .02em;
  padding: 7px 11px;
  border-radius: 8px;
  color: #fff;
  background: rgba(14, 42, 79, .92);
  box-shadow: 0 6px 18px rgba(16, 42, 82, .24);
  opacity: 0;
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
}

.aiw-launcher:hover .aiw-launcher-tip,
.aiw-launcher:focus-visible .aiw-launcher-tip { opacity: 1; transform: translate(0, -50%); }

.aiw-launcher[data-open="1"] { box-shadow: 0 6px 16px rgba(27, 92, 255, .3); }

/* 未读提示点 */
.aiw-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #0E9F9F;
  border: 2px solid #fff;
  display: none;
}
.aiw-dot[data-show="1"] { display: block; }

/* ---------------- 面板 ---------------- */
.aiw-panel {
  position: fixed;
  right: 24px;
  bottom: 92px;
  z-index: 96;
  width: var(--aiw-w);
  max-width: calc(100vw - 32px);
  height: var(--aiw-h);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--aiw-line);
  border-radius: 12px;
  background: #fff;
  box-shadow:
    0 24px 60px rgba(16, 42, 82, .22),
    0 4px 12px rgba(16, 42, 82, .08);
  transform-origin: bottom right;
  opacity: 0;
  transform: translateY(12px) scale(.985);
  pointer-events: none;
  transition: opacity .2s cubic-bezier(.22, .61, .36, 1), transform .2s cubic-bezier(.22, .61, .36, 1);
}

.aiw-panel[data-open="1"] {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* 顶部主色条 */
.aiw-panel::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(90deg, #1B5CFF, #3D77FF 46%, #0E9F9F);
}

/* ---------------- 头部 ---------------- */
.aiw-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 15px 14px 12px;
  border-bottom: 1px solid var(--aiw-line);
  background: linear-gradient(180deg, #F7FAFF, #fff);
}

.aiw-head-mark {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  border: 1px solid rgba(27, 92, 255, .16);
  color: var(--aiw-blue);
  background: #EEF3FF;
}

.aiw-head-mark svg { width: 19px; height: 19px; }

.aiw-head-txt { min-width: 0; flex: 1; }

.aiw-head-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: .01em;
  margin: 0;
  color: var(--aiw-ink);
}

.aiw-head-sub {
  margin: 3px 0 0;
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--aiw-muted-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aiw-head-act {
  display: flex;
  gap: 2px;
  flex: none;
}

.aiw-iconbtn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--aiw-muted-2);
  cursor: pointer;
  transition: background .15s, color .15s;
}

.aiw-iconbtn:hover { background: #EEF3FF; color: var(--aiw-blue); }
.aiw-iconbtn svg { width: 15px; height: 15px; }

/* ---------------- 消息区 ---------------- */
.aiw-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 14px 8px;
  background: #fff;
  scrollbar-width: thin;
  scrollbar-color: #C7D6F5 transparent;
}

.aiw-log::-webkit-scrollbar { width: 7px; }
.aiw-log::-webkit-scrollbar-thumb { background: #D5E1F8; border-radius: 4px; }

.aiw-msg { display: flex; gap: 8px; margin-bottom: 14px; }

.aiw-msg[data-role="user"] { flex-direction: row-reverse; }

.aiw-ava {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--aiw-line);
  color: var(--aiw-muted);
  background: var(--aiw-bg);
  margin-top: 2px;
}

.aiw-msg[data-role="ai"] .aiw-ava {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(145deg, #2F6BFF, #1B5CFF);
}

.aiw-body { min-width: 0; max-width: 86%; }

.aiw-bubble {
  padding: 10px 12px;
  border-radius: 4px 10px 10px 10px;
  font-size: 13.5px;
  line-height: 1.7;
  word-break: break-word;
  background: var(--aiw-bg);
  border: 1px solid var(--aiw-line);
  color: var(--aiw-ink);
}

.aiw-msg[data-role="user"] .aiw-bubble {
  border-radius: 10px 4px 10px 10px;
  background: linear-gradient(145deg, #2F6BFF, #1B5CFF);
  border-color: transparent;
  color: #fff;
}

.aiw-bubble p { margin: 0 0 7px; }
.aiw-bubble p:last-child { margin-bottom: 0; }
.aiw-bubble b, .aiw-bubble strong { color: var(--aiw-blue); font-weight: 600; }
.aiw-bubble .aiw-num { color: var(--aiw-blue); font-weight: 600; }

/* 打字光标 */
.aiw-caret::after {
  content: "▍";
  color: var(--aiw-blue);
  animation: aiw-blink .9s steps(1) infinite;
}
@keyframes aiw-blink { 50% { opacity: 0; } }

/* 三点等待 */
.aiw-typing { display: inline-flex; gap: 4px; align-items: center; height: 18px; }
.aiw-typing i {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--aiw-blue); opacity: .3;
  animation: aiw-bounce 1.05s ease-in-out infinite;
}
.aiw-typing i:nth-child(2) { animation-delay: .14s; }
.aiw-typing i:nth-child(3) { animation-delay: .28s; }
@keyframes aiw-bounce { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* ---------------- 推荐卡片 ---------------- */
.aiw-picks { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }

.aiw-card {
  display: block;
  padding: 9px 11px;
  border: 1px solid var(--aiw-line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition: border-color .16s, box-shadow .16s, transform .16s, background .16s;
  text-decoration: none;
  color: inherit;
}

.aiw-card:hover {
  border-color: var(--aiw-line-blue);
  background: #FBFDFF;
  box-shadow: 0 4px 14px rgba(27, 92, 255, .12);
  transform: translateY(-1px);
}

.aiw-card-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  justify-content: space-between;
}

.aiw-card-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--aiw-ink);
  min-width: 0;
}

.aiw-card-tag {
  flex: none;
  font-size: 10px;
  letter-spacing: .04em;
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--aiw-blue);
  background: #EEF3FF;
  border: 1px solid rgba(27, 92, 255, .16);
}

.aiw-card-tag[data-kind="policy"] {
  color: #0E7F7F;
  background: #E9F7F6;
  border-color: rgba(14, 159, 159, .22);
}

.aiw-card-meta {
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--aiw-muted-2);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.aiw-card-reason {
  margin-top: 5px;
  font-size: 12px;
  color: var(--aiw-muted);
  line-height: 1.55;
}

/* ---------------- 追问选项（clarify） ---------------- */
.aiw-quicks {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.aiw-quick {
  padding: 6px 11px;
  border: 1px solid var(--aiw-line-blue);
  border-radius: 999px;
  background: #F2F7FF;
  color: var(--aiw-blue);
  font-size: 12.5px;
  line-height: 1.4;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}

.aiw-quick:hover {
  background: var(--aiw-blue);
  border-color: var(--aiw-blue);
  color: #fff;
  box-shadow: 0 3px 10px rgba(27, 92, 255, .22);
}

.aiw-quick:active { transform: scale(.98); }

/* ---------------- 开始态（示例问题） ---------------- */
.aiw-start { padding: 4px 2px 8px; }

.aiw-hello {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.6;
  margin: 2px 0 4px;
  color: var(--aiw-ink);
}

.aiw-hello span { color: var(--aiw-blue); }

.aiw-hint { font-size: 12.5px; color: var(--aiw-muted); margin: 6px 0 12px; line-height: 1.65; }
.aiw-hint b { color: var(--aiw-ink); font-weight: 600; }

.aiw-chips { display: flex; flex-direction: column; gap: 6px; }

.aiw-chip {
  text-align: left;
  padding: 9px 11px;
  border: 1px dashed var(--aiw-line-blue);
  border-radius: 8px;
  background: #FBFDFF;
  color: var(--aiw-muted);
  font-size: 12.5px;
  line-height: 1.55;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s, box-shadow .15s;
}

.aiw-chip:hover {
  border-style: solid;
  border-color: var(--aiw-blue);
  color: var(--aiw-blue);
  background: #F2F7FF;
  box-shadow: 0 3px 10px rgba(27, 92, 255, .1);
}

.aiw-chip b { color: var(--aiw-blue); font-weight: 500; }

/* ---------------- 底部输入 ---------------- */
.aiw-foot {
  border-top: 1px solid var(--aiw-line);
  padding: 9px 10px 8px;
  background: #fff;
}

.aiw-inputrow {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  border: 1px solid var(--aiw-line);
  border-radius: 9px;
  background: var(--aiw-bg);
  padding: 5px 5px 5px 11px;
  transition: border-color .16s, box-shadow .16s, background .16s;
}

.aiw-inputrow:focus-within {
  border-color: var(--aiw-line-blue);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(27, 92, 255, .08);
}

.aiw-input {
  flex: 1;
  min-height: 22px;
  max-height: 96px;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--aiw-ink);
  font-size: 13px;
  line-height: 1.55;
  padding: 3px 0;
  font-family: var(--sans);
}

.aiw-input::placeholder { color: var(--aiw-muted-2); }

.aiw-send {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: #fff;
  background: var(--aiw-blue);
  cursor: pointer;
  transition: background .16s, opacity .16s, transform .16s;
}

.aiw-send:hover { background: var(--aiw-blue-2); }
.aiw-send:active { transform: scale(.96); }
.aiw-send[disabled] { opacity: .4; cursor: not-allowed; }
.aiw-send svg { width: 15px; height: 15px; }

.aiw-disc {
  margin: 7px 2px 0;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--aiw-muted-2);
  display: flex;
  gap: 8px;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
}

.aiw-disc a { color: var(--aiw-blue); }
.aiw-disc a:hover { text-decoration: underline; }

/* ---------------- 状态条 ---------------- */
.aiw-status {
  display: none;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  padding: 7px 9px;
  font-size: 11.5px;
  line-height: 1.5;
  border-radius: 7px;
  border: 1px solid #F5D6C9;
  color: #9A4B2A;
  background: #FEF6F1;
}
.aiw-status[data-show="1"] { display: flex; }
.aiw-status button {
  flex: none;
  color: #B4531F;
  font-size: 11.5px;
  border-bottom: 1px solid currentColor;
  cursor: pointer;
}

/* ---------------- 移动端：全屏抽屉 ---------------- */
@media (max-width: 640px) {
  .aiw-root { --aiw-w: 100vw; }
  .aiw-launcher { right: 16px; bottom: 16px; width: 52px; height: 52px; }
  .aiw-launcher-tip { display: none; }
  .aiw-launcher svg { width: 24px; height: 24px; }
  .aiw-panel {
    right: 0; left: 0; bottom: 0;
    width: 100vw; max-width: none;
    height: 100%;
    height: 100dvh;
    border-radius: 0;
    border-left: 0; border-right: 0; border-bottom: 0;
  }
  .aiw-body { max-width: 90%; }
  .aiw-log { padding: 14px 12px 6px; }
  .aiw-input { font-size: 15px; } /* 防 iOS 聚焦缩放 */
  .aiw-head { padding: 14px 12px 11px; }
}

/* 屏幕很矮时压缩 */
@media (max-height: 520px) {
  .aiw-panel { height: calc(100vh - 24px); bottom: 12px; }
}

/* 减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  .aiw-launcher, .aiw-panel, .aiw-card, .aiw-chip { transition: none !important; }
  .aiw-launcher::after, .aiw-typing i, .aiw-caret::after { animation: none !important; }
}

/* 打印/PDF 不显示 */
@media print {
  .aiw-root { display: none !important; }
}
