/* ===================== TOPPLA AI 客服挂件样式（天空蓝品牌色 #66C0EE） ===================== */
#ai-chat-root { font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; }

/* 悬浮按钮：PC 端右侧垂直居中 */
.aiw-fab {
    position: fixed; right: 22px; top: 50%; z-index: 99998;
    width: 60px; height: 60px; border-radius: 50%;
    background: linear-gradient(135deg, #2FA3DC, #66C0EE);
    box-shadow: 0 6px 20px rgba(47, 163, 220, .38);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: transform .2s ease, box-shadow .2s ease;
    transform: translateY(-50%) scale(1);
}
.aiw-fab:hover { transform: translateY(-50%) scale(1.06); box-shadow: 0 10px 28px rgba(47, 163, 220, .5); }
.aiw-fab-avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background:#fff; }
.aiw-fab-badge {
    position: absolute; top: -4px; right: -4px; background: #ff4757; color: #fff;
    font-size: 11px; line-height: 1; padding: 3px 6px; border-radius: 10px; border: 2px solid #fff;
}
.aiw-fab-hidden { display: none; }

/* 聊天面板：PC 端在按钮左侧垂直居中 */
.aiw-panel {
    position: fixed; right: 92px; top: 50%; z-index: 99999;
    width: 372px; height: 560px; max-height: calc(100vh - 40px);
    background: #fff; border-radius: 16px; overflow: hidden;
    box-shadow: 0 12px 48px rgba(0, 0, 0, .22);
    display: flex; flex-direction: column;
    transform: translateY(-48%) scale(.98); opacity: 0; pointer-events: none;
    transition: transform .22s ease, opacity .22s ease;
}
.aiw-panel.aiw-open { transform: translateY(-50%) scale(1); opacity: 1; pointer-events: auto; }

/* 头部 */
.aiw-header {
    background: linear-gradient(135deg, #2FA3DC, #66C0EE); color: #fff;
    padding: 14px 16px; display: flex; align-items: center; gap: 12px; flex-shrink: 0;
}
.aiw-avatar { width: 42px; height: 42px; border-radius: 50%; background: #fff; object-fit: cover; }
.aiw-head-text { flex: 1; min-width: 0; }
.aiw-name { font-size: 15px; font-weight: 600; }
.aiw-status { font-size: 12px; opacity: .85; margin-top: 2px; }
.aiw-close {
    background: rgba(255,255,255,.18); border: none; color: #fff; width: 28px; height: 28px;
    border-radius: 50%; font-size: 18px; line-height: 1; cursor: pointer; flex-shrink: 0;
}
.aiw-close:hover { background: rgba(255,255,255,.32); }

/* 消息区 */
.aiw-body { flex: 1; overflow-y: auto; padding: 16px; background: #f5f7fa; }
.aiw-msg { max-width: 82%; margin-bottom: 12px; padding: 10px 13px; border-radius: 14px; font-size: 14px; line-height: 1.6; word-break: break-word; white-space: pre-wrap; }
.aiw-msg-bot { background: #fff; color: #222; border-top-left-radius: 4px; align-self: flex-start; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.aiw-msg-user { background: linear-gradient(135deg, #2FA3DC, #66C0EE); color: #fff; border-top-right-radius: 4px; margin-left: auto; }
.aiw-row { display: flex; flex-direction: column; }
.aiw-row-user { align-items: flex-end; }
.aiw-row-bot { align-items: flex-start; }
.aiw-typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.aiw-typing span { width: 7px; height: 7px; border-radius: 50%; background: #bbb; animation: aiw-blink 1.2s infinite both; }
.aiw-typing span:nth-child(2) { animation-delay: .2s; }
.aiw-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes aiw-blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

/* 转人工卡片 */
.aiw-handover {
    background: #fff7e6; border: 1px solid #ffd591; border-radius: 12px; padding: 12px 14px;
    margin: 4px 0 12px; font-size: 13px; line-height: 1.7; color: #614700;
}
.aiw-handover b { color: #d4380d; }
.aiw-handover a { color: #2FA3DC; font-weight: 600; }

/* 输入栏 */
.aiw-inputbar { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid #eee; background: #fff; flex-shrink: 0; }
.aiw-inputbar input {
    flex: 1; border: 1px solid #d9e1ec; border-radius: 20px; padding: 9px 14px; font-size: 14px; outline: none;
}
.aiw-inputbar input:focus { border-color: #66C0EE; }
.aiw-inputbar button {
    background: linear-gradient(135deg, #2FA3DC, #66C0EE); color: #fff; border: none;
    border-radius: 20px; padding: 0 18px; font-size: 14px; cursor: pointer; flex-shrink: 0;
}
.aiw-inputbar button:active { opacity: .85; }
.aiw-foot { text-align: center; font-size: 11px; color: #9aa5b1; padding: 6px 0 8px; background: #fff; flex-shrink: 0; }

/* ===================== 移动端适配 ===================== */
@media (max-width: 640px) {
    .aiw-fab { right: 16px; bottom: 18px; top: auto; width: 56px; height: 56px; transform: none; }
    .aiw-fab:hover { transform: scale(1.06); }
    .aiw-fab-avatar { width: 40px; height: 40px; }
    .aiw-panel {
        right: 0; left: 0; bottom: 0; top: auto; width: 100%; height: 84vh; max-height: 84vh;
        border-radius: 16px 16px 0 0;
        transform: translateY(20px) scale(.98);
    }
    .aiw-panel.aiw-open { transform: translateY(0) scale(1); }
}
