/* Advanced Animations and Visual Effects */

/* Modern Entrance Animations */
.animate-fade-in {
    animation: fadeInUp 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.animate-slide-in-left {
    animation: slideInLeft 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.animate-slide-in-right {
    animation: slideInRight 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.animate-zoom-in {
    animation: zoomIn 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.animate-float {
    animation: float 6s ease-in-out infinite;
}

.floating {
    animation: float 6s ease-in-out infinite;
    will-change: transform;
}

.animate-bounce {
    animation: gentleBounce 2s ease-in-out infinite;
}

.animate-pulse {
    animation: smoothPulse 2s ease-in-out infinite;
}

.animate-rotate {
    animation: smoothRotate 20s linear infinite;
}

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

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

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

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

@keyframes float {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    33% {
        transform: translateY(-15px) rotate(1deg);
    }
    66% {
        transform: translateY(-5px) rotate(-1deg);
    }
}

@keyframes gentleBounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-8px);
    }
    60% {
        transform: translateY(-4px);
    }
}

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

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

/* Enhanced Card Hover Effects */
.card {
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: -100%;
    left: -100%;
    width: 300%;
    height: 300%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.05) 0%, transparent 70%);
    transition: all 0.6s ease;
    transform: scale(0);
    z-index: 1;
}

.card:hover::before {
    transform: scale(1);
    top: -150%;
    left: -150%;
}

.card > * {
    position: relative;
    z-index: 2;
}

.dashboard-card:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.course-card:hover {
    transform: translateY(-8px) rotateY(2deg);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.category-card {
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
}

.category-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s;
}

.category-card:hover::before {
    left: 100%;
}

.category-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
}

/* Enhanced Button Effects */
.btn {
    position: relative;
    overflow: hidden;
    transform-style: preserve-3d;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform: translate(-50%, -50%);
    z-index: 0;
    opacity: 0;
}

.btn:active::before {
    width: 400px;
    height: 400px;
    opacity: 1;
    transition: all 0.3s ease;
}

.btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.btn:hover::after {
    left: 100%;
}

.btn > * {
    position: relative;
    z-index: 2;
}

/* Advanced Hover States */
.btn-primary:hover {
    background: linear-gradient(135deg, #5a67d8 0%, #667eea 100%);
    transform: translateY(-3px);
    box-shadow: 0 12px 25px rgba(99, 102, 241, 0.3);
}

.btn-outline-primary:hover {
    background: var(--primary-color);
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 25px rgba(99, 102, 241, 0.2);
}

/* Enhanced Loading Animations */
.loading-skeleton {
    background: linear-gradient(90deg, 
        rgba(243, 244, 246, 0.8) 25%, 
        rgba(229, 231, 235, 0.4) 50%, 
        rgba(243, 244, 246, 0.8) 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 2s ease-in-out infinite;
    border-radius: var(--border-radius-sm);
    position: relative;
    overflow: hidden;
}

.loading-skeleton::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
    animation: skeletonGlow 1.5s ease-in-out infinite;
}

@keyframes skeletonShimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

@keyframes skeletonGlow {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Spinner Enhancements */
.spinner-border {
    border-width: 3px;
    animation: modernSpin 1s linear infinite;
}

@keyframes modernSpin {
    0% {
        transform: rotate(0deg) scale(1);
    }
    50% {
        transform: rotate(180deg) scale(1.1);
    }
    100% {
        transform: rotate(360deg) scale(1);
    }
}

/* Loading Dots */
.loading-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.loading-dots::before,
.loading-dots::after {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-color);
    animation: loadingDots 1.4s ease-in-out infinite both;
}

.loading-dots::before {
    animation-delay: -0.16s;
}

.loading-dots::after {
    animation-delay: 0.16s;
}

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

/* Pulse Animation for Loading States */
.pulse {
    animation: pulse 2s infinite;
}

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

/* Counter Animation */
.counter {
    transition: all 0.3s ease;
}

/* Smooth Page Transitions */
.page-enter {
    opacity: 0;
    transform: translateY(20px);
}

.page-enter-active {
    opacity: 1;
    transform: translateY(0);
    transition: all 0.3s ease;
}

/* Navbar Animation */
.navbar {
    transition: all 0.3s ease;
}

.navbar.scrolled {
    background-color: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
}

/* Progress Bar Animations */
.progress-bar {
    transition: width 0.5s ease;
}

.progress-bar-animated {
    animation: progress-bar-stripes 1s linear infinite;
}

@keyframes progress-bar-stripes {
    0% {
        background-position: 1rem 0;
    }
    100% {
        background-position: 0 0;
    }
}

/* Modal Animations */
.modal.fade .modal-dialog {
    transition: transform 0.3s ease-out;
    transform: translate(0, -50px);
}

.modal.show .modal-dialog {
    transform: none;
}

/* Toast Animations */
.toast {
    transition: all 0.3s ease;
}

.toast.show {
    animation: slideInRight 0.3s ease;
}

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

/* Dropdown Animations */
.dropdown-menu {
    animation: dropdownFadeIn 0.2s ease;
    transform-origin: top;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: scaleY(0.8);
    }
    to {
        opacity: 1;
        transform: scaleY(1);
    }
}

/* Course Grid Animations */
.course-item {
    animation: slideInUp 0.6s ease forwards;
    opacity: 0;
    transform: translateY(30px);
}

.course-item:nth-child(1) { animation-delay: 0.1s; }
.course-item:nth-child(2) { animation-delay: 0.2s; }
.course-item:nth-child(3) { animation-delay: 0.3s; }
.course-item:nth-child(4) { animation-delay: 0.4s; }

@keyframes slideInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stats Counter Animation */
.stats-card {
    animation: popIn 0.6s ease forwards;
    opacity: 0;
    transform: scale(0.8);
}

.stats-card:nth-child(1) { animation-delay: 0.1s; }
.stats-card:nth-child(2) { animation-delay: 0.2s; }
.stats-card:nth-child(3) { animation-delay: 0.3s; }
.stats-card:nth-child(4) { animation-delay: 0.4s; }

@keyframes popIn {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Scroll-triggered Animations */
.scroll-reveal {
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.6s ease;
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Micro-interactions */
.interactive-element {
    transition: all 0.2s ease;
}

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

.interactive-element:active {
    transform: scale(0.95);
}

/* Badge Animations */
.badge {
    animation: badgeAppear 0.5s ease forwards;
    transform: scale(0);
}

@keyframes badgeAppear {
    to {
        transform: scale(1);
    }
}

/* Enhanced Video Player */
.video-overlay {
    background: linear-gradient(45deg, rgba(99, 102, 241, 0.8), rgba(139, 92, 246, 0.8));
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    overflow: hidden;
}

.video-overlay::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    transform: scale(0);
    transition: transform 0.6s ease;
}

.video-overlay:hover {
    background: linear-gradient(45deg, rgba(99, 102, 241, 0.9), rgba(139, 92, 246, 0.9));
    transform: scale(1.02);
}

.video-overlay:hover::before {
    transform: scale(1);
    animation: videoShimmer 2s ease-in-out;
}

@keyframes videoShimmer {
    0%, 100% {
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
}

/* Play button animation */
.video-play-btn {
    position: relative;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.video-play-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(1);
    animation: playButtonPulse 2s ease-in-out infinite;
}

.video-play-btn:hover {
    transform: scale(1.1);
}

@keyframes playButtonPulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.5;
    }
}

/* Form Focus Animations */
.form-floating input:focus,
.form-floating textarea:focus {
    transform: scale(1.02);
    transition: transform 0.2s ease;
}

/* Notification Slide */
.notification-enter {
    transform: translateX(100%);
    opacity: 0;
}

.notification-enter-active {
    transform: translateX(0);
    opacity: 1;
    transition: all 0.3s ease;
}

.notification-exit {
    transform: translateX(0);
    opacity: 1;
}

.notification-exit-active {
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s ease;
}

/* Parallax Effects */
.parallax-bg {
    transform: translateZ(0);
    will-change: transform;
}

/* Glassmorphism Effects */
.glass-card {
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

/* Gradient Text */
.gradient-text {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: inline-block;
}

/* Hover Line Effect */
.hover-line {
    position: relative;
    text-decoration: none;
}

.hover-line::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transition: width 0.3s ease;
}

.hover-line:hover::after {
    width: 100%;
}

/* Page Loading Animation */
.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--primary-color);
    z-index: 9999;
    transform: scaleX(0);
    transform-origin: left;
    animation: pageLoad 2s ease forwards;
}

@keyframes pageLoad {
    0% { transform: scaleX(0); }
    50% { transform: scaleX(0.7); }
    100% { transform: scaleX(1); opacity: 0; }
}

/* Enhanced Mobile Animations */
@media (max-width: 768px) {
    .animate-fade-in {
        animation-duration: 0.4s;
    }
    
    .course-card:hover {
        transform: none;
    }
    
    .course-card:active {
        transform: scale(0.96) translateY(2px);
        transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .btn:active {
        transform: scale(0.94);
        transition: transform 0.1s ease;
    }
    
    .dashboard-card:active {
        transform: scale(0.98);
    }
    
    /* Reduce motion for better performance */
    .floating {
        animation-duration: 8s;
    }
    
    .animate-float {
        animation-duration: 8s;
    }
}

/* Touch-specific animations */
@media (hover: none) and (pointer: coarse) {
    .card::before {
        display: none;
    }
    
    .btn::after {
        display: none;
    }
    
    .course-card:hover {
        transform: none;
        box-shadow: var(--shadow);
    }
    
    .btn:hover {
        transform: none;
    }
}

/* Enhanced Accessibility and Performance */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .floating,
    .animate-float,
    .animate-bounce,
    .animate-pulse {
        animation: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .card::before,
    .btn::before,
    .btn::after {
        display: none;
    }
    
    .course-card {
        border-width: 2px;
    }
    
    .btn {
        border-width: 2px;
    }
}

/* Performance optimizations */
.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Modern scroll animations */
@supports (animation-timeline: scroll()) {
    @keyframes scrollAnimation {
        from {
            opacity: 0;
            transform: translateY(50px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    .scroll-animate {
        animation: scrollAnimation linear;
        animation-timeline: view();
        animation-range: entry 0% cover 30%;
    }
}