/* AI 智能助手样式 - 移动端优化版 */
#ai-assistant {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* 浮标按钮 */
.ai-assistant-button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4), 0 8px 32px rgba(102, 126, 234, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: visible;
}

.ai-assistant-button:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 30px rgba(102, 126, 234, 0.5), 0 12px 48px rgba(102, 126, 234, 0.3);
}

.ai-assistant-button:active {
    transform: translateY(0) scale(0.98);
}

.ai-button-inner {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.ai-assistant-button i {
    font-size: 24px;
    animation: float 3s ease-in-out infinite;
}

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

.ai-button-ripple {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    animation: ripple 2s infinite;
}

@keyframes ripple {
    0% {
        width: 0;
        height: 0;
        opacity: 1;
    }
    100% {
        width: 80px;
        height: 80px;
        opacity: 0;
    }
}

.ai-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
    border-radius: 12px;
    min-width: 20px;
    height: 20px;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    padding: 0 6px;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(238, 90, 111, 0.4);
    z-index: 3;
}

.ai-badge.hidden {
    display: none;
}

/* 聊天窗口 */
.ai-assistant-window {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 600px;
    max-height: calc(100vh - 100px);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    display: none;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(20px);
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.ai-assistant-window.active {
    display: flex;
}

/* 窗口头部 */
.ai-window-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 10;
}

.ai-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.ai-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ai-header-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ai-title {
    font-weight: 600;
    font-size: 15px;
    line-height: 1.4;
}

.ai-status {
    font-size: 11px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
    animation: pulse-status 2s infinite;
}

@keyframes pulse-status {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.ai-actions {
    display: flex;
    gap: 6px;
}

.ai-btn-icon {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 14px;
    backdrop-filter: blur(10px);
}

.ai-btn-icon:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.ai-btn-icon:active {
    transform: scale(0.95);
}

/* 消息区域 */
.ai-window-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: linear-gradient(to bottom, #f8f9fa 0%, #ffffff 100%);
    position: relative;
}

.ai-window-body::-webkit-scrollbar {
    width: 4px;
}

.ai-window-body::-webkit-scrollbar-track {
    background: transparent;
}

.ai-window-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
}

.ai-window-body::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* 欢迎卡片 */
.ai-welcome-card {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    text-align: center;
    border: 1px solid rgba(102, 126, 234, 0.1);
    animation: fadeIn 0.5s ease;
}

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

.ai-welcome-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 22px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.ai-welcome-title {
    font-weight: 600;
    font-size: 16px;
    color: #1a1a1a;
    margin-bottom: 6px;
}

.ai-welcome-desc {
    font-size: 13px;
    color: #6c757d;
    line-height: 1.5;
}

.ai-welcome-card.hidden {
    display: none;
}

.ai-message {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    animation: slideIn 0.3s ease;
}

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

.ai-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.9) 0%, rgba(118, 75, 162, 0.9) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.ai-user-msg {
    flex-direction: row-reverse;
}

.ai-user-msg .ai-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.ai-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
}

.ai-user-msg .ai-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 2px 12px rgba(102, 126, 234, 0.3);
}

.ai-content p {
    margin: 0 0 8px 0;
    line-height: 1.6;
    font-size: 14px;
    font-weight: 400;
}

.ai-content p:last-child {
    margin-bottom: 0;
}

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

.ai-content li {
    margin: 4px 0;
    line-height: 1.6;
    font-size: 14px;
}

.ai-content code {
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
}

.ai-user-msg .ai-content code {
    background: rgba(255, 255, 255, 0.2);
}

.ai-content pre {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
    font-size: 12px;
    line-height: 1.5;
    border: 1px solid #e9ecef;
}

.ai-content pre code {
    background: none;
    padding: 0;
}

.ai-content strong {
    font-weight: 600;
}

/* 快捷操作 */
.ai-quick-actions {
    padding: 12px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-bottom: 1px solid #e9ecef;
    background: #ffffff;
    max-height: 120px;
    overflow-y: auto;
}

.ai-quick-actions::-webkit-scrollbar {
    height: 3px;
}

.ai-quick-actions::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
}

.ai-quick-btn {
    padding: 8px 14px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    color: #495057;
    font-weight: 500;
    white-space: nowrap;
}

.ai-quick-btn:hover {
    background: #e9ecef;
    border-color: #dee2e6;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ai-quick-btn:active {
    transform: translateY(0);
}

/* 输入区域 */
.ai-input-area {
    padding: 12px 16px;
    display: flex;
    gap: 8px;
    background: #ffffff;
    align-items: center;
}

.ai-btn-voice,
.ai-btn-emoji {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f8f9fa;
    border: none;
    color: #6c757d;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 16px;
    flex-shrink: 0;
}

.ai-btn-voice:hover,
.ai-btn-emoji:hover {
    background: #e9ecef;
    color: #495057;
    transform: scale(1.05);
}

#aiInput {
    flex: 1;
    padding: 10px 16px;
    border: 1.5px solid #e9ecef;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    font-weight: 400;
    background: #f8f9fa;
    min-height: 36px;
}

#aiInput:focus {
    border-color: #667eea;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#aiSendBtn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

#aiSendBtn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

#aiSendBtn:active {
    transform: scale(0.95);
}

#aiSendBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* 加载动画 */
.ai-loading {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.ai-loading span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667eea;
    animation: bounce 1.4s infinite;
}

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

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

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

/* 移动端响应式 */
@media (max-width: 768px) {
    #ai-assistant {
        bottom: 16px;
        right: 16px;
    }
    
    .ai-assistant-button {
        width: 56px;
        height: 56px;
    }
    
    .ai-assistant-button i {
        font-size: 24px;
    }
    
    .ai-assistant-window {
        width: calc(100vw - 32px);
        max-width: none;
        height: calc(100vh - 88px);
        max-height: calc(100vh - 88px);
        bottom: 72px;
        right: 0;
        border-radius: 20px 20px 0 0;
    }
    
    .ai-window-body {
        padding: 12px;
    }
    
    .ai-content {
        max-width: 80%;
        font-size: 14px;
        padding: 10px 14px;
    }
    
    .ai-input-area {
        padding: 10px 12px;
    }
    
    #aiInput {
        font-size: 14px;
        padding: 10px 14px;
    }
    
    .ai-quick-actions {
        padding: 10px 12px;
    }
    
    .ai-quick-btn {
        font-size: 12px;
        padding: 7px 12px;
    }
}

/* 小屏幕优化 */
@media (max-width: 480px) {
    .ai-window-header {
        padding: 14px 16px;
    }
    
    .ai-header-avatar {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    .ai-title {
        font-size: 14px;
    }
    
    .ai-status {
        font-size: 10px;
    }
    
    .ai-btn-icon {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    
    .ai-content {
        max-width: 85%;
        font-size: 13px;
    }
    
    .ai-avatar {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
}
