/* Animaciones y estilos responsive mejorados */

/* Animaciones de fade-in */
@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.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Clases de animación */
.animate-fade-in {
    animation: fadeIn 0.6s ease-out forwards;
}

.animate-slide-left {
    animation: slideInFromLeft 0.5s ease-out forwards;
}

.animate-slide-right {
    animation: slideInFromRight 0.5s ease-out forwards;
}

.animate-scale-in {
    animation: scaleIn 0.4s ease-out forwards;
}

/* Mejoras para botones */
.nav-button {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.nav-button:hover::before {
    left: 100%;
}

/* Efectos de hover mejorados */
.mobile-nav-item {
    position: relative;
    overflow: hidden;
}

.mobile-nav-item::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #ef4444, #dc2626);
    transition: width 0.3s ease;
}

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

/* Animaciones para dropdowns */
.dropdown-enter {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
}

.dropdown-enter-active {
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dropdown-exit {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.dropdown-exit-active {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Mejoras para el logo */
.logo-container {
    position: relative;
}

.logo-container::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #ef4444, #dc2626, #b91c1c, #ef4444);
    border-radius: 14px;
    opacity: 0;
    z-index: -1;
    transition: opacity 0.3s ease;
    background-size: 200% 200%;
    animation: gradientShift 3s ease infinite;
}

.logo-container:hover::after {
    opacity: 1;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Animación del hamburger */
.hamburger-line-1,
.hamburger-line-2,
.hamburger-line-3 {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
}

/* Efectos de carga */
.loading-shimmer {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

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

/* Mejoras responsive */
@media (max-width: 640px) {
    .mobile-nav-item {
        font-size: 16px;
        padding: 12px 16px;
    }
    
    .mobile-dropdown-content a {
        font-size: 14px;
        padding: 10px 16px;
    }
    
    /* Asegurar que los elementos táctiles sean lo suficientemente grandes */
    .mobile-menu-btn {
        min-width: 44px;
        min-height: 44px;
    }
    
    .mobile-dropdown-btn {
        min-height: 44px;
    }
}

@media (max-width: 480px) {
    .nav-brand {
        font-size: 18px;
    }
    
    .logo-icon {
        width: 32px;
        height: 32px;
    }
    
    .version-badge {
        font-size: 10px;
        padding: 4px 8px;
    }
}

/* Mejoras para tablets */
@media (min-width: 641px) and (max-width: 1023px) {
    .nav-button {
        padding: 8px 12px;
        font-size: 14px;
    }
    
    .dropdown-menu {
        width: 200px;
    }
}

/* Animaciones de entrada para elementos de página */
.page-enter {
    opacity: 0;
    transform: translateY(30px);
}

.page-enter-active {
    opacity: 1;
    transform: translateY(0);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Efectos de focus mejorados para accesibilidad */
.nav-button:focus,
.mobile-nav-item:focus,
.mobile-dropdown-btn:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 8px;
}

/* Animación de pulso para elementos importantes */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.pulse-animation {
    animation: pulse 2s infinite;
}

/* Mejoras para el sticky header */
.sticky-header {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    background-color: rgba(255, 255, 255, 0.95);
    transition: all 0.3s ease;
}

.sticky-header.scrolled {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    background-color: rgba(255, 255, 255, 0.98);
}

/* Animaciones para elementos de formulario */
.form-group {
    position: relative;
}

.form-input:focus + .form-label,
.form-input:not(:placeholder-shown) + .form-label {
    transform: translateY(-20px) scale(0.8);
    color: #3b82f6;
}

.form-label {
    position: absolute;
    top: 12px;
    left: 12px;
    transition: all 0.3s ease;
    pointer-events: none;
    background: white;
    padding: 0 4px;
}

/* Mejoras para tablas responsive */
@media (max-width: 768px) {
    .table-responsive {
        border: none;
    }
    
    .table-responsive table,
    .table-responsive thead,
    .table-responsive tbody,
    .table-responsive th,
    .table-responsive td,
    .table-responsive tr {
        display: block;
    }
    
    .table-responsive thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    .table-responsive tr {
        border: 1px solid #ccc;
        margin-bottom: 10px;
        padding: 10px;
        border-radius: 8px;
        background: white;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .table-responsive td {
        border: none;
        position: relative;
        padding-left: 50% !important;
        padding-top: 10px;
        padding-bottom: 10px;
    }
    
    .table-responsive td:before {
        content: attr(data-label) ":";
        position: absolute;
        left: 6px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: bold;
        color: #666;
    }
}

/* Animaciones de carga para contenido dinámico */
.content-loading {
    position: relative;
    overflow: hidden;
}

.content-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: loading-sweep 1.5s infinite;
}

@keyframes loading-sweep {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Mejoras para accesibilidad en modo oscuro */
@media (prefers-color-scheme: dark) {
    .nav-button:focus,
    .mobile-nav-item:focus,
    .mobile-dropdown-btn:focus {
        outline-color: #60a5fa;
    }
}

/* Animaciones de entrada escalonadas */
.stagger-animation > * {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeIn 0.6s ease-out forwards;
}

.stagger-animation > *:nth-child(1) { animation-delay: 0.1s; }
.stagger-animation > *:nth-child(2) { animation-delay: 0.2s; }
.stagger-animation > *:nth-child(3) { animation-delay: 0.3s; }
.stagger-animation > *:nth-child(4) { animation-delay: 0.4s; }
.stagger-animation > *:nth-child(5) { animation-delay: 0.5s; }
.stagger-animation > *:nth-child(6) { animation-delay: 0.6s; }
.stagger-animation > *:nth-child(7) { animation-delay: 0.7s; }
.stagger-animation > *:nth-child(8) { animation-delay: 0.8s; }
.stagger-animation > *:nth-child(9) { animation-delay: 0.9s; }
.stagger-animation > *:nth-child(10) { animation-delay: 1.0s; }

/* Estados táctiles */
.touch-active {
    transform: scale(0.95) !important;
    transition: transform 0.1s ease !important;
}

/* Mejoras para el header sticky */
.sticky-header {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Optimizaciones para dispositivos de bajo rendimiento */
.reduced-motion * {
    animation-duration: 0.2s !important;
    transition-duration: 0.2s !important;
}

.reduced-motion .nav-button::before,
.reduced-motion .mobile-nav-item::after {
    display: none;
}

/* Mejoras para elementos en viewport */
.in-viewport {
    animation-play-state: running;
}

.in-viewport.animate-fade-in {
    opacity: 1;
    transform: translateY(0);
}

/* Estilos para botones mejorados */
.btn-enhanced {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border: none;
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-enhanced::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.6s;
}

.btn-enhanced:hover::before {
    left: 100%;
}

.btn-enhanced:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.4);
}

.btn-enhanced:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

/* Mejoras para cards */
.card-enhanced {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.card-enhanced:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

/* Indicadores de carga mejorados */
.loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

/* Mejoras para inputs */
.input-enhanced {
    border: 2px solid #e5e5e5;
    border-radius: 12px;
    padding: 12px 16px;
    transition: all 0.3s ease;
    background: white;
}

.input-enhanced:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    outline: none;
}

/* Mejoras para el menú móvil */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 40;
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Mejoras para tooltips */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-4px);
}

/* Mejoras para notificaciones */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    padding: 16px 20px;
    border-left: 4px solid #10b981;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

.notification.show {
    transform: translateX(0);
}

.notification.error {
    border-left-color: #ef4444;
}

.notification.warning {
    border-left-color: #f59e0b;
}

.notification.info {
    border-left-color: #3b82f6;
}

/* Mejoras para el scroll personalizado */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
    transition: background 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Mejoras para el modo oscuro */
@media (prefers-color-scheme: dark) {
    .card-enhanced {
        background: #1f2937;
        border-color: #374151;
        color: #f9fafb;
    }
    
    .input-enhanced {
        background: #1f2937;
        border-color: #374151;
        color: #f9fafb;
    }
    
    .input-enhanced:focus {
        border-color: #60a5fa;
        box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.1);
    }
    
    ::-webkit-scrollbar-track {
        background: #374151;
    }
    
    ::-webkit-scrollbar-thumb {
        background: #6b7280;
    }
    
    ::-webkit-scrollbar-thumb:hover {
        background: #9ca3af;
    }
}