/**
 * Counter Animation CSS
 * Visual enhancements for counter animations
 */

/* Base counter styling */
[data-counter] {
    display: inline-block;
    font-variant-numeric: tabular-nums;
    transition: all 0.3s ease;
}

/* Animation states */
[data-counter].counter-animating {
    color: #e91e63;
    transform: scale(1.05);
    text-shadow: 0 0 10px rgba(233, 30, 99, 0.3);
}

[data-counter].counter-animation-complete {
    animation: counterComplete 0.5s ease-out;
}

/* Completion animation */
@keyframes counterComplete {
    0% {
        transform: scale(1.1);
        color: #4caf50;
        text-shadow: 0 0 15px rgba(76, 175, 80, 0.5);
    }
    50% {
        transform: scale(1.15);
        color: #4caf50;
        text-shadow: 0 0 20px rgba(76, 175, 80, 0.7);
    }
    100% {
        transform: scale(1);
        color: inherit;
        text-shadow: none;
    }
}

/* Pulse effect during animation */
@keyframes counterPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

[data-counter].counter-animating {
    animation: counterPulse 1s ease-in-out infinite;
}

/* Metric box enhancements */
.item-num [data-counter] {
    font-weight: 700;
    letter-spacing: -0.02em;
}

.item-num [data-counter].counter-animating {
    background: linear-gradient(45deg, #e91e63, #9c27b0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Admin dashboard counters */
.btn-white [data-counter] {
    font-weight: 600;
    color: #2c3e50;
}

.btn-white [data-counter].counter-animating {
    color: #e74c3c;
    font-weight: 700;
}

/* Table counters */
table [data-counter] {
    font-weight: 500;
    color: #34495e;
}

table [data-counter].counter-animating {
    color: #3498db;
    font-weight: 600;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    [data-counter] {
        font-size: 0.9em;
    }
    
    [data-counter].counter-animating {
        transform: scale(1.02);
    }
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    [data-counter].counter-animating {
        color: #ff6b9d;
        text-shadow: 0 0 10px rgba(255, 107, 157, 0.3);
    }
    
    [data-counter].counter-animation-complete {
        color: #4ecdc4;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    [data-counter].counter-animating {
        color: #000;
        background: #ffff00;
        text-shadow: none;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    [data-counter],
    [data-counter].counter-animating,
    [data-counter].counter-animation-complete {
        animation: none;
        transition: none;
        transform: none;
        text-shadow: none;
    }
}

/* Loading state */
[data-counter].counter-loading {
    opacity: 0.6;
    position: relative;
}

[data-counter].counter-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: shimmer 1.5s infinite;
}

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

/* Error state */
[data-counter].counter-error {
    color: #e74c3c;
    position: relative;
}

[data-counter].counter-error::before {
    content: '⚠';
    position: absolute;
    left: -20px;
    color: #e74c3c;
    font-size: 0.8em;
}

/* Success state */
[data-counter].counter-success {
    color: #27ae60;
}

[data-counter].counter-success::after {
    content: '✓';
    margin-left: 5px;
    color: #27ae60;
    font-size: 0.8em;
    opacity: 0;
    animation: fadeInCheck 0.5s ease-out 0.5s forwards;
}

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

/* Hover effects */
[data-counter]:hover {
    cursor: default;
    transform: scale(1.02);
    transition: transform 0.2s ease;
}

/* Focus styles for accessibility */
[data-counter]:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
    border-radius: 2px;
}

/* Print styles */
@media print {
    [data-counter],
    [data-counter].counter-animating,
    [data-counter].counter-animation-complete {
        color: #000 !important;
        background: none !important;
        text-shadow: none !important;
        animation: none !important;
        transform: none !important;
    }
}
