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

   即时沟通组件样式 - Chat Widget

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

/* 基础重置 */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; background: #fff; overflow-x: hidden; overflow-y: auto; }

.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;

    background: linear-gradient(180deg, #fff6f6 0%, #e5e9ff 100%);

    border-radius: 16px;

    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);

    cursor: pointer;

    position: relative;

    padding: 20px 16px 16px;

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

    user-select: none;

    gap: 0;

    width: 104px;

    border: 1px solid rgb(86 82 236 / 15%);

    background-clip: padding-box;

}



.chat-collapsed-bar:hover {

    transform: translateY(-4px);

    box-shadow: 0 10px 32px rgba(59, 130, 246, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06);

    border-color: rgba(99, 102, 241, 0.2);

    background: linear-gradient(180deg, #fafbfe 0%, #f4f7fb 100%);

}



.chat-collapsed-bar:active {

    transform: scale(0.97) translateY(-2px);

}



/* 客服头像区域 */

.chat-staff-avatars {

    display: flex;

    flex-direction: column;

    align-items: center;

    gap: 10px;

    padding: 8px 0;

}



.chat-staff-avatar {

    width: 70px;

    height: 70px;

    border-radius: 50%;

    overflow: hidden;

    border: 3px solid #f1f5f9;

    box-shadow: 0 2px 8px rgba(0,0,0,0.06);

    display: flex;

    align-items: center;

    justify-content: center;

    flex-shrink: 0;

    transition: transform 0.3s ease, border-color 0.3s ease;

}

.chat-collapsed-bar:hover .chat-staff-avatar {

    border-color: #e2e8f0;

}



.chat-staff-avatar img {

    width: 100%;

    height: 100%;

    object-fit: cover;

    display: block;

}



/* 头像1：激活状态（蓝色光环） */

.chat-staff-avatar-1 {

    background: linear-gradient(135deg, #f0f5ff, #e0e7ff);

}



.chat-staff-avatar-1.active {

    animation: ring-pulse 2s ease-out infinite;

}



@keyframes ring-pulse {

    0% {

        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4), 0 0 0 0 rgba(59, 130, 246, 0.2);

    }

    50% {

        box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.2), 0 0 0 12px rgba(59, 130, 246, 0.08);

    }

    100% {

        box-shadow: 0 0 0 12px rgba(59, 130, 246, 0), 0 0 0 24px rgba(59, 130, 246, 0);

    }

}



/* 头像2：粉色背景 */

.chat-staff-avatar-2 {

    background: linear-gradient(135deg, #fce7f3, #fbcfe8);

}



/* 头像3：黄色背景 */

.chat-staff-avatar-3 {

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

}



/* 分隔线 */

.chat-bar-divider {

    width: 28px;

    height: 1px;

    background: #b8c5d6;

    margin: 10px 0;

    border-radius: 1px;

    transition: width 0.3s ease, background 0.3s ease;

}



.chat-collapsed-bar:hover .chat-bar-divider {

    width: 36px;

    background: #94a3b8;

}



/* 底部标签文字 */

.chat-bar-label {

    font-size: 13px;

    color: #374151;

    text-align: center;

    font-weight: 600;

    letter-spacing: 0.5px;

}



/* 聊天窗口 */

.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, #6366f1 0%, #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: #10b981;

}



.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, #6366f1 0%, #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: #6366f1;

    box-shadow: 0 0 0 3px 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, #6366f1 0%, #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 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: 0;

        right: 0;

        left: 0;

        width: 100%;

        display: flex;

        flex-direction: row;

        align-items: center;

        justify-content: center;

        gap: 0;

        z-index: 1003;

    }



    .chat-window {

        position: fixed;

        z-index: 1004;

        left: 0;

        right: 0;

        margin: 0 auto;

        width: calc(100vw - 40px);

        max-width: 360px;

        height: 400px; 

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

        bottom: 20px;

    }



    .chat-window.active {

        transform: translateY(0) scale(1);

    }



    .chat-input {

        min-width: 0;

    }



    .chat-collapsed-bar {

        display: flex;

        flex-direction: row;

        align-items: center;

        justify-content: center;

        padding: 6px 16px;

        border-radius: 0;

        width: 100%;

        gap: 20px;

        background: linear-gradient(90deg, #fff6f6 0%, #e5e9ff 100%);

        border: none;

        border-top: 1px solid rgb(86 82 236 / 15%);

        box-shadow: 0 -4px 20px rgba(59, 130, 246, 0.08), 0 -1px 3px rgba(0, 0, 0, 0.04);

    }

    .chat-collapsed-bar:hover {

        transform: none;

        background: linear-gradient(90deg, #fafbfe 0%, #f4f7fb 100%);

    }



    .chat-staff-avatars {

        display: flex;

        flex-direction: row;

        align-items: center;

        gap: 20px;

        padding: 0;

    }



    .chat-staff-avatar {

        width: 40px;

        height: 40px;

        border: 2px solid #f1f5f9;

    }



    .chat-bar-divider {

        width: 1px;

        height: 24px;

        margin: 0 4px;

        transition: none;

    }



    .chat-collapsed-bar:hover .chat-bar-divider {

        width: 1px;

        background: #b8c5d6;

    }



    .chat-bubble {

        font-size: 11px;

        padding: 6px 10px;

    }



    .chat-bar-label {

        font-size: 16px;

        padding-bottom: 0;

        font-weight: 500;

    }



}



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

   联系方式收集表单样式

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

.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: #6366f1;

    background: #f5f3ff;

    transform: translateY(-2px);

    box-shadow: 0 4px 12px 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: #6366f1;

    background: white;

}



.contact-submit-btn {

    padding: 10px 18px;

    background: linear-gradient(135deg, #6366f1, #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 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: #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: #6366f1;

    font-weight: 600;

}



.thankyou-tip {

    font-size: 12px;

    color: #6b7280;

    padding-top: 8px;

    border-top: 1px solid #d1fae5;

}



.thankyou-tip a {

    color: #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); }

}

