/* EduRAG 动画和交互优化样式 */

/* ==================== 基础动画 ==================== */

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

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

@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 slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(139, 92, 246, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(139, 92, 246, 0.8);
    }
}

/* ==================== 优化按钮交互 ==================== */

.btn-interactive {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.btn-interactive:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-interactive:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 按钮波纹效果 */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    background-image: radial-gradient(circle, rgba(255,255,255,0.4) 10%, transparent 10.01%);
    background-repeat: no-repeat;
    background-position: 50%;
    transform: scale(10, 10);
    opacity: 0;
    transition: transform 0.5s, opacity 1s;
}

.btn-ripple:active::after {
    transform: scale(0, 0);
    opacity: 0.3;
    transition: 0s;
}

/* ==================== 卡片和容器优化 ==================== */

.card-enhanced {
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.card-enhanced:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

/* ==================== 输入框优化 ==================== */

.input-enhanced {
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.input-enhanced:focus {
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
    transform: scale(1.02);
}

/* ==================== 消息气泡优化 ==================== */

.message-animation {
    animation: slideUp 0.3s ease-out;
    transition: all 0.3s ease;
}

.message-animation:hover {
    transform: scale(1.01);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* ==================== 模态框优化 ==================== */

.modal-backdrop {
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    animation: scaleIn 0.3s ease-out;
}

/* ==================== 列表项优化 ==================== */

.list-item-interactive {
    transition: all 0.3s ease;
    cursor: pointer;
}

.list-item-interactive:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateX(4px);
}

.list-item-interactive.active {
    background-color: rgba(255, 255, 255, 0.2);
    border-left: 3px solid #8b5cf6;
}

/* ==================== 加载动画优化 ==================== */

.loading-dots {
    display: inline-flex;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: currentColor;
    margin: 0 2px;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }
.loading-dots span:nth-child(3) { animation-delay: 0s; }

/* 旋转加载器 */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(139, 92, 246, 0.2);
    border-top-color: #8b5cf6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 脉冲加载器 */
.pulse-loader {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

/* ==================== 进度条优化 ==================== */

.progress-enhanced {
    height: 8px;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.progress-enhanced .progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
    transition: width 0.5s ease-out;
    position: relative;
}

.progress-enhanced .progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ==================== 图标动画 ==================== */

.icon-hover {
    transition: all 0.3s ease;
}

.icon-hover:hover {
    transform: scale(1.2);
    color: #8b5cf6;
}

/* 图标旋转 */
.icon-rotate {
    transition: transform 0.5s ease;
}

.icon-rotate:hover {
    transform: rotate(180deg);
}

/* 图标弹跳 */
.icon-bounce:hover {
    animation: bounce 0.5s ease;
}

/* ==================== 状态指示器 ==================== */

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    position: relative;
}

.status-indicator.online {
    background-color: #10b981;
    animation: glow 2s ease-in-out infinite;
}

.status-indicator.offline {
    background-color: #ef4444;
}

.status-indicator.busy {
    background-color: #f59e0b;
}

/* ==================== 提示和通知 ==================== */

.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 12px;
    background-color: #1a1a1a;
    color: white;
    font-size: 12px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

.tooltip:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-5px);
}

/* ==================== 响应式动画 ==================== */

@media (prefers-reduced-motion: reduce) {
    *, ::before, ::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==================== 特殊效果 ==================== */

/* 玻璃态效果 */
.glass-effect {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.glass-effect:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

/* 悬浮卡片 */
.float-card {
    animation: float 6s ease-in-out infinite;
}

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

/* 错误抖动 */
.error-shake {
    animation: shake 0.5s ease-in-out;
}

/* 成功弹跳 */
.success-bounce {
    animation: bounce 0.5s ease-in-out;
}

/* ==================== 滚动条美化 ==================== */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.5);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.8);
}

/* ==================== 表单验证优化 ==================== */

.input-valid {
    border-color: #10b981 !important;
    animation: success-bounce 0.3s ease;
}

.input-invalid {
    border-color: #ef4444 !important;
    animation: error-shake 0.5s ease;
}

/* ==================== 下拉和折叠动画 ==================== */

.collapsible {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.collapsible.active {
    max-height: 1000px;
}

/* ==================== 图表和数据可视化动画 ==================== */

.bar-animate {
    animation: growBar 1s ease-out forwards;
}

@keyframes growBar {
    from {
        height: 0;
    }
    to {
        height: var(--target-height);
    }
}

.pie-slice-animate {
    animation: sliceIn 0.5s ease-out forwards;
}

@keyframes sliceIn {
    from {
        opacity: 0;
        transform: scale(0);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ==================== 通知和Toast ==================== */

.toast {
    animation: slideInRight 0.5s ease-out;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.remove {
    animation: slideOutRight 0.5s ease-out forwards;
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* ==================== 移动端优化 ==================== */

@media (max-width: 768px) {
    .mobile-tap:active {
        opacity: 0.7;
        transform: scale(0.98);
    }
    
    .mobile-swipe {
        transition: transform 0.3s ease;
    }
}

/* 聊天气泡渐入动画 */
@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeInSlide 0.5s ease-out;
}

/* 消息气泡样式 */
.message-ai {
    position: relative;
}

.message-user {
    position: relative;
}

.message-ai::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 20px;
    border-width: 6px;
    border-style: solid;
    border-color: transparent transparent white transparent;
}

.message-user::before {
    content: '';
    position: absolute;
    right: -6px;
    top: 20px;
    border-width: 6px;
    border-style: solid;
    border-color: transparent transparent purple transparent;
}

/* 步骤指示器 */
.step-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #d1d5db;
}

.step-dot.active {
    background-color: #9333ea;
}

.step-dot.completed {
    background-color: #22c55e;
}

/* 模拟思考效果 */
.thinking-dots {
    display: flex;
    gap: 4px;
    padding: 12px;
}

.thinking-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #9333ea;
    animation: thinking 1.4s ease-in-out infinite;
}

.thinking-dot:nth-child(1) {
    animation-delay: 0s;
}

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

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

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

/* 打字机效果 */
.typewriter {
    overflow: hidden;
    white-space: nowrap;
    animation: typing 2s steps(40);
}

@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}
