/* ESclaw AI 悬浮助手 — 图标位于对话框左上角 */
.esclaw-root {
  --esclaw-brand: #007d65;
  --esclaw-w: 360px;
  --esclaw-avatar: 68px;
  position: fixed;
  z-index: 99990;
  left: auto;
  top: auto;
  font-family: PingFang SC, 'Microsoft YaHei', sans-serif;
  touch-action: none;
}

.esclaw-root.is-dragging {
  transition: none !important;
}

.esclaw-panel {
  position: relative;
  width: var(--esclaw-w);
  max-width: calc(100vw - 24px);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(0, 40, 32, 0.18);
  border: 1px solid rgba(0, 125, 101, 0.12);
  overflow: visible;
}

/* 折叠态：仅显示左上角图标 */
.esclaw-root.is-collapsed .esclaw-panel {
  width: var(--esclaw-avatar);
  background: transparent;
  border: none;
  box-shadow: none;
}

.esclaw-root.is-collapsed .esclaw-tabs,
.esclaw-root.is-collapsed .esclaw-body,
.esclaw-root.is-collapsed .esclaw-brand,
.esclaw-root.is-collapsed .esclaw-close {
  display: none !important;
}

.esclaw-root.is-collapsed .esclaw-panel-head {
  background: transparent;
  padding: 0;
  min-height: 0;
}

.esclaw-root.is-docked {
  /* 位置由 JS 控制，避免 right:0 导致展开溢出屏幕 */
}

/* 展开态 */
.esclaw-root.is-hover .esclaw-panel,
.esclaw-root.is-open .esclaw-panel,
.esclaw-root.is-welcome .esclaw-panel {
  width: var(--esclaw-w);
  background: #fff;
  border: 1px solid rgba(0, 125, 101, 0.12);
  box-shadow: 0 20px 50px rgba(0, 40, 32, 0.18);
}

.esclaw-root.is-hover .esclaw-tabs,
.esclaw-root.is-hover .esclaw-body,
.esclaw-root.is-open .esclaw-tabs,
.esclaw-root.is-open .esclaw-body,
.esclaw-root.is-welcome .esclaw-tabs,
.esclaw-root.is-welcome .esclaw-body,
.esclaw-root.is-hover .esclaw-brand,
.esclaw-root.is-open .esclaw-brand,
.esclaw-root.is-welcome .esclaw-brand,
.esclaw-root.is-hover .esclaw-close,
.esclaw-root.is-open .esclaw-close,
.esclaw-root.is-welcome .esclaw-close {
  display: flex;
}

.esclaw-root.is-hover .esclaw-close,
.esclaw-root.is-open .esclaw-close,
.esclaw-root.is-welcome .esclaw-close {
  display: block;
}

.esclaw-panel-head {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 56px;
  padding: 12px 14px 12px calc(var(--esclaw-avatar) + 8px);
  background: linear-gradient(135deg, #007d65, #009e7a);
  color: #fff;
  border-radius: 18px 18px 0 0;
  cursor: grab;
  user-select: none;
}

.esclaw-panel-head:active {
  cursor: grabbing;
}

/* 助手图标 — 对话框左上角 */
.esclaw-avatar {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-12%, -18%);
  width: var(--esclaw-avatar);
  height: var(--esclaw-avatar);
  border: 3px solid #fff;
  border-radius: 50%;
  padding: 0;
  cursor: grab;
  overflow: hidden;
  background: linear-gradient(135deg, #007d65, #00a88a);
  box-shadow: 0 8px 22px rgba(0, 125, 101, 0.35);
  z-index: 3;
  flex-shrink: 0;
}

.esclaw-root.is-collapsed .esclaw-avatar {
  position: relative;
  left: auto;
  top: auto;
  transform: none;
  margin: 0;
}

.esclaw-avatar:active {
  cursor: grabbing;
}

.esclaw-video,
.esclaw-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  display: block;
}

.esclaw-root.is-collapsed .esclaw-video {
  display: none !important;
}

.esclaw-root.is-collapsed .esclaw-thumb {
  display: block !important;
}

.esclaw-root:not(.is-collapsed) .esclaw-thumb {
  display: none !important;
}

.esclaw-root:not(.is-collapsed) .esclaw-video {
  display: block !important;
}

.esclaw-video {
  display: none;
}

.esclaw-brand {
  flex: 1;
  min-width: 0;
  padding-left: 4px;
}

.esclaw-brand strong {
  display: block;
  font-size: 16px;
}

.esclaw-brand span {
  font-size: 12px;
  opacity: 0.85;
}

.esclaw-close {
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  z-index: 5;
}

.esclaw-tabs {
  display: none;
  border-bottom: 1px solid #eee;
  background: #f8fafa;
  border-radius: 0;
}

.esclaw-tabs button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 6px;
  font-size: 13px;
  color: #666;
  cursor: pointer;
}

.esclaw-tabs button.is-active {
  color: var(--esclaw-brand);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--esclaw-brand);
}

.esclaw-body {
  display: none;
  height: 380px;
  overflow: hidden;
  background: #fff;
  border-radius: 0 0 18px 18px;
}

.esclaw-root.is-hover .esclaw-body,
.esclaw-root.is-open .esclaw-body,
.esclaw-root.is-welcome .esclaw-body {
  display: block;
}

.esclaw-tab-pane {
  display: none;
  height: 100%;
  flex-direction: column;
  padding: 12px;
  box-sizing: border-box;
}

.esclaw-tab-pane.is-active {
  display: flex;
}

.esclaw-welcome {
  font-size: 13px;
  color: #666;
  background: #f0f8f5;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  line-height: 1.5;
}

.esclaw-messages {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

.esclaw-msg {
  margin-bottom: 10px;
  max-width: 92%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.esclaw-msg.user {
  margin-left: auto;
  background: #e8f5f1;
  color: #1a3d34;
  border-bottom-right-radius: 4px;
}

.esclaw-msg.bot {
  background: #f5f5f5;
  color: #333;
  border-bottom-left-radius: 4px;
}

.esclaw-chat-input {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.esclaw-chat-input textarea {
  flex: 1;
  resize: none;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
}

.esclaw-send,
.esclaw-search-btn,
.esclaw-message-form button {
  border: none;
  background: var(--esclaw-brand);
  color: #fff;
  border-radius: 10px;
  padding: 0 14px;
  cursor: pointer;
  font-size: 13px;
}

.esclaw-search-box {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.esclaw-search-box input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 8px 10px;
}

.esclaw-search-results {
  flex: 1;
  overflow-y: auto;
}

.esclaw-search-item {
  display: block;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #eee;
  margin-bottom: 8px;
  text-decoration: none;
  color: inherit;
}

.esclaw-search-item:hover {
  border-color: var(--esclaw-brand);
  background: #f6fbfa;
}

.esclaw-search-item h4 {
  font-size: 14px;
  margin: 0 0 4px;
  color: #222;
}

.esclaw-search-item p {
  margin: 0;
  font-size: 12px;
  color: #888;
}

.esclaw-message-form input,
.esclaw-message-form textarea {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 8px;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
}

.esclaw-captcha {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.esclaw-captcha input {
  flex: 1;
  margin-bottom: 0;
}

.esclaw-verify-img {
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
}

.esclaw-message-form {
  overflow-y: auto;
}

@media (max-width: 480px) {
  .esclaw-root {
    --esclaw-w: calc(100vw - 20px);
    right: 10px !important;
    left: auto !important;
    bottom: 16px !important;
    top: auto !important;
  }

  .esclaw-body {
    height: 320px;
  }

  .esclaw-avatar {
    transform: translate(-8%, -12%);
  }
}
