/* ==========================================================================
   Premium Motion & Animations System
   ========================================================================== */

/* 1. Global Smooth Transitions */
a, button, .btn, .card, input, select, textarea, .stat-card, .menu-item, .nav-link, .sidebar-item {
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
}

html {
    scroll-behavior: smooth;
}

/* 2. Micro-interactions & Hover Effects */
.card:hover, .stat-card:hover, .widget-card:hover {
    transform: translateY(-5px) scale(1.01);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1), 0 5px 15px rgba(0, 0, 0, 0.05);
}

.btn:active, .card:active {
    transform: scale(0.97) translateY(0);
}

.nav-link:hover, .sidebar-item:hover {
    transform: translateX(-5px); /* RTL support */
    background-color: rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] .nav-link:hover, [data-theme="dark"] .sidebar-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* 3. Page Load Animations (Entrance) */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.main-content, .dashboard-container, main, .page-header, .content-wrapper {
    animation: fadeInUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* 4. Staggered List Items */
li, .list-item, .table-row, tr, .card-item, .grid-item {
    animation: fadeInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Add dynamic delays based on nth-child for table rows and lists */
tr:nth-child(1), li:nth-child(1), .grid-item:nth-child(1) { animation-delay: 50ms; }
tr:nth-child(2), li:nth-child(2), .grid-item:nth-child(2) { animation-delay: 100ms; }
tr:nth-child(3), li:nth-child(3), .grid-item:nth-child(3) { animation-delay: 150ms; }
tr:nth-child(4), li:nth-child(4), .grid-item:nth-child(4) { animation-delay: 200ms; }
tr:nth-child(5), li:nth-child(5), .grid-item:nth-child(5) { animation-delay: 250ms; }
tr:nth-child(6), li:nth-child(6), .grid-item:nth-child(6) { animation-delay: 300ms; }
tr:nth-child(7), li:nth-child(7), .grid-item:nth-child(7) { animation-delay: 350ms; }
tr:nth-child(8), li:nth-child(8), .grid-item:nth-child(8) { animation-delay: 400ms; }
tr:nth-child(9), li:nth-child(9), .grid-item:nth-child(9) { animation-delay: 450ms; }
tr:nth-child(10), li:nth-child(10), .grid-item:nth-child(10) { animation-delay: 500ms; }
tr:nth-child(11), li:nth-child(11), .grid-item:nth-child(11) { animation-delay: 550ms; }
tr:nth-child(12), li:nth-child(12), .grid-item:nth-child(12) { animation-delay: 600ms; }
tr:nth-child(13), li:nth-child(13), .grid-item:nth-child(13) { animation-delay: 650ms; }
tr:nth-child(14), li:nth-child(14), .grid-item:nth-child(14) { animation-delay: 700ms; }
tr:nth-child(15), li:nth-child(15), .grid-item:nth-child(15) { animation-delay: 750ms; }
tr:nth-child(16), li:nth-child(16), .grid-item:nth-child(16) { animation-delay: 800ms; }
tr:nth-child(17), li:nth-child(17), .grid-item:nth-child(17) { animation-delay: 850ms; }
tr:nth-child(18), li:nth-child(18), .grid-item:nth-child(18) { animation-delay: 900ms; }
tr:nth-child(19), li:nth-child(19), .grid-item:nth-child(19) { animation-delay: 950ms; }
tr:nth-child(20), li:nth-child(20), .grid-item:nth-child(20) { animation-delay: 1000ms; }
tr:nth-child(21), li:nth-child(21), .grid-item:nth-child(21) { animation-delay: 1050ms; }
tr:nth-child(22), li:nth-child(22), .grid-item:nth-child(22) { animation-delay: 1100ms; }
tr:nth-child(23), li:nth-child(23), .grid-item:nth-child(23) { animation-delay: 1150ms; }
tr:nth-child(24), li:nth-child(24), .grid-item:nth-child(24) { animation-delay: 1200ms; }
tr:nth-child(25), li:nth-child(25), .grid-item:nth-child(25) { animation-delay: 1250ms; }
tr:nth-child(26), li:nth-child(26), .grid-item:nth-child(26) { animation-delay: 1300ms; }
tr:nth-child(27), li:nth-child(27), .grid-item:nth-child(27) { animation-delay: 1350ms; }
tr:nth-child(28), li:nth-child(28), .grid-item:nth-child(28) { animation-delay: 1400ms; }
tr:nth-child(29), li:nth-child(29), .grid-item:nth-child(29) { animation-delay: 1450ms; }
tr:nth-child(30), li:nth-child(30), .grid-item:nth-child(30) { animation-delay: 1500ms; }

/* 5. Modals and Dropdowns */
@keyframes dropdownReveal {
    from {
        opacity: 0;
        transform: translateY(-15px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.dropdown-menu, .popover, .modal-content, .toast, .notification-panel {
    animation: dropdownReveal 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transform-origin: top center;
}

/* 6. Subtle Pulse for Alerts and Badges */
@keyframes softPulse {
    0% { box-shadow: 0 0 0 0 rgba(var(--primary-color-rgb, 0, 102, 204), 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(var(--primary-color-rgb, 0, 102, 204), 0); }
    100% { box-shadow: 0 0 0 0 rgba(var(--primary-color-rgb, 0, 102, 204), 0); }
}

.badge-new, .pulse-dot, .notification-indicator {
    animation: softPulse 2s infinite;
}

/* 7. Shimmer Effect for Loading States (Skeletons) */
@keyframes shimmer {
    0% { background-position: -1000px 0; }
    100% { background-position: 1000px 0; }
}

.skeleton, .loading-placeholder {
    background: linear-gradient(90deg, rgba(0,0,0,0.05) 25%, rgba(0,0,0,0.1) 50%, rgba(0,0,0,0.05) 75%);
    background-size: 1000px 100%;
    animation: shimmer 2s infinite linear;
    border-radius: 4px;
}
[data-theme="dark"] .skeleton {
    background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.05) 75%);
    background-size: 1000px 100%;
}

/* 8. Glowing Effect for Premium Elements */
@keyframes glow {
    0% { box-shadow: 0 0 5px rgba(0, 123, 255, 0.2), 0 0 10px rgba(0, 123, 255, 0.2); }
    50% { box-shadow: 0 0 20px rgba(0, 123, 255, 0.6), 0 0 30px rgba(0, 123, 255, 0.4); }
    100% { box-shadow: 0 0 5px rgba(0, 123, 255, 0.2), 0 0 10px rgba(0, 123, 255, 0.2); }
}

.glow-effect {
    animation: glow 3s infinite alternate;
}

/* 9. Floating Animation for Illustrations/Icons */
@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

.floating-icon, .empty-state-img {
    animation: float 4s ease-in-out infinite;
}

/* 10. Input Focus Animations */
input:focus, select:focus, textarea:focus {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.05), 0 0 0 3px rgba(0, 123, 255, 0.1) !important;
}

/* 11. Custom Scrollbar Styling for better aesthetics */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(150, 150, 150, 0.3);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(150, 150, 150, 0.5);
}

/* Apply staggered entrance to dashboard widgets */
.dashboard-grid > div {
    animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.dashboard-grid > div:nth-child(1) { animation-delay: 100ms; }
.dashboard-grid > div:nth-child(2) { animation-delay: 200ms; }
.dashboard-grid > div:nth-child(3) { animation-delay: 300ms; }
.dashboard-grid > div:nth-child(4) { animation-delay: 400ms; }

/* 12. Icon Spin */
@keyframes spinSlow {
    100% { transform: rotate(360deg); }
}
.icon-spin-hover:hover {
    animation: spinSlow 2s linear infinite;
}
