/* Page Transition Styles */

/* Initial page load animation - only for non-dashboard pages */
body:not(.sidebar-page):not(.page-loaded) {
    opacity: 0;
    animation: pageEnter 0.2s ease-out forwards;
}

/* Dashboard pages start visible (sidebar should never flash) */
body.sidebar-page {
    opacity: 1;
}

/* Ensure page is visible when loaded (critical for back button) */
body.page-loaded {
    opacity: 1 !important;
    transform: none !important;
}

@keyframes pageEnter {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Page exit animation class - only when NOT page-loaded */
body.page-exit:not(.page-loaded) {
    animation: pageExit 0.2s ease-in forwards;
}

/* When exiting, temporarily remove page-loaded */
body.page-exit {
    animation: pageExit 0.2s ease-in forwards;
}

@keyframes pageExit {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* Main content area transitions for SPA navigation */
.lg\:ml-64 {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Sidebar should always be visible and static */
#sidebar-container,
#sidebar {
    opacity: 1 !important;
    transform: none !important;
}

/* Mobile overlay transitions */
#mobile-overlay {
    transition: opacity 0.3s ease;
}

/* Fade transition variant */
body.fade-transition {
    animation: fadeIn 0.2s ease-out forwards;
}

body.fade-transition.page-exit {
    animation: fadeOut 0.2s ease-in forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Slide transition for sidebar pages */
.main-content {
    animation: slideIn 0.4s ease-out forwards;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Loading overlay */
.page-transition-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.page-transition-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.page-transition-overlay .loader {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: #00843D;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Smooth link hover transitions */
a {
    transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

/* Card and element entrance animations */
.animate-on-enter {
    opacity: 0;
    transform: translateY(20px);
    animation: elementEnter 0.5s ease-out forwards;
}

.animate-on-enter:nth-child(1) { animation-delay: 0.1s; }
.animate-on-enter:nth-child(2) { animation-delay: 0.15s; }
.animate-on-enter:nth-child(3) { animation-delay: 0.2s; }
.animate-on-enter:nth-child(4) { animation-delay: 0.25s; }
.animate-on-enter:nth-child(5) { animation-delay: 0.3s; }
.animate-on-enter:nth-child(6) { animation-delay: 0.35s; }

@keyframes elementEnter {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Staggered fade in for lists */
.stagger-fade-in > * {
    opacity: 0;
    animation: staggerFadeIn 0.4s ease-out forwards;
}

.stagger-fade-in > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-fade-in > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-fade-in > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-fade-in > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-fade-in > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-fade-in > *:nth-child(6) { animation-delay: 0.3s; }
.stagger-fade-in > *:nth-child(7) { animation-delay: 0.35s; }
.stagger-fade-in > *:nth-child(8) { animation-delay: 0.4s; }

@keyframes staggerFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =============================================
   Global Cursor Styles
   ============================================= */

/* Pointer cursor for all interactive elements */
button,
[type="submit"],
[type="button"],
a,
.cursor-pointer,
input[type="checkbox"],
input[type="radio"],
select,
label[for],
[role="button"],
[onclick],
.clickable,
.btn,
.nav-link,
.dropdown-item,
.menu-item {
    cursor: pointer;
}

/* Text cursor for input fields */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
textarea,
[contenteditable="true"] {
    cursor: text;
}

/* Disabled elements */
button:disabled,
input:disabled,
select:disabled,
textarea:disabled,
.disabled {
    cursor: not-allowed;
    opacity: 0.6;
}
