/**
 * MetroNeuro Animation System CSS
 * 
 * Modern, performant animations with accessibility support
 * Works with Tailwind CSS
 */

/* ================================
   CORE ANIMATION CLASSES
   ================================ */

[data-animate] {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-animate].animate-in {
    opacity: 1;
    transform: translateY(0);
}

/* Animation variants */
[data-animate="fade"] {
    transform: none;
}

[data-animate="slide-left"] {
    transform: translateX(-30px);
}

[data-animate].animate-in[data-animate="slide-left"] {
    transform: translateX(0);
}

[data-animate="slide-right"] {
    transform: translateX(30px);
}

[data-animate].animate-in[data-animate="slide-right"] {
    transform: translateX(0);
}

[data-animate="scale"] {
    transform: scale(0.9);
}

[data-animate].animate-in[data-animate="scale"] {
    transform: scale(1);
}

[data-animate="zoom"] {
    transform: scale(0.8);
}

[data-animate].animate-in[data-animate="zoom"] {
    transform: scale(1);
}

/* ================================
   NAVBAR SCROLL EFFECT
   ================================ */

.mn-nav {
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.mn-nav.scrolled {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(12px);
}

/* ================================
   BUTTON ANIMATIONS
   ================================ */

.mn-btn,
.animated-btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.mn-btn:hover,
.animated-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 24px rgba(192, 16, 32, 0.25);
}

.mn-btn:active,
.animated-btn:active {
    transform: translateY(0) scale(0.98);
}

/* Ripple effect */
.mn-btn::after,
.animated-btn::after {
    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;
}

.mn-btn:active::after,
.animated-btn:active::after {
    width: 300px;
    height: 300px;
}

/* Loading state */
.loading {
    pointer-events: none;
    opacity: 0.7;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    display: inline-block;
    animation: spin 1s linear infinite;
}

.loading-spinner-circle {
    fill: none;
    stroke: currentColor;
    stroke-width: 3;
    stroke-dasharray: 60;
    stroke-dashoffset: 0;
    stroke-linecap: round;
    animation: spinner-dash 1.5s ease-in-out infinite;
}

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

@keyframes spinner-dash {
    0% {
        stroke-dasharray: 1, 150;
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -35;
    }
    100% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -124;
    }
}

/* ================================
   CARD ANIMATIONS
   ================================ */

.animated-card,
.mn-card {
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.animated-card:hover,
.mn-card-hover:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
}

/* Enhanced hover effects for stats and info cards */
.stat-card-hover,
.info-card-hover {
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
}

.stat-card-hover:hover,
.info-card-hover:hover {
    transform: translateY(-6px) scale(1.03);
    box-shadow: 0 16px 40px rgba(192, 16, 32, 0.18);
    border-color: rgba(192, 16, 32, 0.35);
}

/* Pulse effect for numbers on hover */
.stat-card-hover:hover .counter,
.stat-card-hover:hover .text-4xl {
    animation: pulse-scale 0.6s ease-in-out;
}

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

/* Icon hover effect inside cards */
.mn-card:hover .card-icon,
.mn-card-hover:hover .card-icon,
.stat-card-hover:hover .card-icon {
    transform: scale(1.15) rotate(8deg);
    background-color: rgba(192, 16, 32, 0.18);
}

.card-icon {
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform;
}

/* 3D card effect */
[data-card-3d] {
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transform-style: preserve-3d;
}

/* ================================
   TOAST NOTIFICATIONS
   ================================ */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    margin-bottom: 12px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    border-left: 4px solid;
    pointer-events: all;
    min-width: 320px;
    max-width: 450px;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-success { border-color: #10b981; }
.toast-error { border-color: #ef4444; }
.toast-warning { border-color: #f59e0b; }
.toast-info { border-color: #3b82f6; }

.toast-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

.toast-success .toast-icon { color: #10b981; }
.toast-error .toast-icon { color: #ef4444; }
.toast-warning .toast-icon { color: #f59e0b; }
.toast-info .toast-icon { color: #3b82f6; }

.toast-message {
    flex: 1;
    font-size: 14px;
    color: #374151;
    font-weight: 500;
}

.toast-close {
    flex-shrink: 0;
    padding: 4px;
    border-radius: 4px;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
    border: none;
}

.toast-close:hover {
    background: #f3f4f6;
    color: #374151;
}

/* Mobile responsiveness */
@media (max-width: 640px) {
    .toast-container {
        right: 10px;
        left: 10px;
        top: 10px;
    }
    
    .toast {
        min-width: auto;
        width: 100%;
    }
}

/* ================================
   FORM ANIMATIONS
   ================================ */

.mn-input,
input, textarea, select {
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.mn-input:focus,
input:focus,
textarea:focus,
select:focus {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(192, 16, 32, 0.15);
}

.focused {
    animation: input-focus 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes input-focus {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

/* Error animation */
.text-red-600,
.mn-error {
    animation: shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

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

/* ================================
   PARALLAX EFFECTS
   ================================ */

[data-parallax] {
    will-change: transform;
}

/* ================================
   IMAGE LAZY LOADING
   ================================ */

img[data-src] {
    opacity: 0;
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

img[data-src].loaded {
    opacity: 1;
}

/* ================================
   COUNTER ANIMATION
   ================================ */

[data-counter] {
    font-variant-numeric: tabular-nums;
}

/* ================================
   PAGE TRANSITIONS
   ================================ */

.page-enter {
    animation: page-enter 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* ================================
   SKELETON LOADERS
   ================================ */

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

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

/* ================================
   UTILITY ANIMATIONS
   ================================ */

.fade-in {
    animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.slide-up {
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.scale-in {
    animation: scaleIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* ================================
   ACCESSIBILITY
   ================================ */

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    [data-animate] {
        opacity: 1;
        transform: none;
    }
    
    [data-parallax] {
        transform: none !important;
    }
}

/* ================================
   RESPONSIVE ADJUSTMENTS
   ================================ */

/* Mobile optimizations */
@media (max-width: 768px) {
    [data-animate] {
        transform: translateY(20px);
    }
    
    .animated-card:hover,
    .mn-card-hover:hover {
        transform: none; /* Disable hover on mobile */
    }
    
    [data-card-3d] {
        transform: none !important; /* Disable 3D on mobile */
    }
}

/* Performance optimizations */
.mn-btn,
.animated-btn,
.animated-card,
.mn-card,
[data-animate],
[data-parallax] {
    will-change: transform, opacity;
}

.animations-loaded .mn-btn,
.animations-loaded .animated-btn,
.animations-loaded .animated-card,
.animations-loaded .mn-card {
    will-change: auto;
}
