/**
 * CrossBorder Pro 高级动画效果
 * 
 * @package CrossBorder Pro
 */

/* ===== 进入动画 ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

@keyframes slideInUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* ===== 强调动画 ===== */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(230, 126, 34, 0.4);
    }
    50% {
        box-shadow: 0 0 30px 10px rgba(230, 126, 34, 0.2);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

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

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

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

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

@keyframes wave {
    0% {
        transform: translateX(0);
    }
    50% {
        transform: translateX(-25%);
    }
    100% {
        transform: translateX(-50%);
    }
}

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

/* ===== 滚动触发动画 ===== */
.scroll-fade-in {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.scroll-fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

.scroll-zoom-in {
    opacity: 0;
    transform: scale(0.9);
    transition: all 0.8s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.scroll-zoom-in.visible {
    opacity: 1;
    transform: scale(1);
}

.scroll-slide-left {
    opacity: 0;
    transform: translateX(50px);
    transition: all 0.8s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.scroll-slide-left.visible {
    opacity: 1;
    transform: translateX(0);
}

.scroll-slide-right {
    opacity: 0;
    transform: translateX(-50px);
    transition: all 0.8s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.scroll-slide-right.visible {
    opacity: 1;
    transform: translateX(0);
}

/* ===== 应用动画类 ===== */
.animated {
    animation-duration: 0.8s;
    animation-fill-mode: both;
}

.animated.fast {
    animation-duration: 0.5s;
}

.animated.slow {
    animation-duration: 1.2s;
}

.animated.infinite {
    animation-iteration-count: infinite;
}

.fadeInUp {
    animation-name: fadeInUp;
}

.fadeInDown {
    animation-name: fadeInDown;
}

.fadeInLeft {
    animation-name: fadeInLeft;
}

.fadeInRight {
    animation-name: fadeInRight;
}

.zoomIn {
    animation-name: zoomIn;
}

.pulse {
    animation: pulse 2s ease infinite;
}

.pulse-glow {
    animation: pulseGlow 2s ease infinite;
}

.shake {
    animation: shake 0.5s ease;
}

.bounce {
    animation: bounce 2s ease infinite;
}

.float {
    animation: float 3s ease infinite;
}

.rotate {
    animation: rotate 10s linear infinite;
}

.shimmer {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

/* ===== 加载动画 ===== */
.loader {
    width: 50px;
    height: 50px;
    border: 3px solid var(--border-color);
    border-top-color: var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s infinite linear;
}

.loader-dots {
    display: flex;
    gap: 8px;
}

.loader-dots span {
    width: 10px;
    height: 10px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: dots 1.4s infinite ease-in-out both;
}

.loader-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.loader-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

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

.loader-ripple {
    display: inline-block;
    position: relative;
    width: 80px;
    height: 80px;
}

.loader-ripple div {
    position: absolute;
    border: 4px solid var(--secondary-color);
    opacity: 1;
    border-radius: 50%;
    animation: ripple 1s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}

.loader-ripple div:nth-child(2) {
    animation-delay: -0.5s;
}

@keyframes ripple {
    0% {
        top: 36px;
        left: 36px;
        width: 0;
        height: 0;
        opacity: 1;
    }
    100% {
        top: 0px;
        left: 0px;
        width: 72px;
        height: 72px;
        opacity: 0;
    }
}

/* ===== 悬停效果 ===== */
.hover-grow {
    transition: transform 0.3s ease;
}

.hover-grow:hover {
    transform: scale(1.05);
}

.hover-shrink {
    transition: transform 0.3s ease;
}

.hover-shrink:hover {
    transform: scale(0.95);
}

.hover-rotate {
    transition: transform 0.3s ease;
}

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

.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px var(--shadow-hover);
}

.hover-shadow {
    transition: box-shadow 0.3s ease;
}

.hover-shadow:hover {
    box-shadow: 0 10px 30px var(--shadow-hover);
}

.hover-border {
    position: relative;
    overflow: hidden;
}

.hover-border::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--secondary-color);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.hover-border:hover::after {
    transform: translateX(0);
}

/* ===== 页面过渡 ===== */
.page-transition {
    animation: pageTransition 0.5s ease;
}

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

/* ===== 购物车抖动 ===== */
.cart-shake {
    animation: shake 0.5s ease;
}

/* ===== 星星闪烁 ===== */
@keyframes twinkle {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

.star-twinkle {
    animation: twinkle 2s ease infinite;
}

/* ===== 粒子动画 ===== */
.particle {
    position: absolute;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    pointer-events: none;
    animation: particleFloat linear infinite;
}

@keyframes particleFloat {
    from {
        transform: translateY(100vh) translateX(-50%);
    }
    to {
        transform: translateY(-100%) translateX(50%);
    }
}

/* ===== 波浪效果 ===== */
.wave-divider {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    overflow: hidden;
    line-height: 0;
}

.wave-divider svg {
    position: relative;
    display: block;
    width: calc(100% + 1.3px);
    height: 50px;
    animation: wave 20s linear infinite;
}

/* ===== AI推荐卡片样式 ===== */
.ai-recommendation-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 5px 20px var(--shadow-color);
    transition: all 0.3s ease;
    position: relative;
}

.ai-recommendation-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px var(--shadow-hover);
}

.ai-rec-image {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
}

.ai-rec-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
}

.ai-recommendation-card:hover .ai-rec-image img {
    transform: scale(1.1);
}

.ai-rec-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 5px 12px;
    border-radius: 30px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.ai-rec-badge i {
    font-size: 12px;
}

.ai-rec-content {
    padding: 20px;
}

.ai-rec-title {
    font-size: 16px;
    margin-bottom: 10px;
    line-height: 1.4;
}

.ai-rec-title a {
    color: var(--text-color);
    transition: color 0.3s ease;
}

.ai-rec-title a:hover {
    color: var(--secondary-color);
}

.ai-rec-price {
    font-size: 18px;
    font-weight: 700;
    color: var(--secondary-color);
    margin-bottom: 15px;
}

.ai-rec-match-bar {
    margin-bottom: 15px;
}

.match-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 5px;
}

.match-bar {
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.match-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 3px;
    transition: width 0.6s ease;
}

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

.ai-rec-actions .btn {
    flex: 1;
}

.ai-rec-actions .btn-small {
    padding: 8px 12px;
    font-size: 13px;
}

/* ===== 3D查看器样式 ===== */
.product-3d-viewer-wrapper {
    margin-bottom: 30px;
}

.viewer-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.viewer-tab {
    padding: 10px 25px;
    background: none;
    border: none;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.viewer-tab i {
    font-size: 16px;
}

.viewer-tab:hover {
    color: var(--secondary-color);
    background: var(--background-light);
}

.viewer-tab.active {
    background: var(--secondary-color);
    color: white;
}

.viewer-panels {
    position: relative;
    min-height: 400px;
}

.viewer-panel {
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.viewer-panel.active {
    display: block;
    opacity: 1;
}

#viewer-image {
    text-align: center;
}

#viewer-image img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 5px 20px var(--shadow-color);
}

.model-viewer-container {
    position: relative;
    width: 100%;
    height: 500px;
    background: var(--primary-dark);
    border-radius: 12px;
    overflow: hidden;
}

.viewer-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    background: rgba(255, 255, 255, 0.9);
    padding: 10px;
    border-radius: 50px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.viewer-control {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: white;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.viewer-control:hover {
    background: var(--secondary-color);
    color: white;
    transform: scale(1.1);
}

.viewer-control.active {
    background: var(--secondary-color);
    color: white;
}

.viewer-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    color: white;
}

.viewer-loading .loader {
    border-top-color: var(--secondary-color);
}

.viewer-error {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    color: white;
}

.viewer-error i {
    font-size: 48px;
    color: #e74c3c;
    margin-bottom: 20px;
}

/* ===== 推荐网格 ===== */
.ai-recommendations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 25px;
    margin-top: 30px;
}

.recommendations-loading {
    text-align: center;
    padding: 50px;
}

.no-recommendations {
    text-align: center;
    padding: 50px;
    color: var(--text-light);
    font-size: 16px;
}

/* ===== 响应式调整 ===== */
@media (max-width: 768px) {
    .ai-recommendations-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 15px;
    }
    
    .viewer-tabs {
        justify-content: center;
    }
    
    .viewer-tab {
        padding: 8px 20px;
        font-size: 13px;
    }
    
    .viewer-controls {
        bottom: 10px;
        padding: 8px;
    }
    
    .viewer-control {
        width: 35px;
        height: 35px;
    }
    
    .ai-rec-actions {
        flex-direction: column;
    }
}

@media (max-width: 576px) {
    .ai-recommendations-grid {
        grid-template-columns: 1fr;
    }
    
    .model-viewer-container {
        height: 350px;
    }
}

/* ===== 暗黑模式适配 ===== */
@media (prefers-color-scheme: dark) {
    .ai-recommendation-card {
        background: #2d2d2d;
    }
    
    .ai-rec-title a {
        color: #e0e0e0;
    }
    
    .viewer-control {
        background: #3d3d3d;
        color: #e0e0e0;
    }
    
    .viewer-control:hover {
        background: var(--secondary-color);
        color: white;
    }
    
    .viewer-controls {
        background: rgba(45, 45, 45, 0.9);
    }
}