/* ========================================
   广州市佳宏化工有限公司 - 在线客服系统
   风格：蓝白工业B2B，统一橙色高亮
   布局：右下角垂直2个橙色圆形悬浮按钮
   ======================================== */

/* ---------- 右下角悬浮按钮组 ---------- */
.kefu-float-wrap {
    position: fixed;
    right: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 9998;
}

.kefu-float-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f97316, #ea580c);
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(249, 115, 22, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
    position: relative;
    flex-direction: column;
    padding: 0;
    line-height: 1;
}

.kefu-float-btn i {
    font-size: 22px;
    line-height: 1;
}

.kefu-float-label {
    font-size: 10px;
    margin-top: 2px;
    line-height: 1;
    letter-spacing: 0.5px;
}

.kefu-float-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(249, 115, 22, 0.5);
    background: linear-gradient(135deg, #ea580c, #c2410c);
}

.kefu-float-btn:active {
    transform: translateY(0);
}

/* 移动端放大尺寸避免误触 */
@media (max-width: 768px) {
    .kefu-float-wrap {
        right: 16px;
        bottom: 16px;
        gap: 10px;
    }

    .kefu-float-btn {
        width: 58px;
        height: 58px;
        font-size: 22px;
    }

    .kefu-float-btn i {
        font-size: 22px;
    }

    .kefu-float-label {
        font-size: 10px;
    }
}

/* ---------- 聊天弹窗容器 ---------- */
.kefu-modal {
    position: fixed;
    right: 20px;
    bottom: 100px;
    width: 380px;
    height: 540px;
    max-height: calc(100vh - 50px);
    top: auto;
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(15, 23, 42, 0.06);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
}

.kefu-modal.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.kefu-modal.minimized {
    height: 56px;
    min-height: 56px;
}

.kefu-modal.minimized .kefu-body,
.kefu-modal.minimized .kefu-footer {
    display: none;
}

/* ---------- 弹窗顶部 ---------- */
.kefu-header {
    background: linear-gradient(135deg, #0f172a, #1e3a5f);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    flex-shrink: 0;
}

.kefu-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.kefu-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f97316, #ea580c);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
    flex-shrink: 0;
}

.kefu-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.kefu-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
}

.kefu-status {
    font-size: 11px;
    color: #86efac;
    display: flex;
    align-items: center;
    gap: 4px;
}

.kefu-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22c55e;
    animation: kefu-pulse 2s ease-in-out infinite;
}

@keyframes kefu-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.kefu-header-actions {
    display: flex;
    gap: 4px;
}

.kefu-min-btn,
.kefu-close-btn {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    line-height: 1;
    padding: 0;
}

.kefu-min-btn:hover,
.kefu-close-btn:hover {
    background: rgba(255, 255, 255, 0.22);
}

/* ---------- 聊天内容区 ---------- */
.kefu-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafc;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

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

.kefu-body::-webkit-scrollbar-track {
    background: transparent;
}

.kefu-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.kefu-body::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ---------- 消息气泡 ---------- */
.kefu-msg {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    animation: kefu-fade-in 0.3s ease;
}

@keyframes kefu-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.kefu-msg.bot {
    align-items: flex-start;
}

.kefu-msg.user {
    flex-direction: row-reverse;
    align-items: flex-start;
}

.kefu-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.kefu-msg.bot .kefu-msg-avatar {
    background: linear-gradient(135deg, #0f172a, #1e3a5f);
    color: #fff;
}

.kefu-msg.user .kefu-msg-avatar {
    background: linear-gradient(135deg, #f97316, #ea580c);
    color: #fff;
}

.kefu-msg-content {
    max-width: 85%;
}

.kefu-msg-text {
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13.5px;
    line-height: 1.65;
    word-wrap: break-word;
}

.kefu-msg.bot .kefu-msg-text {
    background: #ffffff;
    color: #1e293b;
    border-top-left-radius: 2px;
    border: 1px solid #e2e8f0;
}

.kefu-msg.user .kefu-msg-text {
    background: linear-gradient(135deg, #f97316, #ea580c);
    color: #fff;
    border-top-right-radius: 2px;
}

.kefu-msg-time {
    font-size: 10.5px;
    color: #94a3b8;
    margin-top: 4px;
    text-align: left;
}

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

/* ---------- 欢迎卡片（快捷按钮） ---------- */
.kefu-quick-cards {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kefu-quick-btn {
    width: 100%;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #1e293b;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
    line-height: 1.4;
    box-sizing: border-box;
    font-family: inherit;
}

.kefu-quick-btn i {
    color: #f97316;
    font-size: 14px;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.kefu-quick-btn:hover {
    background: linear-gradient(135deg, #fff7ed, #ffedd5);
    border-color: #f97316;
    color: #ea580c;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.15);
}

.kefu-quick-btn:active {
    transform: translateY(0);
}

/* ---------- 底部输入区域 ---------- */
.kefu-footer {
    padding: 12px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.kefu-input-wrap {
    display: flex;
    gap: 8px;
}

.kefu-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
    background: #f8fafc;
    color: #1e293b;
    box-sizing: border-box;
}

.kefu-input:focus {
    border-color: #f97316;
    background: #fff;
}

.kefu-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: linear-gradient(135deg, #f97316, #ea580c);
    border: none;
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 0;
}

.kefu-send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(249, 115, 22, 0.4);
}

.kefu-send-btn:active {
    transform: translateY(0);
}

/* ---------- 离线留言表单 ---------- */
.kefu-offline-form {
    padding: 14px;
    background: #fff;
}

.kefu-offline-title {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.kefu-offline-title i {
    color: #f97316;
}

.kefu-offline-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    font-size: 13px;
    font-family: inherit;
    margin-bottom: 8px;
    outline: none;
    background: #f8fafc;
    color: #1e293b;
    box-sizing: border-box;
    transition: border-color 0.2s ease;
}

.kefu-offline-input:focus {
    border-color: #f97316;
    background: #fff;
}

textarea.kefu-offline-input {
    resize: vertical;
    min-height: 80px;
    max-height: 130px;
}

.kefu-offline-submit {
    width: 100%;
    padding: 11px;
    background: linear-gradient(135deg, #f97316, #ea580c);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 4px;
    font-family: inherit;
}

.kefu-offline-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(249, 115, 22, 0.4);
}

.kefu-offline-back {
    width: 100%;
    margin-top: 8px;
    padding: 9px;
    background: transparent;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    color: #64748b;
    font-size: 12.5px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.kefu-offline-back:hover {
    background: #f8fafc;
    color: #1e293b;
    border-color: #cbd5e1;
}

/* ---------- Toast提示 ---------- */
.kefu-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(15, 23, 42, 0.92);
    color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 13.5px;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 320px;
    text-align: center;
    line-height: 1.5;
}

.kefu-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

/* ---------- 移动端适配弹窗 ---------- */
@media (max-width: 768px) {
    .kefu-modal {
        right: 10px;
        left: 10px;
        bottom: 150px;
        width: auto;
        height: 60vh;
        max-height: 520px;
    }

    .kefu-min-btn {
        display: none;
    }

    .kefu-title {
        font-size: 14px;
    }

    .kefu-msg-text {
        font-size: 13px;
        padding: 9px 12px;
    }

    .kefu-quick-btn {
        font-size: 12.5px;
        padding: 9px 12px;
    }
}

/* 小屏幕优化 */
@media (max-width: 480px) {
    .kefu-modal {
        right: 8px;
        left: 8px;
        bottom: 140px;
        height: 55vh;
    }

    .kefu-header {
        padding: 12px;
    }

    .kefu-body {
        padding: 12px;
    }

    .kefu-footer {
        padding: 10px;
    }
}
