/* ============================================
   WAP 端 AI 智能客服样式（移动端优化版）
   全屏对话框（悬浮按钮已移至用户中心页面顶部）
   ============================================ */

/* AI 客服对话框 - WAP 移动端全屏 */
.ai-chat-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    background: #f8f9fc;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: aiFadeIn 0.25s ease;
}
.ai-chat-dialog.open {
    display: flex;
}

/* panel 容器 - WAP 移动端不需要，全屏直接占满 */
.ai-chat-panel {
    width: 100%;
    height: 100%;
    background: #f8f9fc;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
@keyframes aiFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 头部 */
.ai-chat-header {
    background: linear-gradient(135deg, #5a6fd6 0%, #6a3fa0 100%);
    color: #fff;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    flex-shrink: 0;
}
.ai-chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.ai-chat-header h3 .ai-icon {
    font-size: 20px;
}
.ai-chat-header .ai-back-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

/* 消息列表 */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
}

/* 消息气泡 */
.ai-msg {
    max-width: 88%;
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
    animation: aiMsgInM 0.3s ease;
}
@keyframes aiMsgInM {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.ai-msg p { margin: 4px 0; }

/* AI 消息 */
.ai-msg-ai {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e8ecf1;
    border-bottom-left-radius: 4px;
    color: #333;
}

/* 用户消息 */
.ai-msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* 输入区域 */
.ai-chat-input-area {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-top: 1px solid #e8ecf1;
    background: #fff;
    gap: 8px;
    position: relative;
    z-index: 1;
}
.ai-chat-input-area input {
    flex: 1;
    border: 1px solid #e0e4e8;
    border-radius: 24px;
    padding: 10px 14px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}
.ai-chat-input-area input:focus {
    border-color: #667eea;
}
.ai-chat-input-area .ai-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}
.ai-chat-input-area .ai-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 输入中... */
.ai-typing {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 18px;
    background: #fff;
    border: 1px solid #e8ecf1;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}
.ai-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667eea;
    animation: aiTypingM 1.4s infinite both;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes aiTypingM {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* 快捷问题按钮 */
.ai-quick-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}
.ai-quick-btn {
    background: #eef1ff;
    border: 1px solid #d5dbf5;
    border-radius: 16px;
    padding: 6px 14px;
    font-size: 13px;
    color: #5a6fd6;
    cursor: pointer;
    transition: all 0.2s;
}
.ai-quick-btn:active {
    background: #667eea;
    color: #fff;
}

/* 消息格式 */
.ai-msg-ai strong { color: #5a6fd6; }
.ai-msg-ai a { color: #667eea; text-decoration: underline; }
.ai-msg-ai ul, .ai-msg-ai ol { padding-left: 18px; margin: 4px 0; }
.ai-msg-ai code {
    background: #f0f2f5;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

/* iPhone 底部安全区适配 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .ai-chat-input-area {
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }
}
