/* 组件样式 */

/* 消息组件 - 微信标准样式 */
.message {
  display: flex;
  flex-direction: column;
  max-width: 70%;
  animation: messageSlideIn 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
  margin-bottom: 0.75rem;
  padding: 0 0.5rem;
}

.message.own {
  align-self: flex-end;
  align-items: flex-end;
}

.message.other {
  align-self: flex-start;
  align-items: flex-start;
}

/* 简洁美观的消息气泡箭头 */
.message.own .message-content::before {
  content: "";
  position: absolute;
  right: -5px;
  bottom: 10px;
  width: 0;
  height: 0;
  border-left: 5px solid #95ec69;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  z-index: 1;
}

.message.other .message-content::before {
  content: "";
  position: absolute;
  left: -5px;
  bottom: 10px;
  width: 0;
  height: 0;
  border-right: 5px solid #ffffff;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  z-index: 1;
}

.message-content {
  background-color: #ffffff;
  padding: 0.625rem 0.875rem;
  border-radius: 0.5rem;
  margin-bottom: 0.375rem;
  word-wrap: break-word;
  line-height: 1.5;
  font-size: 1rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  transition: none;
  position: relative;
  border: 1px solid #e5e5e5;
}

/* 接收消息的圆角调整 */
.message.other .message-content {
  border-radius: 0.5rem 0.5rem 0.5rem 0.5rem;
}

/* 普通文本消息保持紧凑 - 高优先级 */
.message-content .text-message:not(.markdown-rendered) {
  padding: 0 !important;
  margin: 0 !important;
  font-weight: 400;
  letter-spacing: 0.01em;
}

/* Markdown消息可以有额外的内边距 - 高优先级 */
.message-content .text-message.markdown-rendered {
  padding: 0.375rem 28px 0.375rem 0 !important; /* 右边留出按钮空间 */
  font-weight: 400;
  letter-spacing: 0.01em;
}

/* 自己发送的消息 - 微信绿色气泡 */
.message.own .message-content {
  background: #95ec69;
  color: #000000;
  border: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  border-radius: 0.5rem 0.5rem 0.5rem 0.5rem;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  color: #999999;
  margin-bottom: 0.25rem;
  font-weight: 400;
  justify-content: flex-end;
  /* 允许消息元信息被选择 */
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

/* iOS 12 Safari Flexbox Gap 兼容性修复 */
@supports not (gap: 0.375rem) {
  .message.own .message-meta > *:not(:last-child) {
    margin-right: 0.375rem;
  }
  .message.other .message-meta > *:not(:last-child) {
    margin-right: 0.375rem;
  }
}

.message.other .message-meta {
  justify-content: flex-start;
}

.message-time {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: 0.75rem;
  font-weight: 400;
  color: #999999;
  /* 允许时间文本被选择 */
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

.message.own .message-time {
  background: transparent;
  color: #999999;
}

.message-status {
  font-size: 0.8rem;
  opacity: 0.8;
}

.status-sending {
  color: #fbbf24;
}

.status-sent {
  color: #10b981;
}

.status-failed {
  color: #ef4444;
}

/* 文本消息 */
.text-message {
  /* white-space: pre-wrap;  // 已去除，防止首行空白 */
  position: relative;
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
  cursor: text;
  word-break: break-all;
  overflow-wrap: break-word;
}

/* Markdown渲染样式 */
.text-message.markdown-rendered {
  white-space: normal;
  /* 确保Markdown渲染的内容也可以被选择 */
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
  cursor: text;
  word-break: break-all;
  overflow-wrap: break-word;
}

.text-message.markdown-rendered h1,
.text-message.markdown-rendered h2,
.text-message.markdown-rendered h3,
.text-message.markdown-rendered h4,
.text-message.markdown-rendered h5,
.text-message.markdown-rendered h6 {
  margin: 0.3em 0 0.2em 0;
  font-weight: bold;
  line-height: 1.3;
}

.text-message.markdown-rendered h1 {
  font-size: 1.4em;
}
.text-message.markdown-rendered h2 {
  font-size: 1.2em;
}
.text-message.markdown-rendered h3 {
  font-size: 1.1em;
}
.text-message.markdown-rendered h4,
.text-message.markdown-rendered h5,
.text-message.markdown-rendered h6 {
  font-size: 1em;
}

.text-message.markdown-rendered p {
  margin: 0.2em 0;
  line-height: 1.5;
}

/* 第一个和最后一个元素的边距优化 */
.text-message.markdown-rendered > *:first-child {
  margin-top: 0;
}

.text-message.markdown-rendered > *:last-child {
  margin-bottom: 0;
}

.text-message.markdown-rendered ul,
.text-message.markdown-rendered ol {
  margin: 0.3em 0;
  padding-left: 1.2em;
}

.text-message.markdown-rendered li {
  margin: 0.1em 0;
}

.text-message.markdown-rendered blockquote {
  margin: 0.3em 0;
  padding: 0.4em 0.6em;
  border-left: 3px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.message.other .text-message.markdown-rendered blockquote {
  border-left-color: rgba(0, 0, 0, 0.2);
  background: rgba(0, 0, 0, 0.05);
}

.text-message.markdown-rendered code {
  background: rgba(255, 255, 255, 0.2);
  padding: 0.1em 0.3em;
  border-radius: 3px;
  font-family: "Consolas", "Monaco", "Courier New", monospace;
  font-size: 0.9em;
}

.message.other .text-message.markdown-rendered code {
  background: rgba(0, 0, 0, 0.1);
}

.text-message.markdown-rendered pre {
  background: rgba(255, 255, 255, 0.15);
  padding: 0.6em;
  border-radius: 6px;
  overflow-x: auto;
  margin: 0.3em 0;
}

.message.other .text-message.markdown-rendered pre {
  background: rgba(0, 0, 0, 0.08);
}

.text-message.markdown-rendered pre code {
  background: none;
  padding: 0;
}

.text-message.markdown-rendered strong {
  font-weight: bold;
}

.text-message.markdown-rendered em {
  font-style: italic;
}

.text-message.markdown-rendered a {
  color: inherit;
  text-decoration: underline;
  opacity: 0.9;
}

.text-message.markdown-rendered hr {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.3);
  margin: 0.5em 0;
}

.message.other .text-message.markdown-rendered hr {
  border-top-color: rgba(0, 0, 0, 0.2);
}

/* Markdown切换按钮 */
.markdown-toggle {
  position: absolute;
  bottom: -5px;
  right: -7px;
  width: 18px;
  height: 18px;
  background: rgba(255, 255, 255, 0.8);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  transition: all 0.2s ease;
  opacity: 0.6;
  z-index: 1;
  /* 确保按钮不影响文本布局和选择 */
  pointer-events: auto;
  /* 按钮本身不可选择 */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.markdown-toggle:hover {
  opacity: 1;
  transform: scale(1.1);
  background: rgba(255, 255, 255, 0.95);
}

.message.own .markdown-toggle {
  background: rgba(255, 255, 255, 0.3);
}

.message.own .markdown-toggle:hover {
  background: rgba(255, 255, 255, 0.5);
}

/* 文件消息 */
.file-message {
  min-width: 220px;
  /* 允许文件名等文本被选择 */
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}

/* iOS 12 Safari Flexbox Gap 兼容性修复 */
@supports not (gap: 12px) {
  .file-info > *:not(:last-child) {
    margin-right: 12px;
  }
}

.file-icon {
  font-size: 2.25rem;
  flex-shrink: 0;
  /* 移除渐变背景，让emoji图标显示原始颜色 */
  color: inherit;
  /* 保留阴影效果但调整颜色 */
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.08));
  /* 确保emoji图标正常显示 */
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji",
    sans-serif;
  line-height: 1;
}

.file-details {
  flex: 1;
  min-width: 0;
  /* 允许文件详情文本被选择 */
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

.file-name {
  font-weight: 500;
  margin-bottom: 0.375rem;
  word-break: break-all;
  font-size: 0.95rem;
  line-height: 1.4;
  /* 允许文件名被选择 */
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
  cursor: text;
}

.file-size {
  font-size: 0.85rem;
  opacity: 0.75;
  font-weight: 400;
  /* 允许文件大小被选择 */
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
  cursor: text;
}

.download-btn {
  background: #07c160;
  color: white;
  border: none;
  padding: 0.5rem 0.875rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 400;
  transition: background 0.2s ease;
  flex-shrink: 0;
  box-shadow: none;
  position: relative;
  overflow: hidden;
}

.download-btn:hover {
  background: #06ad56;
}

.message.own .download-btn {
  background: rgba(0, 0, 0, 0.1);
  color: #000000;
}

.message.own .download-btn:hover {
  background: rgba(0, 0, 0, 0.15);
}

/* 图片预览 */
.image-preview {
  margin-top: 0.5rem;
  border-radius: 12px;
  overflow: hidden;
  background: #f8f9fa;
  border: 1px solid rgba(0, 0, 0, 0.08);
  max-width: 300px;
  position: relative;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-preview img {
  width: 100%;
  height: auto;
  display: block;
  max-height: 200px;
  object-fit: cover;
  transition: transform 0.2s ease;
  border-radius: 8px;
}

.image-preview img:hover {
  transform: scale(1.02);
  cursor: pointer;
}

/* 图片加载状态 */
.image-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: #666;
  font-size: 14px;
}

.image-loading .loading-spinner {
  font-size: 20px;
  margin-bottom: 8px;
  animation: spin 1s linear infinite;
}

/* 图片加载错误状态 */
.image-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: #999;
  font-size: 14px;
}

.image-error .retry-btn {
  margin-top: 8px;
  background: #07c160;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.2s ease;
}

.image-error .retry-btn:hover {
  background: #06a552;
}

/* 顶部加载指示器 - 无限滚动 */
.top-loading-indicator {
  display: none;
  justify-content: center;
  align-items: center;
  padding: 0.75rem 0;
  margin-bottom: 0.5rem;
  background: linear-gradient(
    135deg,
    rgba(7, 193, 96, 0.05) 0%,
    rgba(26, 173, 25, 0.05) 100%
  );
  border-radius: 12px;
  border: 1px solid rgba(7, 193, 96, 0.1);
  backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.top-loading-indicator.fade-in {
  opacity: 1;
}

.top-loading-content {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #07c160;
  font-size: 0.85rem;
  font-weight: 500;
}

.top-loading-spinner {
  animation: spin 1s linear infinite;
  font-size: 1rem;
}

.top-loading-text {
  letter-spacing: 0.01em;
}

/* 文件上传组件 - 简化版 */

.upload-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #07c160;
  font-weight: 500;
  background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
  border-radius: 12px;
  border: 1px solid rgba(7, 193, 96, 0.2);
}

.upload-spinner {
  font-size: 1.5rem;
}

.upload-progress {
  margin-top: 8px;
  margin-bottom: 8px;
  display: none;
}

.upload-progress.show {
  display: block;
}

.upload-progress-bar {
  width: 100%;
  height: 6px;
  background-color: rgba(7, 193, 96, 0.2);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
  margin-bottom: 4px;
}

.upload-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #07c160, #00d4aa);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
  position: relative;
}

.upload-progress-fill::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 1.5s infinite;
}

.upload-progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.upload-progress-text {
  font-size: 0.75rem;
  color: #666;
  font-weight: 400;
}

.upload-progress-speed {
  font-size: 0.7rem;
  color: #999;
  font-weight: 400;
}

.progress-bar::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 1.5s infinite;
}

/* 消息输入组件 - 微信移动端风格 */
.message-input {
  width: 100%;
  display: flex;
  align-items: center;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  width: 100%;
}

/* iOS 12 Safari Flexbox Gap 兼容性修复 */
@supports not (gap: 12px) {
  .input-wrapper > *:not(:last-child) {
    margin-right: 12px;
  }
}

.input-field-container {
  flex-grow: 1;
  display: flex;
  align-items: center;
  background: #ffffff;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  padding: 0;
  position: relative;
  min-height: 40px;
  box-shadow: none;
  transition: border-color 0.2s ease;
}

/* 文件上传按钮 - 微信移动端风格 */
.file-button {
  background: #ffffff;
  border: 1px solid #d9d9d9;
  color: #666666;
  padding: 0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s ease;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  touch-action: manipulation;
  box-shadow: none;
}

.file-button:hover:not(:disabled) {
  background: #f5f5f5;
  border-color: #bfbfbf;
}

.file-button:active:not(:disabled) {
  background: #e6e6e6;
  border-color: #999999;
}

.input-field-container textarea {
  flex: 1;
  border: none;
  padding: 10px 12px;
  font-size: 16px;
  resize: none;
  min-height: 18px;
  max-height: 80px;
  background: transparent;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.4;
  outline: none;
  font-weight: 400;
}

.input-field-container textarea::placeholder {
  color: #999999;
  font-style: normal;
}

.input-field-container:focus-within {
  border-color: #07c160;
  box-shadow: none;
}

.send-button {
  background: #07c160;
  color: white;
  border: none;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 4px;
  touch-action: manipulation;
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%) scale(0);
  opacity: 0;
  box-shadow: none;
}

/* 发送按钮显示状态 */
.send-button.show {
  transform: translateY(-50%) scale(1);
  opacity: 1;
}

.send-button:hover:not(:disabled) {
  background: #06ad56;
  box-shadow: none;
}

.send-button:active:not(:disabled) {
  background: #059748;
  transform: translateY(-50%) scale(0.95);
}

.send-button:disabled {
  background: #cccccc;
  cursor: not-allowed;
}

/* 发送图标样式 */
.send-icon {
  width: 16px;
  height: 16px;
  color: white;
}

/* 发送按钮加载状态 */
.send-button.loading {
  background: #cccccc;
  cursor: not-allowed;
}

.send-button.loading .send-icon {
  animation: spin 1s linear infinite;
}

/* 功能按钮 - 微信风格 (更新版本) */
.function-button {
  background: #07c160;
  color: white;
  border: none;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 4px;
  touch-action: manipulation;
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%) scale(1);
  opacity: 1;
  box-shadow: 0 2px 8px rgba(7, 193, 96, 0.2);
  font-size: 16px;
  z-index: 10;
  pointer-events: auto;
}

/* 功能按钮显示状态 */
.function-button.show {
  transform: translateY(-50%) scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* 功能按钮隐藏状态 */
.function-button.hide {
  transform: translateY(-50%) scale(0);
  opacity: 0;
  pointer-events: none;
}

.function-button:hover:not(:disabled) {
  background: #06ad56;
  transform: translateY(-50%) scale(1.05);
  box-shadow: 0 4px 12px rgba(7, 193, 96, 0.3);
}

.function-button:hover .function-icon {
  transform: rotate(90deg);
}

.function-button:active:not(:disabled) {
  background: #059748;
  transform: translateY(-50%) scale(0.95);
}

/* 功能按钮图标 */
.function-icon {
  width: 16px;
  height: 16px;
  color: white;
  transition: transform 0.2s ease;
}

/* 功能菜单弹窗 */
.function-menu {
  position: fixed;
  bottom: 80px;
  right: 20px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  padding: 8px;
  z-index: 1000;
  transform: scale(0) translateY(20px);
  opacity: 0;
  transition: all 0.2s ease;
  transform-origin: bottom right;
  min-width: 200px;
}

/* 功能菜单显示状态 */
.function-menu.show {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* 功能菜单项 */
.function-menu-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  gap: 12px;
  font-size: 14px;
  color: #333;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.function-menu-item:hover {
  background-color: #f5f5f5;
}

.function-menu-item:active {
  background-color: #e6e6e6;
}

/* 功能菜单项图标 */
.function-menu-item-icon {
  font-size: 18px;
  width: 20px;
  text-align: center;
}

/* 功能菜单项文本 */
.function-menu-item-text {
  flex: 1;
  font-weight: 400;
}

/* 功能菜单遮罩 */
.function-menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 999;
  background: transparent;
  display: none;
}

.function-menu-overlay.show {
  display: block;
}

/* PWA相关样式 */

/* PWA安装按钮（已禁用） */

/* PWA安装横幅 */
.pwa-install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid #e0e0e0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
  z-index: 1001;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.pwa-install-banner.show {
  transform: translateY(0);
}

.pwa-install-banner.hide {
  transform: translateY(100%);
}

.install-content {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  gap: 16px;
}

.install-icon {
  font-size: 32px;
  flex-shrink: 0;
}

.install-text {
  flex: 1;
}

.install-text h3 {
  margin: 0 0 4px 0;
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.install-text p {
  margin: 0;
  font-size: 14px;
  color: #666;
}

.install-actions {
  display: flex;
  gap: 1rem;
}

/* iOS 12 Safari Flexbox Gap 兼容性修复 */
@supports not (gap: 1rem) {
  .install-actions > *:not(:last-child) {
    margin-right: 1rem;
  }
}

.install-yes,
.install-no {
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.install-yes {
  background: #07c160;
  color: white;
  border: none;
}

.install-yes:hover {
  background: #06a552;
}

.install-no {
  background: transparent;
  color: #666;
  border: 1px solid #d0d0d0;
}

.install-no:hover {
  background: #f5f5f5;
}

/* PWA更新横幅 */
.pwa-update-banner {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #07c160;
  color: white;
  padding: 12px 20px;
  border-radius: 25px;
  box-shadow: 0 4px 20px rgba(7, 193, 96, 0.3);
  z-index: 1002;
  animation: slideDown 0.3s ease;
}

.update-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.update-btn,
.close-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 15px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
}

.update-btn:hover,
.close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.close-btn {
  padding: 4px 8px;
  font-size: 14px;
  font-weight: bold;
}

/* 连接状态指示器 */
.connection-status {
  position: fixed;
  top: 10px;
  right: 10px;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  z-index: 999;
  transition: all 0.3s ease;
}

.connection-status:empty {
  padding: 0;
  border: none;
  background: transparent;
}

.connection-status.online {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.connection-status.connecting {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.connection-status.offline {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.connection-status.reconnecting {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

/* PWA动画效果 */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@media (max-width: 600px) {
  .connection-status {
    top: 10px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: auto;
    min-width: unset;
    max-width: 80vw;
    border-radius: 12px;
    text-align: center;
    font-size: 13px;
    padding: 6px 16px;
    z-index: 1001;
    margin: 0;
    box-sizing: border-box;
  }
}

.file-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* iOS 12 Safari Flexbox Gap 兼容性修复 */
@supports not (gap: 8px) {
  .file-actions > *:not(:last-child) {
    margin-right: 8px;
  }
}

.message-btns-top-right {
  position: absolute;
  top: 2px;
  right: 2px;
  z-index: 2;
  display: flex;
  gap: 4px;
}

.copy-btn {
  top: 2px;
  right: 2px;
  position: absolute;
  background: rgba(255, 255, 255, 0.8);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  opacity: 0.6;
  transition: all 0.2s;
  pointer-events: auto;
  user-select: none;
  z-index: 2;
  padding: 0;
}
.copy-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.95);
}
.message.own .copy-btn {
  background: rgba(255, 255, 255, 0.3);
}
.message.own .copy-btn:hover {
  background: rgba(255, 255, 255, 0.5);
}

.global-notification {
  position: fixed;
  top: 40px;
  left: 50%;
  transform: translateX(-50%) scale(0.95);
  min-width: 120px;
  max-width: 80vw;
  background: #333;
  color: #fff;
  padding: 12px 32px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  opacity: 0;
  z-index: 9999;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  text-align: center;
}
.global-notification.show {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}
.global-notification-success {
  background: #07c160;
  color: #fff;
}
.global-notification-error {
  background: #ff4d4f;
  color: #fff;
}
.global-notification-info {
  background: #333;
  color: #fff;
}

/* 滑动确认弹窗样式 */
.slide-confirm-overlay {
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
}
.slide-confirm-modal {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 32px rgba(0, 0, 0, 0.12);
  padding: 28px 20px 20px 20px;
  min-width: 320px;
  max-width: 90vw;
  width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: modalFadeScale 0.22s cubic-bezier(0.4, 1.4, 0.6, 1) both;
}
.slide-confirm-title {
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 10px;
  color: #222;
}
.slide-confirm-message {
  font-size: 15px;
  color: #666;
  margin-bottom: 22px;
  text-align: center;
}
.slide-confirm-slider {
  position: relative;
  width: 90%;
  max-width: 320px;
  height: 48px;
  background: #f3f4f6;
  border-radius: 24px;
  margin-bottom: 18px;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}
.slide-confirm-track {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background: #e5e7eb;
  border-radius: 24px;
}
.slide-confirm-thumb {
  position: relative;
  z-index: 2;
  width: 44px;
  height: 44px;
  background: linear-gradient(90deg, #10b981 60%, #34d399 100%);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.08);
  color: #fff;
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: box-shadow 0.2s, background 0.2s;
  left: 2px;
  top: 2px;
  user-select: none;
  /* 无箭头，纯圆形 */
}
.slide-confirm-thumb.dragging {
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.18);
  background: linear-gradient(90deg, #059669 60%, #10b981 100%);
}
.slide-confirm-label {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  color: #10b981;
  font-size: 16px;
  font-weight: 500;
  pointer-events: none;
  justify-content: center;
  text-align: center;
}
.slide-confirm-cancel {
  margin-top: 6px;
  background: none;
  border: none;
  color: #888;
  font-size: 15px;
  cursor: pointer;
  padding: 6px 0;
  border-radius: 8px;
  transition: background 0.2s;
}
.slide-confirm-cancel:hover {
  background: #f3f4f6;
}
@media (max-width: 600px) {
  .slide-confirm-modal {
    min-width: 90vw;
    width: 98vw;
    padding: 18px 4vw 16px 4vw;
  }
  .slide-confirm-slider {
    max-width: 98vw;
    height: 44px;
  }
  .slide-confirm-title {
    font-size: 18px;
  }
  .slide-confirm-message {
    font-size: 14px;
  }
  .slide-confirm-label {
    font-size: 15px;
  }
}

/* 淡入缩放动画 */
@keyframes modalFadeScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* 删除按钮样式 */
.delete-btn {
  position: absolute;
  background: rgba(255, 255, 255, 0.8);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  opacity: 0.6;
  transition: all 0.2s;
  pointer-events: auto;
  user-select: none;
  z-index: 2;
  padding: 0;
  width: 18px;
  height: 18px;
}

.delete-btn:hover {
  opacity: 1;
  background: rgba(255, 0, 0, 0.1);
  transform: scale(1.1);
}

.message.own .delete-btn {
  background: rgba(255, 255, 255, 0.3);
}

.message.own .delete-btn:hover {
  background: rgba(255, 0, 0, 0.2);
}

/* 文本消息删除按钮 - 左下角 */
.delete-btn {
  bottom: -1px;
  left: -1px;
}

/* 文件操作按钮容器 */
.file-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  justify-content: flex-start;
}

/* 下载进度条样式 */
.download-progress {
  margin-top: 8px;
  margin-bottom: 8px;
  display: none;
}

.download-progress.show {
  display: block;
}

.download-progress-bar {
  width: 100%;
  height: 6px;
  background-color: rgba(7, 193, 96, 0.2);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
  margin-bottom: 4px;
}

.download-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #07c160, #00d4aa);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
  position: relative;
}

.download-progress-fill::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 1.5s infinite;
}

.download-progress-text {
  font-size: 0.75rem;
  color: #666;
  text-align: center;
  font-weight: 400;
}

.download-progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.download-progress-speed {
  font-size: 0.7rem;
  color: #999;
  font-weight: 400;
}

/* 图片下载进度条样式 */
.image-download-progress {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 4px;
  padding: 6px 8px;
  display: none;
  z-index: 10;
}

.image-download-progress.show {
  display: block;
}

.image-download-progress-bar {
  width: 100%;
  height: 4px;
  background-color: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
  margin-bottom: 4px;
}

.image-download-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ffffff, #e0e0e0);
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease;
  position: relative;
}

.image-download-progress-fill::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.5),
    transparent
  );
  animation: shimmer 1.5s infinite;
}

.image-download-progress-text {
  font-size: 0.7rem;
  color: #ffffff;
  text-align: center;
  font-weight: 400;
}

.image-download-progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}

.image-download-progress-speed {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 400;
}

/* 文件消息按钮样式 */
.file-actions .download-btn,
.file-actions .delete-btn {
  position: static;
  background: #07c160;
  color: white;
  border: none;
  padding: 0.5rem 0.875rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 400;
  transition: background 0.2s ease;
  flex-shrink: 0;
  width: auto;
  height: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  overflow: hidden;
}

.file-actions .download-btn:hover {
  background: #06ad56;
}

.file-actions .delete-btn {
  background: #ff4444;
}

.file-actions .delete-btn:hover {
  background: #e63939;
}

/* 表情选择器样式 */
.emoji-picker-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.emoji-picker-modal {
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  max-width: 400px;
  width: 100%;
  max-height: 80vh;
  overflow: hidden;
}

.emoji-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e0e0e0;
}

.emoji-picker-title {
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.emoji-picker-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #666;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s ease;
}

.emoji-picker-close:hover {
  background-color: #f0f0f0;
}

.emoji-picker-content {
  padding: 20px;
  max-height: 60vh;
  overflow-y: auto;
}

.emoji-category-title {
  font-size: 14px;
  font-weight: 500;
  color: #666;
  margin-bottom: 12px;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
}

.emoji-item {
  background: none;
  border: none;
  font-size: 24px;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
}

.emoji-item:hover {
  background-color: #f0f0f0;
  transform: scale(1.1);
}

.emoji-item:active {
  transform: scale(0.95);
}

.message.own .file-actions .download-btn {
  background: rgba(0, 0, 0, 0.1);
  color: #000000;
}

.message.own .file-actions .download-btn:hover {
  background: rgba(0, 0, 0, 0.15);
}

.message.own .file-actions .delete-btn {
  background: rgba(255, 68, 68, 0.8);
  color: #ffffff;
}

.message.own .file-actions .delete-btn:hover {
  background: rgba(255, 68, 68, 0.9);
}

/* 移动端文件按钮优化 */
@media (max-width: 600px) {
  .file-actions {
    gap: 6px;
    margin-top: 6px;
  }

  .file-actions .download-btn,
  .file-actions .delete-btn {
    padding: 0.4rem 0.7rem;
    font-size: 0.8rem;
    min-width: 60px;
  }

  /* 移动端上传进度条优化 */
  .upload-progress {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin-top: 6px;
    margin-bottom: 6px;
  }

  .upload-progress.show {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  .upload-progress-bar {
    height: 8px;
    margin-bottom: 6px;
  }

  .upload-progress-text {
    font-size: 0.8rem;
  }

  .upload-progress-speed {
    font-size: 0.75rem;
  }
}

/* PWA环境下的上传进度条强制显示 */
@media (display-mode: standalone) {
  .upload-progress {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  .upload-progress.show {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  /* PWA环境下进度条更明显 */
  .upload-progress-bar {
    height: 8px;
    background-color: rgba(7, 193, 96, 0.3);
  }

  .upload-progress-fill {
    background: linear-gradient(90deg, #07c160, #00d4aa);
    box-shadow: 0 0 4px rgba(7, 193, 96, 0.3);
  }
}
