/**
 * AI聊天面板通用样式
 * 支持CSS变量定制主题色
 */

/* ==================== 聊天面板容器 ==================== */
.ai-chat-panel-wrapper {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
}

/* ==================== 消息容器 ==================== */
.chat-messages-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f5f5f5;
    max-height: 630px;
}

/* 关闭按钮（浮动窗口模式） */
.ai-chat-close-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    font-size: 18px;
    line-height: 1;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    flex-shrink: 0;
    transition: background 0.2s;
}
.ai-chat-close-btn:hover {
    background: rgba(255,255,255,0.4);
}

/* ==================== 消息气泡 ==================== */
.message-bubble {
    display: flex;
    margin-bottom: 15px;
    max-width: 85%;
    position: relative;
}

.message-content {
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 15px;
    line-height: 1.4;
    word-wrap: break-word;
    position: relative;
}

/* 用户消息 */
.message-bubble.user {
    margin-left: auto;
    flex-direction: row-reverse;
}

.message-bubble.user .message-content {
    background: #95EC69;
    color: #000;
}

/* AI消息 */
.message-bubble.ai {
    margin-right: auto;
}

.message-bubble.ai .message-content {
    background: #fff;
    color: #333;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ==================== 输入区域 ==================== */
.chat-footer {
    display: flex;
    align-items: center;
    padding: 8px;
    background: #F5F5F5;
    border-top: 1px solid #E0E0E0;
}

.chat-input,
#chat-input {
    flex-grow: 1;
    min-width: 0;
    border: 1px solid #ccc;
    border-radius: 5px;
    padding: 8px;
    font-size: 15px;
    resize: none;
    margin-right: 8px;
    font-family: inherit;
}

.chat-send-btn,
#chat-send-btn {
    flex-shrink: 0;
    background: var(--zhuti_clor, #07C160);
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 0 15px;
    height: 38px;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s;
}

.chat-send-btn:hover,
#chat-send-btn:hover {
    background: var(--zhuti_clor_hover, #06ad56);
}

.chat-send-btn:disabled,
#chat-send-btn:disabled {
    background: #a0e7b7;
    cursor: not-allowed;
}

/* ==================== 加载动画 ==================== */
.lds-ellipsis {
    display: inline-block;
    position: relative;
    width: 60px;
    height: 20px;
}

.lds-ellipsis div {
    position: absolute;
    top: 5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #888;
    animation-timing-function: cubic-bezier(0,1,1,0);
}

.lds-ellipsis div:nth-child(1) {
    left: 8px;
    animation: lds1 0.6s infinite;
}

.lds-ellipsis div:nth-child(2) {
    left: 8px;
    animation: lds2 0.6s infinite;
}

.lds-ellipsis div:nth-child(3) {
    left: 32px;
    animation: lds2 0.6s infinite;
}

.lds-ellipsis div:nth-child(4) {
    left: 56px;
    animation: lds3 0.6s infinite;
}

@keyframes lds1 {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

@keyframes lds2 {
    0% { transform: translate(0, 0); }
    100% { transform: translate(24px, 0); }
}

@keyframes lds3 {
    0% { transform: scale(1); }
    100% { transform: scale(0); }
}

/* ==================== AI标题动画 ==================== */
.ai-chat-title {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-title-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #7fffb0;
    box-shadow: 0 0 0 0 rgba(127,255,176,0.7);
    animation: ai-pulse 1.8s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes ai-pulse {
    0% { box-shadow: 0 0 0 0 rgba(127,255,176,0.7); }
    60% { box-shadow: 0 0 0 7px rgba(127,255,176,0); }
    100% { box-shadow: 0 0 0 0 rgba(127,255,176,0); }
}

.ai-title-text {
    display: inline-flex;
    gap: 0;
}

.ai-title-text span {
    display: inline-block;
    animation: ai-wave 2s ease-in-out infinite;
    opacity: 0.6;
}

.ai-title-text span:nth-child(1) { animation-delay: 0s; }
.ai-title-text span:nth-child(2) { animation-delay: 0.1s; }
.ai-title-text span:nth-child(3) { animation-delay: 0.2s; }
.ai-title-text span:nth-child(4) { animation-delay: 0.3s; }
.ai-title-text span:nth-child(5) { animation-delay: 0.4s; }
.ai-title-text span:nth-child(6) { animation-delay: 0.5s; }
.ai-title-text span:nth-child(7) { animation-delay: 0.6s; }
.ai-title-text span:nth-child(8) { animation-delay: 0.7s; }

@keyframes ai-wave {
    0%, 100% { opacity: 0.6; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(-2px); }
}

/* ==================== 消息操作按钮 ==================== */
.delete-msg-btn {
    position: absolute;
    left: -25px;
    top: 50%;
    transform: translateY(-50%);
    background: #e0e0e0;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    font-size: 14px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.message-bubble.user:hover .delete-msg-btn {
    opacity: 1;
}

.copy-ai-msg-btn {
    position: absolute;
    bottom: 5px;
    right: 8px;
    background: #e0e0e0;
    border: none;
    border-radius: 5px;
    width: 24px;
    height: 24px;
    text-align: center;
    font-size: 14px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.message-bubble.ai:hover .copy-ai-msg-btn {
    opacity: 1;
}

/* ==================== AI消息操作区 ==================== */
.ai-msg-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
    padding-top: 5px;
    border-top: 1px dashed #eee;
}

.ai-action-btn {
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 12px;
    cursor: pointer;
    color: #666;
    transition: all 0.2s;
}

.ai-action-btn:hover {
    background: #f0f0f0;
}

.ai-action-btn.active {
    color: var(--zhuti_clor, #07C160);
    border-color: var(--zhuti_clor, #07C160);
}

/* ==================== 评分弹窗 ==================== */
.rating-popup {
    display: none;
    position: absolute;
    bottom: 100%;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 5px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.rating-popup.show {
    display: flex;
    gap: 5px;
}

.rate-opt-btn {
    background: none;
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
}

.rate-opt-btn:hover {
    background: #f5f5f5;
}

/* ==================== 响应式布局 ==================== */
@media (max-width: 768px) {
    .message-bubble {
        max-width: 90%;
    }

    .chat-input,
    #chat-input {
        font-size: 14px;
    }

    .chat-send-btn,
    #chat-send-btn {
        padding: 0 12px;
        font-size: 14px;
    }
}

/* ==================== 右侧列布局适配 ==================== */
#right-col .ai-chat-panel-wrapper {
    display: flex;
    flex-direction: column;
    max-height: 810px;
    min-height: 520px;
}

#right-col .chat-messages-container {
    flex: 1;
    height: auto !important;
    max-height: none !important;
    min-height: 200px;
}

/* ==================== 用户积分徽章（通用）==================== */
.user-points-badge {
    display: inline-flex;
    align-items: center;
    background: #fff;
    border-radius: 12px;
    padding: 3px 8px;
    font-size: 12px;
    color: #854d0e;
    cursor: pointer;
    font-weight: normal;
    white-space: nowrap;
    transition: background 0.3s, border-color 0.3s;
    border: 1px solid transparent;
    line-height: 1.4;
}
.user-points-badge:hover {
    background: #fef9c3;
}

/* ==================== 浮动弹窗模式（v1/index.php 奇门遁甲专业版等）==================== */

/* 遮罩层：全屏半透明黑底 */
.ai-float-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 15px;
    box-sizing: border-box;
}

/* 遮罩激活时显示（JS 通过 style.display='flex' 控制，不依赖 class） */

/* 弹窗主体 */
.ai-float-window {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 600px;
    height: 90%;
    max-height: 700px;
    background: #F0F2F5;
    border-radius: 12px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    z-index: 10000;
}

/* 弹窗内的消息容器覆盖通用限制 */
.ai-float-window .chat-messages-container {
    flex: 1;
    max-height: none !important;
    min-height: 200px;
    height: auto;
}

/* 弹窗内关闭按钮悬停效果 */
.ai-float-window .ai-chat-close-btn {
    font-size: 20px;
    width: 28px;
    height: 28px;
}
.ai-float-window .ai-chat-close-btn:hover {
    background: rgba(239, 68, 68, 0.7);
}
