/* Estilos para el sistema AJAX */

/* Animaciones de transición */
.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

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

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

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

/* Estados de loading */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--color-primary);
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 11;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Navegación activa */
.nav-link.active {
    @apply text-primary bg-primary bg-opacity-10;
}

/* Modales */
.modal-active {
    animation: modalShow 0.3s ease-out;
}

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

/* Notificaciones */
.notification-enter {
    transform: translateX(100%);
    opacity: 0;
}

.notification-enter-active {
    transform: translateX(0);
    opacity: 1;
    transition: all 0.3s ease-out;
}

.notification-exit {
    transform: translateX(0);
    opacity: 1;
}

.notification-exit-active {
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s ease-in;
}

/* Estados de formulario */
.form-loading {
    opacity: 0.6;
    pointer-events: none;
}

.form-success {
    border-color: var(--color-success);
    background-color: #F0FDF4; /* Mantendremos un color claro para el éxito o lo ajustamos */
}

.form-error {
    border-color: var(--color-danger);
    background-color: #FEF2F2; /* Mantendremos un color claro para el error o lo ajustamos */
}

/* Botones con estados */
.btn-loading {
    position: relative;
    color: transparent;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid currentColor;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Transiciones suaves */
.transition-all {
    transition: all 0.2s ease-in-out;
}

/* Estados de hover mejorados */
.hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* Indicadores de estado */
.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
}

.status-success { background-color: var(--color-success); }
.status-warning { background-color: var(--color-warning); }
.status-error { background-color: var(--color-danger); }
.status-info { background-color: var(--color-primary); }

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, var(--color-bg-tertiary) 25%, #e0e0e0 50%, var(--color-bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

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

/* Scrollbar personalizada */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: var(--color-bg-tertiary);
    border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Responsive utilities */
@media (max-width: 768px) {
    .modal-responsive {
        margin: 1rem;
        max-width: calc(100% - 2rem);
    }
    
    .nav-responsive {
        flex-direction: column;
        align-items: stretch;
    }
    
    .nav-responsive .nav-link {
        text-align: center;
        padding: 0.75rem;
    }
}

/* Estilos para drag & drop */
.drag-over {
    background-color: #DBEAFE !important; /* Considerar variable o mantener */
    border-color: var(--color-primary) !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    transition: all 0.2s ease-in-out;
}

.asignacion-arrastrable {
    cursor: grab;
    transition: all 0.2s ease-in-out;
}

.asignacion-arrastrable:hover {
    cursor: grabbing;
    transform: scale(1.02);
}

.asignacion-arrastrable:active {
    cursor: grabbing;
}

.asignacion-arrastrable.opacity-50 {
    opacity: 0.5;
}

.asignacion-arrastrable.scale-95 {
    transform: scale(0.95);
}

/* Estilos para el modal de drag & drop */
#dragDropModal {
    z-index: 9999;
}

#dragDropModal .bg-gray-600 {
    backdrop-filter: blur(4px);
}

#dragDropContent {
    max-height: 80vh;
    overflow-y: auto;
}

/* Modal de confirmación - Siempre encima */
#confirmModal {
    z-index: 99999 !important;
    backdrop-filter: blur(2px);
    animation: modalFadeIn 0.2s ease-out;
}

#confirmModal > div {
    z-index: 100000 !important;
    animation: modalSlideIn 0.3s ease-out;
}

#confirmModal .bg-black {
    z-index: 99998 !important;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(2px);
    }
}

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

/* Animaciones para elementos arrastrables */
@keyframes dragPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.drag-pulse {
    animation: dragPulse 1s ease-in-out infinite;
}

/* === ESTILOS PARA CORs ARRASTRABLES === */
.cor-item {
    transition: all 0.3s ease-in-out;
    position: relative;
    overflow: hidden;
}

.cor-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.cor-item[draggable="true"]:hover {
    cursor: grab;
}

.cor-item[draggable="true"]:active {
    cursor: grabbing;
}

/* Efectos visuales durante drag */
.cor-item.dragging {
    opacity: 0.6;
    transform: rotate(5deg) scale(0.95);
    z-index: 9999;
}

/* Celdas de destino durante drag */
.drag-target {
    position: relative;
    transition: all 0.2s ease-in-out;
}

.drag-target::before {
    content: '📋 Soltar aquí para asignar';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(59, 130, 246, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease-in-out;
    z-index: 10;
}

.drag-target:hover::before {
    opacity: 1;
}

/* Filtro de CORs */
#filtro-cors {
    transition: all 0.2s ease-in-out;
}

#filtro-cors:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Animación para CORs filtradas */
.cor-item {
    animation: fadeInUp 0.3s ease-out;
}

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

/* Estados de hover mejorados para CORs */
.cor-item:hover .cor-drag-hint {
    opacity: 1;
    transform: translateY(0);
}

.cor-drag-hint {
    opacity: 0;
    transform: translateY(5px);
    transition: all 0.2s ease-in-out;
}

/* Efecto de spotlight durante filtrado */
.cor-item:not(.hidden) {
    animation: spotlight 0.5s ease-out;
}

@keyframes spotlight {
    0% {
        box-shadow: 0 0 0 rgba(59, 130, 246, 0);
    }
    50% {
        box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
    }
    100% {
        box-shadow: 0 0 0 rgba(59, 130, 246, 0);
    }
}

.loading::after {
    background: var(--color-bg-primary);
    opacity: 0.8;
}

.dark-mode .form-success {
    background-color: rgba(16, 185, 129, 0.1);
    border-color: var(--color-success);
}

.dark-mode .form-error {
    background-color: rgba(239, 68, 68, 0.1);
    border-color: var(--color-danger);
}

.dark-mode .skeleton {
    background: linear-gradient(90deg, var(--color-bg-secondary) 25%, var(--color-bg-tertiary) 50%, var(--color-bg-secondary) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

.dark-mode .custom-scrollbar::-webkit-scrollbar-track {
    background: var(--color-bg-secondary);
}

.dark-mode .custom-scrollbar::-webkit-scrollbar-thumb {
    background: var(--color-bg-tertiary);
}

.dark-mode .custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: var(--color-secondary);
}

.dark-mode .drag-over {
    background-color: rgba(59, 130, 246, 0.2) !important;
    border-color: var(--color-primary) !important;
}

.dark-mode .hover-lift:hover {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

/* Estilos para filtro de órdenes ERP */
.orden-erp-item {
    transition: all 0.2s ease-in-out;
}

.orden-erp-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.orden-erp-item.selected {
    background-color: rgb(219, 234, 254) !important;
    border-color: rgb(59, 130, 246) !important;
    border-width: 2px;
}

#filtroOrdenesERP {
    transition: all 0.2s ease-in-out;
}

#filtroOrdenesERP:focus {
    transform: scale(1.01);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

#limpiarFiltroERP {
    transition: opacity 0.2s ease-in-out;
}

#limpiarFiltroERP:hover {
    opacity: 0.8;
}

/* Animación para resultados filtrados */
.orden-erp-item[style*="display: none"] {
    opacity: 0;
    transform: scale(0.95);
}

.orden-erp-item[style*="display: block"] {
    opacity: 1;
    transform: scale(1);
}

/* Contador de resultados */
#contadorResultados {
    font-style: italic;
    color: #6b7280;
}

/* Mensaje sin resultados */
#sinResultados {
    animation: fadeIn 0.3s ease-in-out;
}

/* Estilos para el filtro de órdenes ERP */
.filter-erp-container {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
    transition: all 0.2s ease;
}

.filter-erp-container:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    background: white;
}

.filter-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.filter-input-wrapper input {
    padding-left: 40px !important;
    padding-right: 40px !important;
    border: 1px solid #d1d5db !important;
    border-radius: 6px !important;
    font-size: 14px !important;
    transition: all 0.2s ease !important;
    background: white !important;
}

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

.filter-input-wrapper input::placeholder {
    color: #9ca3af !important;
    font-style: italic;
}

.filter-icon {
    position: absolute;
    left: 12px;
    color: #6b7280;
    z-index: 1;
    transition: color 0.2s ease;
}

.filter-input-wrapper:focus-within .filter-icon {
    color: #3b82f6;
}

.clear-filter-btn {
    position: absolute;
    right: 8px;
    background: #ef4444;
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
    z-index: 1;
}

.clear-filter-btn:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.filter-results-counter {
    font-size: 12px;
    color: #6b7280;
    margin-top: 8px;
    font-weight: 500;
}

/* Animación para las órdenes filtradas */
.orden-erp-item {
    transition: all 0.3s ease !important;
}

.orden-erp-item:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Resaltado de selección mejorado */
.orden-erp-item.selected {
    background: linear-gradient(135deg, #e0f2fe 0%, #f0f9ff 100%);
    border-color: #0284c7 !important;
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.2);
    position: relative;
}

.orden-erp-item.selected::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #0284c7;
    border-radius: 0 4px 4px 0;
}

/* Resaltado de términos de búsqueda */
.orden-erp-item mark {
    background: linear-gradient(120deg, #fef08a 0%, #fbbf24 100%);
    color: #92400e;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 600;
    animation: highlight 0.3s ease-in-out;
}

@keyframes highlight {
    0% { background-color: #fbbf24; transform: scale(1.05); }
    100% { background-color: #fef08a; transform: scale(1); }
}

/* Mensaje sin resultados del filtro */
#sinResultados {
    background: #fefefe;
    border: 2px dashed #e5e7eb;
    border-radius: 8px;
    margin: 16px 0;
    animation: fadeInFilter 0.3s ease;
}

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

/* Responsive para filtro */
@media (max-width: 768px) {
    .filter-erp-container {
        padding: 8px;
        margin-bottom: 12px;
    }
    
    .filter-input-wrapper input {
        font-size: 16px !important; /* Evita zoom en iOS */
    }
}
