/**
 * Micro-animations for DocuFlow
 * Smooth, subtle animations following Apple HIG and Material Design 3
 * Optimized for performance with GPU acceleration
 */

/* ========== Button Animations ========== */
@keyframes buttonPress {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

@keyframes buttonRipple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

.btn, .btn-primary, .btn-secondary, .btn-icon {
    position: relative;
    overflow: hidden;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.btn:active, .btn-primary:active, .btn-secondary:active {
    animation: buttonPress 0.2s ease;
}

.btn::before, .btn-primary::before, .btn-secondary::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.3s, height 0.3s;
    pointer-events: none;
}

.btn:hover::before, .btn-primary:hover::before, .btn-secondary:hover::before {
    width: 300px;
    height: 300px;
}

/* ========== Card Animations ========== */
@keyframes cardHover {
    from {
        transform: translateY(0);
        box-shadow: 0 2px 4px var(--shadow);
    }
    to {
        transform: translateY(-4px);
        box-shadow: 0 8px 16px var(--shadow-lg);
    }
}

@keyframes cardPress {
    0% { transform: scale(1); }
    50% { transform: scale(0.98); }
    100% { transform: scale(1); }
}

.card, .mobile-card, .article-card, .task-item, 
.incident-item, .course-card, .project-card, .ticket-item,
.operation-card, .dashboard-card {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, box-shadow;
}

@media (min-width: 768px) {
    .card:hover, .mobile-card:hover, .article-card:hover,
    .task-item:hover, .incident-item:hover, .course-card:hover,
    .project-card:hover, .ticket-item:hover, .operation-card:hover,
    .dashboard-card:hover {
        animation: cardHover 0.3s ease forwards;
    }
}

.card:active, .mobile-card:active {
    animation: cardPress 0.2s ease;
}

/* ========== List Item Animations ========== */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.list-item, .mobile-list-item, .mobile-table-card {
    animation: slideInRight 0.3s ease;
    animation-fill-mode: both;
}

.list-item:nth-child(1), .mobile-list-item:nth-child(1) { animation-delay: 0.05s; }
.list-item:nth-child(2), .mobile-list-item:nth-child(2) { animation-delay: 0.1s; }
.list-item:nth-child(3), .mobile-list-item:nth-child(3) { animation-delay: 0.15s; }
.list-item:nth-child(4), .mobile-list-item:nth-child(4) { animation-delay: 0.2s; }
.list-item:nth-child(5), .mobile-list-item:nth-child(5) { animation-delay: 0.25s; }

/* ========== Loading Animations ========== */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes shimmer {
    0% { background-position: -1000px 0; }
    100% { background-position: 1000px 0; }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

.spinner {
    animation: spin 1s linear infinite;
    will-change: transform;
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--surface) 0%,
        var(--surface-hover) 50%,
        var(--surface) 100%
    );
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

.loading-bounce {
    animation: bounce 1s ease-in-out infinite;
}

/* ========== Modal Animations ========== */
@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-overlay, .mobile-modal-overlay {
    animation: fadeIn 0.2s ease;
}

.modal-content {
    animation: modalFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-modal, .mobile-bottom-sheet {
    animation: modalSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== Toast Animations ========== */
@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
}

.toast {
    animation: toastSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.hiding {
    animation: toastSlideOut 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== Coffee-themed Animations ========== */
@keyframes coffeeSteam {
    0%, 100% {
        opacity: 0;
        transform: translateY(0) scale(1);
    }
    50% {
        opacity: 0.6;
        transform: translateY(-10px) scale(1.1);
    }
}

@keyframes coffeeBean {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(5deg);
    }
    75% {
        transform: rotate(-5deg);
    }
}

.coffee-icon {
    animation: coffeeSteam 3s ease-in-out infinite;
}

.coffee-bean-icon {
    animation: coffeeBean 2s ease-in-out infinite;
}

/* ========== SVG Icon Styles ========== */
.svg-icon {
    display: inline-block;
    vertical-align: middle;
    transition: transform 0.2s ease, opacity 0.2s ease;
    will-change: transform;
}

.svg-icon:hover {
    transform: scale(1.1);
}

.svg-icon-animated {
    animation: pulse 2s ease-in-out infinite;
}

.svg-icon-loading {
    opacity: 0.5;
    animation: pulse 1s ease-in-out infinite;
}

/* Coffee-themed SVG animations */
.svg-icon[data-icon="coffee-cup"] {
    animation: coffeeSteam 3s ease-in-out infinite;
}

.svg-icon[data-icon="coffee-bean"] {
    animation: coffeeBean 2s ease-in-out infinite;
}

/* ========== Input Animations ========== */
@keyframes inputFocus {
    from {
        box-shadow: 0 0 0 0 var(--input-focus-shadow);
    }
    to {
        box-shadow: 0 0 0 3px var(--input-focus-shadow);
    }
}

input:focus, textarea:focus, select:focus,
.mobile-form-input:focus {
    animation: inputFocus 0.2s ease forwards;
}

/* ========== Tab Animations ========== */
@keyframes tabSlide {
    from {
        transform: translateX(-10px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.tab-content {
    animation: tabSlide 0.3s ease;
}

/* ========== Smooth Transitions ========== */
/* Base transitions are in main.css, but we add performance optimizations here */
* {
    transition: background-color 0.2s ease,
                color 0.2s ease,
                border-color 0.2s ease,
                box-shadow 0.2s ease;
}

/* Disable transitions for performance-critical elements */
canvas, video, iframe, svg:not(.svg-icon-animated) {
    transition: none !important;
}

/* GPU acceleration for animated elements */
.card, .mobile-card, .btn, .modal-content,
.mobile-modal, .toast {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* ========== Hover Effects ========== */
@keyframes iconRotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.btn-icon:hover i.fa-sync,
.btn-icon:hover i.fa-refresh {
    animation: iconRotate 1s linear infinite;
}

/* ========== Progress Bar Animation ========== */
@keyframes progressBar {
    from {
        width: 0%;
    }
}

.progress-bar {
    animation: progressBar 1s ease-out;
}

/* ========== Notification Badge Animation ========== */
@keyframes badgePulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.badge, .notification-badge {
    animation: badgePulse 2s ease-in-out infinite;
}

/* ========== Skeleton Loading ========== */
@keyframes skeletonWave {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: calc(200px + 100%) 0;
    }
}

.skeleton-text, .skeleton-box {
    background: linear-gradient(
        90deg,
        var(--surface) 0%,
        var(--surface-hover) 50%,
        var(--surface) 100%
    );
    background-size: 200px 100%;
    animation: skeletonWave 1.5s ease-in-out infinite;
}

