/* Modal Transition Animations */

/* Base modal animation classes */
.modal-overlay {
    opacity: 0;
    transform: scale(0.95);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.show {
    opacity: 1;
    transform: scale(1);
}

.modal-content {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transition-delay: 0.05s;
}

.modal-content.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Backdrop animations */
.modal-backdrop {
    opacity: 0;
    transition: opacity 0.25s ease-in-out;
}

.modal-backdrop.show {
    opacity: 1;
}

/* Specific modal animations */

/* AI Suggestions Modal */
#suggestion-task-modal {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#suggestion-task-modal.show {
    opacity: 1;
}

#suggestion-task-modal .bg-white,
.dark #suggestion-task-modal .bg-gray-800 {
    transform: translateY(20px) scale(0.9);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#suggestion-task-modal.show .bg-white,
.dark #suggestion-task-modal.show .bg-gray-800 {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Task Details Modal */
#task-details-modal .bg-white,
.dark #task-details-modal .bg-gray-800 {
    transform: translateY(-30px) scale(0.8);
    opacity: 0;
    transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#task-details-modal.show .bg-white,
.dark #task-details-modal.show .bg-gray-800 {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Create Task Modal */
#create-task-modal .bg-white,
.dark #create-task-modal .bg-gray-800 {
    transform: scale(0.85) rotateX(10deg);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#create-task-modal.show .bg-white,
.dark #create-task-modal.show .bg-gray-800 {
    transform: scale(1) rotateX(0deg);
    opacity: 1;
}

/* Edit Task Modal */
#edit-task-modal .bg-white,
.dark #edit-task-modal .bg-gray-800 {
    transform: translateX(20px) scale(0.9);
    opacity: 0;
    transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#edit-task-modal.show .bg-white,
.dark #edit-task-modal.show .bg-gray-800 {
    transform: translateX(0) scale(1);
    opacity: 1;
}

/* Quick Add Modal */
#quick-add-modal {
    z-index: 9999999 !important;
    position: fixed !important;
}

#quick-add-modal .bg-white,
.dark #quick-add-modal .bg-gray-800 {
    transform: translateY(-50px) scale(0.8);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10000000 !important;
}

#quick-add-modal.show .bg-white,
.dark #quick-add-modal.show .bg-gray-800 {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Task Group Modal */
#task-group-modal .bg-white,
.dark #task-group-modal .bg-gray-800 {
    transform: scale(0.7) rotateY(15deg);
    opacity: 0;
    transition: all 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#task-group-modal.show .bg-white,
.dark #task-group-modal.show .bg-gray-800 {
    transform: scale(1) rotateY(0deg);
    opacity: 1;
}

/* Fade-in animation for modal elements */
.modal-fade-in {
    opacity: 0;
    animation: modalFadeIn 0.3s ease-out forwards;
}

@keyframes modalFadeIn {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Slide-up animation */
.modal-slide-up {
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-slide-up.show {
    transform: translateY(0);
}

/* Scale and fade animation */
.modal-scale-fade {
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-scale-fade.show {
    opacity: 1;
    transform: scale(1);
}

/* Bounce effect for confirmation dialogs */
.modal-bounce {
    animation: modalBounce 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes modalBounce {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Stagger animation for modal content */
.modal-stagger > * {
    opacity: 0;
    transform: translateY(20px);
    animation: modalStagger 0.4s ease-out forwards;
}

.modal-stagger > *:nth-child(1) { animation-delay: 0.1s; }
.modal-stagger > *:nth-child(2) { animation-delay: 0.15s; }
.modal-stagger > *:nth-child(3) { animation-delay: 0.2s; }
.modal-stagger > *:nth-child(4) { animation-delay: 0.25s; }
.modal-stagger > *:nth-child(5) { animation-delay: 0.3s; }

@keyframes modalStagger {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Close animation */
.modal-closing {
    opacity: 1;
    transform: scale(1);
    animation: modalClose 0.2s ease-in forwards;
}

@keyframes modalClose {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.8);
    }
}

/* Responsive animation adjustments */
@media (max-width: 767px) {
    .modal-content {
        transform: translateY(20px) scale(0.98);
        transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    /* Reduced motion for mobile */
    .modal-bounce {
        animation: modalBounce 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    @keyframes modalBounce {
        0% {
            transform: scale(0.9);
            opacity: 0;
        }
        100% {
            transform: scale(1);
            opacity: 1;
        }
    }
}

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
    .modal-overlay,
    .modal-content,
    .modal-backdrop,
    #suggestion-task-modal,
    #suggestion-task-modal .bg-white,
    .dark #suggestion-task-modal .bg-gray-800,
    #task-details-modal .bg-white,
    .dark #task-details-modal .bg-gray-800,
    #create-task-modal .bg-white,
    .dark #create-task-modal .bg-gray-800,
    #edit-task-modal .bg-white,
    .dark #edit-task-modal .bg-gray-800,
    #quick-add-modal .bg-white,
    .dark #quick-add-modal .bg-gray-800,
    #task-group-modal .bg-white,
    .dark #task-group-modal .bg-gray-800 {
        transition: opacity 0.1s ease-out;
        transform: none;
        animation: none;
    }
    
    .modal-fade-in,
    .modal-slide-up,
    .modal-scale-fade,
    .modal-bounce,
    .modal-stagger > * {
        animation: none;
        transform: none;
        opacity: 1;
        transition: opacity 0.1s ease-out;
    }
}