/* 挂件按钮基础样式 */
.widget-bot-button {
  position: fixed;
  z-index: 9999;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease-in-out;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-family: var(--font-gilory, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif);
  border: none;
  opacity: 0;
  transform: translateY(20px);
  /* 优化拖拽性能 */
  will-change: transform;
  backface-visibility: hidden;
  -webkit-font-smoothing: antialiased;
}

.widget-bot-button:hover:not(.dragging) {
  transform: translateY(-1px);
}

.widget-bot-hover-ball:hover:not(.dragging) {
  transform: scale(1.1) !important;
}

.widget-bot-button.dragging {
  cursor: grabbing;
  transition: none !important;
  /* 拖拽时禁用过渡，提升性能 */
  /* transform 由 JS 控制，包含 rotate 和 translate */
}

.widget-bot-button-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: inherit;
}

/* 图标样式 */
.widget-bot-icon {
  border-radius: 50%;
  object-fit: cover;
}

/* 文字样式 */
.widget-bot-text {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.2;
  text-align: center;
  letter-spacing: 0.5px;
}

.widget-bot-text span {
  display: block;
  margin: 1px 0;
}

/* 侧边吸附按钮样式 */
.widget-bot-side-sticky {
  width: 48px;
  padding: 6px 6px 12px 6px;
  background: #FFFFFF;
  box-shadow: 0px 6px 16px 0px rgba(33, 34, 45, 0.02), 0px 8px 40px 0px rgba(50, 73, 45, 0.12);
  border-radius: 24px;
  border: 1px solid #ECEEF1;
  min-height: auto;
}

.widget-bot-side-sticky .widget-bot-icon {
  width: 36px;
  height: 36px;
  margin-bottom: 4px;
}

.widget-bot-side-sticky .widget-bot-text {
  font-size: 12px;
  color: #646a73;
  line-height: 16px;
}

/* 悬浮球按钮样式 */
.widget-bot-hover-ball {
  width: 48px;
  height: 48px;
  border-radius: 24px;
  background: #FFFFFF;
  box-shadow: 0px 6px 16px 0px rgba(33, 34, 45, 0.02), 0px 8px 40px 0px rgba(50, 73, 45, 0.12);
  border: 1px solid #ECEEF1;
  padding: 0;
  min-height: auto;
}

.widget-bot-hover-ball .widget-bot-hover-ball-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 0;
}

/* 模态框样式 - 基于MUI主题 */
.widget-bot-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.widget-bot-modal-fixed {
  align-items: center;
  justify-content: center;
}

.widget-bot-modal-content {
  position: absolute;
  width: 600px;
  height: 725px;
  max-width: calc(100% - 32px);
  max-height: 80vh;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  animation: slideInUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.widget-bot-modal-content-fixed {
  position: relative;
  width: 800px;
  height: auto;
  max-height: 90vh;
  margin: auto;
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* 关闭按钮样式 - 透明框 */
.widget-bot-close-btn {
  position: absolute;
  top: 22.5px;
  right: 16px;
  background: transparent;
  width: 36.26px;
  height: 25px;
  border: none;
  border-radius: 0;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  opacity: 1;
  z-index: 10001;
  transition: none;
  font-family: var(--font-gilory, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
  padding: 0;
  margin: 0;
  pointer-events: none;
  /* 允许鼠标穿透到下方 */
}

/* iframe样式 */
.widget-bot-iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 10px;
  display: block;
  background: #F8F9FA;
}

.widget-bot-modal-content-fixed .widget-bot-iframe {
  min-height: 600px;
  height: auto;
}

/* 防止页面滚动 */
body.widget-bot-modal-open {
  overflow: hidden;
}

/* 暗色主题支持 - 基于data-theme属性 */
.widget-bot-button[data-theme="dark"] {
  box-shadow: 0 2px 4px rgba(110, 115, 254, 0.15);
}

.widget-bot-side-sticky[data-theme="dark"] {
  background: #6E73FE;
}

.widget-bot-side-sticky[data-theme="dark"]:hover {
  background: #5d68fd;
  box-shadow: 0 4px 8px rgba(110, 115, 254, 0.2);
}

.widget-bot-side-sticky[data-theme="dark"].dragging {
  box-shadow: 0 6px 12px rgba(110, 115, 254, 0.25);
}

.widget-bot-hover-ball[data-theme="dark"] {
  background: #6E73FE;
}

.widget-bot-hover-ball[data-theme="dark"]:hover {
  transform: scale(1.1) !important;
}

.widget-bot-hover-ball[data-theme="dark"].dragging {
  box-shadow: 0 8px 20px rgba(110, 115, 254, 0.3);
}

.widget-bot-modal[data-theme="dark"] {
  background: rgba(0, 0, 0, 0.7);
}

.widget-bot-modal[data-theme="dark"] .widget-bot-modal-content {
  background: #202531;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* 移动端适配 - 统一处理 */
@media (max-width: 768px) {
  .widget-bot-side-sticky {
    width: 48px;
    padding: 6px 6px 12px 6px;
    border-radius: 24px;
  }

  .widget-bot-hover-ball {
    width: 48px;
    height: 48px;
    border-radius: 24px;
    padding: 0;
  }

  .widget-bot-hover-ball .widget-bot-hover-ball-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 0;
  }

  .widget-bot-text {
    font-size: 12px;
  }

  .widget-bot-icon {
    width: 16px;
    height: 16px;
    margin-bottom: 6px;
  }

  /* 移动端弹框统一居中显示，宽度100%-32px，高度90vh */
  .widget-bot-modal-content {
    position: relative !important;
    width: calc(100% - 32px) !important;
    height: 90vh !important;
    max-width: none !important;
    max-height: 90vh !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    margin: auto !important;
  }

  .widget-bot-modal-content-fixed {
    width: calc(100% - 32px) !important;
    height: 90vh !important;
    max-height: 90vh !important;
  }

  .widget-bot-close-btn {
    top: 22.5px;
    right: 16px;
    width: 36.26px;
    height: 25px;
    font-size: 0;
  }
}

/* 确保挂件不会被其他元素遮挡 */
.widget-bot-button,
.widget-bot-modal {
  pointer-events: auto;
}

/* 加载状态 */
.widget-bot-button.loading {
  opacity: 0.7;
  pointer-events: none;
}

.widget-bot-button.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #FFFFFF;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* 减少动画模式支持 */
@media (prefers-reduced-motion: reduce) {

  .widget-bot-button,
  .widget-bot-modal-content,
  .widget-bot-close-btn,
  .widget-bot-text span {
    animation: none;
    transition: none;
  }

  .widget-bot-button:hover,
  .widget-bot-button.dragging {
    transform: none;
  }
}

/* 浅色主题样式 - 显式定义 */
.widget-bot-side-sticky[data-theme="light"] {
  background: #FFFFFF;
  box-shadow: 0px 6px 16px 0px rgba(33, 34, 45, 0.02), 0px 8px 40px 0px rgba(50, 73, 45, 0.12);
  border: 1px solid #ECEEF1;
}

.widget-bot-side-sticky[data-theme="light"]:hover {
  background: #FFFFFF;
}

.widget-bot-side-sticky[data-theme="light"].dragging {
  background: #FFFFFF;
}

.widget-bot-hover-ball[data-theme="light"] {
  background: #FFFFFF;
  box-shadow: 0px 6px 16px 0px rgba(33, 34, 45, 0.02), 0px 8px 40px 0px rgba(50, 73, 45, 0.12);
  border: 1px solid #ECEEF1;
}

.widget-bot-hover-ball[data-theme="light"]:hover {
  transform: scale(1.1) !important;
}

.widget-bot-hover-ball[data-theme="light"].dragging {
  box-shadow: 0 8px 20px rgba(50, 72, 242, 0.3);
}

.widget-bot-modal[data-theme="light"] {
  background: rgba(0, 0, 0, 0.5);
}

.widget-bot-modal[data-theme="light"] .widget-bot-modal-content {
  background: #fff;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}