/* ==========================================================================
   DIALLO HRMS — ANIMATIONS & TRANSITIONS
   Professional, subtle enterprise animations
   ========================================================================== */

/* ----------------------------------------------------
   KEYFRAME DEFINITIONS
   ---------------------------------------------------- */

/* Fade + slide up for page content */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade in only */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Scale in from slightly smaller */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Slide in from left (sidebar) */
@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Slide in from right */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Slide down for dropdowns */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Subtle pulse for badges/notifications */
@keyframes subtlePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* Shimmer for loading states */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Gentle float for empty states */
@keyframes gentleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* Spin for loaders */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Count-up number reveal */
@keyframes countReveal {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Toast slide in from top-right */
@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(40px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

/* Toast slide out */
@keyframes toastSlideOut {
  from {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateX(40px) scale(0.95);
  }
}

/* Progress bar fill */
@keyframes progressFill {
  from { width: 0%; }
}

/* Ripple effect */
@keyframes ripple {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* Staggered entrance for grid children */
@keyframes staggerIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Checkmark draw */
@keyframes drawCheck {
  from { stroke-dashoffset: 24; }
  to { stroke-dashoffset: 0; }
}

/* Highlight flash for newly added rows */
@keyframes highlightFlash {
  0% { background-color: var(--primary-light); }
  100% { background-color: transparent; }
}

/* ----------------------------------------------------
   PAGE / VIEW TRANSITIONS
   ---------------------------------------------------- */

/* Main content area entrance animation */
.main-content {
  animation: fadeInUp 0.35s var(--transition-ease) both;
}

/* Welcome banner entrance */
.welcome-banner {
  animation: fadeInUp 0.4s var(--transition-ease) both;
  animation-delay: 0.05s;
}

/* ----------------------------------------------------
   KPI CARD STAGGERED ENTRANCE
   ---------------------------------------------------- */
.kpi-grid {
  /* Clean immediate grid rendering */
}

.kpi-card {
  opacity: 1;
}

/* KPI numbers always visible immediately */
.kpi-value {
  opacity: 1;
}

/* Enhanced KPI card hover */
.kpi-card {
  transition: transform 0.25s var(--transition-ease),
              box-shadow 0.25s var(--transition-ease),
              border-color 0.25s var(--transition-ease);
}

.kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.kpi-card:active {
  transform: translateY(-1px);
  transition-duration: 0.1s;
}

/* ----------------------------------------------------
   SIDEBAR ANIMATIONS
   ---------------------------------------------------- */

/* Sidebar nav link transitions */
.nav-link {
  transition: all 0.2s var(--transition-ease);
  position: relative;
  overflow: hidden;
}

.nav-link::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%) scaleY(0);
  width: 3px;
  height: 60%;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
  transition: transform 0.25s var(--transition-ease);
}

.nav-link.active::before,
.nav-link:hover::before {
  transform: translateY(-50%) scaleY(1);
}

.nav-link:hover {
  background-color: var(--bg-hover);
  transform: translateX(2px);
}

.nav-link.active {
  transform: translateX(2px);
}

/* Sidebar section title entrance */
.sidebar-section-title {
  animation: slideInLeft 0.3s var(--transition-ease) both;
}

/* Stagger sidebar links on load */
.sidebar-nav-section .nav-link {
  animation: slideInLeft 0.3s var(--transition-ease) both;
}

.sidebar-nav-section .nav-link:nth-child(2)  { animation-delay: 0.03s; }
.sidebar-nav-section .nav-link:nth-child(3)  { animation-delay: 0.05s; }
.sidebar-nav-section .nav-link:nth-child(4)  { animation-delay: 0.07s; }
.sidebar-nav-section .nav-link:nth-child(5)  { animation-delay: 0.09s; }
.sidebar-nav-section .nav-link:nth-child(6)  { animation-delay: 0.11s; }
.sidebar-nav-section .nav-link:nth-child(7)  { animation-delay: 0.13s; }
.sidebar-nav-section .nav-link:nth-child(8)  { animation-delay: 0.15s; }
.sidebar-nav-section .nav-link:nth-child(9)  { animation-delay: 0.17s; }
.sidebar-nav-section .nav-link:nth-child(10) { animation-delay: 0.19s; }
.sidebar-nav-section .nav-link:nth-child(11) { animation-delay: 0.21s; }
.sidebar-nav-section .nav-link:nth-child(12) { animation-delay: 0.23s; }
.sidebar-nav-section .nav-link:nth-child(13) { animation-delay: 0.25s; }
.sidebar-nav-section .nav-link:nth-child(14) { animation-delay: 0.27s; }
.sidebar-nav-section .nav-link:nth-child(15) { animation-delay: 0.29s; }
.sidebar-nav-section .nav-link:nth-child(16) { animation-delay: 0.31s; }

/* Sidebar icon hover spin */
.nav-link svg {
  transition: transform 0.3s var(--transition-ease);
}

.nav-link:hover svg {
  transform: rotate(-6deg) scale(1.1);
}

/* Sidebar collapse/expand transition */
.app-sidebar {
  transition: width 0.3s var(--transition-ease),
              transform 0.3s var(--transition-ease);
}

/* ----------------------------------------------------
   CARD & MODULE GRID ANIMATIONS
   ---------------------------------------------------- */

/* Standard cards */
.card,
.module-card,
.stat-card,
.widget-card,
.chart-card {
  transition: transform 0.25s var(--transition-ease),
              box-shadow 0.25s var(--transition-ease),
              border-color 0.25s var(--transition-ease);
}

.card:hover,
.module-card:hover,
.stat-card:hover,
.widget-card:hover,
.chart-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Module grid staggered entrance */
.module-grid > *,
.dashboard-grid > *,
.chart-grid > * {
  animation: staggerIn 0.4s var(--transition-ease) both;
}

.module-grid > *:nth-child(1),
.dashboard-grid > *:nth-child(1),
.chart-grid > *:nth-child(1) { animation-delay: 0.06s; }

.module-grid > *:nth-child(2),
.dashboard-grid > *:nth-child(2),
.chart-grid > *:nth-child(2) { animation-delay: 0.12s; }

.module-grid > *:nth-child(3),
.dashboard-grid > *:nth-child(3),
.chart-grid > *:nth-child(3) { animation-delay: 0.18s; }

.module-grid > *:nth-child(4),
.dashboard-grid > *:nth-child(4),
.chart-grid > *:nth-child(4) { animation-delay: 0.24s; }

.module-grid > *:nth-child(5),
.dashboard-grid > *:nth-child(5) { animation-delay: 0.30s; }

.module-grid > *:nth-child(6),
.dashboard-grid > *:nth-child(6) { animation-delay: 0.36s; }

/* Quick access shortcuts stagger */
.quick-access-grid > * {
  animation: scaleIn 0.35s var(--transition-ease) both;
}

.quick-access-grid > *:nth-child(1) { animation-delay: 0.05s; }
.quick-access-grid > *:nth-child(2) { animation-delay: 0.10s; }
.quick-access-grid > *:nth-child(3) { animation-delay: 0.15s; }
.quick-access-grid > *:nth-child(4) { animation-delay: 0.20s; }
.quick-access-grid > *:nth-child(5) { animation-delay: 0.25s; }
.quick-access-grid > *:nth-child(6) { animation-delay: 0.30s; }

/* Quick access shortcut cards */
.shortcut-card {
  transition: transform 0.2s var(--transition-ease),
              box-shadow 0.2s var(--transition-ease),
              border-color 0.2s var(--transition-ease),
              background-color 0.2s var(--transition-ease);
}

.shortcut-card:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-border);
}

.shortcut-card:active {
  transform: translateY(0) scale(0.98);
  transition-duration: 0.1s;
}

/* Shortcut icon hover */
.shortcut-card svg,
.shortcut-card .shortcut-icon {
  transition: transform 0.3s var(--transition-ease),
              color 0.2s ease;
}

.shortcut-card:hover svg,
.shortcut-card:hover .shortcut-icon {
  transform: scale(1.15);
  color: var(--primary);
}

/* ----------------------------------------------------
   BUTTON ANIMATIONS
   ---------------------------------------------------- */

.btn {
  transition: all 0.2s var(--transition-ease);
  position: relative;
  overflow: hidden;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn:active {
  transform: translateY(1px);
  box-shadow: none;
  transition-duration: 0.08s;
}

/* Ripple effect on buttons */
.btn::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, rgba(255,255,255,0.25) 10%, transparent 10.01%);
  background-repeat: no-repeat;
  background-position: 50%;
  transform: scale(10);
  opacity: 0;
  transition: transform 0.4s, opacity 0.6s;
}

.btn:active::after {
  transform: scale(0);
  opacity: 1;
  transition: 0s;
}

/* Primary button glow on hover */
.btn-primary:hover {
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

/* Danger button glow on hover */
.btn-danger:hover {
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.3);
}

/* Success button glow on hover */
.btn-success:hover {
  box-shadow: 0 4px 14px rgba(22, 163, 74, 0.3);
}

/* ----------------------------------------------------
   TABLE ANIMATIONS
   ---------------------------------------------------- */

/* Table rows fade in */
.data-table tbody tr {
  animation: fadeIn 0.3s ease both;
  transition: background-color 0.15s ease;
}

/* Stagger table rows slightly */
.data-table tbody tr:nth-child(1)  { animation-delay: 0.02s; }
.data-table tbody tr:nth-child(2)  { animation-delay: 0.04s; }
.data-table tbody tr:nth-child(3)  { animation-delay: 0.06s; }
.data-table tbody tr:nth-child(4)  { animation-delay: 0.08s; }
.data-table tbody tr:nth-child(5)  { animation-delay: 0.10s; }
.data-table tbody tr:nth-child(6)  { animation-delay: 0.12s; }
.data-table tbody tr:nth-child(7)  { animation-delay: 0.14s; }
.data-table tbody tr:nth-child(8)  { animation-delay: 0.16s; }
.data-table tbody tr:nth-child(9)  { animation-delay: 0.18s; }
.data-table tbody tr:nth-child(10) { animation-delay: 0.20s; }

/* Table row hover lift */
.data-table tbody tr:hover {
  box-shadow: var(--shadow-xs);
}

/* Highlight new row */
.data-table tbody tr.newly-added {
  animation: highlightFlash 1.5s ease both;
}

/* ----------------------------------------------------
   DROPDOWN & POPOVER ANIMATIONS
   ---------------------------------------------------- */

.dropdown-popover {
  transition: opacity 0.2s var(--transition-ease),
              visibility 0.2s var(--transition-ease),
              transform 0.2s var(--transition-ease);
  transform: translateY(-6px);
}

.dropdown-popover.active {
  animation: slideDown 0.2s var(--transition-ease) both;
}

/* Dropdown items hover */
.dropdown-item {
  transition: background-color 0.15s ease,
              color 0.15s ease,
              padding-left 0.2s var(--transition-ease);
}

.dropdown-item:hover {
  padding-left: 16px;
}

/* ----------------------------------------------------
   MODAL ANIMATIONS (Enhanced)
   ---------------------------------------------------- */

.modal-backdrop {
  transition: opacity 0.25s var(--transition-ease),
              visibility 0.25s var(--transition-ease);
}

.modal-dialog {
  transition: transform 0.3s var(--transition-ease),
              opacity 0.3s var(--transition-ease);
}

.modal-backdrop.active .modal-dialog {
  animation: scaleIn 0.3s var(--transition-ease) both;
}

/* ----------------------------------------------------
   TOAST NOTIFICATIONS
   ---------------------------------------------------- */

.toast {
  animation: toastSlideIn 0.4s var(--transition-ease) both;
}

.toast.toast-exit {
  animation: toastSlideOut 0.3s var(--transition-ease) both;
}

/* ----------------------------------------------------
   BADGE & STATUS ANIMATIONS
   ---------------------------------------------------- */

/* Notification badge pulse */
.badge-primary[style*="position: absolute"],
#top-nav-notification-badge {
  animation: subtlePulse 2s ease-in-out infinite;
}

/* Status dot pulse */
.status-dot.active,
.status-online {
  position: relative;
}

.status-dot.active::after,
.status-online::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid currentColor;
  animation: subtlePulse 2s ease-in-out infinite;
  opacity: 0.4;
}

/* Badge hover scale */
.badge {
  transition: transform 0.2s var(--transition-ease);
}

.badge:hover {
  transform: scale(1.05);
}

/* ----------------------------------------------------
   FORM ANIMATIONS
   ---------------------------------------------------- */

/* Input focus glow */
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  transition: border-color 0.2s ease,
              box-shadow 0.2s ease,
              background-color 0.2s ease;
}

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* Checkbox / toggle transitions */
input[type="checkbox"] {
  transition: background-color 0.2s ease,
              border-color 0.2s ease;
}

/* Form group label float (if using floating labels) */
.form-group label {
  transition: all 0.2s var(--transition-ease);
}

/* ----------------------------------------------------
   HEADER ANIMATIONS
   ---------------------------------------------------- */

/* Header entrance */
.app-header {
  animation: fadeIn 0.3s ease both;
}

/* Header buttons hover */
.header-icon-btn,
.header-dropdown-btn {
  transition: all 0.2s var(--transition-ease);
}

.header-icon-btn:hover,
.header-dropdown-btn:hover {
  transform: translateY(-1px);
}

.header-icon-btn:active,
.header-dropdown-btn:active {
  transform: translateY(1px);
}

/* User profile avatar hover */
.user-profile-trigger {
  transition: opacity 0.2s ease;
}

.user-profile-trigger:hover {
  opacity: 0.85;
}

.avatar-img {
  transition: transform 0.3s var(--transition-ease),
              box-shadow 0.3s var(--transition-ease);
}

.user-profile-trigger:hover .avatar-img {
  transform: scale(1.08);
  box-shadow: 0 0 0 2px var(--primary-border);
}

/* Theme toggle button spin */
.theme-toggle-btn .theme-icon-container {
  transition: transform 0.4s var(--transition-ease);
}

.theme-toggle-btn:hover .theme-icon-container {
  transform: rotate(30deg);
}

/* Brand logo hover */
.brand-logo {
  transition: opacity 0.2s ease;
}

.brand-logo:hover {
  opacity: 0.85;
}

.brand-icon-box {
  transition: transform 0.3s var(--transition-ease),
              box-shadow 0.3s var(--transition-ease);
}

.brand-logo:hover .brand-icon-box {
  transform: scale(1.06) rotate(-3deg);
}

/* ----------------------------------------------------
   LOADING & SKELETON ANIMATIONS
   ---------------------------------------------------- */

.skeleton,
.loading-shimmer {
  background: linear-gradient(
    90deg,
    var(--bg-hover) 25%,
    var(--border-light) 50%,
    var(--bg-hover) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

/* Spinner */
.spinner {
  animation: spin 0.8s linear infinite;
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--border-main);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ----------------------------------------------------
   EMPTY STATE ANIMATIONS
   ---------------------------------------------------- */

.empty-state svg,
.empty-state img,
.empty-state-icon {
  animation: gentleFloat 3s ease-in-out infinite;
}

.empty-state {
  animation: fadeInUp 0.5s var(--transition-ease) both;
}

/* ----------------------------------------------------
   TAB ANIMATIONS
   ---------------------------------------------------- */

.tab-btn,
.tab-link {
  transition: all 0.2s var(--transition-ease);
  position: relative;
}

.tab-btn::after,
.tab-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--primary);
  transition: width 0.25s var(--transition-ease),
              left 0.25s var(--transition-ease);
}

.tab-btn.active::after,
.tab-btn:hover::after,
.tab-link.active::after,
.tab-link:hover::after {
  width: 100%;
  left: 0;
}

/* ----------------------------------------------------
   PROGRESS BAR ANIMATIONS
   ---------------------------------------------------- */

.progress-fill,
.progress-bar-fill {
  animation: progressFill 0.8s var(--transition-ease) both;
  transition: width 0.5s var(--transition-ease);
}

/* ----------------------------------------------------
   TOOLTIP ANIMATIONS
   ---------------------------------------------------- */

[data-tooltip]:hover::after,
.tooltip {
  animation: fadeIn 0.2s ease both;
}

/* ----------------------------------------------------
   SIDEBAR FOOTER
   ---------------------------------------------------- */

.sidebar-footer {
  animation: fadeIn 0.5s ease 0.3s both;
}

.workspace-status {
  transition: background-color 0.2s ease;
}

/* ----------------------------------------------------
   MOBILE SIDEBAR DRAWER
   ---------------------------------------------------- */

.sidebar-backdrop {
  transition: opacity 0.3s var(--transition-ease),
              visibility 0.3s var(--transition-ease);
}

/* Mobile sidebar slide-in */
@media (max-width: 768px) {
  .app-sidebar {
    transition: transform 0.3s var(--transition-ease);
  }

  .mobile-sidebar-open .app-sidebar {
    animation: slideInLeft 0.3s var(--transition-ease) both;
  }
}

/* ----------------------------------------------------
   SCROLL-TRIGGERED ANIMATIONS (Utility Classes)
   ---------------------------------------------------- */

.animate-on-scroll {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s var(--transition-ease),
              transform 0.5s var(--transition-ease);
}

.animate-on-scroll.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Utility delay classes */
.delay-100 { animation-delay: 0.1s !important; }
.delay-200 { animation-delay: 0.2s !important; }
.delay-300 { animation-delay: 0.3s !important; }
.delay-400 { animation-delay: 0.4s !important; }
.delay-500 { animation-delay: 0.5s !important; }

/* ----------------------------------------------------
   PREFERS-REDUCED-MOTION
   Respect user accessibility preferences
   ---------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
