/**
 * Animaciones y Transiciones - tienda3d
 * Sistema de Cotización y Gestión de Impresión 3D
 * 
 * @author tienda3d Development Team
 * @version 2.0.0
 */

/* =================================================================
   ANIMACIONES GLOBALES
   ================================================================= */

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

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

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

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

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

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

@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;
    }
}

/* =================================================================
   HAMBURGER MENU ANIMACIONES
   ================================================================= */

@keyframes hamburgerTop {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(8px) rotate(45deg);
    }
}

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

@keyframes hamburgerBottom {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(-8px) rotate(-45deg);
    }
}

/* =================================================================
   APLICACIÓN DE ANIMACIONES A ELEMENTOS
   ================================================================= */

.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

.slide-up {
    animation: slideUpFadeIn 0.4s ease-out;
}

.slide-down {
    animation: slideDownFadeIn 0.4s ease-out;
}

.slide-left {
    animation: slideLeftFadeIn 0.4s ease-out;
}

.slide-right {
    animation: slideRightFadeIn 0.4s ease-out;
}

.scale-in {
    animation: scaleIn 0.3s ease-out;
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* =================================================================
   LOADING SPINNER MEJORADO
   ================================================================= */

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-border);
    border-top: 3px solid var(--color-secondary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.dark .loading-spinner {
    border-color: var(--color-border);
    border-top-color: var(--color-secondary);
}

/* =================================================================
   TAB ANIMACIONES
   ================================================================= */

.tab-section {
    animation: slideUpFadeIn 0.4s ease-out;
}

.nav-tab {
    position: relative;
    transition: all 0.3s ease;
}

.nav-tab::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(to right, var(--color-primary), var(--color-secondary));
    transition: width 0.3s ease;
}

.nav-tab.active::after {
    width: 100%;
}

/* =================================================================
   BUTTON HOVER ANIMACIONES
   ================================================================= */

.btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

/* =================================================================
   CARD HOVER ANIMACIONES
   ================================================================= */

.metric-card,
.pedidos-table tbody tr,
.catalog-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.metric-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
}

.pedidos-table tbody tr:hover {
    background-color: var(--color-bg-hover);
}

.dark .pedidos-table tbody tr:hover {
    background-color: var(--color-bg-hover);
}

/* =================================================================
   MODAL ANIMACIONES
   ================================================================= */

.modal-overlay {
    animation: fadeIn 0.2s ease-out;
}

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

/* =================================================================
   SKELETON LOADER
   ================================================================= */

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

.dark .skeleton {
    background: linear-gradient(
        90deg,
        #1c212a 25%,
        #222933 50%,
        #1c212a 75%
    );
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

/* =================================================================
   TRANSICIONES SUAVES GENERALES
   ================================================================= */

* {
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    animation: scaleIn 0.2s ease-out;
}

/* =================================================================
   NOTIFICACIONES/TOAST
   ================================================================= */

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

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.toast {
    animation: slideInRight 0.3s ease-out;
}

.toast.closing {
    animation: slideOutRight 0.3s ease-out forwards;
}

/* =================================================================
   RESPONSIVE: Mobile First
   ================================================================= */

@media (max-width: 768px) {
    .tab-section {
        animation: slideUpFadeIn 0.3s ease-out;
    }

    .nav-tab {
        animation: slideUpFadeIn 0.4s ease-out;
    }

    /* Animación más rápida en móvil */
    .metric-card:active {
        transform: scale(0.98);
    }
}
