/* ============================================================
   AI 智能客服聊天组件（深蓝风格 / 响应式 / 零依赖）
   ============================================================ */
.cs-fab {
    /* bottom 148px = 避让右下角 .float-consult 浮标组（电话+留言，bottom:20 + 总高116 + 间距12） */
    position: fixed; right: 22px; bottom: 148px; z-index: 1000;
    width: 56px; height: 56px; border-radius: 50%;
    background: #1B3A6B; color: #fff; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 20px rgba(27,58,107,.35);
    transition: transform .2s, background .2s;
}
.cs-fab:hover { background: #F0822A; transform: scale(1.06); }
.cs-fab-badge { position: absolute; top: -2px; right: -2px; width: 14px; height: 14px; background: #F0822A; border-radius: 50%; border: 2px solid #fff; }
/* 未读消息数字角标（窗口关着时收到回复点亮） */
.cs-fab-badge.num { top: -5px; right: -5px; width: auto; min-width: 18px; height: 18px; padding: 0 4px; box-sizing: border-box; font-size: 11px; font-weight: 700; color: #fff; line-height: 14px; display: flex; align-items: center; justify-content: center; border-radius: 9px; animation: csBadgePop .25s ease; }
@keyframes csBadgePop { 0% { transform: scale(.4); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }

.cs-win {
    /* bottom 216px = 客服按钮148 + 按钮高56 + 间距12；max-height 同步收紧防小屏顶出 */
    position: fixed; right: 22px; bottom: 216px; z-index: 1001;
    width: 380px; max-width: calc(100vw - 24px); height: 560px; max-height: calc(100vh - 240px);
    background: #fff; border-radius: 14px; overflow: hidden;
    box-shadow: 0 12px 40px rgba(20,44,82,.28);
    display: flex; flex-direction: column;
    opacity: 0; transform: translateY(16px); pointer-events: none;
    transition: opacity .22s, transform .22s;
}
.cs-win.open { opacity: 1; transform: translateY(0); pointer-events: auto; }

.cs-head { background: #1B3A6B; color: #fff; padding: 12px 14px; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.cs-head-avatar { width: 38px; height: 38px; border-radius: 50%; background: #F0822A; display: flex; align-items: center; justify-content: center; font-weight: 700; overflow: hidden; flex-shrink: 0; }
.cs-head-avatar img { width: 100%; height: 100%; object-fit: cover; }
.cs-head-info { flex: 1; min-width: 0; }
.cs-head-name { font-size: 15px; font-weight: 600; }
.cs-head-status { font-size: 12px; opacity: .8; }
.cs-head-actions { display: flex; gap: 6px; }
.cs-head-btn { background: rgba(255,255,255,.14); border: none; color: #fff; border-radius: 8px; padding: 5px 10px; font-size: 12px; cursor: pointer; }
.cs-head-btn:hover { background: #F0822A; }

.cs-body { flex: 1; overflow-y: auto; padding: 14px; background: #F5F7FA; display: flex; flex-direction: column; gap: 10px; }
.cs-msg { display: flex; gap: 8px; max-width: 88%; }
.cs-msg.ai { align-self: flex-start; }
.cs-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.cs-msg-avatar { width: 30px; height: 30px; border-radius: 50%; background: #1B3A6B; color: #fff; font-size: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; }
.cs-msg-avatar img { width: 100%; height: 100%; object-fit: cover; }
.cs-msg.user .cs-msg-avatar { background: #8A94A6; }
.cs-bubble { border-radius: 10px; padding: 9px 13px; font-size: 14px; line-height: 1.65; word-break: break-word; }
.cs-msg.ai .cs-bubble { background: #fff; color: #2B3445; border: 1px solid #E3E8F0; border-top-left-radius: 2px; }
.cs-msg.user .cs-bubble { background: #1B3A6B; color: #fff; border-top-right-radius: 2px; }
.cs-bubble + .cs-media-list { margin-top: 6px; }

/* 富媒体（图片缩略图/视频/外链卡片） */
.cs-media-list { display: flex; flex-direction: column; gap: 8px; max-width: 260px; }
.cs-media-img { border-radius: 8px; overflow: hidden; cursor: zoom-in; border: 1px solid #E3E8F0; background: #fff; }
.cs-media-img img { width: 100%; display: block; }
.cs-media-cap { font-size: 12px; color: #6B7688; padding: 4px 6px; background: #fff; }
/* 视频缩略图（点击弹窗播放，站内不跳转） */
.cs-video-thumb { position: relative; border-radius: 8px; overflow: hidden; background: #0B1526; cursor: pointer; border: 1px solid #E3E8F0; }
.cs-video-thumb img, .cs-video-thumb video { width: 100%; display: block; aspect-ratio: 16/9; object-fit: cover; pointer-events: none; }
.cs-video-thumb video { background: #000; }
.cs-video-play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(10,20,40,.18); transition: background .2s; }
.cs-video-play svg { width: 22px; height: 22px; color: #fff; background: rgba(27,58,107,.85); border-radius: 50%; padding: 12px; box-sizing: content-box; box-shadow: 0 4px 14px rgba(0,0,0,.35); transition: transform .2s, background .2s; }
.cs-video-thumb:hover .cs-video-play { background: rgba(10,20,40,.05); }
.cs-video-thumb:hover .cs-video-play svg { transform: scale(1.12); background: #F0822A; }
.cs-media-ext { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid #E3E8F0; border-radius: 8px; padding: 10px 12px; }
.cs-media-ext .play { width: 36px; height: 36px; border-radius: 50%; background: #F0822A; color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 14px; }
.cs-media-ext .t { font-size: 13px; color: #1B3A6B; font-weight: 600; line-height: 1.4; }
.cs-media-ext .s { font-size: 11px; color: #8A94A6; }
a.cs-media-ext:hover { border-color: #F0822A; }

/* 打字中动画 */
.cs-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.cs-typing i { width: 7px; height: 7px; border-radius: 50%; background: #B6C2D6; animation: csBounce 1.2s infinite; }
.cs-typing i:nth-child(2) { animation-delay: .15s; }
.cs-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes csBounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }

/* 输入区 */
.cs-foot { border-top: 1px solid #E3E8F0; padding: 10px; display: flex; gap: 8px; align-items: flex-end; background: #fff; flex-shrink: 0; }
.cs-input { flex: 1; border: 1px solid #E3E8F0; border-radius: 10px; padding: 10px 12px; font-size: 14px; font-family: inherit; resize: none; min-height: 52px; max-height: 110px; line-height: 1.5; }
.cs-input:focus { outline: none; border-color: #1B3A6B; }
.cs-send { background: #F0822A; color: #fff; border: none; border-radius: 10px; padding: 10px 18px; font-size: 14px; font-weight: 600; cursor: pointer; flex-shrink: 0; }
.cs-send:hover { background: #D06F1F; }
.cs-send:disabled { opacity: .5; cursor: not-allowed; }

/* 留资预约表单（Modal 内部） */
.cs-lead-form .form-group { margin-bottom: 12px; }
.cs-lead-form label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: #2B3445; }
.cs-lead-form .form-input { width: 100%; border: 1px solid #E3E8F0; border-radius: 8px; padding: 9px 12px; font-size: 14px; font-family: inherit; }
.cs-lead-form .form-input:focus { outline: none; border-color: #1B3A6B; }
.cs-lead-tip { font-size: 12px; color: #8A94A6; margin-bottom: 12px; line-height: 1.6; }

/* 图片放大预览 */
/* 媒体灯箱：图片/视频站内弹窗预览，遮罩/✕/ESC 关闭 */
.cs-lightbox { position: fixed; inset: 0; z-index: 1200; background: rgba(10,20,40,.85); display: flex; align-items: center; justify-content: center; padding: 20px; animation: csLbFade .18s ease; }
@keyframes csLbFade { from { opacity: 0; } to { opacity: 1; } }
.cs-lb-box { max-width: 96vw; max-height: 92vh; display: flex; align-items: center; justify-content: center; }
.cs-lightbox img { max-width: 96vw; max-height: 92vh; border-radius: 8px; }
.cs-lightbox video { max-width: 92vw; max-height: 86vh; width: min(860px, 92vw); border-radius: 10px; background: #000; box-shadow: 0 18px 60px rgba(0,0,0,.5); outline: none; }
/* 平台视频内嵌播放器（B站/腾讯/优酷，站内播放不跳转） */
.cs-lightbox iframe.cs-lb-iframe { width: min(920px, 94vw); height: min(580px, 78vh); border: none; border-radius: 10px; background: #000; box-shadow: 0 18px 60px rgba(0,0,0,.5); }
/* 无封面平台视频缩略占位底 */
.cs-video-ph { width: 100%; aspect-ratio: 16/9; background: linear-gradient(135deg, #142542 0%, #0B1526 100%); }
.cs-lb-close { position: absolute; top: 16px; right: 16px; width: 38px; height: 38px; border-radius: 50%; border: none; background: rgba(255,255,255,.16); color: #fff; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .2s; }
.cs-lb-close:hover { background: #F0822A; }

@media (max-width: 640px) {
    .cs-win { right: 8px; left: 8px; bottom: 212px; width: auto; max-width: none; height: 60vh; }
    .cs-fab { right: 14px; bottom: 148px; }
}

/* ---------- 留资弹窗/提示（挂件自绘，站点无全局UI组件时兜底） ---------- */
.cs-toast { position: fixed; top: 76px; left: 50%; transform: translateX(-50%) translateY(-8px); z-index: 100002; padding: 10px 20px; border-radius: 8px; font-size: 14px; color: #fff; background: #2B3445; box-shadow: 0 6px 24px rgba(0,0,0,.18); opacity: 0; transition: opacity .3s, transform .3s; max-width: 86vw; text-align: center; pointer-events: none; }
.cs-toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }
.cs-toast-success { background: #15803D; }
.cs-toast-error { background: #DC2626; }
.cs-toast-warning { background: #D97706; }

.cs-modal-overlay { position: fixed; inset: 0; z-index: 100001; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; padding: 16px; opacity: 0; transition: opacity .2s; }
.cs-modal-show { opacity: 1; }
.cs-modal { width: 400px; max-width: 100%; max-height: 86vh; overflow-y: auto; background: #fff; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.cs-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px 13px; border-bottom: 1px solid #EEF1F6; font-size: 16px; font-weight: 700; color: #1B3A6B; }
.cs-modal-x { border: none; background: none; font-size: 22px; line-height: 1; color: #8A94A6; cursor: pointer; padding: 0 2px; }
.cs-modal-x:hover { color: #2B3445; }
.cs-modal-body { padding: 16px 18px 6px; }
.cs-modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 10px 18px 16px; }
.cs-modal-btn { border-radius: 8px; padding: 9px 20px; font-size: 14px; cursor: pointer; border: 1px solid #E3E8F0; background: #fff; color: #2B3445; font-family: inherit; }
.cs-modal-btn:hover { border-color: #C6CEDA; }
.cs-modal-ok { background: #1B3A6B; border-color: #1B3A6B; color: #fff; font-weight: 600; }
.cs-modal-ok:hover { background: #15305A; border-color: #15305A; }
@media (max-width: 640px) {
    .cs-modal-overlay { align-items: flex-end; padding: 0; }
    .cs-modal { width: 100%; max-width: none; border-radius: 14px 14px 0 0; max-height: 80vh; }
}
