/* ============================================

   即时沟通组件样式 - Chat Widget

   ============================================ */

/* 基础重置 */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

.chat-widget {

    position: fixed;

    bottom: 90px;

    right: 30px;

    z-index: 998;

    display: flex;

    flex-direction: column;

    align-items: center;

    gap: 8px;

}



/* 折叠状态：右下角悬浮圆形按钮 */

.chat-collapsed-bar {

    display: flex;

    flex-direction: column;

    align-items: center;

    justify-content: center;

    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

    border-radius: 50%;

    cursor: pointer;

    position: relative;

    width: 56px;

    height: 56px;

    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);

    user-select: none;

    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);

    visibility: hidden;

}



.chat-collapsed-bar.kf-ready {
    visibility: visible;
}



.chat-collapsed-bar:hover {

    transform: translateY(-4px) scale(1.05);

    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.45);

}



.chat-collapsed-bar:active {

    transform: scale(0.95);

}



/* 客服头像区域（圆形按钮模式下隐藏） */

.chat-staff-avatars {

    display: none;

}



.chat-staff-avatar {

    display: none;

}



/* 分隔线（圆形按钮模式下隐藏） */

.chat-bar-divider {

    display: none;

}



/* 底部标签文字（圆形按钮模式下隐藏） */

.chat-bar-label {

    display: none;

}



/* 聊天窗口 */

.chat-window {

    position: absolute;

    bottom: 70px;

    right: 0;

    width: 360px;

    height: 500px;

    background: white;

    border-radius: 16px;

    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.1);

    display: flex;

    flex-direction: column;

    opacity: 0;

    visibility: hidden;

    transform: translateY(20px) scale(0.95);

    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    overflow: hidden;

}



.chat-window.active {

    opacity: 1;

    visibility: visible;

    transform: translateY(0) scale(1);

}



/* 聊天头部 */

.chat-header {

    background: linear-gradient(135deg, var(--kf-win-header-start, #6366f1) 0%, var(--kf-win-header-end, #8b5cf6) 100%);

    color: white;

    padding: 16px 20px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    flex-shrink: 0;

}



.chat-header-info {

    display: flex;

    align-items: center;

    gap: 12px;

}



.chat-avatar {

    width: 40px;

    height: 40px;

    background: rgba(255, 255, 255, 0.2);

    border-radius: 50%;

    display: flex;

    align-items: center;

    justify-content: center;

}



.chat-header-text h4 {

    font-size: 16px;

    font-weight: 600;

    margin: 0 0 2px 0;

}



.chat-status {

    font-size: 12px;

    opacity: 0.9;

    display: flex;

    align-items: center;

    gap: 4px;

}

.status-dot {

    color: var(--kf-win-status-color, #10b981);

    line-height: 1;

    transform: translateY(1px);

}



.chat-close-btn {

    background: rgba(255, 255, 255, 0.2);

    border: none;

    color: white;

    width: 32px;

    height: 32px;

    border-radius: 8px;

    cursor: pointer;

    display: flex;

    align-items: center;

    justify-content: center;

    transition: all 0.2s ease;

}



.chat-close-btn:hover {

    background: rgba(255, 255, 255, 0.3);

    transform: rotate(90deg);

}



/* 消息区域 */

.chat-messages {

    flex: 1;

    overflow-y: auto;

    padding: 16px;

    background: #f8fafc;

    display: flex;

    flex-direction: column;

    gap: 12px;

}



.chat-messages::-webkit-scrollbar {

    width: 6px;

}



.chat-messages::-webkit-scrollbar-track {

    background: transparent;

}



.chat-messages::-webkit-scrollbar-thumb {

    background: #cbd5e1;

    border-radius: 3px;

}



.chat-messages::-webkit-scrollbar-thumb:hover {

    background: #94a3b8;

}



/* 消息气泡 */

.chat-message {

    display: flex;

    flex-direction: column;

    max-width: 85%;

    animation: messageSlideIn 0.3s ease;

}



@keyframes messageSlideIn {

    from {

        opacity: 0;

        transform: translateY(10px);

    }

    to {

        opacity: 1;

        transform: translateY(0);

    }

}



.chat-message-system {

    align-self: flex-start;

}



.chat-message-user {

    align-self: flex-end;

}



.message-content {

    padding: 12px 16px;

    border-radius: 12px;

    font-size: 14px;

    line-height: 1.6;

    word-wrap: break-word;

}



.chat-message-system .message-content {

    background: white;

    color: #1e293b;

    border: 1px solid #e2e8f0;

    border-bottom-left-radius: 4px;

}



.chat-message-user .message-content {

    background: linear-gradient(135deg, var(--kf-win-btn-start, #6366f1) 0%, var(--kf-win-btn-end, #8b5cf6) 100%);

    color: white;

    border-bottom-right-radius: 4px;

}



.message-time {

    font-size: 11px;

    color: #94a3b8;

    margin-top: 4px;

    padding: 0 4px;

}



.chat-message-user .message-time {

    text-align: right;

}



/* 输入区域 */

.chat-input-area {

    padding: 12px 16px;

    background: white;

    border-top: 1px solid #e2e8f0;

    display: flex;

    gap: 8px;

    flex-shrink: 0;

}



.chat-input {

    flex: 1;

    padding: 10px 14px;

    border: 1px solid #e2e8f0;

    border-radius: 24px;

    font-size: 14px;

    outline: none;

    transition: all 0.2s ease;

    font-family: inherit;

}



.chat-input:focus {

    border-color: var(--kf-win-btn-start, #6366f1);

    box-shadow: 0 0 0 3px var(--kf-win-btn-glow, rgba(99, 102, 241, 0.1));

}



.chat-input::placeholder {

    color: #94a3b8;

}



.chat-send-btn {

    width: 40px;

    height: 40px;

    border: none;

    border-radius: 50%;

    background: linear-gradient(135deg, var(--kf-win-btn-start, #6366f1) 0%, var(--kf-win-btn-end, #8b5cf6) 100%);

    color: white;

    cursor: pointer;

    display: flex;

    align-items: center;

    justify-content: center;

    transition: all 0.2s ease;

    flex-shrink: 0;

}



.chat-send-btn:hover {

    transform: scale(1.05);

    box-shadow: 0 4px 12px var(--kf-win-btn-hover, rgba(99, 102, 241, 0.3));

}



.chat-send-btn:active {

    transform: scale(0.95);

}



.chat-send-btn:disabled {

    opacity: 0.5;

    cursor: not-allowed;

    transform: none;

}



/* 正在输入指示器 */

.typing-indicator .message-content {

    display: flex;

    align-items: center;

    gap: 4px;

    padding: 12px 16px;

}



.typing-dot {

    width: 8px;

    height: 8px;

    background: #94a3b8;

    border-radius: 50%;

    animation: typingBounce 1.4s infinite ease-in-out both;

}



.typing-dot:nth-child(1) {

    animation-delay: -0.32s;

}



.typing-dot:nth-child(2) {

    animation-delay: -0.16s;

}



@keyframes typingBounce {

    0%, 80%, 100% {

        transform: scale(0);

    }

    40% {

        transform: scale(1);

    }

}



/* 响应式适配 */

@media (max-width: 768px) {

    .chat-widget {

        bottom: 80px;

        right: 20px;

        display: flex;

        flex-direction: column;

        align-items: center;

        gap: 6px;

    }



    .chat-window {

        width: calc(100vw - 40px);

        max-width: 360px;

        height: 450px;

        right: 0;

    }



    .chat-collapsed-bar {

        width: 52px;

        height: 52px;

    }

    .chat-staff-avatar {

        display: none;

    }

    .chat-bubble {

        font-size: 11px;

        padding: 6px 10px;

    }

    .chat-bar-label {

        display: none;

    }

}



/* ============================================

   联系方式收集表单样式

   ============================================ */

.contact-form-container {

    align-self: flex-start;

    max-width: 100%;

    animation: messageSlideIn 0.3s ease;

}



.contact-form-message {

    background: white;

    padding: 12px 16px;

    border-radius: 12px;

    border-bottom-left-radius: 4px;

    border: 1px solid #e2e8f0;

    margin-bottom: 10px;

}



.contact-form-message p {

    margin: 0;

    font-size: 14px;

    color: #1e293b;

    line-height: 1.6;

}



.contact-options {

    display: flex;

    gap: 8px;

    flex-wrap: wrap;

}



  .contact-option-btn {

    flex: 1;

    min-width: 90px;

    padding: 10px 6px;

    border: 1px solid #e2e8f0;

    border-radius: 10px;

    background: white;

    cursor: pointer;

    display: flex;

    flex-direction: column;

    align-items: center;

    justify-content: center;

    gap: 4px;

    transition: all 0.2s ease;

    font-size: 13px;

    color: #475569;


}



.contact-option-btn:hover {

    border-color: var(--kf-win-btn-start, #6366f1);

    background: #f5f3ff;

    transform: translateY(-2px);

    box-shadow: 0 4px 12px var(--kf-win-btn-soft, rgba(99, 102, 241, 0.15));

}



.contact-option-btn:active {

    transform: translateY(0);

}



  .option-icon {

    display: inline-flex;

    align-items: center;

    justify-content: center;

    width: 36px;

    height: 36px;

    margin-bottom: 4px;

}



.option-text {

    font-weight: 500;

}

/* ============================================

   内嵌留资输入框 + 提交按钮

   ============================================ */

.contact-input-area {

    margin-top: 10px;

    animation: fadeInDown 0.25s ease;

}



.contact-input-row {

    display: flex;

    gap: 8px;

    align-items: center;

}



.contact-text-input {

    flex: 1;

    padding: 10px 14px;

    border: 2px solid #e2e8f0;

    border-radius: 10px;

    font-size: 14px;

    outline: none;

    transition: border-color 0.2s;

    background: #f8fafc;

}



.contact-text-input:focus {

    border-color: var(--kf-win-btn-start, #6366f1);

    background: white;

}



.contact-submit-btn {

    padding: 10px 18px;

    background: linear-gradient(135deg, var(--kf-win-btn-start, #6366f1), var(--kf-win-btn-end, #8b5cf6));

    color: white;

    border: none;

    border-radius: 10px;

    font-size: 14px;

    font-weight: 600;

    cursor: pointer;

    transition: all 0.2s;

    white-space: nowrap;

}



.contact-submit-btn:hover {

    transform: translateY(-1px);

    box-shadow: 0 4px 12px var(--kf-win-btn-hover, rgba(99, 102, 241, 0.35));

}



.contact-submit-btn:disabled {

    opacity: 0.6;

    cursor: not-allowed;

    transform: none;

}



.contact-error-msg {

    display: none;

    color: #ef4444;

    font-size: 12px;

    margin-top: 6px;

    padding-left: 4px;

}



.contact-result-success {

    display: flex;

    align-items: center;

    gap: 8px;

    padding: 12px 16px;

    background: #ecfdf5;

    border: 1px solid #a7f3d0;

    border-radius: 10px;

    color: #065f46;

    font-size: 13px;

}



.contact-success-icon {

    display: inline-flex;

    align-items: center;

    justify-content: center;

    width: 22px;

    height: 22px;

    background: var(--kf-win-status-color, #10b981);

    color: white;

    border-radius: 50%;

    font-size: 12px;

    font-weight: bold;

}



/* 留资感谢卡 */

.contact-thankyou-card {

    align-self: flex-start;

    max-width: 90%;

    background: linear-gradient(135deg, #f0fdf4, #ecfdf5);

    border: 2px solid #a7f3d0;

    border-radius: 16px;

    padding: 16px;

    margin: 8px 0;

    animation: messageSlideIn 0.4s ease;

    text-align: center;

}



.thankyou-icon {

    font-size: 36px;

    margin-bottom: 6px;

}



.thankyou-title {

    font-size: 16px;

    font-weight: 700;

    color: #065f46;

    margin-bottom: 8px;

}



.thankyou-desc {

    font-size: 13px;

    color: #374151;

    line-height: 1.6;

    margin-bottom: 8px;

}



.thankyou-desc strong {

    color: var(--kf-win-btn-start, #6366f1);

    font-weight: 600;

}



.thankyou-tip {

    font-size: 12px;

    color: #6b7280;

    padding-top: 8px;

    border-top: 1px solid #d1fae5;

}



.thankyou-tip a {

    color: var(--kf-win-btn-start, #6366f1);

    font-weight: 600;

    text-decoration: none;

}



/* 重连横幅 */

.chat-reconnect-banner {

    display: flex;

    align-items: center;

    gap: 8px;

    padding: 10px 14px;

    background: linear-gradient(135deg, #fffbeb, #fef3c7);

    border-bottom: 2px solid #fcd34d;

    color: #92400e;

    font-size: 13px;

    font-weight: 500;

    animation: fadeInDown 0.3s ease;

}



.reconnect-spinner {

    display: inline-block;

    width: 16px;

    height: 16px;

    border: 2px solid #d97706;

    border-top-color: transparent;

    border-radius: 50%;

    animation: spin 0.8s linear infinite;

}



@keyframes spin {

    to { transform: rotate(360deg); }

}



@keyframes fadeInDown {

    from { opacity: 0; transform: translateY(-10px); }

    to { opacity: 1; transform: translateY(0); }

}



/* ============================================

   客服样式配置（由管理后台"客服样式选择"页面控制，main.js 注入 CSS 变量）

   ============================================ */



/* 极简模式：默认隐藏图标，极简模式下展示 */

.chat-collapsed-bar .minimal-icon {

    display: flex;

    align-items: center;

    justify-content: center;

    line-height: 0;

    color: #ffffff;

}



.chat-collapsed-bar.minimal {

    width: 56px;

    height: 56px;

    padding: 0;

    gap: 0;

    justify-content: center;

    overflow: hidden;

    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

    border: none;

    border-radius: 50%;

    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);

}



.chat-collapsed-bar.minimal .minimal-icon {

    display: flex;

    color: #ffffff;

}



.chat-collapsed-bar.minimal .chat-staff-avatars,

.chat-collapsed-bar.minimal .chat-bar-divider {

    display: none !important;

}



.chat-collapsed-bar.minimal .chat-bar-label {

    display: none;

}