/* 聊天窗口样式 */
.chat-widget {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* 聊天按钮（悬浮按钮） */
.chat-widget-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color, #3498db) 0%, #2980b9 100%);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.3s ease;
    position: relative;
}

.chat-widget-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.chat-widget-button:active {
    transform: translateY(0);
}

/* 未读消息红点 */
.chat-widget-badge {
    position: absolute;
    top: -5px;
    left: -5px;
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    padding: 0 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* 聊天窗口容器 */
.chat-widget-container {
    position: absolute;
    bottom: 80px;
    left: 0;
    width: 380px;
    height: 600px;
    max-height: 80vh;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    pointer-events: none;
    transition: all 0.3s ease;
}

.chat-widget-container.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* 聊天窗口头部 */
.chat-widget-header {
    background: linear-gradient(135deg, var(--color, #3498db) 0%, #2980b9 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-widget-header-title {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-widget-header-status {
    font-size: 12px;
    opacity: 0.9;
    margin-top: 4px;
}

.chat-widget-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.chat-widget-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

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

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

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

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

.chat-widget-messages::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* 消息气泡 */
.chat-message {
    display: flex;
    gap: 10px;
    animation: fadeIn 0.3s ease;
}

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

.chat-message.visitor {
    flex-direction: row-reverse;
}

.chat-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color, #3498db);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    flex-shrink: 0;
}

.chat-message.visitor .chat-message-avatar {
    background: #95a5a6;
}

.chat-message-content {
    max-width: 70%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-message-text {
    padding: 10px 14px;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 14px;
}

.chat-message.staff .chat-message-text {
    background: white;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
}

.chat-message.visitor .chat-message-text {
    background: var(--color, #3498db);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message-time {
    font-size: 11px;
    color: #999;
    padding: 0 4px;
}

.chat-message.staff .chat-message-time {
    text-align: left;
}

.chat-message.visitor .chat-message-time {
    text-align: right;
}

/* 正在输入提示 */
.chat-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    width: fit-content;
    border-bottom-left-radius: 4px;
}

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

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

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

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

/* 输入区域 */
.chat-widget-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-widget-input-wrapper {
    flex: 1 1 auto;
    max-width: calc(100% - 60px); /* 为按钮（40px）和间距（10px gap + padding）留出空间 */
    min-width: 0; /* 允许flex子元素缩小 */
    position: relative;
}

.chat-widget-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.chat-widget-input:focus {
    border-color: var(--color, #3498db);
}

.chat-widget-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color, #3498db);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-widget-send:hover:not(:disabled) {
    background: #2980b9;
    transform: scale(1.05);
}

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

/* 移动端适配 */
@media (max-width: 768px) {
    .chat-widget {
        bottom: 15px;
        left: 15px;
    }
    
    .chat-widget-button {
        width: 56px;
        height: 56px;
        font-size: 22px;
    }
    
    .chat-widget-container {
        width: calc(100vw - 30px);
        height: calc(100vh - 100px);
        max-height: 85vh;
        bottom: 76px;
        left: 0;
        border-radius: 16px 16px 0 0;
    }
    
    .chat-message-content {
        max-width: 80%;
    }
}

/* 欢迎消息 */
.chat-welcome {
    text-align: center;
    padding: 30px 20px;
    color: #666;
}

.chat-welcome-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.chat-welcome-text {
    font-size: 14px;
    line-height: 1.6;
}

/* 加载状态 */
.chat-loading {
    text-align: center;
    padding: 20px;
    color: #999;
    font-size: 14px;
}

