/* ==========================================================================
   AI 语音找房 —— 3D 浮窗 + 语音交互面板
   独立样式文件，可挂在任意页面（引入本 CSS 与 ai-float.js 即可生效）。
   ========================================================================== */

/* ==========================================================================
   1. 3D 浮窗按钮 (.ai-orb)
   ========================================================================== */
.ai-orb {
  position: fixed;
  right: 14px;
  bottom: calc(var(--nav-h, 57px) + 76px);
  width: 56px;
  height: 56px;
  z-index: 78;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  /* 3D 舞台 */
  perspective: 600px;
}

/* 呼吸光晕 */
.ai-orb::before {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(47, 178, 135, .45) 0%, rgba(47, 178, 135, 0) 70%);
  animation: ai-orb-glow 2.4s ease-in-out infinite;
  z-index: -1;
}

/* 主体球体（3D 悬浮） */
.ai-orb__core {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, .92) 0%, rgba(255, 255, 255, .08) 26%, transparent 40%),
    linear-gradient(135deg, #2fb287 0%, #0b7a52 55%, #086243 100%);
  box-shadow:
    0 8px 22px rgba(90, 80, 255, .45),
    inset 0 -6px 14px rgba(0, 0, 0, .22);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: ai-orb-float 3.2s ease-in-out infinite;
  transform-style: preserve-3d;
}
.ai-orb__core svg { width: 26px; height: 26px; fill: #fff; }

/* 3D 环绕光环 */
.ai-orb__ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(120, 120, 255, .55);
  transform-style: preserve-3d;
  animation: ai-orb-spin 5s linear infinite;
}
.ai-orb__ring.r2 {
  inset: -12px;
  border: 1.5px solid rgba(90, 200, 255, .5);
  animation-duration: 7s;
  animation-direction: reverse;
}
.ai-orb__ring.r3 {
  inset: -18px;
  border: 1px dashed rgba(255, 255, 255, .55);
  animation-duration: 9s;
}

/* 点击态 */
.ai-orb:active .ai-orb__core { transform: scale(.92); }

/* 休眠时的角标提示气泡 */
.ai-orb__hint {
  position: absolute;
  right: 64px;
  top: 50%;
  transform: translateY(-50%);
  background: #fff;
  color: var(--c-title, #101d37);
  font-size: 12px;
  line-height: 1;
  padding: 7px 10px;
  border-radius: 14px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, .14);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
}
.ai-orb__hint::after {
  content: "";
  position: absolute;
  right: -4px;
  top: 50%;
  transform: translateY(-50%) rotate(45deg);
  width: 8px; height: 8px;
  background: #fff;
}
.ai-orb.show-hint .ai-orb__hint { opacity: 1; }

/* ==========================================================================
   2. 语音交互面板 (.ai-panel)
   ========================================================================== */
.ai-mask {
  display: none;
  position: fixed; inset: 0; z-index: 120;
  background: rgba(15, 20, 40, .55);
  backdrop-filter: blur(2px);
}
.ai-mask.show { display: block; }

.ai-panel {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 105%);
  width: 100%;
  max-width: 640px;
  max-height: 78vh;
  background: linear-gradient(180deg, #f4faf7 0%, #fff 18%);
  border-radius: 18px 18px 0 0;
  z-index: 130;
  display: flex;
  flex-direction: column;
  transition: transform .28s cubic-bezier(.22, .9, .3, 1);
  box-shadow: 0 -8px 30px rgba(20, 20, 60, .18);
}
.ai-panel.show { transform: translate(-50%, 0); }

.ai-panel__head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 14px 16px 10px;
}
.ai-panel__head .logo {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, #2fb287, #086243);
  display: flex; align-items: center; justify-content: center;
  margin-right: 8px;
}
.ai-panel__head .logo svg { width: 15px; height: 15px; fill: #fff; }
.ai-panel__head .t { font-size: 15px; font-weight: 700; color: #101d37; }
.ai-panel__head .t em { font-style: normal; color: #0b7a52; }
.ai-panel__close {
  margin-left: auto;
  width: 28px; height: 28px;
  font-size: 22px; line-height: 26px; text-align: center;
  color: #999;
}

/* 聆听区 */
.ai-stage {
  flex-shrink: 0;
  text-align: center;
  padding: 6px 16px 4px;
}
.ai-stage__status {
  font-size: 13px; color: #666;
  min-height: 20px; margin-bottom: 8px;
}
.ai-stage__status.listening { color: #2fb287; font-weight: 700; }

/* 麦克风大按钮 */
.ai-mic {
  position: relative;
  width: 74px; height: 74px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2fb287, #0b7a52);
  box-shadow: 0 6px 18px rgba(90, 80, 255, .4);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform .15s;
  -webkit-tap-highlight-color: transparent;
}
.ai-mic svg { width: 30px; height: 30px; fill: #fff; }
.ai-mic:active { transform: scale(.94); }
.ai-mic.listening { background: linear-gradient(135deg, #ff4d6d, #ff7a45); }
.ai-mic.listening::before,
.ai-mic.listening::after {
  content: ""; position: absolute; inset: -8px; border-radius: 50%;
  border: 2px solid rgba(255, 90, 120, .55);
  animation: ai-pulse 1.3s ease-out infinite;
}
.ai-mic.listening::after { animation-delay: .65s; }

/* 识别文字 */
.ai-recog {
  font-size: 14px; color: #101d37;
  min-height: 22px; padding: 0 8px 12px;
  line-height: 1.5;
}
.ai-recog .placeholder { color: #bbb; }

/* 热门话术 */
.ai-hot {
  flex-shrink: 0;
  padding: 0 16px 12px;
}
.ai-hot .hot-title { font-size: 12px; color: #999; margin-bottom: 8px; }
.ai-hot__wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.ai-hot__chip {
  font-size: 12px; color: #4a5ac8;
  background: #eef1ff;
  border: 1px solid #dde3ff;
  border-radius: 14px;
  padding: 6px 12px;
  cursor: pointer;
}

/* 结果区 */
.ai-result {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 16px;
  min-height: 80px;
}
.ai-reply {
  font-size: 13px; color: #555;
  background: #f2f5ff;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  line-height: 1.55;
}
.ai-empty {
  text-align: center;
  color: #bbb;
  font-size: 13px;
  padding: 28px 0;
}

/* 结果卡片 */
.ai-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(30, 40, 90, .06);
  margin-bottom: 10px;
  overflow: hidden;
  animation: ai-card-in .35s ease both;
}
.ai-card a { display: flex; padding: 10px; }
.ai-card .thumb {
  width: 104px; height: 78px;
  border-radius: 8px;
  background: #eee;
  object-fit: cover;
  flex-shrink: 0;
  margin-right: 10px;
}
.ai-card .info { flex: 1; min-width: 0; }
.ai-card .title {
  font-size: 14px; font-weight: 700; color: #101d37;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ai-card .other {
  font-size: 12px; color: #888;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin: 3px 0 6px;
}
.ai-card .price {
  font-size: 15px; color: #fa5741; font-weight: 700;
}
.ai-card .price .u { font-size: 11px; font-weight: 400; color: #fa5741; margin-left: 2px; }
.ai-card .score {
  float: right; font-size: 11px; color: #fff;
  background: linear-gradient(135deg, #2fb287, #086243);
  border-radius: 10px; padding: 2px 8px;
}
.ai-card .reasons { margin-top: 6px; }
.ai-card .reasons i {
  font-style: normal; font-size: 11px; color: #0b7a52;
  background: #eaf7f1; border-radius: 4px; padding: 2px 6px; margin-right: 5px;
}

/* 文本输入兜底 */
.ai-input {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid #f0f0f0;
  background: #fff;
}
.ai-input input {
  flex: 1; height: 38px;
  background: #f2f3f7;
  border-radius: 19px;
  padding: 0 16px;
  font-size: 13px;
  color: #333;
}
.ai-input button {
  height: 38px; padding: 0 16px;
  background: linear-gradient(135deg, #2fb287, #0b7a52);
  color: #fff; border-radius: 19px;
  font-size: 13px; font-weight: 700;
  cursor: pointer;
}

/* 关闭语音识别按钮 */
.ai-stop { display: none; }

/* ==========================================================================
   动画
   ========================================================================== */
@keyframes ai-orb-float {
  0%, 100% { transform: translateY(0) rotateX(6deg); }
  50%      { transform: translateY(-7px) rotateX(-4deg); }
}
@keyframes ai-orb-spin {
  from { transform: rotateX(65deg) rotateZ(0deg); }
  to   { transform: rotateX(65deg) rotateZ(360deg); }
}
@keyframes ai-orb-glow {
  0%, 100% { opacity: .55; transform: scale(.9); }
  50%      { opacity: 1; transform: scale(1.12); }
}
@keyframes ai-pulse {
  0%   { transform: scale(.85); opacity: .9; }
  100% { transform: scale(1.5); opacity: 0; }
}
@keyframes ai-card-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
