/* chat.css */

/* 聊天图标 */
.live-chat-icon {
    position: fixed;
    bottom: 15px;
    right: 70px;
    background: #d4a5a5; /* 柔和的粉红色 */
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    transition: transform 0.3s ease;
    overflow: hidden; /* 确保内容不会溢出 */
}

.live-chat-icon:hover {
    transform: scale(1.1);
}

.live-chat-icon span {
    font-size: 24px;
    line-height: 1;
    text-align: center;
    position: relative; /* 确保 span 不会被其他定位干扰 */
    display: inline-block; /* 确保 span 的大小由内容决定 */
}

/* 强制对话框图标居中 */
.live-chat-icon span::before {
    content: url('path-to-chat-icon.png'); /* 替换为实际的对话框图标路径 */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
}

/* 防止动态样式干扰 */
.live-chat-icon * {
    position: relative !important;
    left: auto !important;
    top: auto !important;
}

/* 聊天窗口 */
.chat-window {
    position: fixed;
    bottom: 90px;
    right: 20px; /* 默认在桌面端靠右 */
    width: 350px;
    max-height: 520px;
    background: linear-gradient(135deg, #fff5f7, #f9e4e8);
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    display: none;
    flex-direction: column;
    font-family: 'Playfair Display', serif;
    overflow: hidden;
    border: 1px solid #f0c4c9;
    z-index: 10000; /* 提高 z-index，确保高于导航栏 */
}

/* 导航栏 */
.nav__navbar {
    z-index: 1000 !important; /* 设置较低的 z-index，确保低于聊天窗口 */
}

/* 移动端调整：屏幕宽度小于 768px 时居中 */
@media (max-width: 768px) {
    .live-chat-icon {
        right: 70px;
        bottom: 14px;
    }

    .chat-window {
        right: auto; /* 移除固定右边距 */
        left: 50%; /* 将窗口定位到水平中心 */
        transform: translateX(-50%); /* 向左偏移自身宽度的一半，实现居中 */
        width: 90%; /* 调整宽度为屏幕的90%，避免过宽 */
        max-width: 350px; /* 保持最大宽度为350px */
        bottom: 120px; /* 增加底部间距，避免被顶部导航栏遮挡 */
    }
    .faq-list ul li a {
        font-size: 12px; /* 减小字体大小 */
    }
    .faq-title {
        font-size: 13px; /* 减小标题字体 */
    }
}

/* 头部 */
.chat-header {
    background: #f7d7da; /* 浅粉色 */
    padding: 15px;
    text-align: center;
    border-bottom: 1px solid #f0c4c9;
    position: relative;
}

.chat-header h3 {
    margin: 0;
    font-size: 16px;
    color: #5a3e3e; /* 深棕色文字 */
    font-weight: 400;
}

.chat-header p {
    margin: 5px 0 0;
    font-size: 12px;
    color: #5a3e3e;
}

.close-chat {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 18px;
    color: #5a3e3e;
    cursor: pointer;
}

/* FAQ 列表 */
.faq-list {
    padding: 15px;
    height: 350px;
    overflow-y: auto;
    background: #fff; /* 白色背景 */
    border-radius: 8px;
    margin: 10px;
}

.faq-title {
    font-weight: bold;
    color: #5a3e3e;
    margin-bottom: 10px;
    font-size: 14px;
}

.faq-list ul {
    list-style: none;
    padding: 0;
}

.faq-list ul li {
    margin-bottom: 8px;
}

.faq-list ul li a {
    color: #d4a5a5;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.3s ease;
}

.faq-list ul li a:hover {
    color: #c68b8b;
}

.contact-link {
    margin-top: 10px;
    font-size: 12px;
    color: #5a3e3e;
}

.contact-link a {
    color: #d4a5a5;
    text-decoration: none;
}

.contact-link a:hover {
    text-decoration: underline;
}

/* 聊天区域 */
.chat-area {
    display: none;
    padding: 15px;
    height: 350px;
    overflow-y: auto;
    background: #fff; /* 白色背景 */
    border-radius: 8px;
    margin: 10px;
}

/* 返回 FAQ 按钮 */
.back-to-faq {
    display: block;
    margin: 0 auto 10px;
    padding: 8px 15px;
    background: #d4a5a5; /* 柔和的粉红色 */
    color: #fff;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.3s;
    font-family: 'Playfair Display', serif;
    font-size: 14px;
    text-align: center;
}

.back-to-faq:hover {
    background: #c68b8b; /* 稍深的粉红色 */
}

.chat-message {
    margin-bottom: 10px;
    padding: 8px 12px;
    border-radius: 15px;
    max-width: 80%;
    font-size: 14px;
    line-height: 1.4;
    word-break: break-word; /* 确保长单词换行 */
}

.chat-message.user {
    background: #f7d7da; /* 浅粉色 */
    color: #5a3e3e;
    margin-left: auto;
    text-align: right;
}

.chat-message.bot {
    background: #f0f0f0; /* 浅灰色 */
    color: #333;
    margin-right: auto;
}

/* 正在输入提示的动画效果 */
.typing {
    background: #fff;
    border: 1px solid #f0c4c9;
}

.typing-dots {
    display: inline-block;
    width: 30px;
    text-align: left;
    position: relative;
}

.typing-dots span {
    display: inline-block;
    opacity: 1;
    animation: typing 1.5s infinite;
}

.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0% { opacity: 0.3; }
    50% { opacity: 1; }
    100% { opacity: 0.3; }
}

/* 输入区域 */
.chat-footer {
    display: flex;
    align-items: center; /* 垂直居中对齐 */
    justify-content: space-between; /* 保持左右分布 */
    flex-wrap: wrap; /* 允许换行，防止溢出 */
    padding: 10px 15px; /* 调整内边距 */
    background: #f7d7da;
    border-top: 1px solid #f0c4c9;
    box-sizing: border-box;
    gap: 8px; /* 减小元素间距 */
}

.chat-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #f0c4c9;
    border-radius: 20px;
    outline: none;
    font-family: 'Playfair Display', serif;
    font-size: 14px;
    background: #fff;
    margin-right: 0; /* 移除 margin-right，使用 gap 控制间距 */
    max-width: calc(100% - 90px); /* 确保输入框留出足够空间给按钮 */
    min-width: 0; /* 移除最小宽度限制，允许输入框缩小 */
    box-sizing: border-box;
}

.chat-submit {
    padding: 8px 15px;
    background: #d4a5a5;
    color: #fff;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.3s;
    font-family: 'Playfair Display', serif;
    font-size: 12px;
    width: auto; /* 让按钮宽度自适应内容 */
    min-width: 70px; /* 设置最小宽度，确保按钮不会太小 */
    white-space: nowrap; /* 防止文本换行 */
    box-sizing: border-box;
}

.chat-submit:hover {
    background: #c68b8b;
}

/* 移动端调整 */
@media (max-width: 768px) {
    .chat-footer {
        padding: 8px 10px; /* 减少内边距 */
        gap: 5px; /* 进一步减小元素间距 */
    }

    .chat-input {
        font-size: 12px; /* 减小字体大小 */
        padding: 6px 10px; /* 减少内边距 */
        max-width: calc(100% - 80px); /* 在移动端调整输入框的最大宽度 */
    }

    .chat-submit {
        font-size: 10px; /* 减小字体大小 */
        padding: 6px 12px; /* 减少内边距 */
        min-width: 60px; /* 减小最小宽度 */
    }
}

/* 底部文本 */
.chat-footer-text {
    padding: 10px;
    text-align: center;
    font-size: 12px;
    color: #5a3e3e;
    background: #f7d7da;
}

/* 滚动条样式 */
.faq-list::-webkit-scrollbar,
.chat-area::-webkit-scrollbar {
    width: 6px;
}

.faq-list::-webkit-scrollbar-track,
.chat-area::-webkit-scrollbar-track {
    background: #f0f0f0;
}

.faq-list::-webkit-scrollbar-thumb,
.chat-area::-webkit-scrollbar-thumb {
    background: #d4a5a5;
    border-radius: 3px;
}