/*!
 * 客服聊天组件 H5 端样式
 * 配色：蓝(#136ad5) + 绿(#36cc70)
 * ----------------------------------------------------------------------------
 */

/* ===== 悬浮按钮 ===== */
.kefu-fab {
    position: fixed;
    right: 80px;
    bottom: 80px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 99998;
    transition: transform 0.2s;
}

.kefu-fab:hover {
    transform: translateY(-2px) scale(1.05);
}

/* 客服头像图片 */
.kefu-fab-img {
    position: relative;
    z-index: 2;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    box-shadow: 0 4px 12px rgba(19, 106, 213, 0.4);
}

/* 波浪扩散动画 - 两层叠加错开时间 */
.kefu-fab .kefu-ripple {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(19, 106, 213, 0.35);
    z-index: 1;
    animation: kefu-ripple 2s ease-out infinite;
}

.kefu-fab .kefu-ripple-2 {
    animation-delay: 1s;
    background: rgba(19, 106, 213, 0.22);
}

@keyframes kefu-ripple {
    0% {
        transform: scale(1);
        opacity: 0.75;
    }
    100% {
        transform: scale(2.4);
        opacity: 0;
    }
}

/* 鼠标悬停时波浪加快加强 */
.kefu-fab:hover .kefu-ripple {
    animation-duration: 1.4s;
    background: rgba(19, 106, 213, 0.5);
}

/* 在线指示点 */
.kefu-fab .online-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #36cc70;
    border: 2px solid #fff;
    box-sizing: content-box;
    z-index: 3;
}

/* 未读角标 */
.kefu-fab .unread-badge {
    position: absolute;
    top: -4px;
    left: -4px;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #ff5e00;
    color: #fff;
    font-size: 11px;
    text-align: center;
    border: 2px solid #fff;
    box-sizing: content-box;
    z-index: 4;
}

/* ===== 聊天窗口 ===== */
.kefu-window {
    position: fixed;
    right: 80px;
    bottom: 80px;
    width: 360px;
    height: 520px;
    max-height: calc(100vh - 100px);
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    z-index: 99999;
    display: none;
    flex-direction: column;
}

.kefu-window.open {
    display: flex;
}

/* ===== 头部 ===== */
.kefu-header {
    height: 48px;
    padding: 0 15px;
    background: linear-gradient(135deg, #136ad5 0%, #0e5bb8 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.kefu-header .title {
    font-size: 16px;
    font-weight: 500;
}

.kefu-header .close {
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    opacity: 0.85;
    transition: opacity 0.15s;
        border: 0;
}

.kefu-header .close:hover {
    opacity: 1;
}

/* ===== 消息区 ===== */
.kefu-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f5f5f5;
}

.kefu-messages::-webkit-scrollbar {
    width: 6px;
}

.kefu-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.kefu-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.kefu-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* ===== 消息行 ===== */
.kefu-msg-row {
    display: flex;
    margin-bottom: 12px;
    align-items: flex-start;
}

.kefu-msg-row.system {
    justify-content: center;
}

.kefu-msg-row.kefu {
    justify-content: flex-start;
}

.kefu-msg-row.customer {
    justify-content: flex-end;
}

/* 系统消息气泡（浅灰色居中） */
.kefu-msg-row.system .kefu-msg-bubble {
    background: #e8e8e8;
    color: #888;
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 12px;
    max-width: 80%;
    text-align: center;
    margin: 8px 0;
}

/* 头像 */
.kefu-msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    flex-shrink: 0;
}

.kefu-msg-row.kefu .kefu-msg-avatar {
    background: #136ad5;
    margin-right: 8px;
}

.kefu-msg-row.customer .kefu-msg-avatar {
    background: #36cc70;
    margin-left: 8px;
}

/* 消息内容容器 */
.kefu-msg-content {
    max-width: 70%;
    min-width: 0;
}

/* 消息气泡 */
.kefu-msg-bubble {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-all;
}

.kefu-msg-row.kefu .kefu-msg-bubble {
    background: #fff;
    color: #333;
    border: 1px solid #e5e7eb;
}

.kefu-msg-row.customer .kefu-msg-bubble {
    background: #136ad5;
    color: #fff;
}

/* 消息时间 */
.kefu-msg-time {
    font-size: 11px;
    color: #aaa;
    margin-top: 4px;
}

.kefu-msg-row.kefu .kefu-msg-time {
    text-align: left;
}

.kefu-msg-row.customer .kefu-msg-time {
    text-align: right;
}

/* ===== 输入区 ===== */
.kefu-input-area {
    border-top: 1px solid #f0f0f0;
    background: #fff;
    flex-shrink: 0;
}

.kefu-toolbar {
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
    position: relative;
}

.kefu-emoji-trigger {
    font-size: 20px;
    cursor: pointer;
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s;
}

.kefu-emoji-trigger:hover {
    background: #f0f7ff;
}

/* 表情面板 */
.kefu-emoji-panel {
    display: none;
    position: absolute;
    bottom: 140px;
    left: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    padding: 8px;
    width: 260px;
    max-height: 180px;
    overflow-y: auto;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 100;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
}

.kefu-emoji-panel.show {
    display: grid;
}

.kefu-emoji-panel span {
    display: flex;
    align-items: center;
    float: left;
    justify-content: center;
    width: 36px;
    height: 36px;
    font-size: 22px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s;
}

.kefu-emoji-panel span:hover {
    background: #f0f0f0;
}

/* 输入行 */
.kefu-input-row {
    display: flex;
    align-items: stretch;
    padding: 10px 12px;
}

.kefu-input-row textarea {
    flex: 1;
    height: 60px;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: 8px 10px;
    resize: none;
    font-family: inherit;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
}

.kefu-input-row textarea:focus {
    border-color: #136ad5;
}

.kefu-input-row .send-btn {
    margin-left: 8px;
    padding: 0 18px;
    background: #136ad5;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.15s;
}

.kefu-input-row .send-btn:hover {
    background: #0e5bb8;
}

.kefu-input-row .send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* ===== 底部版权 ===== */
.kefu-footer {
    height: 28px;
    background: #f9f9f9;
    color: #999;
    font-size: 11px;
    text-align: center;
    line-height: 28px;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}

/* ===== 移动端响应式 ===== */
@media (max-width: 480px) {
    .kefu-fab {
        right: 16px;
        bottom: 70px;
        width: 48px;
        height: 48px;
    }

    .kefu-fab-img {
        width: 48px;
        height: 48px;
    }

    .kefu-window {
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
}