/* ============================================================
   在线咨询浮动组件 · 独立打包版（移植至 99727 网站）
   类名统一使用 cwk- 前缀，避免与宿主网站样式冲突
   主题色已适配网站橙黄风格（#1f2937）
   电脑端 + 手机端均已适配（见文末 @media 480px）
   ============================================================ */
#cwk-root .cwk {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9999;
    --cwk-theme: #1f2937;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    line-height: 1.5;
}
#cwk-root .cwk *, #cwk-root .cwk *::before, #cwk-root .cwk *::after { box-sizing: border-box; }

@keyframes cwkBreathe {
    0%, 100% {
        box-shadow: 0 8px 28px rgba(31, 41, 55, 0.35), 0 0 0 0 rgba(31, 41, 55, 0.25);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 12px 36px rgba(31, 41, 55, 0.5), 0 0 0 12px rgba(31, 41, 55, 0);
        transform: scale(1.06);
    }
}

#cwk-root .cwk-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: var(--cwk-theme);
    color: #fff;
    box-shadow: 0 8px 28px rgba(31, 41, 55, 0.35);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    animation: cwkBreathe 2.6s ease-in-out infinite;
    position: relative;
}

#cwk-root .cwk.active .cwk-toggle { animation-play-state: paused; }
#cwk-root .cwk-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 10px 32px rgba(31, 41, 55, 0.45);
}
#cwk-root .cwk-toggle svg {
    width: 28px;
    height: 28px;
    position: absolute;
    transition: all 0.3s ease;
}
#cwk-root .cwk-icon-open { opacity: 1; transform: rotate(0deg) scale(1); }
#cwk-root .cwk-icon-close { opacity: 0; transform: rotate(-90deg) scale(0.6); }
#cwk-root .cwk.active .cwk-icon-open { opacity: 0; transform: rotate(90deg) scale(0.6); }
#cwk-root .cwk.active .cwk-icon-close { opacity: 1; transform: rotate(0deg) scale(1); }

#cwk-root .cwk-panel {
    position: absolute;
    right: 0;
    bottom: 76px;
    width: 360px;
    max-width: calc(100vw - 48px);
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#cwk-root .cwk.active .cwk-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

#cwk-root .cwk-header {
    padding: 18px 20px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #1f2937 0%, #9ca3af 100%);
}
#cwk-root .cwk-title { font-size: 1.1rem; font-weight: 700; }
#cwk-root .cwk-close {
    width: 32px; height: 32px; border-radius: 50%; border: none;
    background: rgba(255,255,255,0.25); color: #fff;
    font-size: 1.4rem; line-height: 1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s;
}
#cwk-root .cwk-close:hover { background: rgba(255,255,255,0.4); }

#cwk-root .cwk-body { padding: 20px; max-height: 70vh; overflow-y: auto; }

#cwk-root .cwk-agent {
    display: flex; align-items: center; gap: 14px;
    margin-bottom: 20px; padding-bottom: 18px;
    border-bottom: 1px solid #f0f0f5;
}
#cwk-root .cwk-agent-avatar {
    width: 54px; height: 54px; border-radius: 50%;
    object-fit: cover; flex-shrink: 0;
}
#cwk-root .cwk-agent-initial {
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 1.4rem; font-weight: 700;
}
#cwk-root .cwk-agent-name { font-weight: 700; font-size: 1.05rem; color: #1f2937; }
#cwk-root .cwk-agent-subtitle { font-size: 0.85rem; color: #64748b; margin-top: 2px; }

#cwk-root .cwk-methods { display: flex; flex-direction: column; gap: 10px; }
#cwk-root .cwk-method {
    position: relative;
    display: flex; align-items: center; gap: 10px;
    padding: 12px; border-radius: 14px;
    background: #f8f7fc;
    text-decoration: none; color: inherit;
    transition: all 0.2s ease; cursor: pointer;
}
#cwk-root .cwk-method:hover { background: #eef0f3; transform: translateX(-3px); }
#cwk-root .cwk-method.has-qr::after {
    content: '';
    position: absolute; left: 0; bottom: 0;
    width: 0; height: 3px;
    background: var(--cwk-theme);
    border-radius: 0 0 0 14px;
    transition: width 0.2s ease;
}
#cwk-root .cwk-method.has-qr:hover::after { width: 40%; }

#cwk-root .cwk-method-icon {
    width: 40px; height: 40px; border-radius: 11px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
#cwk-root .cwk-method-icon svg { width: 22px; height: 22px; }
#cwk-root .cwk-method-content { flex: 1; min-width: 0; }
#cwk-root .cwk-method-label { font-size: 0.75rem; color: #64748b; margin-bottom: 1px; }
#cwk-root .cwk-method-value {
    font-size: 0.95rem; font-weight: 600; color: #1f2937;
    display: flex; align-items: center; gap: 6px; min-width: 0;
}
#cwk-root .cwk-method-value .cm-text {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
/* 邮箱强制单行完整显示 */
#cwk-root .email-method .cwk-method-value { overflow: visible; }
#cwk-root .email-method .cwk-method-value .cm-text {
    white-space: nowrap; overflow: visible; text-overflow: clip; font-size: 0.88rem;
}
#cwk-root .email-method .cwk-method-copy { width: 20px; height: 20px; }
#cwk-root .email-method .cwk-method-action { padding: 4px 8px; font-size: 0.7rem; }

#cwk-root .cwk-method-copy {
    width: 22px; height: 22px; border: none; background: transparent;
    color: #94a3b8; cursor: pointer; padding: 3px; border-radius: 5px;
    display: inline-flex; align-items: center; justify-content: center;
    transition: all 0.2s ease; flex-shrink: 0;
}
#cwk-root .cwk-method-copy:hover { background: #f1f5f9; color: var(--cwk-theme); }
#cwk-root .cwk-method-copy svg { width: 14px; height: 14px; }

#cwk-root .cwk-method-action {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 0.75rem; font-weight: 600; color: var(--cwk-theme);
    padding: 6px 12px; border-radius: 20px;
    background: rgba(31, 41, 55, 0.08);
    flex-shrink: 0; transition: all 0.2s ease;
}
#cwk-root .cwk-method-action svg { width: 14px; height: 14px; }
#cwk-root .cwk-method:hover .cwk-method-action { background: var(--cwk-theme); color: #fff; }

/* 左侧悬浮二维码预览（仅电脑端 hover 显示） */
#cwk-root .cwk-qr-float {
    position: absolute;
    top: 0;
    right: calc(100% + 14px);
    width: 170px;
    padding: 12px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    opacity: 0;
    pointer-events: none;
    transform: translateX(10px) translateY(-50%) scale(0.95);
    transform-origin: right center;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 100;
    text-align: center;
    cursor: pointer;
}
#cwk-root .cwk-qr-float:hover { box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2); }
#cwk-root .cwk-qr-float.active {
    opacity: 1; pointer-events: auto;
    transform: translateX(0) translateY(-50%) scale(1);
}
#cwk-root .cwk-qr-float::after {
    content: '';
    position: absolute; right: -6px; top: 50%;
    transform: translateY(-50%);
    width: 0; height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 6px solid #fff;
}
#cwk-root .cwk-qr-float img {
    width: 100%; height: auto; border-radius: 10px;
    border: 1px solid #f0f0f5; display: block;
}
#cwk-root .cwk-qr-float p { margin: 8px 0 0; font-size: 0.7rem; color: #94a3b8; }

/* QR 弹窗 */
.cwk-modal {
    position: fixed; inset: 0; z-index: 10000;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    line-height: 1.5;
}
.cwk-modal *, .cwk-modal *::before, .cwk-modal *::after { box-sizing: border-box; }
.cwk-modal.active { opacity: 1; pointer-events: auto; }
.cwk-modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); }
.cwk-modal-content {
    position: relative; background: #fff; border-radius: 24px;
    padding: 28px 24px 24px; width: 100%; max-width: 360px;
    text-align: center; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.25);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.cwk-modal.active .cwk-modal-content { transform: scale(1); }
.cwk-modal-close {
    position: absolute; top: 14px; right: 14px;
    width: 32px; height: 32px; border-radius: 50%; border: none;
    background: #f3f4f6; color: #64748b; font-size: 1.5rem; line-height: 1;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s ease;
}
.cwk-modal-close:hover { background: #e5e7eb; color: #374151; }
.cwk-modal-brand { margin-bottom: 14px; }
.cwk-modal-brand-icon {
    width: 64px; height: 64px; border-radius: 50%; margin: 0 auto;
    display: flex; align-items: center; justify-content: center;
    color: #fff; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.cwk-modal-brand-icon svg { width: 34px; height: 34px; }
.cwk-modal-title { font-size: 1.25rem; font-weight: 700; color: #1f2937; margin-bottom: 6px; }
.cwk-modal-subtitle { font-size: 0.9rem; color: #64748b; margin-bottom: 20px; line-height: 1.5; }
.cwk-modal-qr {
    width: 220px; height: 220px; margin: 0 auto 16px;
    border-radius: 18px; overflow: hidden; border: 1px solid #f0f0f5;
    background: #fff; padding: 10px; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}
.cwk-modal-qr img { width: 100%; height: 100%; object-fit: contain; border-radius: 10px; }
.cwk-modal-hint { font-size: 0.85rem; color: #94a3b8; margin-bottom: 4px; }
.cwk-modal-id { font-size: 1.15rem; font-weight: 700; color: #1f2937; margin-bottom: 20px; word-break: break-all; }
.cwk-modal-actions { display: flex; flex-direction: row; gap: 10px; }
.cwk-copy-btn, .cwk-open-btn {
    flex: 1; padding: 13px 16px; border: none; border-radius: 14px;
    font-size: 0.95rem; font-weight: 600; cursor: pointer;
    transition: all 0.2s ease; text-decoration: none;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.cwk-copy-btn { background: linear-gradient(135deg, #1f2937 0%, #9ca3af 100%); color: #fff; box-shadow: 0 4px 14px rgba(31, 41, 55, 0.3); }
.cwk-copy-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.cwk-copy-btn:hover { background: linear-gradient(135deg, #111827 0%, #6b7280 100%); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(31, 41, 55, 0.4); }
.cwk-open-btn { background: #f3f4f6; color: #1f2937; }
.cwk-open-btn:hover { background: #e5e7eb; }

/* Toast 复制提示 */
#cwk-toast {
    position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%);
    background: #1f2937; color: #fff; padding: 10px 20px; border-radius: 50px;
    font-size: 0.9rem; z-index: 10001; opacity: 0; pointer-events: none;
    transition: opacity 0.3s;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* ===== 手机端适配 ===== */
@media (max-width: 480px) {
    #cwk-root .cwk { right: 16px; bottom: 16px; }
    #cwk-root .cwk-panel {
        width: calc(100vw - 32px);
        max-width: none;
        bottom: 72px;
    }
    #cwk-root .cwk-toggle { width: 54px; height: 54px; }
    #cwk-root .cwk-toggle svg { width: 24px; height: 24px; }
    #cwk-root .cwk-qr-float { display: none; }  /* 手机上禁用 hover 悬浮预览，直接弹窗 */
    .cwk-modal-content { padding: 24px 20px 20px; max-width: 320px; }
    .cwk-modal-qr { width: 190px; height: 190px; }
    .cwk-modal-actions { flex-direction: column; }
}
