/* ============================================================
   枢汇安全课堂 · 在线客服聊天组件样式
   ============================================================ */

/* ---------- 浮动气泡按钮 ---------- */
.cw-bubble {
    position: fixed;
    right: 28px;
    bottom: 28px;
    z-index: 9999;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 28px;
    padding: 12px 22px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(102,126,234,.4);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: transform .2s, box-shadow .2s;
    font-family: inherit;
}
.cw-bubble:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(102,126,234,.5);
}
.cw-bubble-icon { font-size: 18px; }
.cw-dot {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    animation: cwPulse 2s infinite;
}
.cw-dot:empty { display: none; }
@keyframes cwPulse {
    0%,100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* ---------- 聊天窗 ---------- */
.cw-window {
    position: fixed;
    right: 28px;
    bottom: 92px;
    z-index: 9999;
    width: 380px;
    height: 540px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: cwSlideUp .25s ease-out;
}
@keyframes cwSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(.96); }
    to   { opacity: 1; transform: none; }
}

/* 头部 */
.cw-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    flex-shrink: 0;
}
.cw-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.cw-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,.25);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.cw-title {
    font-size: 15px;
    font-weight: 600;
}
.cw-status {
    font-size: 12px;
    opacity: .9;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}
.cw-status-dot {
    width: 7px; height: 7px;
    background: #4ade80;
    border-radius: 50%;
    animation: cwPulse 1.5s infinite;
}
.cw-close {
    background: transparent;
    border: none;
    color: rgba(255,255,255,.9);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background .15s;
}
.cw-close:hover { background: rgba(255,255,255,.2); }

/* 消息区 */
.cw-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8f9fc;
    scroll-behavior: smooth;
}
.cw-messages::-webkit-scrollbar { width: 5px; }
.cw-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }

.cw-msg {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    max-width: 90%;
    animation: cwMsgIn .2s ease-out;
}
@keyframes cwMsgIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}
.cw-msg.bot { flex-direction: row; }
.cw-msg.user { flex-direction: row-reverse; margin-left: auto; }

.cw-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}
.cw-msg.bot .cw-msg-avatar {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
}
.cw-msg.user .cw-msg-avatar {
    background: #e5e7eb;
    color: #334155;
}
.cw-msg-body {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
}
.cw-msg.bot .cw-msg-body {
    background: #fff;
    color: #1e293b;
    border-top-left-radius: 4px;
    box-shadow: 0 2px 6px rgba(0,0,0,.06);
}
.cw-msg.user .cw-msg-body {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border-top-right-radius: 4px;
}
.cw-msg-body a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}
.cw-msg.user .cw-msg-body a { color: #fff; text-decoration: underline; }
.cw-msg-body ul { margin: 6px 0 0 18px; padding: 0; }
.cw-msg-body li { margin-bottom: 2px; }

/* 打字指示 */
.cw-typing {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}
.cw-typing span {
    width: 7px; height: 7px;
    background: #9ca3af;
    border-radius: 50%;
    animation: cwBounce 1.2s infinite;
}
.cw-typing span:nth-child(2) { animation-delay: .2s; }
.cw-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes cwBounce {
    0%,80%,100% { transform: translateY(0); opacity: .4; }
    40% { transform: translateY(-4px); opacity: 1; }
}

/* 快捷问题按钮 */
.cw-quick {
    padding: 10px 12px 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex-shrink: 0;
    background: #fff;
    border-top: 1px solid #f0f0f0;
}
.cw-quick.hidden { display: none; }
.cw-quick-btn {
    padding: 7px 13px;
    border: 1px solid #e5e7eb;
    background: #fff;
    border-radius: 16px;
    font-size: 12.5px;
    color: #475569;
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
}
.cw-quick-btn:hover {
    border-color: #667eea;
    color: #667eea;
    background: #f5f6ff;
}

/* 输入区 */
.cw-input {
    display: flex;
    padding: 10px 12px;
    border-top: 1px solid #f0f0f0;
    background: #fff;
    flex-shrink: 0;
    gap: 8px;
}
.cw-input input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    padding: 9px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color .15s;
    font-family: inherit;
}
.cw-input input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,.1);
}
.cw-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .15s;
    flex-shrink: 0;
}
.cw-send:hover { transform: scale(1.06); }

/* ---------- 移动端 ---------- */
@media (max-width: 768px) {
    .cw-bubble {
        right: 16px;
        bottom: 20px;
        padding: 11px 16px;
        border-radius: 24px;
    }
    .cw-bubble-label { display: none; }
    .cw-bubble-icon { font-size: 22px; }

    .cw-window {
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        animation: cwSlideUpMobile .3s ease-out;
    }
    @keyframes cwSlideUpMobile {
        from { transform: translateY(100%); }
        to   { transform: none; }
    }
    .cw-header { padding: 14px 16px; }
    .cw-title { font-size: 14px; }
    .cw-avatar { width: 36px; height: 36px; font-size: 20px; }
}
