/**
 * 商务通前端样式
 * 美观的现代化聊天界面
 */

/* === 主容器 === */
.business-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* === 浮动按钮 === */
.chat-float-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    animation: pulse 2s ease-in-out infinite;
}

.chat-float-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.6);
}

.chat-float-button.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0);
}

.chat-float-button .dashicons {
    font-size: 32px;
    width: 32px;
    height: 32px;
    color: #ffffff;
}

/* 未读徽章 */
.unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: #ffffff;
    border-radius: 12px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: bold;
    min-width: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(255, 71, 87, 0.4);
    animation: bounce 0.5s ease;
}

.chat-float-button.has-unread {
    animation: shake 0.5s ease-in-out;
}

/* === 聊天窗口 === */
.chat-window {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    height: 550px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideInUp 0.3s ease;
}

/* === 头部 === */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-content .dashicons {
    font-size: 32px;
    width: 32px;
    height: 32px;
}

.header-text h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.9;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #2ecc71;
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s ease-in-out infinite;
}

.close-button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.close-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.close-button .dashicons {
    color: #ffffff;
    font-size: 20px;
    width: 20px;
    height: 20px;
}

/* === 消息区域 === */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
    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: #cbd5e0;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* 欢迎横幅 */
.welcome-banner {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border-radius: 12px;
    margin-bottom: 10px;
}

.welcome-banner .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    color: #667eea;
    margin-bottom: 10px;
}

.welcome-banner p {
    margin: 0;
    color: #4a5568;
    font-size: 14px;
}

/* === 消息项 === */
.message-item {
    display: flex;
    margin-bottom: 8px;
    animation: fadeIn 0.3s ease;
}

.message-item.user-message {
    justify-content: flex-end;
}

.message-item.admin-message {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 12px;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.user-message .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.admin-message .message-bubble {
    background: #ffffff;
    color: #2d3748;
    border-bottom-left-radius: 4px;
    border: 1px solid #e2e8f0;
}

.message-text {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 4px;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    text-align: right;
}

.admin-message .message-time {
    text-align: left;
}

/* 系统消息 */
.system-message .message-bubble {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
    max-width: 85%;
    margin: 0 auto;
}

.system-message .message-bubble.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.system-message .dashicons {
    vertical-align: middle;
    margin-right: 4px;
}

/* === 输入区域 === */
.chat-input {
    padding: 16px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input textarea {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    font-family: inherit;
    transition: all 0.2s ease;
}

.chat-input textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.send-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-button .dashicons {
    color: #ffffff;
    font-size: 24px;
    width: 24px;
    height: 24px;
}

/* === 底部 === */
.chat-footer {
    padding: 8px;
    text-align: center;
    background: #f8f9fa;
    border-top: 1px solid #e2e8f0;
}

.chat-footer small {
    color: #a0aec0;
    font-size: 11px;
}

/* === 动画 === */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === 响应式设计 === */
@media (max-width: 768px) {
    .business-chat-widget {
        bottom: 10px;
        right: 10px;
    }
    
    .chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 10px;
        right: 10px;
    }
}

@media (max-width: 480px) {
    .chat-window {
        width: 100vw;
        height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
    
    .chat-float-button {
        width: 50px;
        height: 50px;
    }
    
    .chat-float-button .dashicons {
        font-size: 28px;
        width: 28px;
        height: 28px;
    }
}

