<template>
  <div class="chat-container">
    <ChatHeader />
    <div class="chat-messages" ref="chatContainer">
      <!-- 聊天背景按钮 -->
      <div v-if="chatStore.chatModes[chatStore.currentMode]?.chatBackground" class="chat-background">
        <div class="background-toggle" @click="toggleBackground">
          <span class="background-btn">聊天背景</span>
        </div>
        <div v-if="showBackground" class="background-section">
          <div class="background-content">
            <div class="background-text"
              v-html="formatMarkdown(chatStore.chatModes[chatStore.currentMode].chatBackground)"></div>
          </div>
        </div>
      </div>
      <!-- 历史缓存 -->
      <div v-for="(message, index) in currentMessages" :key="message.messageId" class="message-group">
        <!-- 用户消息 -->
        <div class="message">
          <div class="message-wrapper user">
            <el-avatar :src="userAvatarUrl" :size="40" class="avatar" />
            <div class="message-content">
              <div class="message-text-wrapper">
                <div v-if="message.createdAt" class="message-timestamp">
                  {{ formatTimestamp(message.createdAt) }}
                </div>
                <div class="message-text">{{ message.question }}</div>
              </div>
              <div class="message-actions">
                <!-- 改进建议 -->
                <EvaluationButton :show-evaluation="message.showEvaluation" :responding-type="message.respondingType"
                  @toggle="chatStore.toggleEvaluation(message.messageId)" />
              </div>
              <!-- 评价总结内容 -->
              <div v-if="message.showEvaluation && (message.pingfen || message.zongjie)" class="evaluation-section">
                <el-button class="evaluation-close-btn" type="info" size="small" circle :icon="Close"
                  @click="chatStore.toggleEvaluation(message.messageId)" />
                <div class="evaluation-content">
                  <div class="evaluation-text pingfen" v-html="formatMarkdown(message.pingfen, 'pingfen')"></div>
                  <div class="evaluation-text zongjie" v-html="formatMarkdown(message.zongjie, 'zongjie')"></div>
                  <div v-if="['pingfen', 'zongjie'].includes(message?.respondingType)" class="typing-indicator">
                    <span></span><span></span><span></span>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- 回答 -->
        <div class="message">
          <div class="message-wrapper assistant">
            <el-avatar :src="customAvatarUrl" :size="40" class="avatar" />
            <div class="message-content">
              <div class="message-text-wrapper">
                <div v-if="message.createdAt" class="message-timestamp">
                  {{ formatTimestamp(message.createdAt) }}
                </div>
                <div class="message-text">
                  <span v-html="message.kehu"></span>
                  <span v-if="message.respondingType === 'kehu'" class="typing-indicator">
                    <span></span><span></span><span></span>
                  </span>
                </div>
              </div>
              <div class="message-actions">
                <!-- 文字转语音 -->
                <TextToVoiceButton v-if="message.kehu && message.respondingType !== 'kehu'"
                  class="message-action-button" :text="message.kehu" />
              </div>
            </div>
          </div>
        </div>
      </div>
      <!-- 会话结束标签 -->
      <div v-if="chatStore.currentConversation?.conversationStatus === 'finished'" class="conversation-end">
        <el-tag size="large" type="info" class="end-tag">会话已结束</el-tag>
      </div>
    </div>
    <!-- Input Area Wrapper -->
    <div class="input-area-wrapper">
      <el-button class="mode-switch-btn" :icon="isVoiceInputMode ? ChatDotSquare : Microphone" circle
        @click="switchInputMode" :disabled="isInputDisabled" />
      <ChatInput v-if="!isVoiceInputMode" :is-disabled="isInputDisabled" @send="handleSendMessage" ref="chatInputRef" />
      <VoiceInput v-else :is-disabled="isInputDisabled" @sendText="handleVoiceSendText"
        @fillInput="handleVoiceFillInput" />
    </div>
    <!-- 总结弹窗 -->
    <div v-if="lastMessageWithDafen" class="summary-panel" :class="{ 'summary-panel-collapsed': isSummaryCollapsed }">
      <div class="summary-header" @click="toggleSummary">
        <span class="summary-title">会话总结</span>
        <span class="summary-toggle-icon">{{ isSummaryCollapsed ? '▼' : '▲' }}</span>
      </div>
      <div class="summary-content" v-html="formatMarkdown(lastMessageWithDafen.dafen)"></div>
    </div>
  </div>
</template>

<script setup>
import customAvatarUrl from '@/assets/custom.png'
import userAvatarUrl from '@/assets/user.png'
import { useChatStore } from '@/store/chat'
import ChatHeader from '@/views/chat/components/ChatHeader.vue'
import ChatInput from '@/views/chat/components/ChatInput.vue'
import EvaluationButton from '@/views/chat/components/EvaluationButton.vue'
import TextToVoiceButton from '@/views/chat/components/TextToVoiceButton.vue'
import VoiceInput from '@/views/chat/components/VoiceInput.vue'
import { ChatDotSquare, Close, Microphone } from '@element-plus/icons-vue'
import { ElAvatar, ElButton, ElTag } from 'element-plus'
import { marked } from 'marked'
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue'

defineOptions({
  name: 'ChatInterface'
})

const chatStore = useChatStore()
const messageInputRef = ref(null)
const chatInputRef = ref(null)
const chatContainer = ref(null)
const maxRows = 6
const isUserScrolling = ref(false)
const shouldAutoScroll = ref(true)
const lastScrollTop = ref(0)
const lastScrollHeight = ref(0)
const isSummaryCollapsed = ref(false)
const showBackground = ref(false)
const isVoiceInputMode = ref(false)

// 计算属性：获取当前会话消息
const currentMessages = computed(() => {
  return chatStore.currentMessages
})

// 计算属性：判断发送按钮是否禁用
const sendButtonsDisabled = computed(() => {
  if (!chatStore.currentConversation) return false
  const currentConversation = chatStore.currentConversation
  if (!currentConversation.conversationStatus) return false
  return ['finished', 'typing'].includes(currentConversation.conversationStatus)
})

// 计算属性：获取最后一条包含评分字段的消息
const lastMessageWithDafen = computed(() => {
  if (!chatStore.currentMessages.length) return null
  // 从后往前查找第一条包含评分字段的消息
  for (let i = chatStore.currentMessages.length - 1; i >= 0; i--) {
    if (chatStore.currentMessages[i].dafen) {
      return chatStore.currentMessages[i]
    }
  }
  return null
})

// 配置marked选项
marked.setOptions({
  breaks: true,
  gfm: true,
  sanitize: false,
  headerIds: false,
  mangle: false
})

// 检查是否接近底部
const isNearBottom = (threshold = 100) => {
  const container = chatContainer.value
  if (!container) return false
  return container.scrollHeight - container.scrollTop - container.clientHeight < threshold
}

// 处理滚动事件
const handleScroll = () => {
  const container = chatContainer.value
  if (!container) return

  // 检测用户是否主动滚动
  if (Math.abs(container.scrollTop - lastScrollTop.value) > 10) {
    isUserScrolling.value = true
    // 根据是否接近底部决定是否恢复自动滚动
    shouldAutoScroll.value = isNearBottom(50)
  }

  lastScrollTop.value = container.scrollTop
  lastScrollHeight.value = container.scrollHeight
}

// 滚动到底部
const scrollToBottom = (force = false) => {
  nextTick(() => {
    const container = chatContainer.value
    if (!container) return

    // 在以下情况滚动到底部：
    // 1. 强制滚动
    // 2. 允许自动滚动且没有用户滚动操作
    // 3. 用户已接近底部
    if (force || (shouldAutoScroll.value && !isUserScrolling.value) || isNearBottom(50)) {
      container.scrollTop = container.scrollHeight
      lastScrollTop.value = container.scrollTop
      lastScrollHeight.value = container.scrollHeight
      isUserScrolling.value = false
    }
  })
}

// 监听消息缓存变化
watch(() => chatStore.messageCache, (newCache, oldCache) => {
  if (!oldCache || Object.keys(newCache).length > Object.keys(oldCache).length) {
    scrollToBottom(shouldAutoScroll.value)
  }
}, { deep: true })

// 监听当前会话消息
watch(() => currentMessages.value, (newMessages, oldMessages) => {
  if (!oldMessages || newMessages.length > oldMessages.length) {
    scrollToBottom(shouldAutoScroll.value)
    return
  }

  // 检查最后一条消息的类型
  const lastMessage = newMessages[newMessages.length - 1]
  if (lastMessage && ['kehu', 'pingfen', 'zongjie'].includes(lastMessage.respondingType)) {
    scrollToBottom(true) // 特定类型消息强制滚动
  }
}, { deep: true })

// 监听消息类型变化
watch(() => currentMessages.value?.map(msg => msg.respondingType), (newTypes, oldTypes) => {
  if (!newTypes || !oldTypes) return
  const lastType = newTypes[newTypes.length - 1]
  if (['kehu', 'pingfen', 'zongjie'].includes(lastType)) {
    scrollToBottom(true) // 特定类型消息强制滚动
  }
}, { deep: true })

// 统一消息发送函数
const handleSendMessage = (message) => {
  if (!message || !message.trim() || isInputDisabled.value) return;
  console.log("ChatInterface sending message:", message);
  chatStore.sendMessage(message);
  shouldAutoScroll.value = true; // 发送消息时恢复自动滚动
  scrollToBottom(true);

  // 从语音输入切换回文本模式并聚焦
  if (isVoiceInputMode.value) {
    isVoiceInputMode.value = false;
    nextTick(() => {
      chatInputRef.value?.focus();
    });
  }
};

// 处理语音直接发送
function handleVoiceSendText(text) {
  if (!text || !text.trim() || isInputDisabled.value) return;
  chatStore.sendMessage(text);
  shouldAutoScroll.value = true;
  scrollToBottom(true);
}

// 处理语音转文字填入输入框
function handleVoiceFillInput(text) {
  if (!text || !text.trim()) return;
  isVoiceInputMode.value = false; // 切换到文本输入
  nextTick(() => {
    if (chatInputRef.value) {
      // 确保输入框存在并设置值
      chatInputRef.value.setValue?.(text) || (chatInputRef.value.value = text);
      // 聚焦输入框
      chatInputRef.value.focus?.();
      // 触发输入事件以确保值更新
      const input = chatInputRef.value.$el?.querySelector('textarea');
      if (input) {
        input.dispatchEvent(new Event('input', { bubbles: true }));
      }
    }
  });
}

// 格式化聊天内容
const formatMarkdown = (text, tagType) => {
  if (!text) return ''
  return marked.parse(text)
}

// 调整文本区域高度
const adjustTextareaHeight = () => {
  const textarea = messageInputRef.value
  textarea.style.height = 'auto'
  const newHeight = Math.min(textarea.scrollHeight, maxRows * 24)
  textarea.style.height = newHeight + 'px'
}

// 切换总结面板
const toggleSummary = () => {
  isSummaryCollapsed.value = !isSummaryCollapsed.value
}

// 格式化时间戳
const formatTimestamp = (timestamp) => {
  if (!timestamp) return ''

  // 检查时间戳是否为字符串，如果是则转换为数字
  const timestampNum = typeof timestamp === 'string' ? parseInt(timestamp) : timestamp

  // 检查时间戳是否为毫秒级，如果不是则转换为毫秒
  const date = new Date(timestampNum.toString().length === 10 ? timestampNum * 1000 : timestampNum)

  // 检查日期是否有效
  if (isNaN(date.getTime())) {
    console.error('Invalid timestamp:', timestamp)
    return ''
  }

  return date.toLocaleString('zh-CN', {
    year: 'numeric',
    month: '2-digit',
    day: '2-digit',
    hour: '2-digit',
    minute: '2-digit',
    second: '2-digit',
    hour12: false
  })
}

// 计算属性：判断输入框是否禁用
const isInputDisabled = computed(() => {
  // 没有会话时允许输入
  if (!chatStore.currentConversation) {
    return false
  }
  // 会话结束 或 正在回复/生成时禁用输入
  const status = chatStore.currentConversation.conversationStatus
  return status !== 'active'
})

// 切换背景显示
const toggleBackground = () => {
  showBackground.value = !showBackground.value
}

// 切换输入模式
const switchInputMode = () => {
  isVoiceInputMode.value = !isVoiceInputMode.value;
  // 切换回文本模式时聚焦输入框
  if (!isVoiceInputMode.value) {
    nextTick(() => {
      chatInputRef.value?.focus();
    });
  }
};

onMounted(() => {
  if (chatContainer.value) {
    chatContainer.value.addEventListener('scroll', handleScroll)
    // 初始化时滚动到底部
    scrollToBottom(true)
    shouldAutoScroll.value = true
  }
})

onUnmounted(() => {
  // 移除滚动事件监听
  if (chatContainer.value) {
    chatContainer.value.removeEventListener('scroll', handleScroll)
  }
})
</script>

<style lang="scss" scoped>
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  background-color: var(--el-bg-color-page);
  position: relative;
  overflow: hidden;
}

// Dark mode override for chat container
html.dark .chat-container {
  background-color: var(--el-color-primary-dark-1);
}

.chat-background {
  margin: 0 0 20px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.background-toggle {
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;

  .background-btn {
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 12px;
    background-color: var(--el-fill-color-light);
    border: 1px solid var(--el-border-color-lighter);
    color: var(--el-text-color-secondary);
    transition: all 0.3s ease;

    &:hover {
      background-color: var(--el-fill-color);
      color: var(--el-text-color-regular);
    }
  }
}

.background-section {
  margin-top: 12px;
  width: 90%;
  max-width: 800px;
  background: var(--el-bg-color);
  border-radius: 8px;
  box-shadow: var(--el-box-shadow-light);
  border: 1px solid var(--el-border-color-lighter);

  .background-content {
    padding: 16px 24px 16px 16px;
    background: var(--el-color-primary-light-9);
    max-height: 300px;
    overflow-y: auto;
    border-radius: 8px;

    &::-webkit-scrollbar {
      width: 8px;
      height: 8px;
      display: block;
    }

    &::-webkit-scrollbar-track {
      background: transparent;
      margin: 4px 0;
    }

    &::-webkit-scrollbar-thumb {
      background: var(--el-border-color-darker);
      border-radius: 4px;
      border: 2px solid transparent;
      background-clip: padding-box;

      &:hover {
        background: var(--el-border-color);
      }
    }

    .background-text {
      opacity: 0.9;
      color: var(--el-text-color-regular);
      line-height: 1.6;

      :deep(p) {
        margin: 0 0 12px 0;
        line-height: 1.6;

        &:last-child {
          margin-bottom: 0;
        }
      }

      :deep(ul),
      :deep(ol) {
        margin: 8px 0;
        padding-left: 20px;
      }

      :deep(strong) {
        color: var(--el-text-color-primary);
        font-weight: 600;
      }

      :deep(h1) {
        font-size: 20px;
        font-weight: 600;
        margin: 0 0 16px 0;
        color: var(--el-text-color-primary);
      }

      :deep(h2) {
        font-size: 18px;
        font-weight: 600;
        margin: 20px 0 12px 0;
        color: var(--el-text-color-primary);
      }

      :deep(h3) {
        font-size: 16px;
        font-weight: 600;
        margin: 16px 0 8px 0;
        color: var(--el-text-color-primary);
      }
    }
  }
}

// Dark mode override for background content
html.dark .background-section .background-content {
  background: var(--el-fill-color-light); // Use a neutral dark fill color
}

.chat-messages {
  flex: 1;
  overflow-y: scroll;
  padding: 20px;
  padding-bottom: 120px;
  padding-right: 24px;
  margin-right: -12px;
  position: relative;
  z-index: 1;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;

  &::-webkit-scrollbar {
    width: 8px;
  }

  &::-webkit-scrollbar-track {
    background: transparent;
    margin: 4px 0;
  }

  &::-webkit-scrollbar-thumb {
    background: var(--el-border-color-darker);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: padding-box;

    &:hover {
      background: var(--el-border-color);
    }
  }
}

.message-group {
  margin-bottom: 24px;
}

.message {
  margin-bottom: 16px;
  position: relative;

  .message-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 12px;

    &.user {
      flex-direction: row-reverse;
      justify-content: flex-start;

      .message-text {
        background-color: var(--el-color-primary);
        color: var(--el-color-white);
        border-color: transparent;
      }

      .message-content {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
      }

      .message-timestamp {
        right: 0;
      }
    }

    &.assistant {
      flex-direction: row;
      justify-content: flex-start;

      .message-text {
        background-color: var(--el-bg-color);
        color: var(--el-text-color-primary);
      }

      .message-content {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
      }
    }

    .avatar {
      width: 40px;
      height: 40px;
      flex-shrink: 0;
    }
  }
}

.message-content {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 70%;
  word-wrap: break-word;
  position: relative;

  .message-text-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;

    .message-text {
      // min-width: 60px;
      line-height: 1.5;
      font-size: 16px;
      padding: 8px 12px;
      border-radius: 6px;
      white-space: pre-wrap;
      position: relative;
      box-shadow: var(--el-box-shadow-light);
      border: 1px solid var(--el-border-color-lighter);
      display: inline-block;
      max-width: 100%;
      min-height: 24px;

      &::before {
        content: '';
        position: absolute;
        width: 0;
        height: 0;
        border: 6px solid transparent;
        top: 10px;
      }
    }
  }
}

.message-wrapper.user .message-text-wrapper {
  display: flex;
  align-items: center;
}

.evaluation-section {
  position: relative;
  margin-top: 12px;
  font-size: 14px;
  background: var(--el-bg-color);
  border-radius: 8px;
  overflow: visible;
  box-shadow: var(--el-box-shadow-light);
  max-width: 100%;
  border: 1px solid var(--el-border-color-lighter);

  .evaluation-content {
    padding: 16px 24px 16px 16px;
    background: var(--el-fill-color-light);
    overflow-y: scroll;
    position: relative;

    &::-webkit-scrollbar {
      width: 8px;
      height: 8px;
      display: block;
    }

    &::-webkit-scrollbar-track {
      background: transparent;
      margin: 4px 0;
    }

    &::-webkit-scrollbar-thumb {
      background: var(--el-border-color-darker);
      border-radius: 4px;
      border: 2px solid transparent;
      background-clip: padding-box;

      &:hover {
        background: var(--el-border-color);
      }
    }

    .evaluation-text {
      opacity: 0.9;
      color: var(--el-text-color-regular);
      border: none;
      box-shadow: none;
      padding: 0;
      margin-bottom: 12px;
      min-height: unset;
      line-height: 1.6;

      &:last-child {
        margin-bottom: 0;
      }

      :deep(p) {
        margin: 0;
        line-height: 1.6;
      }

      :deep(ul),
      :deep(ol) {
        margin: 8px 0;
        padding-left: 20px;
      }

      :deep(strong) {
        color: var(--el-text-color-primary);
        font-weight: 600;
      }

      :deep(em) {
        color: var(--el-text-color-secondary);
        font-style: italic;
      }
    }
  }
}

.evaluation-close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  font-size: 14px;
  background: transparent;
  border: none;
  color: var(--el-text-color-primary);
  transition: color 0.2s;
}

.evaluation-close-btn:hover {
  color: var(--el-color-primary);
}

.input-area-wrapper {
  display: flex;
  align-items: flex-end;

  &> :deep(.chat-input-area),
  &> :deep(div > .voice-trigger-btn) {
    flex: 1;
    min-width: 0;
  }

  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--el-border-color-light);
  background-color: var(--el-bg-color);
  position: relative;
  z-index: 1;
}

.mode-switch-btn {
  width: 40px;
  height: 40px;
  font-size: 20px;
  flex-shrink: 0; // Prevent shrinking
}

.summary-panel {
  position: absolute;
  bottom: 80px;
  left: 20px;
  right: 20px;
  background: var(--el-bg-color);
  border-radius: 8px;
  box-shadow: var(--el-box-shadow-light);
  transition: all 0.3s ease;
  z-index: 2;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 300px;

  &.summary-panel-collapsed {
    max-height: 42px;

    .summary-content {
      opacity: 0;
      transform: translateY(-20px);
      visibility: hidden;
    }

    .summary-header {
      border-bottom: none;
    }
  }

  .summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: var(--el-fill-color-light);
    cursor: pointer;
    border-bottom: 1px solid var(--el-border-color-light);
    transition: all 0.3s ease;
    flex-shrink: 0;
    height: 24px;

    .summary-title {
      font-weight: 600;
      color: var(--el-text-color-primary);
      font-size: 15px;
    }

    .summary-toggle-icon {
      color: var(--el-text-color-secondary);
      font-size: 14px;
      transition: transform 0.3s ease;
    }
  }

  .summary-content {
    flex: 1;
    min-height: 0;
    max-height: 250px;
    overflow-y: auto;
    padding: 16px;
    background: var(--el-bg-color);
    color: var(--el-text-color-regular);
    line-height: 1.6;
    font-size: 14px;
    transition: all 0.3s ease;
    opacity: 1;
    transform: translateY(0);
    visibility: visible;

    :deep(p) {
      margin: 0 0 12px 0;

      &:last-child {
        margin-bottom: 0;
      }
    }

    :deep(ul),
    :deep(ol) {
      margin: 8px 0;
      padding-left: 20px;

      &:last-child {
        margin-bottom: 0;
      }
    }

    :deep(strong) {
      color: var(--el-text-color-primary);
      font-weight: 600;
    }

    :deep(em) {
      color: var(--el-text-color-secondary);
      font-style: italic;
    }

    :deep(code) {
      background: var(--el-fill-color-light);
      padding: 2px 4px;
      border-radius: 4px;
      color: var(--el-color-primary);
      font-family: 'Courier New', Courier, monospace;
    }
  }
}

.message-timestamp {
  font-size: 12px;
  color: var(--el-text-color-secondary);
  position: absolute;
  top: -20px;
  opacity: 0;
  transition: opacity 0.2s ease;
  width: max-content;
}

.message-text-wrapper {
  position: relative;
  display: inline-block;
  max-width: 100%;

  &:hover {
    .message-timestamp {
      opacity: 1;
    }
  }

  .message-text {
    // min-width: 60px;
    line-height: 1.5;
    font-size: 16px;
    padding: 8px 12px;
    border-radius: 6px;
    white-space: pre-wrap;
    position: relative;
    box-shadow: var(--el-box-shadow-light);
    border: 1px solid var(--el-border-color-lighter);
    display: inline-block;
    max-width: 100%;
    min-height: 40px;

    &::before {
      content: '';
      position: absolute;
      width: 0;
      height: 0;
      border: 6px solid transparent;
      top: 10px;
    }
  }
}

.conversation-end {
  display: flex;
  justify-content: center;
  margin: 20px 0;

  .end-tag {
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 12px;
    background-color: var(--el-fill-color-light);
    border-color: var(--el-border-color-lighter);
    color: var(--el-text-color-secondary);
  }
}

.typing-indicator span {
  width: 4px;
  height: 4px;
  background: var(--el-color-primary);
  border-radius: 50%;
  display: inline-block;
  margin: 0 1px;
  animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes bounce {

  0%,
  80%,
  100% {
    transform: scale(0.8);
  }

  40% {
    transform: scale(1.2);
  }
}

.message-actions .message-action-button {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.message-wrapper:hover .message-actions .message-action-button,
.message-wrapper:focus-within .message-actions .message-action-button {
  opacity: 1;
  pointer-events: auto;
}
</style>
