/* ============================================================================
   商会 AI 助手样式 - v2 全屏视频弹窗版
   引入：<link rel="stylesheet" href="/static/css/ai-assistant.css">
   依赖：ai-assistant.js（自动注入 DOM）
   ============================================================================ */

/* ---------- 浮动按钮（缩小版：48×48,点头像放大成弹窗） ---------- */
.ai-chat-fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-radius: 50%;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.45);
    cursor: pointer;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: transform 0.25s ease;
    user-select: none;
}
.ai-chat-fab:hover { transform: scale(1.08); }
.ai-chat-fab:active { transform: scale(0.95); }
.ai-chat-fab video {
    width: 100%; height: 100%;
    object-fit: cover;
    border-radius: 50%;
}
.ai-chat-fab-pulse {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.6);
    animation: ai-fab-pulse 2.2s infinite;
    pointer-events: none;
}
@keyframes ai-fab-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(99,102,241,0.55); }
    70%  { box-shadow: 0 0 0 18px rgba(99,102,241,0); }
    100% { box-shadow: 0 0 0 0 rgba(99,102,241,0); }
}

/* ---------- 遮罩 ---------- */
.ai-chat-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s;
}
.ai-chat-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ---------- 弹窗主壳（适配比例：中等尺寸 + 自适应） ---------- */
.ai-chat-modal {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0.96);
    width: min(720px, 90vw);
    height: min(560px, 82vh);
    max-height: 90vh;
    background: #0f172a;
    border-radius: 18px;
    box-shadow: 0 30px 80px rgba(0,0,0,0.45);
    z-index: 10000;
    display: flex;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
}
.ai-chat-modal.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

/* ---------- 左侧：全屏视频面板 ---------- */
.ai-chat-video-panel {
    position: relative;
    flex: 0 0 40%;
    background: #000;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ai-chat-video-panel video {
    width: 100%; height: 100%;
    object-fit: cover;
}
.ai-chat-video-overlay {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 18px 20px;
    background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.7) 100%);
    color: #fff;
}
.ai-chat-video-name {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 1px;
}
.ai-chat-video-status {
    font-size: 12px;
    color: #a5b4fc;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.ai-chat-video-status::before {
    content: '';
    width: 8px; height: 8px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 6px #22c55e;
}
.ai-chat-video-sound-toggle {
    position: absolute;
    top: 16px; right: 16px;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}
.ai-chat-video-sound-toggle:hover {
    background: rgba(0,0,0,0.75);
}

/* ---------- 右侧：聊天区 ---------- */
.ai-chat-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f8fafc;
    min-width: 0;
}
.ai-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
}
.ai-chat-avatar {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    overflow: hidden;
    flex-shrink: 0;
}
.ai-chat-info { flex: 1; min-width: 0; }
.ai-chat-title { font-size: 15px; font-weight: 600; color: #1e293b; }
.ai-chat-status { font-size: 12px; color: #64748b; margin-top: 2px; }
.ai-chat-close {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #64748b;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}
.ai-chat-close:hover { background: #f1f5f9; color: #1e293b; }

/* ---------- 推荐问题 ---------- */
.ai-chat-quick {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding: 10px 16px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
}
.ai-chat-quick span {
    font-size: 12px;
    padding: 5px 11px;
    background: #eef2ff;
    color: #4f46e5;
    border-radius: 14px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}
.ai-chat-quick span:hover { background: #ddd6fe; }

/* ---------- 消息区 ---------- */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
}
.ai-msg {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    max-width: 90%;
    animation: ai-msg-in 0.25s ease;
}
@keyframes ai-msg-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: none; }
}
.ai-msg.bot { align-self: flex-start; }
.ai-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.ai-msg-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    overflow: hidden;
    flex-shrink: 0;
}
.ai-msg.user .ai-msg-avatar {
    background: #cbd5e1;
}
.ai-msg-content {
    padding: 9px 13px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
    white-space: pre-wrap;
}
.ai-msg.bot .ai-msg-content {
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-top-left-radius: 4px;
}
.ai-msg.user .ai-msg-content {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border-top-right-radius: 4px;
}
.ai-msg.typing .ai-msg-content { color: #94a3b8; font-style: italic; }

/* ---------- 输入区 ---------- */
.ai-chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
}
.ai-chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    background: #f8fafc;
}
.ai-chat-input:focus { border-color: #6366f1; background: #fff; }
.ai-chat-send {
    padding: 0 18px;
    border: none;
    border-radius: 20px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}
.ai-chat-send:hover { opacity: 0.9; }
.ai-chat-send:active { transform: scale(0.96); }
.ai-chat-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- 移动端 ---------- */
@media (max-width: 720px) {
    .ai-chat-fab {
        bottom: 14px; right: 14px;
        width: 44px; height: 44px;
    }
    .ai-chat-modal {
        width: 100vw; height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        top: 0; left: 0;
        transform: translate(0, 0) scale(0.98);
    }
    .ai-chat-modal.active {
        transform: translate(0, 0) scale(1);
    }
    .ai-chat-video-panel {
        flex: 0 0 35%;
    }
    .ai-chat-quick span {
        font-size: 11px;
        padding: 4px 9px;
    }
    .ai-chat-input { font-size: 16px; } /* iOS 防缩放 */
}

/* ---------- 小屏平板适配 ---------- */
@media (min-width: 721px) and (max-width: 1024px) {
    .ai-chat-modal {
        width: min(640px, 88vw);
        height: min(520px, 80vh);
    }
}

/* ---------- 滚动条美化 ---------- */
.ai-chat-messages::-webkit-scrollbar { width: 6px; }
.ai-chat-messages::-webkit-scrollbar-track { background: transparent; }
.ai-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1; border-radius: 3px;
}
.ai-chat-messages::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
