/* ============================================
   NAI获客系统 - 专用样式 v2.1
   输入框紧贴底部菜单栏
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    background: #ffffff;
    color: #1a1a2e;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
}

/* 内容区域 - 占据剩余空间 */
#content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

/* 聊天区域 - 可滚动 */
.chat-messages {
    flex: 1;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 20px 20px 20px 20px;
    min-height: 0;
    height: auto;
    max-height: calc(100vh - 120px);
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* 底部容器 - 紧贴底部，无多余间距 */
.bottom-container {
    background: #ffffff;
    border-top: 1px solid #eaeef2;
    padding: 12px 20px;
    position: fixed;
    bottom: 44px;
    left: 0;
    right: 0;
    z-index: 999;
    background: white;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

/* 登录后，如果页面底部有菜单栏，通过 body 的 padding-bottom 来控制 */
/* 这个由 PHP 动态添加的底部菜单决定，CSS 不需要额外处理 */

/* 手机端底部容器 */
@media (max-width: 768px) {
    .bottom-container {
        padding: 10px 16px;
    }
}

/* 输入框包装器 */
.input-wrapper {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* 输入区域 */
.input-area {
    flex: 1;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 28px;
    display: flex;
    align-items: center;
    padding: 6px 16px;
    transition: all 0.2s;
}

.input-area:focus-within {
    border-color: #008000;
    box-shadow: 0 0 0 3px rgba(0,128,0,0.1);
    background: white;
}

/* 输入框 */
.chat-input {
    flex: 1;
    border: none;
    padding: 10px 0;
    font-size: 14px;
    resize: none;
    outline: none;
    background: transparent;
    min-height: 44px;
    max-height: 120px;
    font-family: inherit;
    overflow-y: auto;
}

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

/* 附件按钮 */
.attach-btn {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    transition: all 0.2s;
}

.attach-btn:hover {
    background: #f1f5f9;
    color: #008000;
}

/* 发送按钮 */
.send-btn {
    background: linear-gradient(135deg, #008000, #FB9749);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.1s;
}

.send-btn:active {
    transform: scale(0.95);
}

/* 新对话按钮 */
.new-chat-circle {
    background: linear-gradient(135deg, #10b981, #059669);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.1s;
}

.new-chat-circle:active {
    transform: scale(0.95);
}

/* 欢迎屏幕 */
.welcome-screen {
    text-align: center;
    padding: 20px;
    padding-top: 30px;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
}

.welcome-icon img {
    max-width: 120px;
    width: 120px;
    height: auto;
    margin: 0 auto 20px auto;
    display: block;
}

.welcome-title {
    font-size: 32px;
    font-weight: 700;
    margin: 10px 0 8px;
    color: #1a1a2e;
}

.welcome-subtitle {
    font-size: 16px;
    font-weight: 500;
    color: #4a5568;
    margin-top: 8px;
    line-height: 1.5;
}

.feature-tags {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
}

.feature-tag {
    background: #f0fdf4;
    color: #008000;
    padding: 6px 16px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 500;
}

/* 消息样式 */
.message {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
}

.message.user {
    align-items: flex-end;
}

.message.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    max-width: 75%;
    padding: 10px 16px;
    border-radius: 18px;
    font-size: 14px;
}

.message.bot {
    align-items: flex-start;
}

.message.bot .message-content {
    background: #f7f8fa;
    color: #1f2937;
    max-width: 90%;
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 14px;
    line-height: 1.5;
}

/* 结果卡片 */
.result-card {
    background: white;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.result-title {
    font-weight: 600;
    margin-bottom: 6px;
    color: #1a1a2e;
}

.result-detail {
    font-size: 12px;
    color: #718096;
}

.result-contact {
    font-size: 12px;
    color: #008000;
    margin-top: 6px;
    word-break: break-all;
}

/* 消息操作按钮 */
.message-actions {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.message:hover .message-actions {
    opacity: 0.8;
}

.action-icon {
    background: none;
    border: none;
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 11px;
    color: #9ca3af;
    cursor: pointer;
}

.action-icon:hover {
    background: #f3f4f6;
    color: #008000;
}

/* 附件预览区域 */
.attach-preview {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.attach-preview.show {
    display: flex;
}

.attach-item {
    background: #f1f5f9;
    border-radius: 20px;
    padding: 4px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.remove-attach {
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    font-size: 14px;
}

/* 打字动画 */
.typing-indicator {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    padding: 4px 8px;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    animation: typing 1.2s infinite;
}

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

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* 手机端适配 */
@media (max-width: 768px) {
    .chat-messages {
        padding: 16px 16px 100px 16px;
        max-height: calc(100vh - 110px);
    }
    
    .welcome-title {
        font-size: 24px;
    }
    
    .welcome-subtitle {
        font-size: 14px;
    }
    
    .feature-tag {
        font-size: 11px;
        padding: 4px 12px;
    }
    
    .message.user .message-content,
    .message.bot .message-content {
        max-width: 85%;
        font-size: 13px;
    }
    
    .input-wrapper {
        gap: 8px;
    }
    
    .new-chat-circle,
    .send-btn {
        width: 40px;
        height: 40px;
    }
    
    .attach-btn {
        padding: 6px;
    }
}

/* 桌面端优化 */
@media (min-width: 769px) {
    .chat-messages {
        padding: 24px 40px;
    }
}
/* ============================================
   强制修复：输入框紧贴底部菜单栏
   ============================================ */

/* 覆盖 headerai.php 中的多余间距 */
body {
    padding-bottom: 0 !important;
}

#content {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* 底部输入框容器 - 紧贴菜单栏上方 */
.bottom-container {
    margin-bottom: 0 !important;
    padding-bottom: 12px !important;
    border-bottom: none !important;
}

/* 确保底部菜单栏在输入框下方 */
.menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

/* 手机端调整 */
@media (max-width: 768px) {
    .bottom-container {
        padding-bottom: 8px !important;
        margin-bottom: 0 !important;
    }
    
    /* 菜单栏高度 44px，确保输入框不重叠 */
    .chat-messages {
        padding-bottom: 80px !important;
    }
}

/* 桌面端 - 菜单栏高度 30px */
@media (min-width: 769px) {
    .chat-messages {
        padding-bottom: 70px !important;
    }
}
/* 调整输入框位置 - 紧贴底部菜单栏 */
.bottom-container {
    margin-bottom: 0 !important;
    padding-bottom: 5px !important;
    position: relative;
    bottom: -5px;  /* 向下移动5px */
}

/* 或者用 margin-top 把输入框往下推 */
.input-wrapper {
    margin-bottom: 0;
    padding-bottom: 0;
}

/* 手机端 */
@media (max-width: 768px) {
     .bottom-container {
        bottom: 50px;
        padding: 10px 16px;
    }
}
/* ============================================
   修复登录后输入框被底部菜单遮挡的问题
   ============================================ */

/* 底部菜单栏 - 固定定位 */
.menu {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 44px !important;
    background: linear-gradient(to bottom right, #FB9749, #008000) !important;
    z-index: 1000 !important;
    display: flex !important;
    align-items: center !important;
}

/* 底部输入框容器 - 为菜单栏留出空间 */
.bottom-container {
    position: fixed !important;
    bottom: 44px !important;  /* 菜单栏高度 */
    left: 0 !important;
    right: 0 !important;
    background: #ffffff !important;
    border-top: 1px solid #eaeef2 !important;
    padding: 12px 20px !important;
    z-index: 999 !important;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05) !important;
}

/* 聊天区域 - 为固定的输入框和菜单栏留出空间 */
.chat-messages {
    padding-bottom: 100px !important;  /* 底部留出空间 */
    margin-bottom: 0 !important;
}

/* 内容区域 - 确保正确布局 */
#content {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* 手机端适配 */
@media (max-width: 768px) {
    .menu {
        height: 50px !important;
    }
    
    .bottom-container {
        bottom: 50px !important;
        padding: 10px 16px !important;
    }
    
     .chat-messages {
        padding: 16px 16px 100px 16px;
        max-height: calc(100vh - 100px);
    }
}

/* 桌面端 */
@media (min-width: 769px) {
    .menu {
        height: 40px !important;
    }
    
    .bottom-container {
        bottom: 40px !important;
    }
    
    .chat-messages {
        padding-bottom: 100px;
        max-height: calc(100vh - 100px);
    }
    .bottom-container {
        bottom: 40px;
    }
}

/* 确保输入框容器背景色一致 */
.bottom-container {
    background: white !important;
}

/* 修复发送按钮和新对话按钮在手机端的显示 */
@media (max-width: 768px) {
    .send-btn,
    .new-chat-circle {
        width: 40px !important;
        height: 40px !important;
    }
    
    .attach-btn {
        padding: 6px !important;
    }
}
/* ============================================
   登录提示弹窗按钮强制显示（手机端修复）
   ============================================ */

#loginPromptModal,
#loginPromptModal * {
    visibility: visible !important;
    opacity: 1 !important;
}

#loginPromptModal button,
#promptConfirmBtn,
#promptCancelBtn {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    min-width: 80px !important;
    padding: 12px 20px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    z-index: 200001 !important;
    pointer-events: auto !important;
    cursor: pointer !important;
    border-radius: 48px !important;
}

#promptConfirmBtn {
    background: linear-gradient(135deg, #008000, #FB9749) !important;
    border: none !important;
    color: white !important;
}

#promptCancelBtn {
    background: #f1f5f9 !important;
    border: 1px solid #e2e8f0 !important;
    color: #334155 !important;
}

@media (max-width: 768px) {
    #loginPromptModal > div {
        max-width: 280px !important;
        width: 85% !important;
    }
    
    #loginPromptModal button {
        min-width: 70px !important;
        padding: 10px 16px !important;
        font-size: 14px !important;
    }
}

@media (max-width: 400px) {
    #loginPromptModal > div {
        max-width: 260px !important;
    }
    
    #loginPromptModal button {
        min-width: 65px !important;
        padding: 8px 12px !important;
        font-size: 13px !important;
    }
}
/* 登录提示弹窗按钮强制显示 */
#loginPromptModal,
#loginPromptModal * {
    visibility: visible !important;
    opacity: 1 !important;
}

#loginPromptModal button {
    display: block !important;
    visibility: visible !important;
    min-width: 80px !important;
    padding: 12px 20px !important;
    font-size: 16px !important;
    z-index: 200001 !important;
    cursor: pointer !important;
}

#promptConfirmBtn {
    background: linear-gradient(135deg, #008000, #FB9749) !important;
    color: white !important;
    border: none !important;
}

#promptCancelBtn {
    background: #f1f5f9 !important;
    color: #334155 !important;
    border: 1px solid #e2e8f0 !important;
}

@media (max-width: 768px) {
    #loginPromptModal > div {
        max-width: 280px !important;
    }
    #loginPromptModal button {
        min-width: 70px !important;
        padding: 10px 16px !important;
        font-size: 14px !important;
    }
}