/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    line-height: 1.6;
    color: #333;
}

/* 聊天助手容器 */
#ai-chat-container {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9999;
    transition: transform 0.3s ease;
    will-change: transform, opacity;
}

/* 聊天图标样式 */
#chat-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2B6CB6, #3182CE);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15),
                inset 0 2px 5px rgba(255, 255, 255, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
    will-change: transform;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

#chat-icon:before {
    content: '';
    position: absolute;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    z-index: -1;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.2;
    }
    100% {
        transform: scale(1);
        opacity: 0.5;
    }
}

#chat-icon i {
    font-size: 28px;
}

#chat-icon:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2),
                inset 0 2px 5px rgba(255, 255, 255, 0.4);
}

#chat-icon:active {
    transform: scale(0.95);
}

/* 聊天窗口样式 */
#chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 320px;
    height: 500px;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transform: scale(0.9);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s;
    border: 1px solid rgba(43, 108, 182, 0.1);
}

/* 聊天窗口头部 */
.chat-header {
    padding: 12px 16px;
    background: linear-gradient(135deg, #2B6CB6, #3182CE);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
}

.chat-header h3 {
    font-size: 16px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-header h3:before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    background-color: #4ADE80;
    border-radius: 50%;
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.chat-controls {
    display: flex;
    gap: 8px;
}

.chat-controls button {
    background: none;
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s;
}

.chat-controls button:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* 消息列表区域 */
#message-list {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background-color: #f9f9f9;
    background-image: 
        radial-gradient(rgba(0, 0, 0, 0.02) 1px, transparent 1px),
        radial-gradient(rgba(0, 0, 0, 0.02) 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
}

/* 消息样式 */
.message {
    display: flex;
    gap: 8px;
    max-width: 85%;
    transition: transform 0.2s ease, opacity 0.2s;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #e0e0e0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 16px;
    flex-shrink: 0;
}

.ai-message .message-avatar {
    background: linear-gradient(135deg, #2B6CB6, #3182CE);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.user-message .message-avatar {
    background: linear-gradient(135deg, #38A169, #4ADE80);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.message-content {
    padding: 10px 14px;
    background-color: white;
    border-radius: 16px;
    border-top-left-radius: 4px;
    font-size: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.user-message .message-content {
    background-color: #E7F3FF;
    border-radius: 16px;
    border-top-right-radius: 4px;
}

.message-thinking {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 4px 6px;
}

.thinking-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #2B6CB6;
    animation: thinking 1.4s infinite ease-in-out both;
}

.thinking-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.thinking-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes thinking {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* 输入区域 */
.input-area {
    padding: 12px;
    display: flex;
    gap: 8px;
    border-top: 1px solid #eaeaea;
    background-color: white;
}

#user-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) inset;
}

#user-input:focus {
    border-color: #2B6CB6;
    box-shadow: 0 1px 3px rgba(43, 108, 182, 0.2) inset;
}

#send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2B6CB6, #3182CE);
    color: white;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#send-btn:hover {
    background: linear-gradient(135deg, #3182CE, #4299E1);
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

#send-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

#send-btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 展开状态 */
#ai-chat-container.expanded #chat-window {
    transform: scale(1);
    opacity: 1;
    visibility: visible;
}

/* 拖动状态 */
#ai-chat-container.dragging {
    opacity: 0.9;
    transition: none;
}

/* 新消息动画 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-new {
    animation: fadeIn 0.3s ease forwards;
}

/* 响应式设计 */
@media (max-width: 600px) {
    #ai-chat-container {
        right: 50%;
        transform: translateX(50%);
    }
    
    #chat-window {
        right: 50%;
        transform: translateX(50%) scale(0.9);
        width: 100vw;
        max-width: 100vw;
        height: 80vh;
        bottom: 80px;
    }
    
    #ai-chat-container.expanded #chat-window {
        transform: translateX(50%) scale(1);
    }
    
    /* 全屏模式（移动设备） */
    #ai-chat-container.expanded.fullscreen {
        right: 0;
        bottom: 0;
        transform: none;
        width: 100%;
    }
    
    #ai-chat-container.expanded.fullscreen #chat-window {
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        transform: none;
    }
    
    #ai-chat-container.expanded.fullscreen #chat-icon {
        display: none;
    }
} 