/* ========================================
   SOGHAAT Gilan — ANIMATION SYSTEM
   ======================================== */

/* ===== Particle Canvas ===== */
#particle-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.6;
}

/* ===== Page Load ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInLeft {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.88); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(-32px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ===== Sidebar ===== */
.sidebar {
  animation: slideInRight 0.45s cubic-bezier(0.16,1,0.3,1) both;
}
.sidebar-nav li {
  opacity: 0;
  animation: fadeInLeft 0.4s cubic-bezier(0.16,1,0.3,1) both;
}
.sidebar-nav li:nth-child(1) { animation-delay: 0.05s; }
.sidebar-nav li:nth-child(2) { animation-delay: 0.10s; }
.sidebar-nav li:nth-child(3) { animation-delay: 0.15s; }
.sidebar-nav li:nth-child(4) { animation-delay: 0.20s; }
.sidebar-nav li:nth-child(5) { animation-delay: 0.25s; }
.sidebar-nav li:nth-child(6) { animation-delay: 0.30s; }

/* ===== Page Content ===== */
.page-content {
  animation: fadeInUp 0.4s cubic-bezier(0.16,1,0.3,1) both;
}
.topbar {
  animation: fadeInDown 0.4s cubic-bezier(0.16,1,0.3,1) both;
}

/* ===== Stat Cards — stagger ===== */
.stat-card {
  opacity: 0;
  animation: scaleIn 0.5s cubic-bezier(0.34,1.56,0.64,1) both;
}
.stats-grid .stat-card:nth-child(1) { animation-delay: 0.05s; }
.stats-grid .stat-card:nth-child(2) { animation-delay: 0.12s; }
.stats-grid .stat-card:nth-child(3) { animation-delay: 0.19s; }
.stats-grid .stat-card:nth-child(4) { animation-delay: 0.26s; }

/* ===== Stat card hover — glow + lift ===== */
.stat-card {
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1),
              box-shadow 0.25s ease,
              border-color 0.25s ease;
}
.stat-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 20px 40px rgba(91,110,245,0.25), 0 0 0 1px rgba(91,110,245,0.2);
  border-color: rgba(91,110,245,0.3);
}

/* ===== Cards ===== */
.card {
  opacity: 0;
  animation: fadeInUp 0.5s cubic-bezier(0.16,1,0.3,1) 0.1s both;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(0,0,0,0.3);
}

/* ===== Table rows — stagger ===== */
tbody tr {
  opacity: 0;
  animation: fadeInUp 0.35s cubic-bezier(0.16,1,0.3,1) both;
}
tbody tr:nth-child(1)  { animation-delay: 0.04s; }
tbody tr:nth-child(2)  { animation-delay: 0.08s; }
tbody tr:nth-child(3)  { animation-delay: 0.12s; }
tbody tr:nth-child(4)  { animation-delay: 0.16s; }
tbody tr:nth-child(5)  { animation-delay: 0.20s; }
tbody tr:nth-child(6)  { animation-delay: 0.24s; }
tbody tr:nth-child(7)  { animation-delay: 0.28s; }
tbody tr:nth-child(8)  { animation-delay: 0.32s; }
tbody tr:nth-child(9)  { animation-delay: 0.36s; }
tbody tr:nth-child(10) { animation-delay: 0.40s; }

/* ===== Button effects ===== */
.btn {
  position: relative;
  overflow: hidden;
  transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1),
              box-shadow 0.2s ease,
              background 0.2s ease;
}
.btn:hover  { transform: translateY(-2px) scale(1.03); }
.btn:active { transform: translateY(0) scale(0.97); }

/* Ripple */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--rx,50%) var(--ry,50%), rgba(255,255,255,0.25) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
.btn:active::after { opacity: 1; transition: opacity 0s; }

/* ===== Modal — spring ===== */
.modal-overlay {
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.modal {
  transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1),
              opacity 0.25s ease;
}
.modal-overlay:not(.active) .modal {
  transform: scale(0.85) translateY(20px);
  opacity: 0;
}
.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* ===== Toast — bounce in ===== */
@keyframes toastIn {
  0%   { transform: translateX(120%) scale(0.8); opacity: 0; }
  60%  { transform: translateX(-8px) scale(1.03); opacity: 1; }
  80%  { transform: translateX(4px) scale(0.99); }
  100% { transform: translateX(0) scale(1); opacity: 1; }
}
@keyframes toastOut {
  to { transform: translateX(120%) scale(0.8); opacity: 0; }
}
.toast {
  animation: toastIn 0.5s cubic-bezier(0.34,1.56,0.64,1) both;
}
.toast.removing {
  animation: toastOut 0.3s ease forwards;
}

/* ===== Chart bars ===== */
@keyframes barGrow {
  from { transform: scaleY(0); transform-origin: bottom; }
  to   { transform: scaleY(1); transform-origin: bottom; }
}
.chart-bar {
  animation: barGrow 0.6s cubic-bezier(0.34,1.56,0.64,1) both;
  transform-origin: bottom;
}
.chart-bar-g:nth-child(1) .chart-bar { animation-delay: 0.00s; }
.chart-bar-g:nth-child(2) .chart-bar { animation-delay: 0.05s; }
.chart-bar-g:nth-child(3) .chart-bar { animation-delay: 0.10s; }
.chart-bar-g:nth-child(4) .chart-bar { animation-delay: 0.15s; }
.chart-bar-g:nth-child(5) .chart-bar { animation-delay: 0.20s; }
.chart-bar-g:nth-child(6) .chart-bar { animation-delay: 0.25s; }
.chart-bar-g:nth-child(7) .chart-bar { animation-delay: 0.30s; }
.chart-bar:hover {
  filter: brightness(1.3) drop-shadow(0 0 8px rgba(91,110,245,0.6));
  cursor: pointer;
}

/* ===== Counter animation ===== */
@keyframes countUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.stat-value {
  animation: countUp 0.6s cubic-bezier(0.16,1,0.3,1) 0.2s both;
}

/* ===== Nav active indicator ===== */
.sidebar-nav a {
  position: relative;
}
.sidebar-nav a.active::before {
  content: '';
  position: absolute;
  right: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--primary-light);
  border-radius: 2px 0 0 2px;
  animation: scaleIn 0.3s cubic-bezier(0.34,1.56,0.64,1) both;
}

/* ===== Badge pulse (low stock) ===== */
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245,101,101,0.4); }
  50%       { box-shadow: 0 0 0 6px rgba(245,101,101,0); }
}
.badge-danger {
  animation: pulse 2s ease infinite;
}

/* ===== Skeleton shimmer ===== */
@keyframes shimmer {
  from { background-position: -200% 0; }
  to   { background-position:  200% 0; }
}
.skeleton {
  background: linear-gradient(90deg,
    rgba(255,255,255,0.04) 25%,
    rgba(255,255,255,0.10) 50%,
    rgba(255,255,255,0.04) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}

/* ===== Glow on primary elements ===== */
@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 10px rgba(91,110,245,0.2); }
  50%       { box-shadow: 0 0 25px rgba(91,110,245,0.5), 0 0 50px rgba(91,110,245,0.15); }
}
.btn-primary {
  animation: glowPulse 3s ease infinite;
}
.btn-primary:hover {
  animation: none;
  box-shadow: 0 6px 24px rgba(91,110,245,0.5);
}

/* ===== Auth card ===== */
.auth-card {
  animation: scaleIn 0.5s cubic-bezier(0.34,1.56,0.64,1) both;
}
.auth-logo-icon {
  animation: fadeInDown 0.5s cubic-bezier(0.34,1.56,0.64,1) 0.1s both;
  display: inline-block;
}
@keyframes floatIcon {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}
.auth-logo-icon {
  animation: floatIcon 3s ease infinite;
}

/* ===== Table container ===== */
.table-container {
  opacity: 0;
  animation: fadeInUp 0.45s cubic-bezier(0.16,1,0.3,1) 0.15s both;
}

/* ===== Invoice line items ===== */
.invoice-line {
  animation: fadeInUp 0.3s cubic-bezier(0.16,1,0.3,1) both;
  transition: background 0.2s ease;
}
.invoice-line:hover {
  background: rgba(255,255,255,0.06) !important;
}

/* ===== Tab buttons ===== */
.tab-btn {
  transition: all 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
.tab-btn.active {
  transform: scale(1.05);
}
.tab-btn:hover:not(.active) {
  transform: translateY(-2px);
}

/* ===== Sidebar logo glow ===== */
@keyframes logoShine {
  0%   { text-shadow: none; }
  50%  { text-shadow: 0 0 20px rgba(91,110,245,0.5); }
  100% { text-shadow: none; }
}
.sidebar-logo h1 {
  animation: logoShine 4s ease infinite;
}

/* ===== Reduce motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== Ripple keyframe ===== */
@keyframes rippleAnim {
  to { transform: scale(30); opacity: 0; }
}

/* ===== Tilt cards — preserve-3d ===== */
.stats-grid {
  perspective: 800px;
}
.stat-card {
  transform-style: preserve-3d;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  will-change: transform;
}

/* ===== Glow orbs in background ===== */
.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.07;
  pointer-events: none;
  z-index: 0;
  animation: orbFloat linear infinite;
}
.bg-orb-1 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, #5B6EF5, transparent);
  top: -100px; right: -100px;
  animation-duration: 20s;
}
.bg-orb-2 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, #F5A623, transparent);
  bottom: -80px; left: -80px;
  animation-duration: 25s;
  animation-direction: reverse;
}
.bg-orb-3 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, #4CAF7D, transparent);
  top: 40%; left: 40%;
  animation-duration: 18s;
}
@keyframes orbFloat {
  0%   { transform: translate(0, 0) scale(1); }
  25%  { transform: translate(30px, -20px) scale(1.05); }
  50%  { transform: translate(-20px, 30px) scale(0.95); }
  75%  { transform: translate(20px, 20px) scale(1.02); }
  100% { transform: translate(0, 0) scale(1); }
}

/* ===== Scan line effect on sidebar ===== */
.sidebar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(255,255,255,0.01) 2px,
    rgba(255,255,255,0.01) 4px
  );
  pointer-events: none;
  border-radius: inherit;
}

/* ===== Neon border on active nav ===== */
.sidebar-nav a.active {
  box-shadow: inset 0 0 20px rgba(91,110,245,0.08);
}

/* ===== Auth page float animation ===== */
.auth-card {
  animation: scaleIn 0.5s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes authFloat {
  0%, 100% { transform: translateY(0); box-shadow: 0 20px 60px rgba(0,0,0,0.4); }
  50%       { transform: translateY(-8px); box-shadow: 0 30px 80px rgba(0,0,0,0.5); }
}
.auth-card:not(:focus-within) {
  animation: authFloat 5s ease-in-out infinite;
}
