/* 蛋仔AI助手 - 聊天窗口样式 */

#danzi-ai-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* 聊天按钮 */
#danzi-ai-button {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #FFD100 0%, #FF9500 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(255, 149, 0, 0.4);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}

#danzi-ai-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(255, 149, 0, 0.5);
}

#danzi-ai-button:active {
    transform: scale(0.95);
}

#danzi-ai-button .chat-icon {
    font-size: 28px;
    animation: bounce 2s infinite;
}

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

#danzi-ai-button .chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #FF6B6B;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
    display: none;
}

/* 聊天窗口 */
#danzi-ai-chat-window {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: 380px;
    height: 560px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#danzi-ai-chat-window.hidden {
    opacity: 0;
    transform: scale(0);
    pointer-events: none;
}

/* 头部 */
.chat-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, #FFD100 0%, #FF9500 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 16px;
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-close {
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

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

/* 消息区域 */
.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    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: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

/* 消息气泡 */
.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.6;
    animation: messageIn 0.3s ease-out;
}

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

.bot-message {
    align-self: flex-start;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    color: #1e3a5f;
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.08);
}

.user-message {
    align-self: flex-end;
    background: linear-gradient(135deg, #FFD100 0%, #FF9500 100%);
    color: white;
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 8px rgba(255, 149, 0, 0.2);
}

/* 加载动画 */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    align-self: flex-start;
}

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

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

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

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

/* 快捷问题 */
.chat-quick-questions {
    padding: 12px 16px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.quick-question {
    padding: 6px 12px;
    background: rgba(255, 149, 0, 0.1);
    border: 1px solid rgba(255, 149, 0, 0.2);
    border-radius: 20px;
    color: #FF9500;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.quick-question:hover {
    background: rgba(255, 149, 0, 0.2);
    transform: translateY(-2px);
}

/* 输入区域 */
.chat-input-area {
    padding: 12px 16px;
    display: flex;
    gap: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

#chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid rgba(0, 0, 0, 0.08);
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#chat-input:focus {
    border-color: #FF9500;
}

#chat-send {
    width: 46px;
    height: 46px;
    border: none;
    background: linear-gradient(135deg, #FFD100 0%, #FF9500 100%);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#chat-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(255, 149, 0, 0.3);
}

#chat-send:active {
    transform: scale(0.95);
}

/* 底部信息 */
.chat-footer {
    padding: 10px 16px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: #666;
}

.quota-info {
    display: flex;
    align-items: center;
    gap: 4px;
}

.quota-info strong {
    color: #FF9500;
    font-weight: 600;
}

.upgrade-link {
    color: #FF6B6B;
    text-decoration: none;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 12px;
    background: rgba(255, 107, 107, 0.1);
    transition: all 0.2s;
}

.upgrade-link:hover {
    background: rgba(255, 107, 107, 0.2);
}

/* 响应式 */
@media (max-width: 480px) {
    #danzi-ai-widget {
        bottom: 16px;
        right: 16px;
    }

    #danzi-ai-chat-window {
        width: calc(100vw - 32px);
        height: 70vh;
        right: 0;
    }

    .chat-quick-questions {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }
}

/* Markdown 样式支持 */
.bot-message strong {
    font-weight: 600;
}

.bot-message ul,
.bot-message ol {
    margin: 8px 0;
    padding-left: 20px;
}

.bot-message li {
    margin: 4px 0;
}

.bot-message code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 13px;
}

/* 错误消息 */
.message.error {
    background: rgba(255, 107, 107, 0.1);
    color: #FF6B6B;
    border: 1px solid rgba(255, 107, 107, 0.2);
}
