/* Animations for Fitness App */

/* Keyframes */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

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

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

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

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

@keyframes successCheck {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes loadingSpinner {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Login/Registration Animations */
.auth-box {
    animation: fadeIn 0.6s ease-out;
}

.auth-form {
    animation: slideInFromLeft 0.8s ease-out 0.2s both;
}

.form-group {
    animation: fadeIn 0.5s ease-out;
    animation-fill-mode: both;
}

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

/* Button Animations */
.btn-primary, .btn-secondary, .btn-success, .btn-danger {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.btn-primary:hover, .btn-secondary:hover, .btn-success:hover, .btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.btn-primary:active, .btn-secondary:active, .btn-success:active, .btn-danger:active {
    transform: translateY(0);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Ripple effect for buttons */
.btn-primary::before, .btn-secondary::before, .btn-success::before, .btn-danger::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-primary:active::before, .btn-secondary:active::before, .btn-success:active::before, .btn-danger:active::before {
    width: 300px;
    height: 300px;
}

/* Navigation Animations */
.nav-item {
    transition: all 0.3s ease;
    position: relative;
}

.nav-item:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.1);
}

.nav-item.active {
    animation: pulse 2s infinite;
}

.nav-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 3px;
    background: #667eea;
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.nav-item:hover::after,
.nav-item.active::after {
    width: 100%;
}

/* Page Transitions */
.page {
    animation: fadeIn 0.5s ease-out;
}

.page.active {
    animation: slideInFromRight 0.6s ease-out;
}

/* Card Animations */
.card, .exercise-card, .nutrition-card, .hydration-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: fadeIn 0.6s ease-out;
}

.card:hover, .exercise-card:hover, .nutrition-card:hover, .hydration-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
}

/* Input Field Animations */
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    animation: pulse 0.3s ease-out;
}

/* Success/Error Animations */
.notification.success {
    animation: slideInFromRight 0.5s ease-out;
}

.notification.error {
    animation: shake 0.5s ease-out;
}

/* Loading Animations */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: loadingSpinner 1s ease-in-out infinite;
}

/* Progress Bar Animations */
.progress-bar {
    transition: width 1s ease-in-out;
    animation: pulse 2s infinite;
}

/* Chart Animations */
canvas {
    transition: all 0.3s ease;
}

canvas:hover {
    transform: scale(1.02);
}

/* Exercise List Animations */
.exercise-item {
    animation: fadeIn 0.5s ease-out;
    transition: all 0.3s ease;
}

.exercise-item:hover {
    transform: translateX(10px);
    background: rgba(102, 126, 234, 0.05);
}

/* Modal Animations */
.modal {
    animation: scaleIn 0.3s ease-out;
}

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

/* Success Check Animation */
.success-check {
    animation: successCheck 0.6s ease-out;
}

/* Height Input Animation */
.height-input {
    transition: all 0.3s ease;
}

.height-input:focus {
    transform: scale(1.02);
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.3);
}

/* Exercise Video/Image Hover Effects */
.exercise-media {
    transition: all 0.3s ease;
    cursor: pointer;
}

.exercise-media:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

/* Dashboard Stats Animation */
.stat-card {
    animation: bounceIn 0.8s ease-out;
    animation-fill-mode: both;
}

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

/* AI Coach Animation */
.ai-message {
    animation: slideInFromLeft 0.5s ease-out;
}

.user-message {
    animation: slideInFromRight 0.5s ease-out;
}

/* Settings Toggle Animation */
.toggle-switch {
    transition: all 0.3s ease;
}

.toggle-switch:checked {
    animation: pulse 0.3s ease-out;
}

/* Dark Mode Transition */
body {
    transition: background 0.3s ease, color 0.3s ease;
}

/* Responsive Animations */
@media (max-width: 768px) {
    .card:hover, .exercise-card:hover, .nutrition-card:hover, .hydration-card:hover {
        transform: none;
    }
    
    .exercise-item:hover {
        transform: none;
    }
}

/* Accessibility - Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
