/* Superneer AI Engineer 悬浮按钮 + 对话面板 */

/* ---------- 悬浮按钮（避开右下角在线客服，向上错开） ---------- */
#ai-fab {
    position: fixed;
    right: 20px;
    bottom: 96px;
    z-index: 99990;
    width: 64px;
    height: 64px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #0aa2e0, #087fb9);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(8, 127, 185, .45);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.15;
    padding: 0;
}
#ai-fab:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(8, 127, 185, .55); }
#ai-fab .ai-fab-top { font-size: 20px; font-weight: 800; letter-spacing: 1px; }
#ai-fab .ai-fab-bottom { font-size: 11px; font-weight: 600; }

/* ---------- 悬浮弹窗（可拖动 + 可调整大小） ---------- */
#ai-modal {
    position: fixed;
    right: 20px;
    bottom: 172px;
    z-index: 99991;
    width: 430px;
    height: 560px;
    min-width: 320px;
    min-height: 360px;
    max-width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(15, 35, 60, .28);
    /* 右下角调整大小把手 */
    resize: both;
}
#ai-modal.ui-resizing,
#ai-modal.ui-dragging { user-select: none; }

/* ---------- 面板通用 ---------- */
.ai-panel {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e1e7ef;
    border-radius: 14px;
    height: 100%;
    font-family: Arial, Helvetica, sans-serif;
    color: #172033;
}
#ai-modal .ai-panel { border: none; border-radius: 0; }
#ai-engineer-inline { margin: 0 0 22px; }
#ai-engineer-inline .ai-panel { box-shadow: 0 2px 10px rgba(15, 35, 60, .06); }

.ai-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #0aa2e0, #087fb9);
    color: #fff;
    cursor: move;        /* 桌面端整个头部可拖动 */
    user-select: none;
    flex-shrink: 0;
}
.ai-title { font-size: 14px; flex: 1; }
.ai-title strong { font-size: 15px; }
.ai-sub { display: block; font-size: 11px; opacity: .85; margin-top: 2px; }
.ai-auto { font-size: 11px; display: flex; align-items: center; gap: 4px; cursor: pointer; white-space: nowrap; }
.ai-auto input { cursor: pointer; }
.ai-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
}
/* 拖动时让标题和控件不抢鼠标 */
.ai-header .ai-title,
.ai-header .ai-sub,
.ai-header .ai-close { pointer-events: auto; }
.ai-header .ai-auto { pointer-events: auto; }

.ai-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 14px;
    background: #f5f8fb;
    min-height: 0;     /* flex 子项用 overflow 时必须设 */
}
#ai-modal .ai-messages { /* 高度由 flex 决定，不要再写死 */ }

.ai-msg { margin-bottom: 14px; }
.ai-msg-user { text-align: right; }
.ai-bubble {
    display: inline-block;
    max-width: 92%;
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.55;
    text-align: left;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.ai-msg-user .ai-bubble { background: #087fb9; color: #fff; border-bottom-right-radius: 4px; }
.ai-msg-assistant .ai-bubble { background: #fff; border: 1px solid #e1e7ef; border-bottom-left-radius: 4px; }

.ai-msg-tools { margin-top: 4px; }
.ai-listen {
    background: transparent;
    border: 1px solid #c8d6e2;
    color: #087fb9;
    font-size: 11px;
    padding: 2px 10px;
    border-radius: 10px;
    cursor: pointer;
}
.ai-listen:hover, .ai-listen.playing { background: #087fb9; color: #fff; border-color: #087fb9; }

/* ---------- 推荐产品卡片 ---------- */
.ai-products { margin-top: 8px; }
.ai-card {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    background: #fff;
    border: 1px solid #e1e7ef;
    border-radius: 10px;
    padding: 8px 10px;
    margin-bottom: 8px;
    text-decoration: none;
    color: #172033;
}
.ai-card:hover { border-color: #087fb9; box-shadow: 0 2px 8px rgba(8, 127, 185, .15); }
.ai-card img { width: 48px; height: 48px; object-fit: contain; flex-shrink: 0; }
.ai-card-desc { flex: 1; min-width: 160px; font-size: 12px; line-height: 1.45; color: #172033; }
.ai-card-pn { font-size: 11px; color: #087fb9; font-weight: 700; }

/* ---------- 输入区 ---------- */
.ai-inputbar {
    display: flex;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid #e1e7ef;
    background: #fff;
    align-items: stretch;
    flex-shrink: 0;
}
.ai-mic {
    flex: 0 0 40px;
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid #c8d6e2;
    border-radius: 8px;
    background: #fff;
    color: #087fb9;
    cursor: pointer;
}
.ai-mic svg { width: 18px; height: 18px; display: block; }
.ai-mic:hover { border-color: #087fb9; background: #f2f9fd; }
.ai-mic.ai-mic-listening {
    background: #e53935;
    border-color: #e53935;
    color: #fff;
    animation: aiMicPulse 1.2s infinite;
}
@keyframes aiMicPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(229, 57, 53, .45); }
    50% { box-shadow: 0 0 0 7px rgba(229, 57, 53, 0); }
}
.ai-inputbar textarea {
    flex: 1;
    resize: none;
    min-height: 62px;
    max-height: 120px;
    overflow-y: auto;
    border: 1px solid #c8d6e2;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    line-height: 1.4;
    outline: none;
}
.ai-inputbar textarea:focus { border-color: #087fb9; }
.ai-send {
    background: #087fb9;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0 18px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}
.ai-send:hover { background: #075f8c; }
.ai-send:disabled { background: #9ec6da; cursor: not-allowed; }

/* ---------- typing 动画 ---------- */
.ai-dots i { font-style: normal; animation: aiBlink 1.2s infinite; }
.ai-dots i:nth-child(2) { animation-delay: .2s; }
.ai-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes aiBlink { 0%, 60%, 100% { opacity: .2; } 30% { opacity: 1; } }

/* ---------- 移动端：不拖动、不调整大小、占满宽度 ---------- */
@media (max-width: 768px) {
    #ai-fab { right: 14px; bottom: 86px; width: 56px; height: 56px; }
    #ai-fab .ai-fab-top { font-size: 17px; }
    #ai-fab .ai-fab-bottom { font-size: 10px; }
    #ai-modal {
        right: 0;
        left: 0;
        bottom: 0;
        top: auto;
        width: 100% !important;
        height: 70vh !important;
        min-width: 0;
        max-height: none;
        border-radius: 14px 14px 0 0;
        resize: none;
    }
    .ai-header { cursor: default; }
}
