/* 全员聊天面板：悬浮在页面右侧，高度固定为视口 85% */
.web-chat-panel {
  position: fixed;
  right: 0;
  top: 56px;
  width: 360px;
  min-width: 280px;
  max-width: calc(100vw - 24px);
  height: 85vh;
  max-height: 85vh;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.98) 0%, rgba(31, 41, 55, 0.98) 100%);
  border-left: 1px solid rgba(255, 215, 0, 0.35);
  z-index: 1000;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.3);
}

.web-chat-panel.collapsed .web-chat-body {
  display: none;
}

.web-chat-panel.collapsed {
  width: 48px;
  min-width: 48px;
}

.web-chat-panel.collapsed .web-chat-header span,
.web-chat-panel.collapsed .web-chat-header .fa-comments {
  display: none;
}

.web-chat-panel.collapsed .web-chat-collapse-icon {
  transform: rotate(-90deg);
}

/* 完全关闭：顶部「聊天」按钮控制，不占位不干扰 */
.web-chat-panel.fully-closed {
  display: none !important;
}

.web-chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.2) 0%, rgba(212, 165, 116, 0.2) 100%);
  border-bottom: 1px solid rgba(255, 215, 0, 0.35);
  cursor: pointer;
  user-select: none;
  color: #FFD700;
  font-weight: 600;
  font-size: 14px;
}

.web-chat-header:hover {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.3) 0%, rgba(212, 165, 116, 0.3) 100%);
}

.web-chat-sound-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: #FFD700;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.web-chat-sound-btn:hover {
  background: rgba(255, 215, 0, 0.2);
}

.web-chat-sound-btn.web-chat-sound-muted {
  opacity: 0.65;
  color: #9ca3af;
}

.web-chat-sound-btn.web-chat-sound-muted:hover {
  opacity: 0.9;
  color: #d1d5db;
}

.web-chat-settings-btn {
  background: none;
  border: none;
  color: #FFD700;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.web-chat-settings-btn:hover {
  background: rgba(255, 215, 0, 0.2);
}

.web-chat-collapse-icon {
  transition: transform 0.25s ease;
  font-size: 12px;
}

.web-chat-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.web-chat-status-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 11px;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #9ca3af;
  min-height: 28px;
}

.web-chat-status-text {
  flex: 0 0 auto;
}

.web-chat-status-error {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #f87171;
}

.web-chat-status-copy {
  flex-shrink: 0;
  padding: 2px 8px;
  font-size: 11px;
  border: 1px solid rgba(255, 215, 0, 0.4);
  background: rgba(255, 215, 0, 0.15);
  color: #FFD700;
  border-radius: 4px;
  cursor: pointer;
}

.web-chat-status-copy:hover {
  background: rgba(255, 215, 0, 0.25);
}

.web-chat-messages {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
}

.web-chat-messages-placeholder {
  color: #9ca3af;
  font-size: 13px;
  text-align: center;
  padding: 24px 12px;
}

.web-chat-msg {
  display: flex;
  gap: 8px;
  max-width: 100%;
  cursor: pointer;
}

.web-chat-msg.me {
  flex-direction: row-reverse;
}

.web-chat-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.35) 0%, rgba(212, 165, 116, 0.35) 100%);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFD700;
  font-size: 12px;
}

.web-chat-msg-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.web-chat-msg-bubble {
  max-width: 75%;
  min-width: 0;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 4px 8px;
}

/* 用户名在气泡上方 */
.web-chat-msg-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 75%;
}

.web-chat-msg.me .web-chat-msg-inner {
  align-items: flex-end;
}

.web-chat-msg-name {
  font-size: 11px;
  color: #FFD700;
  margin-bottom: 2px;
}

.web-chat-msg.me .web-chat-msg-name {
  text-align: right;
}

.web-chat-msg.me .web-chat-msg-bubble {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.35) 0%, rgba(212, 165, 116, 0.35) 100%);
  border: 1px solid rgba(255, 215, 0, 0.5);
  color: #1a1a2e;
}

body.dark-mode .web-chat-msg.me .web-chat-msg-bubble {
  color: #fff;
}

.web-chat-msg:not(.me) .web-chat-msg-bubble {
  background: rgba(31, 41, 55, 0.8);
  border: 1px solid rgba(255, 215, 0, 0.25);
  color: #e5e7eb;
}

body.dark-mode .web-chat-msg:not(.me) .web-chat-msg-bubble {
  background: rgba(31, 41, 55, 0.9);
  color: #f3f4f6;
}

.web-chat-msg-content {
  flex: 1 1 auto;
  min-width: 0;
}

.web-chat-msg-content .web-chat-msg-emoji {
  font-size: 4em;
  line-height: 1;
  background: none;
  border: none;
  display: inline;
  vertical-align: middle;
  padding: 0;
  margin: 0 2px;
}

.web-chat-msg-bubble--emoji-only {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 4px 0;
}

.web-chat-msg-content img {
  max-width: 100%;
  max-height: 200px;
  border-radius: 8px;
  display: block;
  margin-top: 4px;
}

.web-chat-msg-time {
  font-size: 10px;
  color: #9ca3af;
  flex-shrink: 0;
  white-space: nowrap;
}

.web-chat-input-wrap {
  padding: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
}

.web-chat-toolbar {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
}

.web-chat-btn {
  background: rgba(255, 215, 0, 0.2);
  border: 1px solid rgba(255, 215, 0, 0.35);
  color: #FFD700;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.2s;
}

.web-chat-btn:hover {
  background: rgba(255, 215, 0, 0.35);
  color: #1a1a2e;
}

.web-chat-emoji-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 0;
  max-height: 100px;
  overflow-y: auto;
}

.web-chat-emoji-picker span {
  cursor: pointer;
  font-size: 20px;
  padding: 2px;
  line-height: 1;
}

.web-chat-emoji-picker span:hover {
  transform: scale(1.2);
}

.web-chat-reply-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  margin-bottom: 6px;
  background: rgba(255, 215, 0, 0.15);
  border: 1px solid rgba(255, 215, 0, 0.35);
  border-radius: 8px;
}

.web-chat-reply-label {
  flex: 1;
  font-size: 12px;
  color: #FFD700;
}

.web-chat-reply-cancel {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
}

.web-chat-reply-cancel:hover {
  color: #fff;
}

.web-chat-pending-images {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
  min-height: 0;
}

.web-chat-pending-img {
  position: relative;
  width: 48px;
  height: 48px;
}

.web-chat-pending-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.web-chat-pending-img .web-chat-remove-pending {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.9);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.web-chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.web-chat-input-row textarea {
  flex: 1;
  min-height: 36px;
  max-height: 80px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.3);
  color: #e5e7eb;
  font-size: 13px;
  resize: none;
  font-family: inherit;
}

.web-chat-input-row textarea::placeholder {
  color: #9ca3af;
}

.web-chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, #FFD700 0%, #D4A574 100%);
  color: #1a1a2e;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  transition: all 0.2s;
}

.web-chat-send-btn:hover {
  background: linear-gradient(135deg, #ffdf33 0%, #e0b078 100%);
  filter: brightness(1.05);
}

body.dark-mode .web-chat-send-btn {
  background: linear-gradient(135deg, #FFD700 0%, #D4A574 100%);
  color: #1a1a2e;
}

body.dark-mode .web-chat-send-btn:hover {
  background: linear-gradient(135deg, #ffdf33 0%, #e0b078 100%);
  filter: brightness(1.05);
}

/* 框选截图：遮罩层与选区 */
#webChatScreenshotOverlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0, 0, 0, 0.4);
  cursor: crosshair;
  user-select: none;
  display: none;
}

#webChatScreenshotOverlay.active {
  display: block;
}

#webChatScreenshotOverlay .web-screenshot-hint {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.7);
  color: #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  pointer-events: none;
  white-space: nowrap;
}

#webChatScreenshotOverlay .web-screenshot-cancel {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 24px;
  background: rgba(239, 68, 68, 0.8);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}

#webChatScreenshotOverlay .web-screenshot-cancel:hover {
  background: rgba(239, 68, 68, 1);
}

#webChatScreenshotSelection {
  position: fixed;
  border: 2px solid #FFD700;
  background: rgba(255, 215, 0, 0.08);
  pointer-events: none;
  box-sizing: border-box;
  display: none;
}

#webChatScreenshotSelection.visible {
  display: block;
}

.web-screenshot-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100000;
  padding: 12px 24px;
  background: rgba(0, 0, 0, 0.85);
  color: #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  pointer-events: none;
  display: none;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

/* 聊天图片双击放大：支持缩放与拖拽 */
.web-chat-image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100001;
  background: rgba(0, 0, 0, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: default;
  overflow: hidden;
}

.web-chat-image-lightbox.active {
  display: flex;
}

.web-chat-image-lightbox-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
  transition: transform 0.1s ease-out;
  cursor: grab;
  max-width: 100%;
  max-height: 100%;
}

.web-chat-image-lightbox-wrap:active {
  cursor: grabbing;
}

.web-chat-image-lightbox-img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.web-chat-image-lightbox-close,
.web-chat-image-lightbox-zoom-in,
.web-chat-image-lightbox-zoom-out {
  position: absolute;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #e5e7eb;
  cursor: pointer;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  z-index: 2;
}

.web-chat-image-lightbox-close:hover,
.web-chat-image-lightbox-zoom-in:hover,
.web-chat-image-lightbox-zoom-out:hover {
  background: rgba(255, 215, 0, 0.3);
  color: #FFD700;
}

.web-chat-image-lightbox-close {
  top: 16px;
  right: 24px;
  font-size: 28px;
}

.web-chat-image-lightbox-zoom-in {
  bottom: 24px;
  right: 80px;
}

.web-chat-image-lightbox-zoom-out {
  bottom: 24px;
  right: 32px;
}

@media (max-width: 900px) {
  .web-chat-panel {
    width: 300px;
  }
  .web-chat-panel.collapsed {
    width: 44px;
    min-width: 44px;
  }
}
