/* ============================================================
   AI 员工 · 右下角悬浮数字人对话 widget
   复用全站配色变量（--bg/--ink/--accent 等，定义在 style.css）
   ============================================================ */

.aiw {
  position: fixed;
  right: clamp(16px, 3vw, 28px);
  bottom: clamp(16px, 3vw, 28px);
  z-index: 9999;
  font-family: var(--sans);
}

/* —— 悬浮气泡 —— */
.aiw-bubble {
  position: relative;
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: radial-gradient(120% 120% at 30% 25%, #14203c 0%, #0d0d0d 70%);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .5), 0 0 0 6px rgba(0, 85, 255, .06);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.aiw-bubble:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 12px 36px rgba(0,0,0,.55), 0 0 0 8px rgba(0,85,255,.12); }
.aiw-bubble-txt {
  font-family: var(--display);
  font-weight: 700;
  font-size: 13px;
  line-height: 1.15;
  text-align: center;
  letter-spacing: .02em;
}
.aiw-bubble-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #0d0d0d;
  box-shadow: 0 0 0 0 rgba(34,197,94,.6);
  animation: aiw-pulse 2.2s var(--ease) infinite;
}
@keyframes aiw-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(34,197,94,.55); }
  70%  { box-shadow: 0 0 0 10px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

/* —— 展开面板 —— */
.aiw-panel {
  position: absolute;
  right: 0;
  bottom: 84px;
  width: min(92vw, 360px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .6);
  transform: translateY(12px) scale(.96);
  transform-origin: bottom right;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s var(--ease), transform .22s var(--ease);
}

/* 状态切换：由容器 data-state 控制 */
.aiw[data-state="idle"]  .aiw-panel { }
.aiw[data-state="open"]  .aiw-panel,
.aiw[data-state="connecting"] .aiw-panel,
.aiw[data-state="live"]  .aiw-panel,
.aiw[data-state="ended"] .aiw-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.aiw[data-state="idle"] .aiw-bubble { display: grid; }
.aiw:not([data-state="idle"]) .aiw-bubble { display: none; }

/* —— 头部 —— */
.aiw-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.aiw-title {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  flex: 1;
}
.aiw-live {
  width: 8px; height: 8px; border-radius: 50%;
  background: #666;
}
.aiw[data-state="live"] .aiw-live { background: #22c55e; box-shadow: 0 0 8px #22c55e; }
.aiw[data-state="connecting"] .aiw-live { background: #f59e0b; animation: aiw-blink 1s infinite; }
@keyframes aiw-blink { 50% { opacity: .3; } }
.aiw-timer {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--dim);
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.aiw-close {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border: none; background: transparent;
  color: var(--body);
  font-size: 22px; line-height: 1;
  cursor: pointer; border-radius: 8px;
}
.aiw-close:hover { background: #1a1a1a; color: var(--ink); }

/* —— 视频舞台 —— */
.aiw-stage {
  position: relative;
  aspect-ratio: 3 / 4;
  background: #060606;
}
.aiw-video {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  background: #060606;
}
.aiw-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px; padding: 20px;
  text-align: center;
  background: radial-gradient(120% 90% at 50% 40%, #10162a 0%, #060606 75%);
}
.aiw[data-state="live"] .aiw-overlay { display: none; }
.aiw-status { color: var(--body); font-size: 14px; line-height: 1.5; }
.aiw-start {
  font-family: var(--display); font-weight: 700; font-size: 15px;
  color: #fff;
  background: var(--accent);
  border: none; border-radius: 12px;
  padding: 12px 26px;
  cursor: pointer;
  transition: background .2s var(--ease), transform .2s var(--ease);
}
.aiw-start:hover { background: var(--accent-soft); transform: translateY(-1px); }
.aiw-start:disabled { opacity: .5; cursor: default; transform: none; }
.aiw-spin {
  width: 34px; height: 34px;
  border: 3px solid #ffffff22;
  border-top-color: var(--accent-soft);
  border-radius: 50%;
  animation: aiw-rot .8s linear infinite;
}
@keyframes aiw-rot { to { transform: rotate(360deg); } }

/* 字幕 */
.aiw-caption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  margin: 0;
  padding: 20px 14px 12px;
  font-size: 13px;
  line-height: 1.45;
  color: #fff;
  background: linear-gradient(to top, rgba(0,0,0,.78), transparent);
  min-height: 1.4em;
  opacity: 0;
  transition: opacity .2s var(--ease);
}
.aiw[data-state="live"] .aiw-caption.show { opacity: 1; }

/* —— 底部控制 —— */
.aiw-controls {
  display: flex;
  gap: 8px;
  padding: 12px 12px 10px;
  align-items: center;
}
.aiw[data-state="live"] .aiw-controls { display: flex; }
.aiw:not([data-state="live"]) .aiw-controls { display: none; }
.aiw-input {
  flex: 1;
  background: #060606;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--ink);
  font-size: 14px;
  font-family: var(--sans);
  outline: none;
}
.aiw-input:focus { border-color: #2b3a5c; }
.aiw-input::placeholder { color: var(--dim); }
.aiw-mic, .aiw-send {
  border: 1px solid var(--line);
  background: #101010;
  color: var(--ink);
  border-radius: 999px;
  height: 40px;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 14px;
}
.aiw-mic { width: 40px; font-size: 17px; }
.aiw-send { padding: 0 16px; }
.aiw-mic:hover, .aiw-send:hover { border-color: #2b3a5c; }
.aiw-mic.on { background: var(--accent); border-color: var(--accent); }

.aiw-foot {
  margin: 0;
  padding: 0 14px 12px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--dim);
  text-align: center;
}

@media (max-width: 480px) {
  .aiw-panel { bottom: 80px; }
}
