/* 企业级聊天弹出窗口样式 */

/* 基础变量 */
:root {
    --chat-primary-color: #667eea;
    --chat-secondary-color: #764ba2;
    --chat-success-color: #10b981;
    --chat-warning-color: #f59e0b;
    --chat-error-color: #ef4444;
    --chat-text-color: #1f2937;
    --chat-text-light: #6b7280;
    --chat-bg-color: #ffffff;
    --chat-border-color: #e5e7eb;
    --chat-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    --chat-radius: 12px;
    --chat-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 浮动聊天按钮 */
.chat-floating-btn {
    position: fixed;
    width: 60px;
    height: 60px;
    bottom: 20px;
    right: 20px;
    background: linear-gradient(135deg, var(--chat-primary-color) 0%, var(--chat-secondary-color) 100%);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--chat-shadow);
    transition: var(--chat-transition);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.chat-floating-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 15px 35px rgba(102, 126, 234, 0.4);
}

.chat-floating-btn.chat-active {
    background: var(--chat-success-color);
    transform: scale(1.1);
}

.chat-floating-btn .chat-btn-icon {
    transition: var(--chat-transition);
}

.chat-floating-btn.chat-active .chat-btn-icon {
    transform: rotate(180deg);
}

/* 通知徽章 */
.chat-notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--chat-error-color);
    color: white;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    animation: chatPulse 2s infinite;
}

@keyframes chatPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* 聊天弹窗容器 */
.chat-popup-container {
    position: fixed;
    width: 380px;
    height: 600px;
    bottom: 20px;
    right: 20px;
    background: var(--chat-bg-color);
    border-radius: var(--chat-radius);
    box-shadow: var(--chat-shadow);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    transition: var(--chat-transition);
    overflow: hidden;
}

.chat-popup-container.chat-popup-show {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.chat-popup-container.chat-popup-minimized {
    transform: translateY(100%) scale(0.8);
    opacity: 0;
}

.chat-popup-container.dragging {
    user-select: none;
    cursor: move;
}

/* 弹窗头部 */
.chat-popup-header {
    background: linear-gradient(135deg, var(--chat-primary-color) 0%, var(--chat-secondary-color) 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
    position: relative;
}

.chat-popup-header:active {
    cursor: grabbing;
}

.chat-agent-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.agent-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.agent-name {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 2px;
}

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

.agent-status.online::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--chat-success-color);
    border-radius: 50%;
    display: inline-block;
}

.chat-controls {
    display: flex;
    gap: 8px;
}

.chat-controls button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: var(--chat-transition);
    opacity: 0.8;
}

.chat-controls button:hover {
    background: rgba(255, 255, 255, 0.1);
    opacity: 1;
}

/* 弹窗主体 */
.chat-popup-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8fafc;
    scroll-behavior: smooth;
}

.welcome-message {
    text-align: center;
    margin-bottom: 20px;
}

.message-item {
    margin-bottom: 16px;
    animation: chatFadeInUp 0.3s ease-out;
}

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

.message-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.4;
    position: relative;
}

.user-message {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.user-message .message-bubble {
    background: linear-gradient(135deg, var(--chat-primary-color) 0%, var(--chat-secondary-color) 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.agent-message {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.agent-message .message-bubble {
    background: white;
    color: var(--chat-text-color);
    border: 1px solid var(--chat-border-color);
    border-bottom-left-radius: 6px;
}

.message-time {
    font-size: 11px;
    color: var(--chat-text-light);
    margin-top: 4px;
    opacity: 0.7;
}

/* 快捷回复 */
.chat-quick-replies {
    padding: 0 20px 16px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.quick-reply-btn {
    background: white;
    border: 1px solid var(--chat-border-color);
    color: var(--chat-primary-color);
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: var(--chat-transition);
}

.quick-reply-btn:hover {
    background: var(--chat-primary-color);
    color: white;
    border-color: var(--chat-primary-color);
}

/* 弹窗底部 */
.chat-popup-footer {
    background: white;
    border-top: 1px solid var(--chat-border-color);
    padding: 16px 20px;
}

.chat-input-area {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8fafc;
    padding: 8px 12px;
    border-radius: 25px;
    border: 1px solid var(--chat-border-color);
    transition: var(--chat-transition);
}

.chat-input-area:focus-within {
    border-color: var(--chat-primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-input {
    flex: 1;
    border: none;
    background: none;
    padding: 8px 4px;
    font-size: 14px;
    outline: none;
    color: var(--chat-text-color);
}

.chat-input::placeholder {
    color: var(--chat-text-light);
}

.btn-send {
    background: var(--chat-primary-color);
    color: white;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: var(--chat-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
}

.btn-send:hover {
    background: var(--chat-secondary-color);
    transform: scale(1.05);
}

/* 输入指示器 */
.chat-typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    color: var(--chat-text-light);
    font-size: 13px;
}

.typing-dots {
    display: flex;
    gap: 2px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--chat-primary-color);
    animation: chatTypingDot 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes chatTypingDot {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 滚动条样式 */
.chat-messages::-webkit-scrollbar {
    width: 4px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 2px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.5);
}

/* 主题变体 */
.chat-popup-container[data-theme="dark"] {
    background: #1f2937;
    color: white;
}

.chat-popup-container[data-theme="dark"] .chat-messages {
    background: #111827;
}

.chat-popup-container[data-theme="dark"] .agent-message .message-bubble {
    background: #374151;
    color: white;
    border-color: #4b5563;
}

.chat-popup-container[data-theme="dark"] .chat-input-area {
    background: #374151;
    border-color: #4b5563;
}

.chat-popup-container[data-theme="dark"] .chat-popup-footer {
    background: #1f2937;
    border-color: #374151;
}

/* 响应式设计 */
@media (max-width: 480px) {
    .chat-popup-container {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: 0 !important;
    }
    
    .chat-floating-btn {
        width: 56px;
        height: 56px;
        bottom: 16px !important;
        right: 16px !important;
        /* 确保在安全区域内 */
        bottom: max(16px, env(safe-area-inset-bottom)) !important;
        right: max(16px, env(safe-area-inset-right)) !important;
    }
    
    .chat-popup-header {
        padding: 12px 16px;
        /* 适配刘海屏 */
        padding-top: max(12px, env(safe-area-inset-top)) !important;
    }
    
    .chat-messages {
        padding: 16px;
        /* 适配底部安全区域 */
        padding-bottom: max(16px, env(safe-area-inset-bottom)) !important;
    }
    
    .chat-popup-footer {
        padding: 16px;
        /* 适配底部安全区域 */
        padding-bottom: max(16px, env(safe-area-inset-bottom)) !important;
    }
    
    .message-bubble {
        max-width: 90%;
    }
    
    /* 确保输入框在安全区域内 */
    .chat-input-area {
        padding-bottom: max(16px, env(safe-area-inset-bottom)) !important;
    }
}

/* 针对更小屏幕的优化 */
@media (max-width: 360px) {
    .chat-floating-btn {
        width: 52px;
        height: 52px;
        bottom: 12px !important;
        right: 12px !important;
        /* 确保在安全区域内 */
        bottom: max(12px, env(safe-area-inset-bottom)) !important;
        right: max(12px, env(safe-area-inset-right)) !important;
    }
    
    .chat-popup-header {
        padding: 10px 12px;
        padding-top: max(10px, env(safe-area-inset-top)) !important;
    }
    
    .chat-messages {
        padding: 12px;
        padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
    }
    
    .chat-popup-footer {
        padding: 12px;
        padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
    }
}

/* 动画效果增强 */
.chat-floating-btn {
    animation: chatFloatBounce 6s ease-in-out infinite;
}

@keyframes chatFloatBounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-5px);
    }
    60% {
        transform: translateY(-3px);
    }
}

/* 无障碍支持 */
.chat-popup-container:focus-within {
    outline: 2px solid var(--chat-primary-color);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 加载状态 */
.chat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: var(--chat-text-light);
}

.chat-loading::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid var(--chat-border-color);
    border-top-color: var(--chat-primary-color);
    border-radius: 50%;
    animation: chatSpin 1s linear infinite;
    margin-right: 8px;
}

@keyframes chatSpin {
    to { transform: rotate(360deg); }
}

/* 错误状态 */
.chat-error {
    background: #fef2f2;
    color: var(--chat-error-color);
    padding: 12px 16px;
    border-radius: 8px;
    margin: 10px 20px;
    border-left: 4px solid var(--chat-error-color);
    font-size: 13px;
    animation: chatShake 0.5s ease-in-out;
}

@keyframes chatShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* 成功状态 */
.chat-success {
    background: #f0fdf4;
    color: var(--chat-success-color);
    padding: 12px 16px;
    border-radius: 8px;
    margin: 10px 20px;
    border-left: 4px solid var(--chat-success-color);
    font-size: 13px;
}

/* 位置选择器样式已移除，位置设置由后台管理 */
/* 
.position-selector-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: chatFadeIn 0.3s ease-out;
}

.position-selector {
    background: var(--chat-bg-color);
    border-radius: var(--chat-radius);
    box-shadow: var(--chat-shadow);
    padding: 24px;
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.selector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--chat-border-color);
}

.selector-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--chat-text-color);
}

.btn-close-selector {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--chat-text-light);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: var(--chat-transition);
}

.btn-close-selector:hover {
    background: var(--chat-border-color);
    color: var(--chat-text-color);
}

.position-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.position-option {
    background: var(--chat-bg-color);
    border: 2px solid var(--chat-border-color);
    border-radius: 8px;
    padding: 12px 16px;
    cursor: pointer;
    transition: var(--chat-transition);
    font-size: 14px;
    font-weight: 500;
    color: var(--chat-text-color);
    text-align: center;
}

.position-option:hover {
    border-color: var(--chat-primary-color);
    background: rgba(102, 126, 234, 0.05);
}

.position-option.active {
    border-color: var(--chat-primary-color);
    background: var(--chat-primary-color);
    color: white;
}

@keyframes chatFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}
*/ 