/* 四川航天职业技术学院 · 自定义 AI 客服样式
   改颜色/尺寸/圆角：只动 :root 变量即可 */

:root {
  --scavc-ai-primary: #1672de;
  --scavc-ai-primary-dark: #0f5bb8;
  --scavc-ai-accent: #52a2ff;
  --scavc-ai-text: #101f46;
  --scavc-ai-muted: #7588ac;
  --scavc-ai-bg: #ffffff;
  --scavc-ai-panel-bg: #eaf2fa;
  --scavc-ai-border: #dce9fc;
  --scavc-ai-shadow: 0 12px 40px rgba(0, 40, 90, 0.18);
  --scavc-ai-radius: 16px;
  --scavc-ai-launcher-size: 56px;
  --scavc-ai-gap: 12px;
  --scavc-ai-right: 24px;
  --scavc-ai-bottom: 24px;
  --scavc-ai-panel-width: 380px;
  --scavc-ai-panel-height: 640px;
  --scavc-ai-z: 2147483646;
  --scavc-ai-font: "PingFang SC", "Microsoft YaHei", sans-serif;
}

.scavc-ai-root {
  position: fixed;
  right: max(var(--scavc-ai-right), env(safe-area-inset-right));
  bottom: max(var(--scavc-ai-bottom), env(safe-area-inset-bottom));
  z-index: var(--scavc-ai-z);
  font-family: var(--scavc-ai-font);
  color: var(--scavc-ai-text);
  line-height: 1.5;
  box-sizing: border-box;
  overflow: visible;
  -webkit-tap-highlight-color: transparent;
  /* 入口实际高度由脚本写入，避免文案换行后挡住对话窗 / 挂断键 */
  --scavc-ai-dock-height: 168px;
}

.scavc-ai-root button,
.scavc-ai-root textarea,
.scavc-ai-root p,
.scavc-ai-root img {
  margin: 0;
  font-family: inherit;
  line-height: inherit;
}

.scavc-ai-root *,
.scavc-ai-root *::before,
.scavc-ai-root *::after {
  box-sizing: border-box;
}

.scavc-ai-launchers {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--scavc-ai-gap);
}

.scavc-ai-launcher {
  width: auto;
  min-width: var(--scavc-ai-launcher-size);
  height: auto;
  border: none;
  border-radius: 18px;
  background: transparent;
  color: #fff;
  box-shadow: none;
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.2s ease;
  padding: 0;
}

.scavc-ai-launcher-icon {
  width: var(--scavc-ai-launcher-size);
  height: var(--scavc-ai-launcher-size);
  border-radius: 50%;
  background: #0a2a55;
  box-shadow: var(--scavc-ai-shadow);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.85);
}

.scavc-ai-launcher-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scavc-ai-launcher-icon svg {
  width: 26px;
  height: 26px;
  fill: #fff;
}

.scavc-ai-launcher-caption {
  max-width: 88px;
  font-size: 12px;
  line-height: 1.25;
  font-weight: 700;
  color: #0a2a55;
  text-align: center;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--scavc-ai-border);
  border-radius: 999px;
  padding: 3px 8px;
  box-shadow: 0 4px 12px rgba(0, 40, 90, 0.12);
}

.scavc-ai-launcher:hover {
  transform: translateY(-2px);
}

.scavc-ai-launcher:active {
  transform: translateY(0);
}

.scavc-ai-launcher.is-phone .scavc-ai-launcher-icon {
  background: linear-gradient(145deg, #2f8fff, var(--scavc-ai-primary-dark));
}

.scavc-ai-launcher.is-active .scavc-ai-launcher-icon {
  outline: 3px solid rgba(0, 88, 166, 0.28);
}

.scavc-ai-launcher-label {
  position: absolute;
  right: calc(100% + 10px);
  white-space: nowrap;
  background: rgba(0, 34, 68, 0.88);
  color: #fff;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.scavc-ai-launcher {
  position: relative;
}

.scavc-ai-launcher:hover .scavc-ai-launcher-label {
  opacity: 1;
  transform: translateX(0);
}

.scavc-ai-panel {
  position: absolute;
  right: 0;
  bottom: var(--scavc-ai-dock-height);
  width: min(var(--scavc-ai-panel-width), calc(100vw - var(--scavc-ai-right) - 12px));
  height: min(
    var(--scavc-ai-panel-height),
    calc(100vh - var(--scavc-ai-dock-height) - var(--scavc-ai-bottom) - 16px)
  );
  height: min(
    var(--scavc-ai-panel-height),
    calc(100dvh - var(--scavc-ai-dock-height) - var(--scavc-ai-bottom) - 16px)
  );
  background: var(--scavc-ai-bg);
  border: 1px solid var(--scavc-ai-border);
  border-radius: var(--scavc-ai-radius);
  box-shadow: var(--scavc-ai-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.scavc-ai-root.is-calling .scavc-ai-launchers {
  visibility: hidden;
  pointer-events: none;
}

.scavc-ai-root.is-calling .scavc-ai-call {
  bottom: 0;
}

.scavc-ai-panel.is-open {
  display: flex;
  animation: scavc-ai-rise 0.22s ease;
}

@keyframes scavc-ai-rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.scavc-ai-header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 48px;
  padding: 10px 12px;
  background: #1672de;
  color: #fff;
  position: relative;
}

.scavc-ai-header-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 60%;
  pointer-events: none;
}

.scavc-ai-school-logo {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 6px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  padding: 2px;
  box-sizing: border-box;
}

.scavc-ai-school-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.scavc-ai-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
}

.scavc-ai-back {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  z-index: 1;
}

.scavc-ai-back[hidden] {
  display: none !important;
}

.scavc-ai-back img {
  width: 8px;
  height: 15px;
  display: block;
}

.scavc-ai-header-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
  z-index: 1;
}

.scavc-ai-icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.scavc-ai-icon-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

.scavc-ai-icon-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.scavc-ai-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: linear-gradient(180deg, #eaf2fa 0%, #f7fafd 55%, #eef4fb 100%);
  display: flex;
  flex-direction: column;
}

.scavc-ai-home {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scavc-ai-home[hidden] {
  display: none !important;
}

.scavc-ai-welcome {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  padding: 4px 8px 0 12px;
}

.scavc-ai-mascot {
  width: 77px;
  height: 88px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scavc-ai-mascot img {
  width: 67px;
  height: 80px;
  object-fit: contain;
  display: block;
}

.scavc-ai-bubble {
  position: relative;
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 12px;
  padding: 8px 14px 10px;
  box-shadow: 0 4px 16px rgba(22, 114, 222, 0.08);
}

.scavc-ai-bubble-tail {
  position: absolute;
  left: -6px;
  top: 30px;
  width: 7px;
  height: 11px;
  display: block;
}

.scavc-ai-bubble-title {
  color: #101f46;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.5;
}

.scavc-ai-bubble-title p {
  margin: 0;
}

.scavc-ai-bubble-hint {
  margin: 4px 0 0;
  color: #7588ac;
  font-size: 10.5px;
  line-height: 1.4;
}

.scavc-ai-faq {
  background: rgba(244, 250, 255, 0.85);
  border-radius: 11px;
  padding: 8px 9px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scavc-ai-faq-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.scavc-ai-faq-title {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #0047b7;
  font-size: 14px;
}

.scavc-ai-faq-title img {
  width: 16px;
  height: 19px;
  object-fit: contain;
  display: block;
}

.scavc-ai-faq-title strong {
  font-weight: 700;
}

.scavc-ai-faq-refresh {
  border: none;
  background: transparent;
  color: #0058e9;
  font-size: 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}

.scavc-ai-faq-refresh img {
  width: 11px;
  height: 11px;
  display: block;
}

.scavc-ai-faq-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 0 2px;
  scrollbar-width: none;
}

.scavc-ai-faq-tabs::-webkit-scrollbar {
  display: none;
}

.scavc-ai-faq-tab {
  flex: 0 0 auto;
  min-width: 63px;
  height: 23px;
  border: none;
  border-radius: 12px;
  background: #e3efff;
  color: #0058e9;
  font-size: 10px;
  font-family: inherit;
  cursor: pointer;
  padding: 0 10px;
  white-space: nowrap;
}

.scavc-ai-faq-tab.is-active {
  background: #ff4145;
  color: #fff;
  box-shadow: 0 1px 5px rgba(255, 69, 69, 0.13);
}

.scavc-ai-faq-list {
  background: rgba(255, 255, 255, 0.72);
  border-radius: 10px;
  overflow: hidden;
}

.scavc-ai-faq-empty {
  margin: 0;
  padding: 16px;
  text-align: center;
  color: var(--scavc-ai-muted);
  font-size: 12px;
}

.scavc-ai-faq-item {
  width: 100%;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 35px;
  padding: 0 11px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.scavc-ai-faq-num {
  width: 29px;
  height: 23px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  flex-shrink: 0;
}

.scavc-ai-faq-text {
  flex: 1;
  min-width: 0;
  color: #101f46;
  font-size: 11.2px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-bottom: 0.5px solid #dce9fc;
  padding: 9px 0;
}

.scavc-ai-faq-item:last-child .scavc-ai-faq-text {
  border-bottom: none;
}

.scavc-ai-faq-chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.7;
}

.scavc-ai-services {
  display: flex;
  gap: 4px;
}

.scavc-ai-svc {
  flex: 1;
  min-width: 0;
  border: none;
  background: rgba(255, 255, 255, 0.82);
  border-radius: 10px;
  padding: 10px 2px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  font-family: inherit;
}

.scavc-ai-svc-icon {
  width: 42px;
  height: 36px;
  object-fit: contain;
  display: block;
}

.scavc-ai-svc-title {
  color: #0a326f;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.4;
}

.scavc-ai-svc-desc {
  color: #7e96bc;
  font-size: 8px;
  line-height: 1.4;
  white-space: nowrap;
}

.scavc-ai-contacts {
  display: flex;
  gap: 7px;
}

.scavc-ai-contact {
  flex: 1;
  height: 28px;
  border: none;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.94);
  color: #3b619b;
  font-size: 9.5px;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  padding: 0 6px;
}

.scavc-ai-contact img {
  width: 14px;
  height: 14px;
  display: block;
}

.scavc-ai-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  background: transparent;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scavc-ai-messages[hidden] {
  display: none !important;
}

.scavc-ai-msg {
  max-width: 86%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.scavc-ai-msg.is-ai {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--scavc-ai-border);
  border-bottom-left-radius: 4px;
}

.scavc-ai-msg.is-streaming::after {
  content: "▌";
  display: inline-block;
  margin-left: 2px;
  color: #1672de;
  animation: scavc-ai-caret 0.9s step-end infinite;
  vertical-align: baseline;
}

@keyframes scavc-ai-caret {
  50% {
    opacity: 0;
  }
}

.scavc-ai-msg.is-human {
  align-self: flex-end;
  background: var(--scavc-ai-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.scavc-ai-msg.is-system {
  align-self: center;
  background: transparent;
  color: var(--scavc-ai-muted);
  font-size: 12px;
  padding: 0;
}

.scavc-ai-typing {
  padding: 0 16px 8px;
  background: transparent;
  color: var(--scavc-ai-muted);
  font-size: 12px;
  display: none;
}

.scavc-ai-typing.is-on {
  display: block;
}

.scavc-ai-footer {
  flex-shrink: 0;
  border-top: none;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: transparent;
}

.scavc-ai-composer {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 7px 9px;
  background: rgba(255, 255, 255, 0.78);
  border-radius: 16px;
}

.scavc-ai-grid {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  display: block;
  opacity: 0.9;
}

.scavc-ai-input {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  max-width: 100%;
  min-height: 32px;
  max-height: 88px;
  resize: none;
  border: none;
  border-radius: 20px;
  padding: 8px 12px;
  font: inherit;
  font-size: 11px;
  outline: none;
  background: rgba(255, 255, 255, 0.91);
  color: var(--scavc-ai-text);
}

.scavc-ai-input::placeholder {
  color: #9aabca;
}

.scavc-ai-input:focus {
  box-shadow: none;
}

.scavc-ai-send {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border: none;
  border-radius: 18px;
  background: linear-gradient(180deg, #52a2ff, #1370e6);
  color: #fff;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}

.scavc-ai-send img {
  width: 14px;
  height: 14px;
  display: block;
}

.scavc-ai-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.scavc-ai-call {
  position: absolute;
  right: 0;
  bottom: var(--scavc-ai-dock-height);
  width: 280px;
  min-height: 260px;
  background: #0f2744;
  color: #fff;
  border-radius: var(--scavc-ai-radius);
  box-shadow: var(--scavc-ai-shadow);
  padding: 24px 20px 28px;
  display: none;
  text-align: center;
  overflow: visible;
  box-sizing: border-box;
}

.scavc-ai-call.is-open {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: scavc-ai-rise 0.22s ease;
}

.scavc-ai-call-title {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}

.scavc-ai-call-status {
  margin: 0 0 18px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  flex-shrink: 0;
}

.scavc-ai-call-wave {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-bottom: 24px;
  flex-shrink: 0;
}

.scavc-ai-call-wave span {
  width: 4px;
  height: 12px;
  border-radius: 999px;
  background: #7eb6ff;
  animation: scavc-ai-wave 1s ease-in-out infinite;
}

.scavc-ai-call-wave span:nth-child(2) { animation-delay: 0.1s; }
.scavc-ai-call-wave span:nth-child(3) { animation-delay: 0.2s; }
.scavc-ai-call-wave span:nth-child(4) { animation-delay: 0.3s; }
.scavc-ai-call-wave span:nth-child(5) { animation-delay: 0.4s; }

@keyframes scavc-ai-wave {
  0%, 100% { height: 10px; opacity: 0.5; }
  50% { height: 28px; opacity: 1; }
}

.scavc-ai-hangup {
  width: 64px;
  height: 64px;
  min-width: 64px;
  min-height: 64px;
  margin-top: 4px;
  border: none;
  border-radius: 50%;
  background: #e5484d;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: visible;
  padding: 0;
  line-height: 0;
}

.scavc-ai-hangup:hover {
  background: #d4383d;
}

.scavc-ai-call.is-ended .scavc-ai-call-wave span {
  animation: none;
  height: 10px;
  opacity: 0.45;
}

.scavc-ai-hangup svg {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  fill: currentColor;
  display: block;
  flex-shrink: 0;
}

/* 公众号 H5 全屏模式 */
.scavc-ai-root.is-h5 {
  inset: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
}

.scavc-ai-root.is-h5 .scavc-ai-launchers {
  display: none;
}

.scavc-ai-root.is-h5 .scavc-ai-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: auto;
  width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  max-width: none;
  border-radius: 0;
  border: none;
  display: flex;
}

.scavc-ai-root.is-h5 .scavc-ai-panel.is-open {
  animation: none;
}

.scavc-ai-root.is-h5 .scavc-ai-close,
.scavc-ai-root.is-h5 .scavc-ai-header-phone {
  display: none;
}

.scavc-ai-root.is-h5 .scavc-ai-header {
  min-height: 88px;
  padding: calc(44px + env(safe-area-inset-top)) 16px 12px;
  align-items: flex-end;
}

.scavc-ai-root.is-h5 .scavc-ai-header-center {
  top: auto;
  bottom: 12px;
}

.scavc-ai-root.is-h5 .scavc-ai-back {
  margin-bottom: 2px;
}

.scavc-ai-root.is-h5 .scavc-ai-footer {
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
}

.scavc-ai-root.is-h5 .scavc-ai-panel {
  background: #eaf2fa;
  z-index: 10;
}

.scavc-ai-root.is-h5 {
  background: #eaf2fa;
  isolation: isolate;
}

.scavc-ai-panel.is-chatting .scavc-ai-home {
  display: none !important;
}

.scavc-ai-root.is-h5.is-calling .scavc-ai-panel {
  display: none;
}

.scavc-ai-root.is-h5.is-calling .scavc-ai-call {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: auto;
  width: 100%;
  height: 100dvh;
  min-height: 0;
  border-radius: 0;
  justify-content: center;
}

.scavc-ai-launcher:focus-visible .scavc-ai-launcher-icon,
.scavc-ai-icon-btn:focus-visible,
.scavc-ai-hangup:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.scavc-ai-send:focus-visible,
.scavc-ai-faq-item:focus-visible,
.scavc-ai-faq-tab:focus-visible,
.scavc-ai-svc:focus-visible,
.scavc-ai-contact:focus-visible,
.scavc-ai-input:focus-visible {
  outline: 2px solid var(--scavc-ai-primary);
  outline-offset: 2px;
}

@media (max-height: 520px) {
  .scavc-ai-launcher-caption {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .scavc-ai-panel.is-open,
  .scavc-ai-call.is-open,
  .scavc-ai-launcher,
  .scavc-ai-call-wave span {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 640px) {
  :root {
    --scavc-ai-right: 12px;
    --scavc-ai-bottom: 12px;
    --scavc-ai-launcher-size: 58px;
    --scavc-ai-dock-height: 158px;
    --scavc-ai-panel-width: calc(100vw - 24px);
    --scavc-ai-panel-height: min(78vh, 620px);
  }

  .scavc-ai-call {
    width: min(280px, calc(100vw - 24px));
    min-height: 240px;
  }

  .scavc-ai-launcher-caption {
    max-width: 76px;
    font-size: 11px;
    padding: 2px 6px;
  }

  .scavc-ai-input {
    font-size: 16px;
  }

  .scavc-ai-launchers {
    gap: 10px;
  }
}
