/* AI9090 Chat Widget - 商务科技风 / 低饱和 / 干净高级
 * 命名空间全部 ai9090- 前缀，不污染主题样式。
 * PC：右下角浮窗；移动：底部抽屉。
 *
 * v1.4.1（2026-09-13）
 * 1. 输入框提示文案改中文（Enter -> 按回车）
 * 2. 发送按钮放大：44 -> 54px，图标改为实心纸飞机 20 -> 28px，加投影更醒目
 * 3. 修复主题 button padding 挤压导致图标仅 14px 宽（补 padding:0 / min-width / flex:none）
 *
 * v1.3.0（2026-09-13）
 * 1. PC 弹窗整体放大 2 倍：420x600 -> 840x1200（超出视口时自动收缩到可用区域）
 * 2. 取消背景遮罩（变暗 + 模糊），并让弹窗以外区域恢复鼠标点击/滚动
 * 3. 字号与控件跟随放大（气泡 14 -> 16px 等），移动端底部抽屉同步加大
 */

.ai9090-chat-hidden { display: none !important; }

#ai9090-chat-widget {
    position: fixed;
    inset: 0;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
    color: #1f2937;
    /* 外壳不拦截鼠标事件：弹窗以外的网站区域照常可点击、可滚动 */
    pointer-events: none;
}

/* 遮罩：不再使用（保留节点以兼容旧 DOM，但不显示、不遮挡） */
.ai9090-chat-overlay { display: none !important; }

/* 弹窗容器 */
.ai9090-chat-window {
    position: absolute;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22), 0 2px 6px rgba(15, 23, 42, 0.06);
    overflow: hidden;
    /* 弹窗本体恢复交互 */
    pointer-events: auto;
}

/* PC / 平板横向：放大 2 倍，受视口约束（留 24px 边距） */
@media (min-width: 769px) {
    .ai9090-chat-window {
        right: 24px;
        bottom: 24px;
        width: min(840px, calc(100vw - 48px));
        height: min(1200px, calc(100vh - 48px));
        max-height: calc(100vh - 48px);
        border-radius: 16px;
        animation: ai9090-chat-pop 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    }
}

/* 移动端：底部抽屉（全宽 x 92vh，比原来 80vh 更大） */
@media (max-width: 768px) {
    .ai9090-chat-window {
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 92vh;
        max-height: 92vh;
        border-radius: 16px 16px 0 0;
        animation: ai9090-chat-up 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    }
}

@keyframes ai9090-chat-pop {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes ai9090-chat-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

/* 头部 */
.ai9090-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    background: linear-gradient(135deg, #2563eb 0%, #0e6fcc 100%);
    color: #fff;
    flex-shrink: 0;
}

.ai9090-chat-title { display: flex; align-items: center; gap: 14px; }

.ai9090-chat-avatar {
    width: 46px; height: 46px;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.5px;
}

.ai9090-chat-meta { line-height: 1.3; }
.ai9090-chat-name { font-size: 17px; font-weight: 600; }
.ai9090-chat-subtitle { font-size: 12px; opacity: 0.85; margin-top: 2px; }
.ai9090-chat-points { font-size: 13px; opacity: 0.9; margin-top: 4px; display: inline-flex; align-items: center; gap: 5px; }
.ai9090-chat-points-label { opacity: 0.65; font-weight: 400; }
.ai9090-chat-points .mycred-balance, .ai9090-chat-points strong, .ai9090-chat-points b { font-weight: 600; opacity: 1; letter-spacing: 0.3px; }

.ai9090-chat-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 38px; height: 38px;
    padding: 0;
    border-radius: 10px;
    cursor: pointer;
    font-size: 26px;
    line-height: 1;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s;
}
.ai9090-chat-close:hover { background: rgba(255, 255, 255, 0.28); }

/* 消息区 */
.ai9090-chat-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 22px 22px 10px;
    background: #f8fafc;
    scroll-behavior: smooth;
}

.ai9090-chat-msg {
    display: flex;
    margin-bottom: 16px;
    animation: ai9090-chat-fade 0.18s ease;
}
.ai9090-chat-msg-user { justify-content: flex-end; }
.ai9090-chat-msg-bot  { justify-content: flex-start; }

@keyframes ai9090-chat-fade {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ai9090-chat-bubble {
    max-width: 76%;
    padding: 13px 17px;
    border-radius: 14px;
    font-size: 16px;
    line-height: 1.7;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.ai9090-chat-msg-user .ai9090-chat-bubble {
    background: linear-gradient(135deg, #2563eb 0%, #1f8fff 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ai9090-chat-msg-bot .ai9090-chat-bubble {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
    color: #1f2937;
}

.ai9090-chat-bubble code {
    background: rgba(15, 23, 42, 0.06);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 14px;
    font-family: "SF Mono", Consolas, Monaco, monospace;
}
.ai9090-chat-msg-user .ai9090-chat-bubble code { background: rgba(255, 255, 255, 0.22); }
.ai9090-chat-bubble pre {
    background: #0f172a;
    color: #e2e8f0;
    padding: 12px 14px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 10px 0;
    font-size: 14px;
    line-height: 1.55;
}
.ai9090-chat-bubble pre code { background: none; color: inherit; padding: 0; }
.ai9090-chat-bubble strong { font-weight: 600; }
.ai9090-chat-bubble a { color: #2563eb; text-decoration: underline; }
.ai9090-chat-msg-user .ai9090-chat-bubble a { color: #fff; }

/* 加载动画 */
.ai9090-chat-loading .ai9090-chat-bubble {
    display: flex;
    gap: 5px;
    padding: 16px 18px;
}
.ai9090-chat-dot {
    width: 7px; height: 7px;
    background: #94a3b8;
    border-radius: 50%;
    animation: ai9090-chat-bounce 1.4s infinite ease-in-out both;
}
.ai9090-chat-dot:nth-child(1) { animation-delay: -0.32s; }
.ai9090-chat-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes ai9090-chat-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* 输入区 */
.ai9090-chat-footer {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 14px 18px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.ai9090-chat-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px 15px;
    font-size: 16px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 160px;
    min-height: 54px;
    line-height: 1.5;
    color: #1f2937;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.ai9090-chat-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.ai9090-chat-send {
    background: linear-gradient(135deg, #2563eb 0%, #1f8fff 100%);
    color: #fff;
    border: none;
    width: 54px; height: 54px;
    min-width: 54px;
    padding: 0;
    line-height: 1;
    border-radius: 14px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex: 0 0 auto;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.32);
    transition: filter 0.15s, transform 0.05s, box-shadow 0.15s;
}
.ai9090-chat-send:hover:not(:disabled) { filter: brightness(1.08); box-shadow: 0 6px 18px rgba(37, 99, 235, 0.42); }
.ai9090-chat-send:active:not(:disabled) { transform: scale(0.96); }
.ai9090-chat-send:disabled { background: #93c5fd; cursor: not-allowed; box-shadow: none; }
.ai9090-chat-send svg { width: 28px; height: 28px; min-width: 28px; flex: none; display: block; }

/* 移动端发送按钮同样保持醒目 */
@media (max-width: 480px) {
    .ai9090-chat-send { width: 50px; height: 50px; min-width: 50px; border-radius: 13px; }
    .ai9090-chat-send svg { width: 26px; height: 26px; min-width: 26px; }
    .ai9090-chat-input { min-height: 50px; }
}

.ai9090-chat-brand {
    text-align: center;
    font-size: 12px;
    color: #94a3b8;
    padding: 8px 0 10px;
    background: #f8fafc;
    border-top: 1px solid #eef2f7;
    letter-spacing: 0.5px;
}

/* 滚动条 */
.ai9090-chat-body::-webkit-scrollbar { width: 5px; }
.ai9090-chat-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.ai9090-chat-body::-webkit-scrollbar-track { background: transparent; }

/* 小屏（手机）微调 */
@media (max-width: 480px) {
    .ai9090-chat-window { height: 94vh; max-height: 94vh; }
    .ai9090-chat-bubble { max-width: 84%; }
    .ai9090-chat-header { padding: 15px 16px; }
    .ai9090-chat-body { padding: 18px 16px 8px; }
    .ai9090-chat-footer { padding: 12px 14px; }
}
