/* ========================================
   聊天窗口样式
   ======================================== */

.chat-widget {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 9999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 15px;
}

/* 聊天切换按钮 - 加大并居中显示 */
.chat-toggle {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 12px 30px rgba(102, 126, 234, 0.5);
    transition: all 0.3s ease;
    position: relative;
    animation: pulse-chat 2s infinite, bounce-gentle 3s ease-in-out infinite;
}

.chat-toggle::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    opacity: 0.3;
    animation: ripple-effect 2s ease-out infinite;
}

.chat-toggle::after {
    content: '💬 点击咨询';
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    color: #667eea;
    padding: 10px 18px;
    border-radius: 25px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    white-space: nowrap;
    animation: float-hint 3s ease-in-out infinite;
    pointer-events: none;
    border: 2px solid #667eea;
}

.chat-toggle:hover {
    transform: scale(1.15);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.7);
    animation: shake 0.5s ease infinite;
}

.chat-toggle:hover::after {
    animation: none;
    opacity: 0;
}

.chat-toggle i {
    font-size: 32px;
    position: relative;
    z-index: 1;
    animation: rotate-icon 4s linear infinite;
}

.chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 24px;
    height: 24px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    border: 2px solid white;
    animation: bounce-badge 1s ease infinite;
}

@keyframes pulse-chat {
    0%, 100% {
        box-shadow: 0 12px 30px rgba(102, 126, 234, 0.5);
    }
    50% {
        box-shadow: 0 12px 30px rgba(102, 126, 234, 0.7), 0 0 0 15px rgba(102, 126, 234, 0.2), 0 0 0 30px rgba(102, 126, 234, 0.1);
    }
}

@keyframes bounce-gentle {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-8px);
    }
}

@keyframes ripple-effect {
    0% {
        transform: scale(1);
        opacity: 0.3;
    }
    100% {
        transform: scale(1.8);
        opacity: 0;
    }
}

@keyframes float-hint {
    0%, 100% {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
    50% {
        transform: translateX(-50%) translateY(-5px);
        opacity: 0.8;
    }
}

@keyframes shake {
    0%, 100% {
        transform: scale(1.15) rotate(0deg);
    }
    25% {
        transform: scale(1.15) rotate(-5deg);
    }
    75% {
        transform: scale(1.15) rotate(5deg);
    }
}

@keyframes rotate-icon {
    0%, 90%, 100% {
        transform: rotate(0deg);
    }
    92%, 98% {
        transform: rotate(-15deg);
    }
    94%, 96% {
        transform: rotate(15deg);
    }
}

@keyframes bounce-badge {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.3);
    }
}

/* 聊天窗口 - 右侧居中显示 */
.chat-window {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 420px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 100px);
    background: white;
    border-radius: 20px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.35);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideInRight 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    border: 3px solid transparent;
    background-clip: padding-box;
}

.chat-window.active {
    display: flex;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateY(-50%) translateX(100px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) translateX(0) scale(1);
    }
}

/* 聊天头部 */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-content i {
    font-size: 24px;
}

.chat-header h4 {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 4px 0;
}

.chat-status {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.9;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

.chat-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.chat-close:hover {
    opacity: 1;
}

/* 聊天消息区域 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

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

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

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* 聊天消息 */
.chat-message {
    display: flex;
    gap: 12px;
    animation: fadeInMessage 0.3s ease;
}

@keyframes fadeInMessage {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes highlight-new-message {
    0% {
        background: rgba(40, 167, 69, 0.1);
        transform: scale(1.02);
    }
    50% {
        background: rgba(40, 167, 69, 0.2);
    }
    100% {
        background: transparent;
        transform: scale(1);
    }
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-message .message-avatar {
    background: #e2e8f0;
    color: #475569;
}

.message-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message-content p {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    margin: 0;
    line-height: 1.5;
    color: #334155;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.user-message {
    flex-direction: row-reverse;
}

.user-message .message-content {
    align-items: flex-end;
}

.user-message .message-content p {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message-time {
    font-size: 11px;
    color: #94a3b8;
    padding: 0 8px;
}

/* 快速回复 */
.chat-quick-replies {
    padding: 12px 20px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.quick-reply {
    padding: 8px 16px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    font-size: 13px;
    color: #475569;
    cursor: pointer;
    transition: all 0.3s ease;
}

.quick-reply:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
    transform: translateY(-1px);
}

/* 输入区域 */
.chat-input-area {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e2e8f0;
}

.chat-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 24px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.3s ease;
}

.chat-input:focus {
    outline: none;
    border-color: #667eea;
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.chat-send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 打字指示器 */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
    width: fit-content;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #cbd5e1;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* 响应式设计 */
@media (max-width: 480px) {
    .chat-widget {
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
    }
    
    .chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        right: 0;
        transform: translateY(-50%);
    }
    
    .chat-toggle {
        width: 65px;
        height: 65px;
    }
    
    .chat-toggle i {
        font-size: 28px;
    }
    
    .chat-toggle::after {
        font-size: 11px;
        padding: 8px 14px;
    }
}

/* 加载动画 */
.chat-loading {
    text-align: center;
    padding: 20px;
    color: #94a3b8;
}

.chat-loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* 错误提示 */
.chat-error {
    padding: 12px 16px;
    background: #fee2e2;
    color: #991b1b;
    border-radius: 8px;
    font-size: 13px;
    margin: 10px 0;
    text-align: center;
}

/* 成功提示 */
.chat-success {
    padding: 12px 16px;
    background: #d1fae5;
    color: #065f46;
    border-radius: 8px;
    font-size: 13px;
    margin: 10px 0;
    text-align: center;
}

